复制仲裁器集

时间:2019-12-10 07:06:33

标签: mongodb replication replicaset mongodb-replica-set mongodb-replica

当AWS退出ec2实例“正在退出:此实例已计划退出...”时,我需要更改仲裁者。

因此,我需要更改仲裁服务器,创建了一个新服务器,并添加了该服务器中存在的所有内容,因为我已经为此保存了AMI。

要更改副本集成员,我使用MongoDB官方文档中提到的javascript slice方法 在新变量中设置配置

cfg = rs.conf()

从新变量中删除成员

cfg.members.splice(2,1) //remove the third member that is not in use and need to change

然后使用以下命令覆盖副本集配置文档:-

rs.reconfig(cfg)

myreplicaSetName:ARBITER> rs.status()
{
        "set" : "myreplicaSetName",
        "date" : ISODate("2019-12-10T06:49:35.584Z"),
        "myState" : 7,
        "term" : NumberLong(3),
        "syncingTo" : "",
        "syncSourceHost" : "",
        "syncSourceId" : -1,
        "heartbeatIntervalMillis" : NumberLong(2000),
        "optimes" : {
                "lastCommittedOpTime" : {
                        "ts" : Timestamp(1575960573, 1),
                        "t" : NumberLong(3)
                },
                "readConcernMajorityOpTime" : {
                        "ts" : Timestamp(1575960573, 1),
                        "t" : NumberLong(3)
                },
                "appliedOpTime" : {
                        "ts" : Timestamp(1575960573, 1),
                        "t" : NumberLong(3)
                },
                "durableOpTime" : {
                        "ts" : Timestamp(1575960573, 1),
                        "t" : NumberLong(3)
                }
        },
        "members" : [
                {
                        "_id" : 0,
                        "name" : "myhostname:port",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 120,
                        "optime" : {
                                "ts" : Timestamp(1575960573, 1),
                                "t" : NumberLong(3)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(1575960573, 1),
                                "t" : NumberLong(3)
                        },
                        "optimeDate" : ISODate("2019-12-10T06:49:33Z"),
                        "optimeDurableDate" : ISODate("2019-12-10T06:49:33Z"),
                        "lastHeartbeat" : ISODate("2019-12-10T06:49:33.593Z"),
                        "lastHeartbeatRecv" : ISODate("2019-12-10T06:49:35.267Z"),
                        "pingMs" : NumberLong(0),
                        "lastHeartbeatMessage" : "",
                        "syncingTo" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "electionTime" : Timestamp(1554185040, 1),
                        "electionDate" : ISODate("2019-04-02T06:04:00Z"),
                        "configVersion" : 15
                },
                {
                        "_id" : 1,
                        "name" : "my2ndhostname:port",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 120,
                        "optime" : {
                                "ts" : Timestamp(1575960573, 1),
                                "t" : NumberLong(3)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(1575960573, 1),
                                "t" : NumberLong(3)
                        },
                        "optimeDate" : ISODate("2019-12-10T06:49:33Z"),
                        "optimeDurableDate" : ISODate("2019-12-10T06:49:33Z"),
                        "lastHeartbeat" : ISODate("2019-12-10T06:49:33.592Z"),
                        "lastHeartbeatRecv" : ISODate("2019-12-10T06:49:34.289Z"),
                        "pingMs" : NumberLong(1),
                        "lastHeartbeatMessage" : "",
                        "syncingTo" : "myhostname:port",
                        "syncSourceHost" : "myhostname:port",
                        "syncSourceId" : 0,
                        "infoMessage" : "",
                        "configVersion" : 15
                },
                {
                        "_id" : 2,
                        "name" : "my3rdhostname:port",
                        "health" : 1,
                        "state" : 7,
                        "stateStr" : "ARBITER",
                        "uptime" : 312,
                        "syncingTo" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "maintenanceMode" : 1,
                        "infoMessage" : "could not find member to sync from",
                        "configVersion" : 15,
                        "self" : true,
                        "lastHeartbeatMessage" : ""
                }
        ],
        "ok" : 1
}

一切与重新配置一起进行,首先,当我添加为ARbiter时,它显示OTHER,然后当我在仲裁服务器中登录mongodb时,它也显示ARBITER,所以这意味着新的ARBITER已成功设置。但是为什么它会在

中显示
"infoMessage" : "could not find member to sync from",

0 个答案:

没有答案