Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-05-31 15:38:20 10月02日 Update

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!

Tags: Nodes data delays backups methods synchronization learning success content assurance verification business that is hours that is ideas situations articles time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno macOS Shulou Technology Xiaomi