mongdb副本集部署
两台机器
创新互联建站成立于2013年,是专业互联网技术服务公司,拥有项目做网站、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元册亨做网站,已为上家服务,为册亨各地企业和个人服务,联系电话:13518219792
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.初始化副本集
rs.initiate()
5.添加成员节点
rs.add("worker2:27017")
rs.addArb("182.48.115.239:27017") #添加仲裁节点
6.进入MongoDB shell中查看配置
>>> 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副本集部署
网页网址:http://pwwzsj.com/article/ijposg.html