这可能是一个非常简单/明显的答案但是我已经尝试运行相同命令的以下变体来备份本地mongo数据库并且它们都通过返回而失败:
Failed: error connecting to db server: no reachable servers
这些是命令:
mongodump --host localhost --port 27017 --db mydbname --collection mycollection
mongodump -h localhost:27017 --db mydbname --collection mycollection -u user -p passw --out <folder path>
mongodump -h localhost:27017 --db mydbname --collection mycollection --out <folder path>
mongodump --port 27017 --db mydbname --collection mycollection --out <folder path>
mongod 实例在单独的终端窗口上运行,而我全部尝试了
I JOURNAL [initandlisten] journal dir=/data/db/journal I JOURNAL [initandlisten] recover : no journal files present, no recovery needed I JOURNAL [durability] Durability thread started I CONTROL [initandlisten] MongoDB starting : pid=88451 port=27017 dbpath=/data/db 64-bit host=Diegos-MBP.home I CONTROL [initandlisten] I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 I JOURNAL [journal writer] Journal writer thread started I CONTROL [initandlisten] db version v3.0.6 I CONTROL [initandlisten] git version: nogitversion I CONTROL [initandlisten] build info: Darwin yosemitevm.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49 I CONTROL [initandlisten] allocator: system I CONTROL [initandlisten] options: {} I NETWORK [initandlisten] waiting for connections on port 27017 I NETWORK [initandlisten] connection accepted from 127.0.0.1:55910 #1 (1 connection now open)
我在/etc/mongod.conf
找不到 mongodb.conf 。我用自制软件安装了mongo。也许它与身份验证问题有关?
答案 0 :(得分:4)
我刚遇到同样的问题,似乎在主机设置中使用127.0.0.1而不是localhost ...
喜欢:
mongodump -h 127.0.0.1:27017 -d demo
如果您使用的是复制集(例如&#34; myset&#34;),请改用:
mongodump -h myset / 127.0.0.1:27017 -d demo
希望这会有所帮助......