percona mongo热备
https://www.percona.com/doc/percona-server-for-mongodb/LATEST/hot-backup.html#hot-backup
Hot Backup
Percona Server for MongoDB includes an integrated open-source hot backup system for the default WiredTiger storage engine. It creates a physical data backup on a running server without notable performance and operating degradation.
Making a backup
To take a hot backup of the database in your current dbpath, do the following:
Make sure to provide access to the backup directory for the
mongoduserchown mongod:mongod <backupDir>
Run the
createBackupcommand as administrator on theadmindatabase and specify the backup directory.> use admin
switched to db admin
> db.runCommand({createBackup: 1, backupDir: <backup_data_path})
{ "ok" : 1 }
If the backup was successful, you should receive an { "ok" : 1 } object. If there was an error, you will receive a failing ok status with the error message, for example:
> db.runCommand({createBackup: 1, backupDir: ""})
{ "ok" : 0, "errmsg" : "Destination path must be absolute" }
Saving a backup to a TAR archive
Implementation details
This feature was implemented in Percona Server for MongoDB 4.2.1-1.
To save a backup in the format of tar archive, use the archive field to specify the destination path:
> use admin
...
> db.runCommand({createBackup: 1, archive: <path_to_archive>.tar })
Streaming hot backups to a remote destination
Percona Server for MongoDB enables uploading hot backups to an Amazon S3 or a compatible storage service, such as MinIO.
This method requires that you provide the bucket field in the s3 object:
> use admin
...
> db.runCommand({createBackup: 1, s3: {bucket: "backup20190510", path: <some_optional_path>} })
In addition to the mandatory bucket field, the s3 object may contain the following fields:
| Field | Type | Description |
|---|---|---|
| bucket | string | The only mandatory field. Names are subject to restrictions described in the Bucket Restrictions and Limitations section of Amazon S3 documentation |
| path | string | The virtual path inside the specified bucket where the backup will be created. If the path is not specified then the backup is created in the root of the bucket. If there are any objects under the specified path, the backup will not be created and an error will be reported. |
| endpoint | string | The endpoint address and port - mainly for AWS S3 compatible servers such as the MinIO server. For a local MinIO server, this can be “127.0.0.1:9000”. For AWS S3 this field can be omitted. |
| scheme | string | “HTTP” or “HTTPS” (default). For a local MinIO server started with the minio server command this should field should contain HTTP. |
| useVirtualAddressing | bool | The style of addressing buckets in the URL. By default ‘true’. For MinIO servers, set this field to false. For more information, see Virtual Hosting of Buckets in the Amazon S3 documentation. |
| region | string | The name of an AWS region. The default region is US_EAST_1. For more information see AWS Service Endpoints in the Amazon S3 documentation. |
| profile | string | The name of a credentials profile in the credentials configuration file. If not specified, the profile named default is used. |
| accessKeyId | string | The access key id |
| secretAccessKey | string | The secret access key |
Credentials
If the user provides the access key id and the secret access key parameters, these are used as credentials.
If the access key id parameter is not specified then the credentials are loaded from the credentials configuration file. By default, it is ~/.aws/credentials.
An example of the credentials file
[default]
aws_access_key_id = ABC123XYZ456QQQAAAFFF
aws_secret_access_key = zuf+secretkey0secretkey1secretkey2
[localminio]
aws_access_key_id = ABCABCABCABC55566678
aws_secret_access_key = secretaccesskey1secretaccesskey2secretaccesskey3
Examples
Backup in root of bucket on local instance of MinIO server
> db.runCommand({createBackup: 1, s3: {bucket: "backup20190901500",
scheme: "HTTP",
endpoint: "127.0.0.1:9000",
useVirtualAddressing: false,
profile: "localminio"}})
Backup on MinIO testing server with the default credentials profile
The following command creates a backup under the virtual path “year2019/day42” in the backup bucket:
> db.runCommand({createBackup: 1, s3: {bucket: "backup",
path: "year2019/day42",
endpoint: "sandbox.min.io:9000",
useVirtualAddressing: false}})
Backup on AWS S3 service using default settings
> db.runCommand({createBackup: 1, s3: {bucket: "backup", path: "year2019/day42"}})
See also
- AWS Documentation: Providing AWS Credentials
- https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/credentials.html
Restoring data from backup
Restoring from backup on a standalone server
To restore your database on a standalone server, stop the mongod service, clean out the data directory and copy files from the backup directory to the data directory. The mongod user requires access to those files to start the service. Therefore, make the mongod user the owner of the data directory and all files and subdirectories under it, and restart the mongod service.
Run the following commands as root or by using the sudo command
# Stop the mongod service
$ systemctl stop mongod
# Clean out the data directory
$ rm -rf /var/lib/mongodb/*
# Copy backup files
$ cp -RT <backup_data_path> /var/lib/mongodb/
# Grant permissions to data files for the mongod user
$ chown -R mongod:mongod /var/lib/mongodb/
# Start the mongod service
$ systemctl start mongod
Restoring from backup in a replica set
The recommended way to restore the replica set from a backup is to restore it into a standalone node and then initiate it as the first member of a new replica set.
Note
If you try to restore the node into the existing replica set and there is more recent data, the restored node detects that it is out of date with the other replica set members, deletes the data and makes an initial sync.
Run the following commands as root or by using the sudo command
The restore steps are the following:
Stop the
mongodservice:$ systemctl stop mongod
Clean the data directory and then copy the files from the backup directory to your data directory. Assuming that the data directory is
/var/lib/mongodb/, use the following commands:$ rm -rf /var/lib/mongodb/*
$ cp -RT <backup_data_path> /var/lib/mongodb/Grant permissions to the data files for the
mongoduser$ chown -R mongod:mongod /var/lib/mongodb/
Make sure the replication is disabled in the config file and start the
mongodservice.$ systemctl start mongod
Connect to your standalone node via the
mongoshell and drop the local database> mongo
> use local
> db.dropDatabase()
percona mongo热备的更多相关文章
- KeepAlived+HaProxy+MyCat+Percona双机热备PXC集群
一.搭建PXC集群 1.环境:centos7+PXC5.7.21+mycat1.6.5 2.卸载mariadb rpm -qa | grep mariadb* yum -y remove mariad ...
- MySQL的热备percona-xtrabackup、innobackupex的安装方法
http://blog.csdn.net/dbanote/article/details/13295727 http://blog.csdn.net/yangzhawen/article/detail ...
- INNOBACKUPEX热备MYSQL数据
http://www.databaseclub.com/2014/11/innobackupex/ 1)对MySQL进行全备份1.备份数据 1 innobackupex --user=userna ...
- Docker下配置双机热备PXC集群
架构: 步骤: 1.安装centos7 ,设置宿主机IP:192.168.1.224 2.先更新yum软件管理器,再安装docker 1.yum -y update 2.yum install - ...
- MySQL 基于xtrabackup备份—热备工具
xtrabackup(仅对InnoDB存储引擎支持热备) percona公司开发 改进的MySQL分支:percona-server 存储引擎改进:InnoDB —> XtraDB 使用本地的R ...
- 利用XtraBackup给MYSQL热备(基于数据文件)
利用XtraBackup给MYSQL热备(基于数据文件) By JRoBot on 2013 年 11 月 26 日 | Leave a response 利用XtraBackup给MYSQL热备(基 ...
- CentOS系统MySQL双机热备配置
1 概述 在集成项目中需要应对不同环境下的安装配置,主流操作系统大致可以分为三种:Linux.Windows以及UNIX.其中Linux备受青睐的主要原因有两个: 首先,Linux作为自由软件有两个 ...
- 一张“神图”看懂单机/集群/热备/磁盘阵列(RAID)
单机部署(stand-alone):只有一个饮水机提供服务,服务只部署一份 集群部署(cluster):有多个饮水机同时提供服务,服务冗余部署,每个冗余的服务都对外提供服务,一个服务挂掉时依然可用 热 ...
- Keepalived+LVS+nginx双机热备
Keepalived简介 什么是Keepalived呢,keepalived观其名可知,保持存活,在网络里面就是保持在线了, 也就是所谓的高可用或热备,用来防止单点故障的发生. Keepalived采 ...
- Mysql5.6主从热备配置
数据库是应用系统的核心,为了保证数据库的安全采用主从热备是很常见的方法,也就是主数据库DDL.DML都将被同步到从数据库. 一. 实验环境 操作系统:windowsserver 2008 R ...
随机推荐
- 内容类型框架-ContentType 模型
参考Django官方文档 ContentTypeManager¶ classContentTypeManager¶ ContentType 还有一个自定义管理器, ContentTypeManager ...
- vue调接口导出表格
props:{ form:{ type:Object, default:()=>{} }, indexNum:{ ...
- https原理(五)双向实践(https代理)
本文为了证明: 1 双向可以通过直接转发tcp的中间人代理网关 2 双向可以防止明文中间人 开始.(服务端need,使用myhost.com-pub-capub.jks,myhost.com-pub- ...
- R7-3 十六进制字符串转换成十进制非负整数
R7-3 十六进制字符串转换成十进制非负整数 分数 15 全屏浏览题目 切换布局 作者 颜晖 单位 浙大城市学院 输入一个以#结束的字符串,滤去所有的非十六进制字符(不分大小写),组成一个新的表示十六 ...
- 吴恩达老师机器学习课程chapter10——推荐算法
吴恩达老师机器学习课程chapter10--推荐算法 本文是非计算机专业新手的自学笔记,高手勿喷. 本文仅作速查备忘之用,对应吴恩达(AndrewNg)老师的机器学期课程第十六章. 缺少数学证明,仅作 ...
- 让你深夜emo的“网抑云”,是如何做产品设计的?
网易云音乐作为国内首个以"歌单"为核心架构的音乐APP,有的人喜欢它的热评,有的人却觉得它的版权太少,虽然网易云音乐不是曲库最丰富的听歌软件,但绝对是听歌软件里情感体验最好的. 我 ...
- nginx auth_basic uwsgi 目录简易认证。
mkdir /etc/nginx/conf.d/auth_pwd touch /etc/nginx/conf.d/auth_pwd/xx.pwd htpasswd -c -d /etc/nginx/c ...
- 通过ASP生成html纯静态页面的简单示例
本站收录这篇文章通过ASP生成html纯静态页面的简单示例,详细解说文章中相关静态 asp 技术与知识,欢迎能给大家一些在这方面的支持和帮助!下面是详细内容: 原理:通过浏览器传送变量,如 http: ...
- [ARC140D] One to One
个人思路: 一棵树也只有一个 \(a=-1\) 的点,所以可以把它看做一个点,但是要记录点的大小 \(sz_i\),即为这棵树的大小.如果本来就是一个点,那么大小为 \(1\). 状态:\(dp_{i ...
- unity创建一个数组,让他随机生成一个东西之C#语言(有图教程)
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; ...