您好,登錄后才能下訂單哦!
這篇文章主要講解了“怎么采用secondary的冷備份的方式來(lái)添加新的secondary節(jié)點(diǎn)”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“怎么采用secondary的冷備份的方式來(lái)添加新的secondary節(jié)點(diǎn)”吧!
需要注意兩點(diǎn):
1.保證scp期間,該Secondary節(jié)點(diǎn)的oprlog 不被覆蓋,2.設(shè)置的延遲時(shí)間要保證scp數(shù)據(jù)操作完成
具體步驟如下:
3.1 給某個(gè)集合插入數(shù)據(jù),來(lái)模擬線上業(yè)務(wù);
MongoDB Enterprise liuhe_rs:PRIMARY> use liuwenhe
switched to db liuwenhe
MongoDB Enterprise liuhe_rs:PRIMARY> db.hezi.count()
533387
MongoDB Enterprise liuhe_rs:PRIMARY> for (var i = 0; i < 100; i++) { db.hezi.insert({id: i}); }
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise liuhe_rs:PRIMARY> db.hezi.count()
533487
3.2將某個(gè)Secondary節(jié)點(diǎn)設(shè)置為延遲節(jié)點(diǎn);
MongoDB Enterprise liuhe_rs:PRIMARY>cfg = rs.conf()
MongoDB Enterprise liuhe_rs:PRIMARY>cfg.members[1].priority = 0
MongoDB Enterprise liuhe_rs:PRIMARY>cfg.members[1].slaveDelay = 3600
MongoDB Enterprise liuhe_rs:PRIMARY>rs.reconfig(cfg)
查看是否是延遲的,發(fā)現(xiàn)確實(shí)延遲1個(gè)小時(shí),也就是3600秒!
MongoDB Enterprise liuhe_rs:SECONDARY> rs.printReplicationInfo()
configured oplog size: 51200MB
log length start to end: 5461974secs (1517.22hrs)
oplog first event time: Sat Nov 16 2019 16:53:17 GMT+0800 (CST)
oplog last event time: Sat Jan 18 2020 22:06:11 GMT+0800 (CST)
now: Sat Jan 18 2020 23:06:19 GMT+0800 (CST)
數(shù)據(jù)確實(shí)沒(méi)有insert呢,如下所示:
MongoDB Enterprise liuhe_rs:SECONDARY> db.hezi.count()
533387
3.2直接scp 數(shù)據(jù)目錄到目標(biāo)服務(wù)器
[mongod@beijing-fuli-hadoop-04 ~]$ scp -r db mongod@10.9.21.115:/data/mongodb
3.3 啟動(dòng)新的Secondary節(jié)點(diǎn)
[mongod@beijing-fuli-hadoop-03 ~]$ /usr/bin/mongodb/bin/mongod -f /etc/mongod.conf
3.4 驗(yàn)證結(jié)果是否正確:
3.4.1查看新的Secondary節(jié)點(diǎn)的同步狀態(tài),如下無(wú)延遲:
MongoDB Enterprise liuhe_rs:SECONDARY> rs.printReplicationInfo()
configured oplog size: 51200MB
log length start to end: 5465940secs (1518.32hrs)
oplog first event time: Sat Nov 16 2019 16:53:17 GMT+0800 (CST)
oplog last event time: Sat Jan 18 2020 23:12:17 GMT+0800 (CST)
now: Sat Jan 18 2020 23:17:48 GMT+0800 (CST)
3.4.2查看數(shù)據(jù)是否同步成功,如下所示,確實(shí)同步成功了
MongoDB Enterprise liuhe_rs:SECONDARY> rs.slaveOk()
MongoDB Enterprise liuhe_rs:SECONDARY> db.hezi.count()
533487
感謝各位的閱讀,以上就是“怎么采用secondary的冷備份的方式來(lái)添加新的secondary節(jié)點(diǎn)”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)怎么采用secondary的冷備份的方式來(lái)添加新的secondary節(jié)點(diǎn)這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。