一、修改副本集中各成員的優(yōu)先級(jí):
創(chuàng)新互聯(lián)公司是一家專注于成都網(wǎng)站制作、網(wǎng)站建設(shè)與策劃設(shè)計(jì),上饒網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)十載,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:上饒等地區(qū)。上饒做網(wǎng)站價(jià)格咨詢:18982081108shard1:PRIMARY> conf=rs.conf()
{
"_id" : "shard1",
"version" : 3,
"protocolVersion" : NumberLong(1),
"members" : [
{
"_id" : 0,
"host" : "mongo01-jp:27027",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "mongo02-jp:27027",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 2,
"host" : "mongo03-jp:27027",
"arbiterOnly" : true,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"catchUpTimeoutMillis" : 2000,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("5850deb0205cd94104cd9a38")
}
}
shard1:PRIMARY> conf.members[0].priority=100
100
shard1:PRIMARY> conf.members[1].priority=90
90
shard1:PRIMARY> rs.reconfig(conf)
{ "ok" : 1 }
shard1:PRIMARY> rs.conf()
{
"_id" : "shard1",
"version" : 4,
"protocolVersion" : NumberLong(1),
"members" : [
{
"_id" : 0,
"host" : "mongo01-jp:27027",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 100,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "mongo02-jp:27027",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 90,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 2,
"host" : "mongo03-jp:27027",
"arbiterOnly" : true,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"catchUpTimeoutMillis" : 2000,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("5850deb0205cd94104cd9a38")
}
}
shard1:PRIMARY>
關(guān)于優(yōu)先級(jí)范圍從0 至 1000 (3.2以上版本) ,優(yōu)先級(jí)越大,越可能成為primary;若優(yōu)先級(jí)為0,則該節(jié)點(diǎn)無資格參與primary的選舉。
如果希望某節(jié)點(diǎn)不參與primary的選舉有兩種方法: 1、將該節(jié)點(diǎn)優(yōu)先級(jí)設(shè)置為0;2、rs.freeze(30) 在cluster選舉primary時(shí),將該節(jié)點(diǎn)暫時(shí)凍結(jié)30S。
如果希望將本primary節(jié)點(diǎn)降為secondary狀態(tài),可以執(zhí)行 rs.stepDown() 。
二、在副本集中刪除成員、重新添加成員
shard2:PRIMARY> rs.status()
{
"set" : "shard2",
"date" : ISODate("2016-12-14T06:12:11.986Z"),
"myState" : 1,
"term" : NumberLong(1),
"heartbeatIntervalMillis" : NumberLong(2000),
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1481695926, 1),
"t" : NumberLong(1)
},
"appliedOpTime" : {
"ts" : Timestamp(1481695926, 1),
"t" : NumberLong(1)
},
"durableOpTime" : {
"ts" : Timestamp(1481695926, 1),
"t" : NumberLong(1)
}
},
"members" : [
{
"_id" : 0,
"name" : "mongo02-jp:27028",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 1128,
"optime" : {
"ts" : Timestamp(1481695926, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2016-12-14T06:12:06Z"),
"electionTime" : Timestamp(1481695445, 2),
"electionDate" : ISODate("2016-12-14T06:04:05Z"),
"configVersion" : 4,
"self" : true
},
{
"_id" : 1,
"name" : "mongo01-jp:27028",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 464,
"optime" : {
"ts" : Timestamp(1481695926, 1),
"t" : NumberLong(1)
},
"optimeDurable" : {
"ts" : Timestamp(1481695926, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2016-12-14T06:12:06Z"),
"optimeDurableDate" : ISODate("2016-12-14T06:12:06Z"),
"lastHeartbeat" : ISODate("2016-12-14T06:12:10.206Z"),
"lastHeartbeatRecv" : ISODate("2016-12-14T06:12:11.202Z"),
"pingMs" : NumberLong(0),
"syncingTo" : "mongo02-jp:27028",
"configVersion" : 4
},
{
"_id" : 2,
"name" : "mongo03-jp:27028",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 439,
"lastHeartbeat" : ISODate("2016-12-14T06:12:10.205Z"),
"lastHeartbeatRecv" : ISODate("2016-12-14T06:12:10.125Z"),
"pingMs" : NumberLong(0),
"configVersion" : 4
}
],
"ok" : 1
}
shard2:PRIMARY> rs.remove("mongo01-jp:27028")
{ "ok" : 1 }
shard2:PRIMARY> rs.remove("mongo03-jp:27028")
{ "ok" : 1 }
shard2:PRIMARY> rs.status()
{
"set" : "shard2",
"date" : ISODate("2016-12-14T06:13:18.227Z"),
"myState" : 1,
"term" : NumberLong(1),
"heartbeatIntervalMillis" : NumberLong(2000),
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1481695994, 1),
"t" : NumberLong(1)
},
"appliedOpTime" : {
"ts" : Timestamp(1481695994, 1),
"t" : NumberLong(1)
},
"durableOpTime" : {
"ts" : Timestamp(1481695994, 1),
"t" : NumberLong(1)
}
},
"members" : [
{
"_id" : 0,
"name" : "mongo02-jp:27028",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 1195,
"optime" : {
"ts" : Timestamp(1481695994, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2016-12-14T06:13:14Z"),
"electionTime" : Timestamp(1481695445, 2),
"electionDate" : ISODate("2016-12-14T06:04:05Z"),
"configVersion" : 6,
"self" : true
}
],
"ok" : 1
}
shard2:PRIMARY> rs.add("mongo03-jp:27028")
{ "ok" : 1 }
shard2:PRIMARY> rs.addArb("mongo01-jp:27028")
{ "ok" : 1 }
shard2:PRIMARY> rs.status()
{
"set" : "shard2",
"date" : ISODate("2016-12-14T06:39:40.718Z"),
"myState" : 1,
"term" : NumberLong(1),
"heartbeatIntervalMillis" : NumberLong(2000),
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1481697576, 1),
"t" : NumberLong(1)
},
"appliedOpTime" : {
"ts" : Timestamp(1481697576, 1),
"t" : NumberLong(1)
},
"durableOpTime" : {
"ts" : Timestamp(1481697576, 1),
"t" : NumberLong(1)
}
},
"members" : [
{
"_id" : 0,
"name" : "mongo02-jp:27028",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 2777,
"optime" : {
"ts" : Timestamp(1481697576, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2016-12-14T06:39:36Z"),
"electionTime" : Timestamp(1481695445, 2),
"electionDate" : ISODate("2016-12-14T06:04:05Z"),
"configVersion" : 9,
"self" : true
},
{
"_id" : 1,
"name" : "mongo03-jp:27028",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 1034,
"optime" : {
"ts" : Timestamp(1481697576, 1),
"t" : NumberLong(1)
},
"optimeDurable" : {
"ts" : Timestamp(1481697576, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2016-12-14T06:39:36Z"),
"optimeDurableDate" : ISODate("2016-12-14T06:39:36Z"),
"lastHeartbeat" : ISODate("2016-12-14T06:39:38.838Z"),
"lastHeartbeatRecv" : ISODate("2016-12-14T06:39:39.594Z"),
"pingMs" : NumberLong(0),
"syncingTo" : "mongo02-jp:27028",
"configVersion" : 9
},
{
"_id" : 2,
"name" : "mongo01-jp:27028",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 1128,
"lastHeartbeat" : ISODate("2016-12-14T06:39:39.053Z"),
"lastHeartbeatRecv" : ISODate("2016-12-14T06:39:36.708Z"),
"pingMs" : NumberLong(0),
"configVersion" : 9
}
],
"ok" : 1
}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
分享文章:mongodb副本集的維護(hù)(1)-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://www.rwnh.cn/article48/dhphep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、網(wǎng)站導(dǎo)航、面包屑導(dǎo)航、電子商務(wù)、網(wǎng)站制作、App設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容