Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add a new secondary node by cold backup of secondary

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use secondary cold backup to add new secondary nodes", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to use secondary cold backup to add new secondary nodes" bar!

There are two points to note:

1. Ensure that during the scp, the oprlog of the Secondary node will not be overwritten, 2. The set delay time should ensure the completion of scp data operation.

The specific steps are as follows:

3.1 insert data into a collection to simulate online business

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 set a Secondary node as a delay node

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)

Check to see if it is delayed, and find that the delay is indeed 1 hour, that is, 3600 seconds!

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)

There is no insert in the data, as shown below:

MongoDB Enterprise liuhe_rs:SECONDARY > db.hezi.count ()

533387

3.2 directly scp the data directory to the target server

[mongod@beijing-fuli-hadoop-04] $scp-r db mongod@10.9.21.115:/data/mongodb

3.3 start a new Secondary node

[mongod@beijing-fuli-hadoop-03] $/ usr/bin/mongodb/bin/mongod-f / etc/mongod.conf

3.4 verify that the results are correct:

3.4.1 View the synchronization status of the new Secondary node without delay as follows:

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 check whether the data is synchronized successfully, as shown below.

MongoDB Enterprise liuhe_rs:SECONDARY > rs.slaveOk ()

MongoDB Enterprise liuhe_rs:SECONDARY > db.hezi.count ()

533487

Thank you for your reading, the above is the content of "how to use secondary cold backup to add new secondary nodes". After the study of this article, I believe you have a deeper understanding of how to use secondary cold backup to add new secondary nodes, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report