MongoDB delete, add replica set, and modify the replica set IP and other information

MongoDB delete, add replica set, and modify the replica set IP and other information

 

Add a copy, enter the login to the master node

rs.add("ip:port");

Delete copies

rs.remove("ip:port");

New arbitration node

rs.addArb("ip:port");

Modify the copy host:

shard1:PRIMARY> cfg = rs.conf()
{
        "_id" : "shard1",
        "version" : 5,
        "protocolVersion" : NumberLong(1),
        "members" : [
                {
                        "_id" : 0,
                        "host" : "127.0.0.1:2777",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "slaveDelay" : NumberLong(0),
                        "votes" : 1
                }
        ],
        "settings" : {
                "chainingAllowed" : true,
                "heartbeatIntervalMillis" : 2000,
                "heartbeatTimeoutSecs" : 10,
                "electionTimeoutMillis" : 10000,
                "getLastErrorModes" : {

                },
                "getLastErrorDefaults" : {
                        "w" : 1,
                        "wtimeout" : 0
                },
                "replicaSetId" : ObjectId("5d9c7a7e76695600e03e231f")
        }
}


shard1:PRIMARY> cfg.members[0].host = "10.13.10.2:2777"
10.130.10.72:2777
shard1:PRIMARY> rs.reconfig(cfg)
{ "ok" : 1 }
shard1:PRIMARY> rs.status()
{
        "set" : "shard1",
        "date" : ISODate("2019-10-09T02:59:26.916Z"),
        "myState" : 1,
        "term" : NumberLong(1),
        "heartbeatIntervalMillis" : NumberLong(2000),
        "members" : [
                {
                        "_id" : 0,
                        "name" : "10.130.10.72:2777",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 54711,
                        "optime" : {
                                "ts" : Timestamp(1570589961, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2019-10-09T02:59:21Z"),
                        "electionTime" : Timestamp(1570536062, 2),
                        "electionDate" : ISODate("2019-10-08T12:01:02Z"),
                        "configVersion" : 6,
                        "self" : true
                }
        ],
        "ok" : 1
}

 

Guess you like

Origin www.cnblogs.com/hankyoon/p/11640910.html