- A+
摘要: 1、前言 Create hot InnoDB backups without pausing your database Make incremental backups of MySQL Stream compressed MySQL backups to another server Move...
1、前言
- Create hot InnoDB backups without pausing your database
- Make incremental backups of MySQL
- Stream compressed MySQL backups to another server
- Move tables between MySQL servers on-line
- Create new MySQL replication slaves easily
- Backup MySQL without adding load to the serve
2、流式和压缩备份
Streaming mode, supported by Percona XtraBackup, sends backup to STDOUT in special tar or xbstream format instead of copying files to the backup directory.
Percona XtraBackup支持流式备份,将备份以指定的tar或xbstream格式发送到STDOUT,而不是直接将文件复制到备份目录。
This allows you to use other programs to filter the output of the backup, providing greater flexibility for storage of the backup. For example, compression is achieved by piping the output to a compression utility. One of the benefits of streaming backups and using Unix pipes is that the backups can be automatically encrypted.
这允许您使用其他程序来过滤备份的输出,为备份的存储提供更大的灵活性。例如,压缩是通过将输出管道输送到压缩实用程序来实现的。流式备份和使用Unix管道的优点之一:备份可以被自动加密。
To use the streaming feature, you must use the --stream
, providing the format of the stream (tar
or xbstream
) and where to store the temporary files:
使用流式备份,您需要使用--stream参数,指定流式备份格式(tar或xbstream)以及存储临时文件的绝对路径:
$ innobackupex --stream=tar /tmp
innobackupex starts xtrabackup in --log-stream mode in a child process, and redirects its log to a temporary file. It then uses xbstream to stream all of the data files to STDOUT, in a special xbstream format. See The xbstream binary for details. After it finishes streaming all of the data files to STDOUT, it stops xtrabackup and streams the saved log file too.
innobackupex在子进程中启动xtrabackup --log-stream模式,并将其日志重定向到临时文件。然后,使用xbstream将所有数据文件以xbstream格式传输到STDOUT。有关详细信息,请参阅xbstream二进制文件(详见:
https://www.percona.com/doc/percona-xtrabackup/LATEST/xbstream/xbstream.html)。在将所有的数据文件流到STDOUT之后,停止xtrabackup,并将保存的日志文件进行备份。
When compression is enabled, xtrabackup compresses all output data, except the meta and non-InnoDB files which are not compressed, using the specified compression algorithm. The only currently supported algorithm is quicklz. The resulting files have the qpress archive format, i.e. every *.qp file produced by xtrabackup is essentially a one-file qpress archive and can be extracted and uncompressed by the qpress file archiver which is available from Percona Software repositories.
xtrabackup在压缩过程中,将使用指定的压缩算法,压缩所有输出数据,除了元数据和非innodb文件。目前仅仅支持quicklz算法。结果文件是qpress压缩格式,即每个*.qp,xtrabackup生成的qp文件本质上是一个单文件的qpress压缩文件,可以从Percona软件存储库中获得qpress压缩文件的提取和解压方式。
Using xbstream as a stream option, backups can be copied and compressed in parallel which can significantly speed up the backup process. In case backups were both compressed and encrypted, they’ll need to decrypted first in order to be uncompressed.
使用xbstream作流式备份选项,可以并行复制和压缩备份,从而大大加快备份过程。如果备份是压缩和加密,首先需要解密,以便不被压缩。
3、xbstream压缩备份实例
Store the complete backup directly to a single file:
将完整备份直接存储到单个文件:
$ innobackupex --stream=xbstream /root/backup/ > /root/backup/backup.xbstream
To stream and compress the backup:
进行流式和压缩备份:
$ innobackupex --stream=xbstream --compress /root/backup/ > /root/backup/backup.xbstream
To unpack the backup to the /root/backup/ directory:
将备份解压到/root/backup/目录:
$ xbstream -x < backup.xbstream -C /root/backup/
To send the compressed backup to another host and unpack it:
将压缩后的备份发送到另一个主机并解压:
$ innobackupex --compress --stream=xbstream /root/backup/ | ssh user@otherhost "xbstream -x -C /root/backup/"
4、tar压缩备份实例
Store the complete backup directly to a tar archive:
将完整备份直接存储到tar存档文件:
$ innobackupex --stream=tar /root/backup/ > /root/backup/out.tar
To send the tar archive to another host:
将tar存档文件发送到另一个主机:
$ innobackupex --stream=tar ./ | ssh user@destination \ "cat - > /data/backups/backup.tar"
Warning:
To extract Percona XtraBackup's archive you must use tar with -i option:
用tar压缩备份,在解压时必须使用 -i 参数:
$ tar -xizf backup.tar.gz
Compress with your preferred compression tool:
可以选择的压缩方式:
$ innobackupex --stream=tar ./ | gzip - > backup.tar.gz
$ innobackupex --stream=tar ./ | bzip2 - > backup.tar.bz2
注意:
Note that the streamed backup will need to be prepared before restoration. Streaming mode does not prepare the backup.
在恢复之前需要prepared该备份,因为流式备份不会做prepare。
5、总结
1. XtraBackup备份可以做到事务处理不间断,恢复速度快而高效;
2. 使用流式备份可以节省磁盘空间和网络带宽,快速搭建主从。
- 安卓客户端下载
- 微信扫一扫
- 微信公众号
- 微信公众号扫一扫