全部博文(150)
分类: NOSQL
2017-06-14 14:37:25
解决上文遗留的问题
上次降级回3.0的原因是部分应用的mongodb驱动过低,不支持mongodb3.4造成,本次升级前检查了所有应用的驱动并做了升级并通过了兼容性测试。
假设有一个复制集有一个primary和三个sencondary组成
primary:10.0.1.32 secondary:10.0.1.31 、10.0.1.33、192.168.1.230
rs.status()显示
rs.status() { ...... "members" : [ { "_id" : 0, "name" : "10.0.1.31:27017", "health" : 1, "state" : 1, "stateStr" : "SECONDARY", ...... }, { "_id" : 1, "name" : "10.0.1.32:27017", "health" : 1, "state" : 5, "stateStr" : "PRIMARY", ...... }, { "_id" : 2, "name" : "192.168.1.230:27017", "health" : 1, "state" : 5, "stateStr" : "SECONDARY", ...... }, { "_id" : 3, "name" : "10.0.1.33:27017", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", ...... } ], "ok" : 1 }
切换目标:31升级为primary,32降级为secondary
primary:10.0.1.31 secondary:10.0.1.32 、10.0.1.33、192.168.1.230
切换步骤(均在mongodb shell上执行)
cfg = rs.conf() cfg.members[0].priority = 1 cfg.members[1].priority = 0.5 cfg.members[2].priority = 0.5 cfg.members[3].priority = 0.5 rs.reconfig(cfg)
rs.freeze(120)
rs.stepDown(120)
rs.status() { ...... "members" : [ { "_id" : 0, "name" : "10.0.1.31:27017", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", ...... }, { "_id" : 1, "name" : "10.0.1.32:27017", "health" : 1, "state" : 5, "stateStr" : "SECONDARY", ...... }, { "_id" : 2, "name" : "192.168.1.230:27017", "health" : 1, "state" : 5, "stateStr" : "SECONDARY", ...... }, { "_id" : 3, "name" : "10.0.1.33:27017", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", ...... } ], "ok" : 1 }
5、升级32节点mongodb到3.4版本
详细过程mongodb3.0.7扩容存储记录文中有介绍
6、重新将32节点加入复制集
从节点31上复制集配置文件过来,将bindip修改为本机32保存退出,执行systemctl start mongod即可。
注意事项