当前位置:网站首页>Three basic backup methods of mongodb
Three basic backup methods of mongodb
2022-06-26 19:39:00 【I want to become a monk】
Catalog
3、 ... and 、mongodump And mongorestore
One 、 snapshot
Using snapshots for backup is the most common method , Many enterprise backup products are based on this ( Love number 、commvault etc. ). Take the backup schematic diagram of love digital as an example .

- The management console starts the backup task .
- The console sends backup commands to each physical client , Each client finds whether the local node is Primary( Lord ) node , If not Primary( Lord ) node , The backup task of this node ends .
- Primary( Lord ) The client of the node gets MongoDB The file system where the data directory is located , Create a snapshot volume for the file system and mount it to a temporary directory .
- The client transmits the data of the temporary directory to the storage server .
- Client completes backup , Report the task backup status to the management console , End the entire backup task .
The main advantage of this method is its high speed , Easy to use .
The disadvantages are obvious :
1、 All hosts in the replica set must be preserved > 500MB Of VG Volume space . Although only the primary node performs backup operations , However, in replica set architecture, all nodes may become master nodes .
2、 Unable to achieve incremental backup , The reason is simple , It cannot determine the change of data , It is not clear what changes have taken place between the data at this point in time and the data at the last backup time .
3、 Only right mongod All databases under the instance are collectively backed up , Unable to achieve fine-grained database backup .
4、 Snapshot data recovery is also quite tedious , Especially remote recovery .
Two 、 Data file copy
This method is also relatively simple and direct , Direct will mongoDB Copy all the data under the data directory . But there are a few things to note .
1、 Before copying, you need to lock the database . You cannot write to the database after locking , May affect normal business . Remember to unlock after copying .
2、 You need to stop when you recover mongod example .
The disadvantages of this approach are similar to snapshots . Specific operation , As shown below :
# Get into mongo shell
db.fsyncLock()
# Return to linux shell
# take mongo Of dbpath Copy all to the cache directory
cp -R /var/lib/mongo/* /backup
# Get into mongo shell
db.fsyncUnlock()3、 ... and 、mongodump And mongorestore
These are both mongo Integrated backup and recovery tools , The function is also very powerful .
Use mongodump Database data can be exported as binary bson File format . And support collection Granular backup .
mongorestore It's cooperation mongodump The use of , As long as it is mongodump All exported data can be replied .
And cooperate with mongoDB Enabled in replica set mode oplog function , Incremental backup can be achieved .
Their only drawback is that their performance is too low , Not as good as the above two methods .github It has go Language implementation of the source code , If you have enough energy, you can read and optimize .
Because of the length ( lazy ), See the following link for specific usage mongodump — MongoDB Manual
https://www.mongodb.com/docs/v4.4/reference/program/mongodump/
mongorestore — MongoDB Manual
https://www.mongodb.com/docs/v4.4/reference/program/mongorestore/
边栏推荐
- On the origin of the dispute between the tradition and the future of database -- AWS series column
- C language file cursor fseek
- MySQL - table creation and management
- Unity——Mathf. Similarities and differences between atan and atan2
- 微服务架构
- The king of Internet of things protocol: mqtt
- IK分词器
- Boot指标监测
- 抖音实战~搜索页面~视频详情
- Wechat applet custom pop-up components
猜你喜欢

MySQL - subquery usage

Introduction to single chip microcomputer one-on-one learning strategy, independent development program immediately after reading

Unity——Mathf. Similarities and differences between atan and atan2

Refresh the strong pointer assignment problem in the HP-UX system of Sanguan

数据库范式和主码的选择

Kubernetes 资源拓扑感知调度优化

Tiktok practice ~ search page ~ scan QR code

Convex hull problem

Basic and necessary common plug-ins of vscade

Boot指标监测
随机推荐
DAPP丨LP单双币流动性质押挖矿系统开发原理分析及源码
Introduction to single chip microcomputer one-on-one learning strategy, independent development program immediately after reading
Tiktok practice ~ sharing module ~ copy short video link
抖音实战~首页视频~下拉刷新
项目实战六:分布式事务-Seata
uni-app使用canvas绘制二维码
Feign remote call
郭明錤:苹果 AR / MR 头显是其有史以来设计最复杂的产品,将于 2023 年 1 月发布
Tiktok practice ~ sharing module ~ short video download (save to photo album)
知识点总结
Résolution du problème: la machine virtuelle n'a pas pu copier et coller le fichier
项目实战四:用户登录及token访问验证(reids+jwt)
9. Intelligent transportation project (2)
微信小程序 自定义 弹框组件
Installation and use of filebeat
Redis Basics
威胁猎人必备的六个威胁追踪工具
Résumé des points de connaissance
商品秒杀系统
WebView load pdf