Phần 7 Remove Members from Replica Set
Phần 7 Remove Members from Replica Set
1./ Remove a Member Using rs.remove()
Nếu muốn remove node primary thì nên hạ thấp priority của node đó để thành secondary trước khi thao tác
1.1/ Trên node Secondary cần remove
#
rs0:SECONDARY> db.shutdownServer()
shutdown command only works with the admin database; try 'use admin'
rs0:SECONDARY> use admin
switched to db admin
rs0:SECONDARY> db.shutdownServer()
server should be down...
2.1/ Trên node primary
rs.remove("mongod3.example.net:27017")
rs.remove("mongod3.example.net")
#Lệnh chạy
rs.remove("mongo3.replset.member:27017")
#trên node primary kiểm tra lại xem đã remove thành công chưa
rs.conf()
#
rs0:PRIMARY> rs.conf()
{
"_id" : "rs0",
"version" : 5,
"term" : 3,
"protocolVersion" : NumberLong(1),
"writeConcernMajorityJournalDefault" : true,
"members" : [
{
"_id" : 0,
"host" : "mongo0.replset.member:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 3,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "mongo1.replset.member:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 2,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 2,
"host" : "mongo2.replset.member:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 0.5,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"catchUpTimeoutMillis" : -1,
"catchUpTakeoverDelayMillis" : 30000,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("62160a357307c6ab3cdabe0a")
}
}
Như vậy đã remove thành công