天天看点

Percona XtraBackup 安装介绍篇

<b></b> 

<b>XtraBackup介绍</b>

XtraBackup是Percona公司的开源项目,用以实现类似Innodb官方的热备份工具InnoDB Hot Backup的功能,它支持在线热备份(备份时不影响数据读写)。到目前为止,最新的版本为Percona XtraBackup 2.4.7.

XtraBackup有很多功能和优点:例如支持全备、增量备份、部分备份;支持压缩备份;备份不影响数据读写、事务等,但是也有缺陷不足:例如不支持脱机备份、不支持直接备份到磁带设备、不支持Cloud Back,MyISAM的备份也会阻塞。不过这些小瑕疵不影响XtraBackup成为一款流行的MySQL备份工具。另外,请注意XtraBackup只支持Linux平台,不支持Windows平台。

下面是XtraBackup的官方文档的介绍资料:

Percona XtraBackup is the world’s only open-source, free MySQL hot backup software that performs non-blocking

backups for InnoDB and XtraDB databases. With Percona XtraBackup, you can achieve the following benefits:

• Backups that complete quickly and reliably

• Uninterrupted transaction processing during backups

• Savings on disk space and network bandwidth

• Automatic backup verification

• Higher uptime due to faster restore time

Percona XtraBackup makes MySQL hot backups for all versions of Percona Server, MySQL, and MariaDB. It performs

streaming, compressed, and incremental MySQL backups.

Percona XtraBackup works with MySQL, MariaDB, and Percona Server. It supports completely non-blocking backups

of InnoDB, XtraDB, and HailDB storage engines. In addition, it can back up the following storage engines by briefly

pausing writes at the end of the backup: MyISAM, Merge, and Archive, including partitioned tables, triggers, and

database options.

<b>Percona  XtraBackup</b><b>的特征:</b>

<b></b><b></b> 

Features

Percona  XtraBackup

License

GPL

Pirce

Free

Streaming and encryption formats

Open source

Supported MySQL flavors

MySQL, Percona Server, MariaDB, Percona XtraDB Cluster, MariaDB Supported

Supported operating systems

Linux

Non-blocking InnoDB backups

Yes

Blocking MyISAM backups

Incremental backups

Full compressed backups

Incremental compressed backups

Fast incremental backups

Incremental backups with archived logs feature in Percona Server

Incremental backups with REDO log only

Backup locks

Encrypted backups

Streaming backups

Parallel local backups

Parallel compression

Parallel encryption

Parallel apply-log

Parallel copy-back

Partial backups

Partial backups of individual partitions

Throttling

Backup image validation

Point-in-time recovery support

Safe slave backups

Compact backups

Buffer pool state backups

Individual tables export

Individual partitions export

Restoring tables to a different server

Data &amp; index file statistics

InnoDB secondary indexes defragmentation

rsync support to minimize lock time

Improved FTWRL handlin

Backup history table

Backup progress table

Backup to tape media managers

Cloud backups support

External graphical user interfaces to backup/recovery Zmanda Recovery

Zmanda Recovery Manager for MySQL

<b> </b>

<b>XtraBackup下载</b>

XtraBackup可以从官方链接https://www.percona.com/downloads/XtraBackup/LATEST/下载你需要的稳定版本。到目前为止,XtraBackup最新的版本为Percona-XtraBackup-2.4.7。这个链接也提供Percona XtraBackup Documentation相关文档下载。 下载的时候,注意版本与平台信息。

   Percona XtraBackup的源码放在Github 上,地址为https://github.com/percona/percona-xtrabackup.git

   Percona XtraBackup的文档地址:

        https://www.percona.com/doc/percona-xtrabackup/2.2/index.html

        https://www.percona.com/doc/percona-xtrabackup/2.3/index.html

        https://www.percona.com/doc/percona-xtrabackup/2.4/index.html

<b>XtraBackup安装</b>

Percona XtraBackup的安装方式总体来说有下面三种,我们下面简单的介绍一下。然后都具体都练练手。

Installing Percona XtraBackup from Repositories (recommended)

Installing Percona XtraBackup from Downloaded rpm or apt Packages

Compiling and Installing from Source Code

<b>1:</b><b>Installing Percona XtraBackup from Repositories </b>

<b>Installing Percona XtraBackup on Red Hat Enterprise Linux and CentOS</b>

下面我测试的环境为CentOS Linux release 7.2.1511 (Core) ,安装Percona XtraBackup 2.4为例:

步骤1: Install the Percona repository

RHEL/Centos 5不支持从远程位置直接安装软件包,因此您需要首先下载软件包,然后用rpm手动安装

安装完成后,你就能在/etc/yum.repos.d 下看到一个percona-release.repo文件。

步骤2: 测试Repository,确保Percona XtraBackup相关包已经在Repository中。

步骤3:安装Percona XtraBackup包。

<b>Installing Percona XtraBackup from Percona apt repository</b>

下面我测试的环境为Ubuntu 16.04.1 LTS ,安装Percona XtraBackup 2.4为例:

1:从Percona官方网址获取repository packages:

--2017-02-28 11:57:52--  https://repo.percona.com/apt/percona-release_0.1-4.xenial_all.deb

Resolving repo.percona.com (repo.percona.com)... 74.121.199.234

Connecting to repo.percona.com (repo.percona.com)|74.121.199.234|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 6394 (6.2K) [application/octet-stream]

Saving to: ‘percona-release_0.1-4.xenial_all.deb’

percona-release_0.1-4.xenial_all.deb        100%[==================&gt;]   6.24K  --.-KB/s    in 0s     

2017-02-28 11:57:53 (157 MB/s) - ‘percona-release_0.1-4.xenial_all.deb’ saved [6394/6394]

2: 用dpkg安装下载的package包文件

mylnx02@mylnx02:~$ sudo dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb

Selecting previously unselected package percona-release.

(Reading database ... 76835 files and directories currently installed.)

Preparing to unpack percona-release_0.1-4.xenial_all.deb ...

Unpacking percona-release (0.1-4.xenial) ...

Setting up percona-release (0.1-4.xenial) ...

<a href="mailto:mylnx02@azrlnx02:~%24">mylnx02@azrlnx02:~$</a>

3: update the local cache

mylnx02@mylnx02:~$ sudo apt-get update

Hit:1 http://azure.archive.ubuntu.com/ubuntu xenial InRelease

Get:2 http://azure.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]

Get:3 http://azure.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]

Hit:4 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease             

Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]    

Get:6 http://repo.percona.com/apt xenial InRelease [15.9 kB]                  

Get:7 http://repo.percona.com/apt xenial/main Sources [5,387 B]               

Get:8 http://repo.percona.com/apt xenial/main amd64 Packages [19.1 kB] 

Fetched 347 kB in 1s (212 kB/s)    

Reading package lists... Done

N: Ignoring file '50unattended-upgrades.ucf-dist' in directory '/etc/apt/apt.conf.d/' as it has an invalid filename extension

mylnx02@azrlnx02:~$

4:安装Percona XtraBackup包percona-xtrabackup-24

<b>2:Installing Percona XtraBackup from Downloaded rpm or apt Packages</b>

1:使用yum localinstall package 从本机目录安装软件包

2:原始的rpm安装方式

 这里测试环境,下载的是 Percona-XtraBackup-2.2.12-r8726828-el5-x86_64-bundle.tar安装包。在安装之前最好安装一些其他额外组件,例如perl-DBD-MySQL等。否则你会遇到一些杂七杂八的问题。例如

perl(DBD::mysql) is needed by percona-xtrabackup-2.2.12-1.el5.x86_64

[root@DB-Server tmp]# rpm -ivh percona-xtrabackup-2.2.12-1.el5.x86_64.rpm

warning: percona-xtrabackup-2.2.12-1.el5.x86_64.rpm: Header V4 DSA signature: NOKEY, key ID cd2efd2a

error: Failed dependencies:

        perl(DBD::mysql) is needed by percona-xtrabackup-2.2.12-1.el5.x86_64

<b>3:Compiling and Installing from Source Code</b>

Percona Xtrabackup的源码位于github上,URL链接为https://github.com/percona/percona-xtrabackup 你可以下载,也可以使用git命令下载源码。源码安装的具体过程如下所示:

1:如果没有安装git,则需先安装git包

[root@mylnx005 ~]# sudo yum install git

2:使用git clone获取相关源码

# git clone https://github.com/percona/percona-xtrabackup.git

Percona XtraBackup 安装介绍篇

# cd percona-xtrabackup/

# git checkout 2.4

3:安装相关依赖包

# yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf \

bison libtool ncurses-devel libgcrypt-devel libev-devel libcurl-devel \

vim-common

# cmake -DBUILD_CONFIG=xtrabackup_release -DWITH_MAN_PAGES=OFF &amp;&amp; make –j4

Percona XtraBackup 安装介绍篇

如上所示,在使用cmake编译时,遇到了错误,可以用如下方法解决。

# mkdir -p /usr/local/boost

# cd /usr/local/boost

# wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

# tar -xvzf boost_1_59_0.tar.gz

# rm boost_1_59_0.tar.gz

继续编译,增加参数(红色部分)

#cmake -DBUILD_CONFIG=xtrabackup_release \

          -DWITH_MAN_PAGES=OFF \

          -DWITH_BOOST=/usr/local/boost \

          &amp;&amp; make -j4

# make install

Percona XtraBackup 安装介绍篇

# /usr/local/xtrabackup/bin/innobackupex --version

innobackupex version 2.4.7 Linux (x86_64) (revision id: 5b42862)

<b>XtraBackup卸载</b>

 Xtrabackup的卸载相对来说比较简单,这里从简的介绍一下。

<b>1:apt packages安装方式的卸载</b>

root@mylnx02:~# sudo apt-get remove percona-xtrabackup-24

Building dependency tree      

Reading state information... Done

The following packages were automatically installed and are no longer required:

  libdbd-mysql-perl libdbi-perl libev4 libmysqlclient20

Use 'sudo apt autoremove' to remove them.

The following packages will be REMOVED:

  percona-xtrabackup-24

0 upgraded, 0 newly installed, 1 to remove and 75 not upgraded.

After this operation, 32.1 MB disk space will be freed.

Do you want to continue? [Y/n] y

(Reading database ... 77053 files and directories currently installed.)

Removing percona-xtrabackup-24 (2.4.6-1.xenial) ...

Processing triggers for man-db (2.7.5-1) ...

<b>2:YUM安装方式的卸载</b>

[root@mylnx13 ~]# yum list | grep percona

Repository base is listed more than once in the configuration

Repository updates is listed more than once in the configuration

Repository extras is listed more than once in the configuration

Repository centosplus is listed more than once in the configuration

Repository contrib is listed more than once in the configuration

percona-xtrabackup.x86_64                  2.2.12-1.el6                installed

percona-xtrabackup-debuginfo.x86_64        2.2.12-1.el6                installed

[root@mylnx13 ~]#

操作系统:CentOS Linux release 7.2.1511 (Core)

<b>3:rpm安装方式的卸载</b>

[root@DB-Server ~]# rpm -qa | grep percona

percona-xtrabackup-24-2.4.5-1.el7.x86_64

[root@DB-Server ~]# rpm -ev percona-xtrabackup-24-2.4.5-1.el7.x86_64

<b>4:Source Code安装方式的卸载</b>

Percona XtraBackup的安装、卸载、以及介绍篇就写到这,如果需要了解更多细节,建议参考官方文档,例如Percona-XtraBackup-2.4.6.pdf,后续将展开介绍XtraBackup备份还原篇、原理分析篇。

继续阅读