zoukankan      html  css  js  c++  java
  • percona xtrabackup 简介

    os: centos 7.4
    db: mysql 5.7
    dbbackup: xtrabackup 2.4.9

    xtrabackup是一款优秀的mysql开源备份(物理备份)工具,是由percona公司开发的。

    下载

    官网下载
    https://www.percona.com/software/mysql-database/percona-xtrabackup
    https://www.percona.com/downloads/XtraBackup/LATEST/

    也有git的支持
    https://github.com/percona/percona-xtrabackup

    文档
    https://www.percona.com/doc/percona-xtrabackup/LATEST/index.html
    https://www.percona.com/doc/percona-xtrabackup/2.4/index.html
    Percona-XtraBackup-2.4.9.pdf

    安装

    主要有几种方式
    1)yum Repositories方式
    yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
    yum list|grep -i percona
    yum install percona-xtrabackup-24.x86_64

    2)手动rpm包安装
    Percona-XtraBackup-2.4.9-ra467167cdd4-el7-x86_64-bundle.tar

    3)二进制的方式
    percona-xtrabackup-2.4.9-Linux-x86_64.tar.gz

    4)源码编译
    percona-xtrabackup-2.4.9.tar.gz

    5)git方式,越来越多的项目提供git支持了
    https://github.com/percona/percona-xtrabackup.git
    https://github.com/percona/percona-xtrabackup

    本次采用手动rpm方式

    # cd /tmp/xtrabackup
    # tar -xvf ./Percona-XtraBackup-2.4.9-ra467167cdd4-el7-x86_64-bundle.tar
    # rpm -ivh ./percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm
    warning: ./percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY
    error: Failed dependencies:
        libev.so.4()(64bit) is needed by percona-xtrabackup-24-2.4.9-1.el7.x86_64
    # yum install libev
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirrors.cn99.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package libev.x86_64 0:4.15-7.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =========================================================================================================
     Package               Arch                   Version                       Repository              Size
    =========================================================================================================
    Installing:
     libev                 x86_64                 4.15-7.el7                    extras                  44 k
    
    Transaction Summary
    =========================================================================================================
    Install  1 Package
    
    Total download size: 44 k
    Installed size: 86 k
    Is this ok [y/d/N]: y
    Downloading packages:
    libev-4.15-7.el7.x86_64.rpm                                                       |  44 kB  00:00:05     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : libev-4.15-7.el7.x86_64                                                               1/1 
      Verifying  : libev-4.15-7.el7.x86_64                                                               1/1 
    
    Installed:
      libev.x86_64 0:4.15-7.el7                                                                              
    
    Complete!

    再次安装xtrabackup

    # rpm -ivh ./percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm
    warning: ./percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:percona-xtrabackup-24-2.4.9-1.el7################################# [100%]

    中间出错,可以baidu多搜搜,基本都不难解决
    至此,xtrabackup就算安装好了,下面来简述如何备份和还原,更灵活的用法计划再写几篇xtrabackup专题blog

    # which innobackupex 
    /usr/bin/innobackupex
    # which xtrabackup 
    /usr/bin/xtrabackup
    # ls -l /usr/bin/innobackupex 
    lrwxrwxrwx 1 root root 10 Mar 26 21:06 /usr/bin/innobackupex -> xtrabackup

    可以看到 innobackupex 是到 xtrabackup 的软链

    # innobackupex --help 
    # xtrabackup --help

    这两个的输出还是不太一样innobackupex –help 有这样一句描述

    NOTICE: ‘innobackupex’ is deprecated, please switch to ‘xtrabackup’

    所以还是安心使用 xtrabackup

    Percona XtraBackup is a set of following tools:
    innobackupex 
    innobackupex is the symlink for xtrabackup. innobackupex still supports all features and
    syntax as 2.2 version did, but is now deprecated and will be removed in next major release.
    
    xtrabackup 
    a compiled C binary that provides functionality to backup a whole MySQL database instance with MyISAM, InnoDB, and XtraDB tables.
    
    xbcrypt 
    utility used for encrypting and decrypting backup files.
    
    xbstream 
    utility that allows streaming and extracting files to/from the xbstream format.
    
    xbcloud 
    utility used for downloading and uploading full or part of xbstream archive from/to cloud.
    
    After Percona XtraBackup 2.3 release the recommend way to take the backup is using the xtrabackup script. More
    information on script options can be found in how to use xtrabackup.

    备份

    全量备份

    # xtrabackup --backup --datadir=/var/lib/mysql/ --target-dir=/backup/backupset/20180327_base

    增量备份

    # xtrabackup --backup --datadir=/var/lib/mysql/ --target-dir=/backup/backupset/20180327_inc1 --incremental-basedir=/backup/backupset/20180327_base
    # xtrabackup --backup --datadir=/var/lib/mysql/ --target-dir=/backup/backupset/20180327_inc2 --incremental-basedir=/backup/backupset/20180327_inc1

    prepare

    # xtrabackup --prepare --apply-log-only --target-dir=/backup/backupset/20180327_base
    # xtrabackup --prepare --apply-log-only --target-dir=/backup/backupset/20180327_base --incremental-basedir=/backup/backupset/20180327_inc1

    压缩备份

    # xtrabackup --backup --compress --datadir=/var/lib/mysql/ --target-dir=/backup/backupset/20180327_base
    # xtrabackup --backup --compress --compress-threads=4 --datadir=/var/lib/mysql/ --target-dir=/backup/backupset/20180327_base

    压缩备份prepare 之前需要先解压

    # xtrabackup --decompress --target-dir=/backup/backupset/20180327_base
    # xtrabackup --parallel=4 --decompress --target-dir=/backup/backupset/20180327_base

    恢复

    # xtrabackup --copy-back --target-dir=/backup/backupset/20180327_base
    # xtrabackup --move-back 

    记得查看权限

    # chown -R mysql:mysql /var/lib/mysql
  • 相关阅读:
    Loved
    什么是REST
    统一资源定位符URL(Uniform Resource Locator)
    HTTP工作原理
    系统程序员成长计划内存管理(一)
    系统程序员成长计划工程管理(四)
    系统程序员成长计划-内存管理(四)
    HTTP请求报文格式
    系统程序员成长计划内存管理(二)
    系统程序员成长计划-内存管理(三)
  • 原文地址:https://www.cnblogs.com/ctypyb2002/p/9793030.html
Copyright © 2011-2022 走看看