天天看點

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備份還原篇、原理分析篇。

繼續閱讀