使用Percona Backup for MongoDB备份单实例
1、Percona Backup for MongoDB介绍
Percona Backup for MongoDB (PBM) is an open source and distributed solution for consistent backups and restores of MongoDB sharded clusters and replica sets to a specific point in time.
2、备份单个MongoDB实例
如果是独立的MongoDB实例,在pbm config时就会失败。
[root@mongodb01 ~]# pbm config --file /mongodb/app/pbm/pbm_config.yaml
Error: unable to set config: write to db: get cluster time: no clusterTime in response
官网也给出了支持的部署模式
Percona Backup for MongoDB works with sharded clusters and replica sets. It doesn’t work on standalone MongoDB instances. This is because Percona Backup for MongoDB requires oplog to guarantee backup consistency. Oplog is available on nodes with replication enabled.
For testing purposes, you can deploy Percona Backup for MongoDB on a single-node replica set. To convert a standalone server into a replica set, specify the replication.replSetName option in the configuration file and then initiate the replica set.
重点:支持分别集群和复制集,不支持独立的MongoDB实例,因为需要满足一致性,这里需要oplog
3、如何备份单个MongoDB实例
方法是把这个实例转换成只有一个节点的复制集。
3.1、配置
1.修改参数
replication:
oplogSizeMB: 2048
replSetName: rsdemo
enableMajorityReadConcern: true
2.重启MongoDB
3.初始化集群
[root@mongodb01 ~]# mongosh
rs.initiate( {
_id : "rsdemo",
members: [
{ _id: 0, host: "192.168.5.130:27017" }
]
})
4.检查状态
rs.status()
3.2、pbm config
[root@mongodb01 ~]# pbm config --file /mongodb/app/pbm/pbm_config.yaml
pitr:
enabled: false
oplogSpanMin: 0
storage:
type: filesystem
filesystem:
path: /mongodb/backup
4、创建备份
[root@mongodb01 ~]# pbm backup --type=logical
Starting backup '2024-08-25T07:05:00Z'.........Backup '2024-08-25T07:05:00Z' to remote store '/mongodb/backup' has started
[root@mongodb01 ~]# pbm status
Cluster:
========
rsdemo:
- rsdemo/192.168.5.130:27017 [P]: pbm-agent v2.5.0 OK
PITR incremental backup:
========================
Status [OFF]
Currently running:
==================
(none)
Backups:
========
FS /mongodb/backup
Snapshots:
2024-08-25T07:05:00Z 4.31MB <logical> [restore_to_time: 2024-08-25T07:05:11Z]
[root@mongodb01 ~]# pbm list
Backup snapshots:
2024-08-25T07:05:00Z <logical> [restore_to_time: 2024-08-25T07:05:11Z]
PITR <off>:
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




