我在Ubuntu14.04服务器上安装了mongodb
我无法连接通过"mongoimport","mongodump","mongostat"等方面的MongoDB它总是显示"无可达服务器"
mongoimport --db test --collection restaurants --drop --file dataset.json
2015-08-25T13:08:29.802+0800 [........................] test.restaurants 0.0 B/11.3 MB (0.0%)
2015-08-25T13:08:30.306+0800 Failed: error connecting to db server: no reachable servers
2015-08-25T13:08:30.306+0800 imported 0 documents
Run Code Online (Sandbox Code Playgroud)
不知何故,我能够连接mongo shell
mongo --port 27017
MongoDB shell version: 3.0.6
connecting to: 127.0.0.1:27017/test
Run Code Online (Sandbox Code Playgroud)
起初,我怀疑它是否由我的iptables引起,所以我清除所有iptables规则并为ALL接受创建规则,但它仍然相同
sudo iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A FORWARD -j ACCEPT
-A OUTPUT -j ACCEPT
-A OUTPUT -o lo -j ACCEPT …Run Code Online (Sandbox Code Playgroud) 将mongodb副本集转换为独立服务器后,我遇到以下警告.我做了rs.remove('host')并在启动mongo db时删除了replSet参数.
[root@sam ~]# mongo
MongoDB shell version: 2.4.3
connecting to: test
Server has startup warnings:
Tue Jul 9 17:18:46.076 [initandlisten]
Tue Jul 9 17:18:46.076 [initandlisten] ** WARNING: mongod started without --replSet yet 1 documents are present in local.system.replset
Tue Jul 9 17:18:46.077 [initandlisten] ** Restart with --replSet unless you are doing maintenance and no other clients are connected.
Tue Jul 9 17:18:46.077 [initandlisten] ** The TTL collection monitor will not start because of this.
Tue Jul 9 17:18:46.077 [initandlisten] …Run Code Online (Sandbox Code Playgroud) 我们有一个 mongoDB 副本集,它有 3 个节点;
不知何故,我们的副本集最终将 1 和 2 都设置为次要成员。我不确定这是怎么发生的(我们有一个服务器迁移,其中一个节点运行,但只有一个)。
无论如何,我一直在尝试按照此处的指南为副本集重新选举一个新的主节点
我无法使用
rs.reconfig(cfg)
Run Code Online (Sandbox Code Playgroud)
因为它只有在针对主要(我没有)时才有效。
使用 force 参数
rs.reconfig(cfg, { force: true})
Run Code Online (Sandbox Code Playgroud)
似乎可以工作,但是当我重新查询副本集的状态时,两台服务器仍仅显示为辅助服务器。
为什么强制重新配置不起作用?目前,无论我尝试什么,数据库都被锁定。