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

MongoDB Hot Backup test and pain point

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Preface to Percona MongoDB Hot Backup Test and pain Point

Part1: write at the front

Percona MongoDB supports Hot Backup, which solves the situation that the official version of MongoDB can only use mongodump. Mongodump is fine in the small library, after the quantity comes up, the backup and recovery is painful. In this paper, we reproduce and solve a bug in MongoDB hot backup backup.

Actual combat

Part1: limitation

Prior to the Percona MongoDB3.2.12 version, when making a physical hot backup, if the

DirectoryPerDB: true

DirectoryForIndexes: true

If these two parameters are used, an error will occur when performing the backup:

[root@HE1 bin] #. / mongo 127.0.0.1:27020/adminMongoDB shellversion: 3.2.11-3.1 connecting to:127.0.0.1:27020/admin heleitest:PRIMARY > use adminswitched to db adminheleitest:PRIMARY > db.runCommand ({createBackup: 1, backupDir: "/ home/work/backup"}) {"ok": 0, "errmsg": "boost::filesystem::copy_file: No such file or directory:\" / home/mongodb/data/admin/collection/11-6714811575794894766.wt\ "

Part2: pain point

This problem can be a headache, such as the growing size of the MongoDB library in the production library, prompting us to plan to adopt the hot backup solution, since the original library opened this way, so what is the temporary solution?

It may be useful to simply let a secondary initial sync with those options off, then you could take a hot backup again to populate all the other nodes. This is not a solution but a path to get the production system back into a state you can use the backups. Please note this assume production is built to best practices and is in a replica-set and not a stand alone mongod process.

It means that in our regular MongoDB replication set, if you want to back up this library, you first have to drop a Secondary and empty the data directory for re-replication, which will be very slow and complicated. If you just restart the database, you will not be able to report an error, because the options of multi-path data storage and index independent storage have been enabled, which is not supported by the existing version of hotbackup.

Part3: scenario

Fortunately, the Percona version responded powerfully, and after the Bug was proposed by Mr. he Chunkun, the official corrected this problem in version 3.2.12-3.2, so that the pain points of hot backup could be solved. For example, I needed to re-close the cluster parameters to export and import data, which is undoubtedly a huge workload and will make the database reliability in a low state in a short period of time. Now, all we have to do is upgrade the database, and this problem can be solved.

Part4: reproduce

[root@HE1 bin] #. / mongo 127.0.0.1:27020/adminPercona Server for MongoDB shell version: 3.2.12-3.2connecting to: 127.0.0.1:27020/admin heleitest:PRIMARY > db.runCommand ({createBackup: 1, backupDir: "/ home/work/backup"}) {"ok": 1}

I will first upgrade the previous version 3.2.11-3.1. For more information on how to upgrade the MongoDB database, please see:

Http://suifu.blog.51cto.com/9167728/1947035

At the same time, the configuration file configures the

DirectoryPerDB: true

DirectoryForIndexes: true

As you can see, in version 3.2.12-3.2, there is no exception to the backup.

Part5: verification

[root@HE1 bin] #. / mongo 127.0.0.1:27020/adminPercona Server for MongoDB shell version v3.4.4-1.4connecting to: mongodb://127.0.0.1:27020/adminPercona Server for MongoDB server version: v3.4.4-1.4heleitest:PRIMARY > db.runCommand ({createBackup: 1, backupDir: "/ home/work/backup"}) {"ok": 1}

As you can see, there is nothing wrong with the latest version.

Part6: official log

# PSMDB-123: Fixed the creation of proper subdirectories inside the backup destination directory

Jira submitted by teacher he Chunxing

Https://jira.percona.com/browse/PSMDB-123

-- Summary.

Thanks to teacher he Chunxing for his bug submission, thanks to the Percona team for its efficient repair rate, open source, to make the world a better place ~ as the author's level is limited and the writing time is very short, there will inevitably be some errors or inaccuracies in the article. I urge readers to criticize and correct them.

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