您好,登錄后才能下訂單哦!
兩臺機器
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")
}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。