์ฐ๋ถํฌ ํธ์คํธ 3EA์ ๋ฉ์ธ ๋ ธ๋ ๋ฐ ์กฐ์ธ๋ ธ๋ 2๊ฐ๋ฅผ ๊ฐ์ ํ๊ณ ์ค๋ช ํ๋ค.
๊ฐ ๋ชฝ๊ณ DB ์ค์ ํ์ผ์ ๋ ํ๋ฆฌ์นด ์ด๋ฆ์ ์ค์ ํ๋ค
vim /etc/mongod.conf
replication:
replSetName: "rs0"
๋ชฝ๊ณ DB๋ฅผ ์ฌ์์ ํ๋ค
systemctl restart mongod
๋ง์คํฐ ๋ ธ๋์ ๋ชฝ๊ณ DB ์ ์ ํ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ๋ค.
rs.initiate( {
_id : "rs0",
members: [
{ _id: 0, host: "192.168.0.131:27017" },
{ _id: 1, host: "192.168.0.132:27017" },
{ _id: 2, host: "192.168.0.133:27017" }
]
})
์ ์ฉ ๊ฒฐ๊ณผ๋ฅผ ํ์ธํ๋ค.
rs.conf()
rs0:PRIMARY> rs.conf()
{
"_id" : "rs0",
"version" : 1,
"term" : 1,
"protocolVersion" : NumberLong(1),
"writeConcernMajorityJournalDefault" : true,
"members" : [
{
"_id" : 0,
"host" : "192.168.0.131:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "192.168.0.132:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 2,
"host" : "192.168.0.133: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("66a27110f4e019bb33cfd89c")
}
}