【你不知道的mongodb】-【Replica Sets操作二】

1、在副本集中移除一个node


remove
Arguments
• hostname – Specify one of the existing hosts to remove from the current replica set.
Removes the node described by the hostname parameter from the current replica set. This function will
disconnect the shell briefly and forces a reconnection as the replica set renegotiates negotiates which node will
be primary. As a result, the shell will display an error even if this command succeeds.
Note: Before running the rs.remove() (page 67) operation, you must shut down the replica set member that
you’re removing. Changed in version 2.2: This procedure is no longer required when using rs.remove()
(page 67), but it remains good practice.


二、移除node6


1、关闭node6

ctrl+c或者use admin db.shutdownServer()或者kill -2 /-15 pid干掉它

2、移除node6

PRIMARY> rs.remove("lenovo-2395031b:29996");
Fri Oct 19 13:42:14 DBClientCursor::init call() failed
Fri Oct 19 13:42:14 query failed : admin.$cmd { replSetReconfig: { _id: "rs", ve
rsion: 9, members: [ { _id: 0, host: "lenovo-2395031b:29991" }, { _id: 1, host:
"lenovo-2395031b:29992" }, { _id: 2, host: "lenovo-2395031b:29993" }, { _id: 3,
host: "lenovo-2395031b:29994" }, { _id: 4, host: "lenovo-2395031b:29995" } ] } }
 to: 127.0.0.1:29991
Fri Oct 19 13:42:14 Error: error doing query: failed shell/collection.js:151
Fri Oct 19 13:42:14 trying reconnect to 127.0.0.1:29991
Fri Oct 19 13:42:14 reconnect 127.0.0.1:29991 ok

3、移除后状态

PRIMARY> rs.conf();
{
        "_id" : "rs",
        "version" : 9,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "lenovo-2395031b:29991"
                },
                {
                        "_id" : 1,
                        "host" : "lenovo-2395031b:29992"
                },
                {
                        "_id" : 2,
                        "host" : "lenovo-2395031b:29993"
                },
                {
                        "_id" : 3,
                        "host" : "lenovo-2395031b:29994"
                },
                {
                        "_id" : 4,
                        "host" : "lenovo-2395031b:29995"
                }
        ]
}

4、查看同步状态

PRIMARY> db.printSlaveReplicationInfo();
source:   lenovo-2395031b:29992
         syncedTo: Fri Oct 19 2012 13:42:14 GMT+0800
                 = 1282 secs ago (0.36hrs)
source:   lenovo-2395031b:29993
         syncedTo: Fri Oct 19 2012 13:42:14 GMT+0800
                 = 1282 secs ago (0.36hrs)
source:   lenovo-2395031b:29994
         syncedTo: Fri Oct 19 2012 13:42:14 GMT+0800
                 = 1282 secs ago (0.36hrs)
source:   lenovo-2395031b:29995
         syncedTo: Fri Oct 19 2012 13:42:14 GMT+0800
                 = 1282 secs ago (0.36hrs)




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值