First of all thank you that you look at my question.
I have installed MongoDB cluster:
- mdb0.domain.com - Arbitr
- mdb1.domain.com - Primary (priority 3)
- mdb2.domain.com - Secondary (priority 2)
- mdb3.domain.com - Secondary (priority 1)
with enabled authorization (part of config):
security:
authorization: enabled
keyFile: /etc/mongodb.key
replication:
replSetName: prodreplset
It works fine. rs.status()
show all nodes and their info. I can connect to replicaset via command line (amd robo3t also) with the following command:
./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
and it works fine:
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>
When i stop mdb1.domain.com manually (reproduce a possible troubles), replicaset voted for new "Primary" and I can see that new primary mdb2.domain.com. In that time mdb1.domain.com node with status "stateStr" : "(not reachable/healthy)"
In that time I am trying to connect replicaset and getting the following errors:
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
BUT when I start mdb1.domain.com and it started to be Primary, I can connect again!
Why I can't connect seplicaset without one server and new Primary?