首先感谢您关注我的问题。
我已经安装了MongoDB集群:
已启用授权(配置的一部分):
security:
authorization: enabled
keyFile: /etc/mongodb.key
replication:
replSetName: prodreplset
工作正常。 rs.status()
显示所有节点及其信息。我可以使用以下命令通过命令行(也可以是amd robo3t)连接到copysetset:
./mongo --host mongodb://mdb1.domain.com:27017,mdb2.domain.com:27017,mdb3.domain.com:27017/db_production?replicaSet=prodreplset -u dbuser -p dbpass --authenticationDatabase db_production
工作正常:
2018-07-25T16:32:29.525+0300 I NETWORK [js] Starting new replica set monitor for prodreplset/mdb1.domain.com:27017,mdb2.domain.com:27017,mdb3.domain.com:27017
2018-07-25T16:32:29.578+0300 I NETWORK [js] Successfully connected to mdb2.domain.com:27017 (1 connections now open to mdb2.domain.com:27017 with a 5 second timeout)
2018-07-25T16:32:29.578+0300 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to mdb1.domain.com:27017 (1 connections now open to mdb1.domain.com:27017 with a 5 second timeout)
2018-07-25T16:32:29.648+0300 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to mdb3.domain.com:27017 (1 connections now open to mdb3.domain.com:27017 with a 5 second timeout)
MongoDB server version: 4.0.0
prodreplset:PRIMARY>
当我手动停止mdb1.domain.com(重现可能的麻烦)时,副本集投票赞成新的“ Primary”,我可以看到新的主要mdb2.domain.com。那时状态为"stateStr" : "(not reachable/healthy)"
那时候我试图连接副本集并收到以下错误:
MongoDB shell version v4.0.0
connecting to: mongodb://mdb1.domain.com:27017,mdb2.domain.com:27017,mdb3.domain.com:27017/db_production?replicaSet=prodreplset
2018-07-25T16:42:01.466+0300 I NETWORK [js] Starting new replica set monitor for prodreplset/mdb1.domain.com:27017,mdb2.domain.com:27017,mdb3.domain.com:27017
2018-07-25T16:42:01.506+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:01.506+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2018-07-25T16:42:02.072+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:02.072+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
2018-07-25T16:42:02.632+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:02.632+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2018-07-25T16:42:03.192+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:03.192+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 4 checks in a row.
2018-07-25T16:42:03.752+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:03.752+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 5 checks in a row.
2018-07-25T16:42:04.314+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:04.314+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 6 checks in a row.
2018-07-25T16:42:04.874+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:04.874+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 7 checks in a row.
2018-07-25T16:42:05.434+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:05.434+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 8 checks in a row.
2018-07-25T16:42:05.996+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:05.996+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 9 checks in a row.
2018-07-25T16:42:06.560+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:06.560+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 10 checks in a row.
2018-07-25T16:42:07.120+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:07.120+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 11 checks in a row.
2018-07-25T16:42:07.681+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:09.303+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:09.866+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:10.425+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:10.990+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:11.550+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:12.110+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:12.670+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:13.231+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:13.800+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:13.800+0300 I NETWORK [js] Cannot reach any nodes for set prodreplset. Please check network connectivity and the status of the set. This has happened for 21 checks in a row.
2018-07-25T16:42:14.360+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:14.924+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:15.484+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:16.048+0300 W NETWORK [js] Unable to reach primary for set prodreplset
2018-07-25T16:42:16.048+0300 E QUERY [js] Error: connect failed to replica set prodreplset/mdb1.domain.com:27017,mdb2.domain.com:27017,mdb3.domain.com:27017 :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed
但是当我启动mdb1.domain.com并且它开始是Primary时,我可以再次连接!
为什么没有一台服务器和新的主服务器就无法连接seplicaset?