Martin.xu

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

查看master的oplog元数据信息:

> db.printReplicationInfo()

查看salve的同步状态:

> db.printSlaveReplicationInfo()
删除复制集节点
PRIMARY> rs.remove("10.250.7.241:27017");
{ "ok" : 1 }
增加复制集节点
PRIMARY> rs.add("10.250.7.241:27017");
{ "ok" : 1 } --添加成功
增加中裁复制集节点
PRIMARY> rs.addArb("10.250.7.241:27017");
{ "ok" : 1 } --添加成功
备份
mongodump -h 127.0.0.1:30000
备份可以是mongo、mongos,可加-d 指定数据库 -o 指定备份位置 , 都不指定会备份当前所有的库到当前dump目录中。
还原
mongorestore -h 127.0.0.1:30000 dump/
//完整还原时,需要先移除config库,否则还原会报错
查询oplog的大小及保存的操作记录持续的时长
repltest:PRIMARY> db.printReplicationInfo()
configured oplog size:   1024MB
log length start to end: 3705secs (1.03hrs)
oplog first event time:  Thu Oct 10 2013 11:13:29 GMT+0800 (CST)
oplog last event time:   Thu Oct 10 2013 12:15:14 GMT+0800 (CST)
now:                     Fri Oct 11 2013 16:33:42 GMT+0800 (CST)

查询从节点的数据源列表,其中有数据滞后的时间

repltest:PRIMARY> db.printSlaveReplicationInfo()
source:   172.16.62.138:27017
 syncedTo: Fri Oct 11 2013 16:38:16 GMT+0800 (CST)
 = 1 secs ago (0hrs)
source:   172.16.62.131:27017
 no replication info, yet.  State: ARBITER
重新设置replica set时,使用force,强制执行(未测试成功)
mongo -port 27017
config = {_id:'shard1',members:[{_id:0,host:'192.168.1.236:27017',arbiterOnly:true},{_id:1,host:'192.168.1.237:27017'},{_id:2,host:'192.168.1.238:27017'}]}
rs.reconfig(ctf, { force: true})
rs.status();
mongo -port 27018
config = {_id:'shard2',members:[{_id:0,host:'192.168.1.236:27018'},{_id:1,host:'192.168.1.237:27018',arbiterOnly:true},{_id:2,host:'192.168.1.238:27018'}]}
rs.reconfig(config, { force: true})
rs.status();
mongo -port 27019
config = {_id:'shard3',members:[{_id:0,host:'192.168.1.236:27019'},{_id:1,host:'192.168.1.237:27019'},{_id:2,host:'192.168.1.238:27019',arbiterOnly:true}]}
rs.reconfig(config, { force: true})
rs.status();

 

posted on 2017-07-20 14:14  Martin.xu  阅读(183)  评论(0编辑  收藏  举报