mongdb副本集部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mongdb副本集部署相关的知识,希望对你有一定的参考价值。
两台机器
1.在/etc/hosts文件中写上
192.168.255.133 worker1
192.168.255.134 worker2
2.修改配置文件/etc/mongdb.conf
bindIp: 0.0.0.0 #供所有机器访问
replication:
replSetName: rs # 给副本集取名字叫rs
3.启动
mongod
4.初始化副本集
mongo
rs.initiate()
5.添加成员节点
rs.add("worker2:27017")
rs.addArb("182.48.115.239:27017") #添加仲裁节点
6.进入mongodb shell中查看配置
mongo
rs.conf()
MongoDB Enterprise rs:PRIMARY> rs.conf()
{
"_id" : "rs",
"version" : 2,
"protocolVersion" : NumberLong(1),
"writeConcernMajorityJournalDefault" : true,
"members" : [
{
"_id" : 0,
"host" : "worker1:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "worker2:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"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("5dd12530c247798c40d9cfef")
}
}
以上是关于mongdb副本集部署的主要内容,如果未能解决你的问题,请参考以下文章