修改mongodb集群IP

  1. 关闭集群的所有节点
  2. 以单机模式启动b
# bind_ip 为新地址
./mongod --bind_ip xx.xx.xx.xx --port 29012 --dbpath /rs1/mongodb/lcc2 --logpath /home/qboxserver/mongodb/log/lcc2.log -logappend --oplogSize 20000 --storageEngine rocksdb --rocksdbCacheSizeGB 10 &
  1. 进入到数据库里面修改副本信息
./mongo xx.xx.xx.xx:29012
use local
db.system.replset.find()
{ "_id" : "lcc2", "version" : 1, "protocolVersion" : NumberLong(1), "members" : [ { "_id" : 1, "host" : "xx.xx.xx.xx:29012", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 3, "tags" : {  }, "slaveDelay" : NumberLong(0), "votes" : 1 }, { "_id" : 2, "host" : "xx.xx.xx.xx:29012", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 2, "tags" : {  }, "slaveDelay" : NumberLong(0), "votes" : 1 }, { "_id" : 3, "host" : "xx.xx.xx.xx:29012", "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("5c24cbaa2045a8fe36840702") } }
# 修改为新集群IP
cfg={ "_id" : "lcc2", "version" : 1, "protocolVersion" : NumberLong(1), "members" : [ { "_id" : 1, "host" : "xx.xx.xx.xx:29012", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 3, "tags" : {  }, "slaveDelay" : NumberLong(0), "votes" : 1 }, { "_id" : 2, "host" : "xx.xx.xx.xx:29012", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 2, "tags" : {  }, "slaveDelay" : NumberLong(0), "votes" : 1 }, { "_id" : 3, "host" : "xx.xx.xx.xx:29012", "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("5c24cbaa2045a8fe36840702") } }
db.system.replset.update({"_id":"lcc2”},cfg
  1. 以集群的方式启动,需改动启动文件里面的IP为新IP
./mongod --bind_ip xx.xx.xx.xx --port 29012 --dbpath /rs1/mongodb/lcc2 --logpath /home/qboxserver/mongodb/log/lcc2.log -logappend --oplogSize 20000 --storageEngine rocksdb --rocksdbCacheSizeGB 10 --replSet lcc2 &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值