您好,登錄后才能下訂單哦!
兩臺機(jī)器
1.在/etc/hosts文件中寫上
192.168.255.133 worker1
192.168.255.134 worker2
2.修改配置文件/etc/mongdb.conf
bindIp: 0.0.0.0 #供所有機(jī)器訪問
replication:
replSetName: rs # 給副本集取名字叫rs
3.啟動
mongod
4.初始化副本集
rs.initiate()
5.添加成員節(jié)點(diǎn)
rs.add("worker2:27017")
rs.addArb("182.48.115.239:27017") #添加仲裁節(jié)點(diǎn)
6.進(jìn)入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")
}
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。