티스토리 뷰
서울 아파트실거래가를 2013~현재까지 받아다가 엑셀로 만드니, 58만여건임.
해당 엑셀자료를 R jsonlite 이용하여 json 파일로 만들었다.
# mongodb에 import 하기전에 json 파일로 변환. 229.4MB 너무큼.
write_json(apart, path = file.path(getwd(), 'docs', 'apart', 'data', 'apart_all.json'))
# csv 로 변환하니 90.9mb
write_csv(apart, path = file.path(getwd(), 'docs', 'apart', 'data', 'apart_all.csv'))
mongodb 에 import 할 수 있는 파일은 json, csv, tsv 정도임. 아래링크로 옵션확인.(https://docs.mongodb.com/manual/reference/program/mongoimport/)
json 파일로 import 해보자. (13초정도걸림)
> mongoimport --db test --collection apart --file apart_all.json --jsonArray
mongoimport --db test --collection apart --file apart_all.json --jsonArray
2019-06-30T00:33:34.786+0900 connected to: localhost
2019-06-30T00:33:37.783+0900 [####....................] test.apart 38.1MB/219MB (17.4%)
2019-06-30T00:33:40.786+0900 [##########..............] test.apart 94.6MB/219MB (43.2%)
2019-06-30T00:33:43.787+0900 [################........] test.apart 151MB/219MB (69.1%)
2019-06-30T00:33:46.783+0900 [######################..] test.apart 207MB/219MB (94.5%)
2019-06-30T00:33:47.429+0900 [########################] test.apart 219MB/219MB (100.0%)
2019-06-30T00:33:47.429+0900 imported 580255 documents
csv 로 동일하게 import 했는데, 13초정도로 거의 동일하다. 파일의 크기가 중요하지 않은듯하다.
> mongoimport --db test --collection apart --file apart_all.csv --type csv --headerline
2019-06-30T00:40:04.722+0900 connected to: localhost
2019-06-30T00:40:07.723+0900 [####....................] test.apart 16.4MB/86.6MB (18.9%)
2019-06-30T00:40:10.719+0900 [###########.............] test.apart 40.3MB/86.6MB (46.5%)
2019-06-30T00:40:13.721+0900 [#################.......] test.apart 62.8MB/86.6MB (72.5%)
2019-06-30T00:40:16.720+0900 [#######################.] test.apart 83.6MB/86.6MB (96.5%)
2019-06-30T00:40:17.144+0900 [########################] test.apart 86.6MB/86.6MB (100.0%)
2019-06-30T00:40:17.144+0900 imported 580255 documents
잘넣어둔 데이터를 백업해보자. 1~2초 걸림.
> mongodump --db test --collection apart
2019-06-30T00:45:46.102+0900 writing test.apart to
2019-06-30T00:45:47.987+0900 done dumping test.apart (580255 documents)
백업된 파일을 확인해보니, 거의 bson 파일자체가 json 파일과 용량이 차이가 없다.
다만 폴더로 열려있다보니, 묶는절차가 필요할지도 모르겠다.
> ls ./dump/test
total 448632
drwxr-xr-x 4 emflant wheel 136B 6 30 00:45 ./
drwxr-xr-x 3 emflant wheel 102B 6 30 00:45 ../
-rw-r--r-- 1 emflant wheel 219M 6 30 00:45 apart.bson
-rw-r--r-- 1 emflant wheel 124B 6 30 00:45 apart.metadata.json
하나의 파일로 백업파일을 만들어보자. 2초정도로 별차이가 없다.
> mongodump --archive=test.apart.20190630.archive --db test --collection apart
2019-06-30T00:47:57.780+0900 writing test.apart to archive 'test.apart.20190630.archive'
2019-06-30T00:47:59.640+0900 done dumping test.apart (580255 documents)
아래같은 파일이 만들어진다.
-rw-r--r-- 1 emflant wheel 219M 6 30 00:47 test.apart.20190630.archive
압축을 하는 옵션이 있다. 이건 4초정도 걸렸지만, 용량이 13MB 로 줄었다.
> mongodump --archive=test.apart.20190630.gz --gzip --db test --collection apart
2019-06-30T00:49:34.689+0900 writing test.apart to archive 'test.apart.20190630.gz'
2019-06-30T00:49:37.684+0900 [######################..] test.apart 550867/580255 (94.9%)
2019-06-30T00:49:37.868+0900 [########################] test.apart 580255/580255 (100.0%)
2019-06-30T00:49:38.016+0900 done dumping test.apart (580255 documents)
> ls
-rw-r--r-- 1 emflant wheel 219M 6 30 00:47 test.apart.20190630.archive
-rw-r--r-- 1 emflant wheel 13M 6 30 00:49 test.apart.20190630.gz
- Total
- Today
- Yesterday
- 아이맥
- python
- 도넛차트
- docker
- Spring
- MongoDB
- Google Chart Tools
- 막대그래프
- 마인크래프트
- github
- MySQL
- ggplot2
- eclipse
- 맥북
- ipTIME
- 이클립스
- SVN
- heroku
- ubuntu
- vagrant
- ktm모바일
- javascript
- 셀프개통
- 자급제폰
- java
- MyBatis
- R
- Oracle
- 알뜰요금제
- ggplot
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |