MongoDB shell version: 3.0.6 connecting to: test Server has startup warnings: 2017-01-26T17:25:54.657+0800 I CONTROL [initandlisten] 2017-01-26T17:25:54.657+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
通过终端ulimit -a显示,指的是 -n openfile选项
$mongoimport --db test --collection restaurants --drop --file ~/downloads/primer-dataset.json
2017-01-26T17:27:11.882+0800 [........................] test.restaurants 0.0 B/11.3 MB (0.0%)
2017-01-26T17:27:12.409+0800 Failed: error connecting to db server: no reachable servers
2017-01-26T17:27:12.409+0800 imported 0 documents
$ mongorestore dump --host=127.0.0.1
2017-01-26T17:27:42.124+0800 building a list of dbs and collections to restore from dump dir
2017-01-26T17:27:42.125+0800 Failed: error scanning filesystem: error reading root dump folder: open dump: no such file or directory
$ mongoimport --host=127.0.0.1 --db test --collection restaurants --drop --file ~/downloads/primer-dataset.json
2017-01-26T17:32:44.206+0800 connected to: 127.0.0.1
2017-01-26T17:32:44.207+0800 dropping: test.restaurants
2017-01-26T17:32:45.572+0800 imported 25359 documents
百思不得其解,按照官网代码敲出来的,不过没用。加上--host=127.0.0.1来让mongodb知道host是本机。网上说3.0.7以后不会有这个问题,但显然我遇到了。