Mongodb: подключение к набору реплик

Прежде всего спасибо, что вы посмотрите на мой вопрос.

Я установил кластер MongoDB:

  • mdb0.domain.com - Арбитр
  • mdb1.domain.com - Основной (приоритет 3)
  • mdb2.domain.com - Вторичный (приоритет 2)
  • mdb3.domain.com - Вторичный (приоритет 1)

с включенной авторизацией (часть конфигурации):

security:
  authorization: enabled
  keyFile: /etc/mongodb.key

replication:
  replSetName: prodreplset

Работает нормально. rs.status() показать все узлы и их информацию. Я могу подключиться к replicaset через командную строку (также amd robo3t) с помощью следующей команды:

./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 (воспроизведите возможные проблемы), replicaset голосовал за новый "Первичный", и я вижу этот новый первичный mdb2.domain.com. В это время узел mdb1.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, и он стал Первичным, я могу подключиться снова!

Почему я не могу подключить seplicaset без одного сервера и нового основного?

0 ответов

Другие вопросы по тегам