1

我需要更改我的仲裁器,因为 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,然后当我在 arbiter 服务器中登录 mongodb 时,它也显示 ARBITER,因此这意味着新的 ARBITER 已成功设置。但为什么它的节目在

"infoMessage" : "could not find member to sync from",
4

0 回答 0