MongoDB Database Tools 安装实现备份、恢复

本文涉及的产品
云数据库 MongoDB,独享型 2核8GB
推荐场景:
构建全方位客户视图
简介: MongoDB Database Tools 安装实现备份、恢复

1.下载

https://www.mongodb.com/try/download/database-tools

curl -O https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel70-x86_64-100.6.1.tgz

2.解压

tar -zxvf mongodb-database-tools-rhel70-x86_64-100.6.1.tgz

3.实践

3.1备份

[root@10-0-42-211 bin]# ./mongodump --host 10.0.42.211 --port 27017 --out /data/backup/
2022-11-22T20:47:54.070+0800    writing admin.system.users to /data/backup/admin/system.users.bson
2022-11-22T20:47:54.071+0800    done dumping admin.system.users (1 document)
2022-11-22T20:47:54.071+0800    writing admin.system.version to /data/backup/admin/system.version.bson
2022-11-22T20:47:54.072+0800    done dumping admin.system.version (2 documents)
2022-11-22T20:47:54.074+0800    writing db01.db01 to /data/backup/db01/db01.bson
2022-11-22T20:47:54.075+0800    writing config.external_validation_keys to /data/backup/config/external_validation_keys.bson
2022-11-22T20:47:54.076+0800    writing config.tenantMigrationDonors to /data/backup/config/tenantMigrationDonors.bson
2022-11-22T20:47:54.076+0800    writing config.tenantMigrationRecipients to /data/backup/config/tenantMigrationRecipients.bson
2022-11-22T20:47:54.077+0800    done dumping config.tenantMigrationDonors (0 documents)
2022-11-22T20:47:54.078+0800    done dumping config.external_validation_keys (0 documents)
2022-11-22T20:47:54.079+0800    done dumping db01.db01 (1 document)
2022-11-22T20:47:54.079+0800    done dumping config.tenantMigrationRecipients (0 documents)

3.2 恢复

[root@10-0-42-211 bin]# ./mongorestore --host 10.0.42.211 --port 27017 /data/backup/
2022-11-22T20:51:03.347+0800    preparing collections to restore from
2022-11-22T20:51:03.349+0800    reading metadata for config.external_validation_keys from /data/backup/config/external_validation_keys.metadata.json
2022-11-22T20:51:03.350+0800    reading metadata for config.tenantMigrationDonors from /data/backup/config/tenantMigrationDonors.metadata.json
2022-11-22T20:51:03.350+0800    reading metadata for config.tenantMigrationRecipients from /data/backup/config/tenantMigrationRecipients.metadata.json
2022-11-22T20:51:03.350+0800    reading metadata for db01.db01 from /data/backup/db01/db01.metadata.json
2022-11-22T20:51:03.351+0800    restoring to existing collection config.external_validation_keys without dropping
2022-11-22T20:51:03.351+0800    restoring config.external_validation_keys from /data/backup/config/external_validation_keys.bson
2022-11-22T20:51:03.352+0800    restoring to existing collection db01.db01 without dropping
2022-11-22T20:51:03.352+0800    restoring db01.db01 from /data/backup/db01/db01.bson
2022-11-22T20:51:03.353+0800    restoring to existing collection config.tenantMigrationDonors without dropping
2022-11-22T20:51:03.353+0800    restoring config.tenantMigrationDonors from /data/backup/config/tenantMigrationDonors.bson
2022-11-22T20:51:03.354+0800    restoring to existing collection config.tenantMigrationRecipients without dropping
2022-11-22T20:51:03.354+0800    restoring config.tenantMigrationRecipients from /data/backup/config/tenantMigrationRecipients.bson
2022-11-22T20:51:03.366+0800    finished restoring config.external_validation_keys (0 documents, 0 failures)
2022-11-22T20:51:03.366+0800    finished restoring db01.db01 (1 document, 0 failures)
2022-11-22T20:51:03.368+0800    finished restoring config.tenantMigrationDonors (0 documents, 0 failures)
2022-11-22T20:51:03.385+0800    finished restoring config.tenantMigrationRecipients (0 documents, 0 failures)
2022-11-22T20:51:03.385+0800    restoring users from /data/backup/admin/system.users.bson
2022-11-22T20:51:03.473+0800    no indexes to restore for collection db01.db01
2022-11-22T20:51:03.473+0800    restoring indexes for collection config.tenantMigrationDonors from metadata
2022-11-22T20:51:03.473+0800    index: &idx.IndexDocument{Options:primitive.M{"expireAfterSeconds":0, "name":"TenantMigrationDonorTTLIndex", "v":2}, Key:primitive.D{primitive.E{Key:"expireAt", Value:1}}, PartialFilterExpression:primitive.D(nil)}
2022-11-22T20:51:03.473+0800    restoring indexes for collection config.tenantMigrationRecipients from metadata
2022-11-22T20:51:03.473+0800    index: &idx.IndexDocument{Options:primitive.M{"expireAfterSeconds":0, "name":"TenantMigrationRecipientTTLIndex", "v":2}, Key:primitive.D{primitive.E{Key:"expireAt", Value:1}}, PartialFilterExpression:primitive.D(nil)}
2022-11-22T20:51:03.474+0800    restoring indexes for collection config.external_validation_keys from metadata
2022-11-22T20:51:03.474+0800    index: &idx.IndexDocument{Options:primitive.M{"expireAfterSeconds":0, "name":"ExternalKeysTTLIndex", "v":2}, Key:primitive.D{primitive.E{Key:"ttlExpiresAt", Value:1}}, PartialFilterExpression:primitive.D(nil)}
2022-11-22T20:51:03.476+0800    1 document(s) restored successfully. 0 document(s) failed to restore.

参考文档

https://www.mongodb.com/docs/database-tools/

相关实践学习
MongoDB数据库入门
MongoDB数据库入门实验。
快速掌握 MongoDB 数据库
本课程主要讲解MongoDB数据库的基本知识,包括MongoDB数据库的安装、配置、服务的启动、数据的CRUD操作函数使用、MongoDB索引的使用(唯一索引、地理索引、过期索引、全文索引等)、MapReduce操作实现、用户管理、Java对MongoDB的操作支持(基于2.x驱动与3.x驱动的完全讲解)。 通过学习此课程,读者将具备MongoDB数据库的开发能力,并且能够使用MongoDB进行项目开发。   相关的阿里云产品:云数据库 MongoDB版 云数据库MongoDB版支持ReplicaSet和Sharding两种部署架构,具备安全审计,时间点备份等多项企业能力。在互联网、物联网、游戏、金融等领域被广泛采用。 云数据库MongoDB版(ApsaraDB for MongoDB)完全兼容MongoDB协议,基于飞天分布式系统和高可靠存储引擎,提供多节点高可用架构、弹性扩容、容灾、备份回滚、性能优化等解决方案。 产品详情: https://www.aliyun.com/product/mongodb
相关文章
|
3月前
|
NoSQL MongoDB 数据库
MongoDB备份与恢复总结
MongoDB备份与恢复总结
106 0
|
4月前
|
NoSQL MongoDB Python
【Python】已完美解决(MongoDB安装报错)Service ‘MongoDB Server (MongoDB)’ (MongoDB) failed tostart
【Python】已完美解决(MongoDB安装报错)Service ‘MongoDB Server (MongoDB)’ (MongoDB) failed tostart
214 1
|
8天前
|
NoSQL MongoDB 数据库
|
15天前
|
NoSQL Ubuntu Linux
Linux平台安装MongoDB
10月更文挑战第11天
23 5
|
15天前
|
NoSQL Shell MongoDB
Mac OSX 平台安装 MongoDB
10月更文挑战第11天
16 4
|
16天前
|
NoSQL Shell MongoDB
Windows 平台安装 MongoDB
10月更文挑战第10天
29 0
Windows 平台安装 MongoDB
|
23天前
|
存储 NoSQL MongoDB
docker安装Mongodb
这篇文章详细说明了如何使用Docker安装MongoDB,包括拉取镜像、创建并运行容器、数据持久化存储以及访问容器内的MongoDB服务的具体步骤。
45 1
|
3月前
|
JavaScript NoSQL 前端开发
|
3月前
|
NoSQL 网络安全 MongoDB
MongoDB 备份与恢复
MongoDB 中的数据备份和恢复主要依赖于 `mongodump` 和 `mongorestore` 两个命令。`mongodump` 用于备份数据,它可以将数据导出为 BSON 格式的文件,支持多种部署类型,包括独立运行部署、副本集、分片集群等。通过指定不同的参数,如 `--uri`、`--host`、`--port` 等,可以连接到不同的 MongoDB 实例。备份时还可以指定要备份的数据库、集合等。
33 1
|
3月前
|
NoSQL Ubuntu MongoDB
在Ubuntu 16.04上安装和保护MongoDB的方法
在Ubuntu 16.04上安装和保护MongoDB的方法
30 1