MongoDB副本集辅助节点(不可达/不正常)

时间:2018-11-30 15:00:14

标签: mongodb nosql database-administration

  • 列表项

我当前正在运行一个MongoDB副本集,该副本集具有1个主要,1个辅助和1个仲裁器,所有副本都托管在AWS EC2实例上。我最近关闭了辅助服务器以升级硬件。重新启动后,它具有另一个IP地址(如预期)。

重新启动后,我在辅助服务器上重新启动了knex.transaction(function(trx) { return Promise.map(array, function(item) { return trx.insert(item).into('table') .then(returnedFields => { try{ //do some validation/operation and return the result or the returnedFields themselves as input in the next loop. /* START Testing a case of rejection */ if (array.indexOf(item) === 3) { //uncomment the code below to test //throw new Error('BreakException'); } /* END */ }catch(err){ fail=true; } }).then(val => { if (fail) { trx.rollback()//you can ignore this as is automatically triggered here - tested return Promise.reject(new Error('Rejected')) } return val }) .catch(err => { fail = true trx.rollback()//you can ignore this as is automatically triggered here - tested return Promise.reject(new Error('Rejected')) }); }); }) .then(function(inserts) { console.log(inserts.length + 'Items saved.'); }) .catch(function(error) { console.error(error); })并更新了DNS,以便mongo2。**************。com现在指向新的IP地址。

我能够从初级连接到次级

mongod

在次要对象之间或从次要对象相同。

但是,当我在连接到副本集的同时执行mongo1.**************.com:~$ curl -ik mongo2.**************.com:27017 HTTP/1.0 200 OK Connection: close Content-Type: text/plain Content-Length: 84 It looks like you are trying to access MongoDB over HTTP on the native driver port. 时,我与辅助服务器的连接出错。

rs.status()

当通过Robo 3T连接到副本集时,这里是{ "set" : "myReplicaSet", "date" : ISODate("2018-11-30T14:29:43.308Z"), "myState" : 1, "term" : NumberLong(-1), "heartbeatIntervalMillis" : NumberLong(2000), "members" : [ { "_id" : 23, "name" : "mongo1.**************.com:27017", "health" : 1.0, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 13108, "optime" : Timestamp(1543588183, 6), "optimeDate" : ISODate("2018-11-30T14:29:43.000Z"), "electionTime" : Timestamp(1543575397, 1), "electionDate" : ISODate("2018-11-30T10:56:37.000Z"), "configVersion" : 788876, "self" : true }, { "_id" : 24, "name" : "mongoarb.**************.com:27017", "health" : 1.0, "state" : 7, "stateStr" : "ARBITER", "uptime" : 12785, "lastHeartbeat" : ISODate("2018-11-30T14:29:41.491Z"), "lastHeartbeatRecv" : ISODate("2018-11-30T14:29:43.056Z"), "pingMs" : NumberLong(0), "configVersion" : 788876 }, { "_id" : 25, "name" : "mongo2.**************.com:27017", "health" : 0.0, "state" : 8, "stateStr" : "(not reachable/healthy)", "uptime" : 0, "optime" : Timestamp(0, 0), "optimeDate" : ISODate("1970-01-01T00:00:00.000Z"), "lastHeartbeat" : ISODate("2018-11-30T14:29:41.754Z"), "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00.000Z"), "pingMs" : NumberLong(0), "lastHeartbeatMessage" : "Our replica set configuration is invalid or does not include us", "configVersion" : -1 } ], "ok" : 1.0 } 的输出

rs.conf()

我能够通过Robo 3T与辅助服务器建立直接连接。

在主节点的日志中,看到以下错误:

{ "_id" : "myReplicaSet", "version" : 788876, "members" : [ { "_id" : 23, "host" : "mongo1.**************.com:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1.0, "tags" : {}, "slaveDelay" : NumberLong(0), "votes" : 1 }, { "_id" : 24, "host" : "mongoarb.**************.com:27017", "arbiterOnly" : true, "buildIndexes" : true, "hidden" : false, "priority" : 1.0, "tags" : {}, "slaveDelay" : NumberLong(0), "votes" : 1 }, { "_id" : 25, "host" : "mongo2.**************.com:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1.0, "tags" : {}, "slaveDelay" : NumberLong(0), "votes" : 1 } ], "settings" : { "chainingAllowed" : true, "heartbeatIntervalMillis" : 2000, "heartbeatTimeoutSecs" : 10, "electionTimeoutMillis" : 10000, "getLastErrorModes" : {}, "getLastErrorDefaults" : { "w" : 1, "wtimeout" : 0 } } }

所有节点都在运行Mongo 3.2.19版

如何获取副本集以连接到辅助副本?

0 个答案:

没有答案