Xtrabackup2.0.8原始碼安裝使用
Xtrabackup2.0.8原始碼安裝使用
Xtrabackup是一個對InnoDB做資料備份的工具,支援線上熱備份(備份時不影響資料讀寫),是商業備份工具InnoDB Hotbackup的一個很好的替代品。
Xtrabackup有兩個主要的工具:xtrabackup、innobackupex
(1)xtrabackup只能備份InnoDB和XtraDB兩種資料表,而不能備份MyISAM資料表
(2)innobackupex 則封裝了xtrabackup,是一個指令碼封裝,所以能同時備份處理innodb和myisam,但在處理myisam時需要加一個讀鎖
(3)Xtrabackup 2.1.x版本的支援MySQL 5.5 and 5.6 servers,Xtrabackup 2.0.x版本的支援MySQL 5.0, 5.1, 5.5 and 5.6 servers
官網下載地址:
/>
百度網盤下載地址:
/>
安裝文件:
/>
環境:
mysql Ver 14.14 Distrib 5.1.66, for redhat-linux-gnu (x86_64) using readline 5.1
1. 原始碼安裝
包安裝:
[root@nagios tmp]# yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bzr bison libtool ncurses-devel zlib-devel
[root@nagios tmp]# ll
total 10984
-rw-r--r-- 1 root root 11241809 Oct 10 15:21 percona-xtrabackup-2.0.8.tar.gz
[root@nagios tmp]# tar -xvf percona-xtrabackup-2.0.8.tar.gz
[root@nagios tmp]# mysql -V
mysql Ver 14.14 Distrib 5.1.66, for redhat-linux-gnu (x86_64) using readline 5.1
[root@nagios tmp]#
[root@nagios tmp]#
[root@nagios tmp]# cd percona-xtrabackup-2.0.8
[root@nagios percona-xtrabackup-2.0.8]# ll
total 172
-rw-r--r-- 1 root root 2396 Sep 3 2013 BUILD.txt
-rw-r--r-- 1 root root 2992 Sep 3 2013 BUILD-WIN.txt
-rw-r--r-- 1 root root 1695 Sep 3 2013 CMakeLists.txt
drwxr-xr-x 2 root root 4096 Oct 10 15:23 contrib
-rw-r--r-- 1 root root 19070 Sep 3 2013 COPYING
drwxr-xr-x 3 root root 4096 Oct 10 15:23 doc
-rwxr-xr-x 1 root root 113912 Sep 3 2013 innobackupex
drwxr-xr-x 2 root root 4096 Oct 10 15:23 patches
drwxr-xr-x 4 root root 4096 Oct 10 15:23 src
drwxr-xr-x 8 root root 4096 Oct 10 15:23 test
drwxr-xr-x 3 root root 4096 Oct 10 15:23 utils
-rw-r--r-- 1 root root 25 Sep 3 2013 VERSION
[root@nagios percona-xtrabackup-2.0.8]# cat BUILD.txt
================================
How to build XtraBackup on Linux
================================
Prerequisites
-------------
The following packages and tools must be installed to compile
Percona XtraBackup from source. These might vary from system to system.
In Debian-based distributions, you need to:
$ apt-get install build-essential flex bison automake autoconf bzr \
libtool cmake libaio-dev mysql-client libncurses-dev zlib1g-dev
In RPM-based distributions, you need to:
$ yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bzr \
bison libtool ncurses5-devel
Compiling with build.sh
-----------------------
Once you have all dependencies met, the compilation is straight-forward with
the bundled build.sh script in the utils/ directory of the distribution.
The script needs the codebase for which the building is targeted, you must
provide it with one of the following values or aliases:
================== ========= =============================================
Value Alias Server
================== ========= =============================================
innodb51_builtin 5.1 build against built-in InnoDB in MySQL 5.1
innodb51 plugin build against InnoDB plugin in MySQL 5.1
innodb55 5.5 build against InnoDB in MySQL 5.5
xtradb51 xtradb build against Percona Server with XtraDB 5.1
xtradb55 xtradb55 build against Percona Server with XtraDB 5.5
innodb56 5.6 build against InnoDB in MySQL 5.6
================== ========= =============================================
Note that the script must be executed from the base directory of Xtrabackup
sources, and that directory must contain the packages with the source code of
the codebase selected. This may appear cumbersome, but if the variable
AUTO_DOWNLOAD="yes" is set, the build.sh script will download all the source
code needed for the build.
At the base directory of the downloaded source code, if you execute
$ AUTO_DOWNLOAD="yes" ./utils/build.sh xtradb
and you go for a coffee, at your return XtraBackup will be ready to be used.
The xtrabackup binary will located in the "percona-xtrabackup/src" subdirectory.
After this you'll need to copy innobackupex and the corresponding xtrabackup
binary to some directory listed in the PATH environment variable, e.g. /usr/bin.
[root@nagios percona-xtrabackup-2.0.8]#
採用內網安裝,所以不用 AUTO_DOWNLOAD="yes"
先下載:mysql-5.1.59.tar.gz 官網安裝文件上有下載地址
/>
[root@nagios percona-xtrabackup-2.0.8]# ./utils/build.sh innodb51
Downloading sources
Put mysql-5.1.59.tar.gz in /tmp/percona-xtrabackup-2.0.8 or set environment variable AUTO_DOWNLOAD to "yes"
[root@nagios percona-xtrabackup-2.0.8]# cp /tmp/mysql-5.1.59.tar.gz /tmp/percona-xtrabackup-2.0.8
[root@nagios percona-xtrabackup-2.0.8]# ./utils/build.sh innodb51
Downloading sources
Preparing sources
。
。
。
安裝出來後,可以發現innodb備份工具。 innobackupex
[root@nagios percona-xtrabackup-2.0.8]# ll
total 23932
-rw-r--r-- 1 root root 2396 Sep 3 2013 BUILD.txt
-rw-r--r-- 1 root root 2992 Sep 3 2013 BUILD-WIN.txt
-rw-r--r-- 1 root root 1695 Sep 3 2013 CMakeLists.txt
drwxr-xr-x 2 root root 4096 Oct 12 09:45 contrib
-rw-r--r-- 1 root root 19070 Sep 3 2013 COPYING
drwxr-xr-x 3 root root 4096 Oct 12 09:45 doc
-rwxr-xr-x 1 root root 113912 Sep 3 2013 innobackupex
drwxrwxrwx 33 7155 wheel 4096 Oct 12 09:56 mysql-5.1
-rw-r--r-- 1 root root 24325443 Oct 12 09:45 mysql-5.1.59.tar.gz
drwxr-xr-x 2 root root 4096 Oct 12 09:45 patches
drwxr-xr-x 4 root root 4096 Oct 12 09:58 src
drwxr-xr-x 8 root root 4096 Oct 12 09:45 test
drwxr-xr-x 3 root root 4096 Oct 12 09:45 utils
-rw-r--r-- 1 root root 25 Sep 3 2013 VERSION
[root@nagios percona-xtrabackup-2.0.8]# ./innobackupex --help
Options:
--apply-log
Prepare a backup in BACKUP-DIR by applying the transaction log file
named "xtrabackup_logfile" located in the same directory. Also,
create new transaction logs. The InnoDB configuration is read from
the file "backup-my.cnf".
--compress
This option instructs xtrabackup to compress backup copies of InnoDB
data files. It is passed directly to the xtrabackup child process.
Try 'xtrabackup --help' for more details.
--compress-threads
This option specifies the number of worker threads that will be used
for parallel compression. It is passed directly to the xtrabackup
child process. Try 'xtrabackup --help' for more details.
--copy-back
Copy all the files in a previously made backup from the backup
directory to their original locations.
--databases=LIST
This option specifies the list of databases that innobackupex should
back up. The option accepts a string argument or path to file that
contains the list of databases to back up. The list is of the form
"databasename1[.table_name1] databasename2[.table_name2] . . .". If
this option is not specified, all databases containing MyISAM and
InnoDB tables will be backed up. Please make sure that --databases
contains all of the InnoDB databases and tables, so that all of the
innodb.frm files are also backed up. In case the list is very long,
this can be specified in a file, and the full path of the file can
be specified instead of the list. (See option --tables-file.)
--defaults-file=[MY.CNF]
This option specifies what file to read the default MySQL options
from. The option accepts a string argument. It is also passed
directly to xtrabackup's --defaults-file option. See the xtrabackup
documentation for details.
--defaults-extra-file=[MY.CNF]
This option specifies what extra file to read the default MySQL
options from before the standard defaults-file. The option accepts a
string argument. It is also passed directly to xtrabackup's
--defaults-extra-file option. See the xtrabackup documentation for
details.
--export
This option is passed directly to xtrabackup's --export option. It
enables exporting individual tables for import into another server.
See the xtrabackup documentation for details.
--extra-lsndir=DIRECTORY
This option specifies the directory in which to save an extra copy
of the "xtrabackup_checkpoints" file. The option accepts a string
argument. It is passed directly to xtrabackup's --extra-lsndir
option. See the xtrabackup documentation for details.
--galera-info
This options creates the xtrabackup_galera_info file which contians
the local node state at the time of the backup. Option should be
used when performing the backup of Percona-XtraDB-Cluster.
--help
This option displays a help screen and exits.
--host=HOST
This option specifies the host to use when connecting to the
database server with TCP/IP. The option accepts a string argument.
It is passed to the mysql child process without alteration. See
mysql --help for details.
--ibbackup=IBBACKUP-BINARY
This option specifies which xtrabackup binary should be used. The
option accepts a string argument. IBBACKUP-BINARY should be the
command used to run XtraBackup. The option can be useful if the
xtrabackup binary is not in your search path or working directory.
If this option is not specified, innobackupex attempts to determine
the binary to use automatically. By default, "xtrabackup" is the
command used. However, when option --copy-back is specified,
"xtrabackup_51" is the command used. And when option --apply-log is
specified, the binary is used whose name is in the file
"xtrabackup_binary" in the backup directory, if that file exists.
--include=REGEXP
This option is a regular expression to be matched against table
names in databasename.tablename format. It is passed directly to
xtrabackup's --tables option. See the xtrabackup documentation for
details.
--incremental
This option tells xtrabackup to create an incremental backup, rather
than a full one. It is passed to the xtrabackup child process. When
this option is specified, either --incremental-lsn or
--incremental-basedir can also be given. If neither option is given,
option --incremental-basedir is passed to xtrabackup by default, set
to the first timestamped backup directory in the backup base
directory.
--incremental-basedir=DIRECTORY
This option specifies the directory containing the full backup that
is the base dataset for the incremental backup. The option accepts a
string argument. It is used with the --incremental option.
--incremental-dir=DIRECTORY
This option specifies the directory where the incremental backup
will be combined with the full backup to make a new full backup. The
option accepts a string argument. It is used with the --incremental
option.
--log-copy-interval
This option specifies time interval between checks done by log
copying thread in milliseconds.
--incremental-lsn
This option specifies the log sequence number (LSN) to use for the
incremental backup. The option accepts a string argument. It is used
with the --incremental option. It is used instead of specifying
--incremental-basedir. For databases created by MySQL and Percona
Server 5.0-series versions, specify the LSN as two 32-bit integers
in high:low format. For databases created in 5.1 and later, specify
the LSN as a single 64-bit integer.
--move-back
Move all the files in a previously made backup from the backup
directory to the actual datadir location. Use with caution, as it
removes backup files.
--no-lock
Use this option to disable table lock with "FLUSH TABLES WITH READ
LOCK". Use it only if ALL your tables are InnoDB and you DO NOT CARE
about the binary log position of the backup. This option shouldn't
be used if there are any DDL statements being executed or if any
updates are happening on non-InnoDB tables (this includes the system
MyISAM tables in the mysql database), otherwise it could lead to an
inconsistent backup. If you are considering to use --no-lock because
your backups are failing to acquire the lock, this could be because
of incoming replication events preventing the lock from succeeding.
Please try using --safe-slave-backup to momentarily stop the
replication slave thread, this may help the backup to succeed and
you then don't need to resort to using this option.
--no-timestamp
This option prevents creation of a time-stamped subdirectory of the
BACKUP-ROOT-DIR given on the command line. When it is specified, the
backup is done in BACKUP-ROOT-DIR instead.
--parallel=NUMBER-OF-THREADS
This option specifies the number of threads the xtrabackup child
process should use to back up files concurrently. The option accepts
an integer argument. It is passed directly to xtrabackup's
--parallel option. See the xtrabackup documentation for details.
--password=WORD
This option specifies the password to use when connecting to the
database. It accepts a string argument. It is passed to the mysql
child process without alteration. See mysql --help for details.
--port=PORT
This option specifies the port to use when connecting to the
database server with TCP/IP. The option accepts a string argument.
It is passed to the mysql child process. It is passed to the mysql
child process without alteration. See mysql --help for details.
--redo-only
This option should be used when preparing the base full backup and
when merging all incrementals except the last one. This option is
passed directly to xtrabackup's --apply-log-only option. This forces
xtrabackup to skip the "rollback" phase and do a "redo" only. This
is necessary if the backup will have incremental changes applied to
it later. See the xtrabackup documentation for details.
--remote-host=HOSTNAME
This option is DEPRECATED and will be removed in Percona XtraBackup
2.1. In Percona XtraBackup 2.0 and later, you should use streaming
backups instead. This option specifies the remote host on which the
backup files will be created, by using an ssh connection. The option
accepts a string argument.
--rsync
Uses the rsync utility to optimize local file transfers. When this
option is specified, innobackupex uses rsync to copy all non-InnoDB
files instead of spawning a separate cp for each file, which can be
much faster for servers with a large number of databases or tables.
This option cannot be used together with --remote-host or --stream.
--safe-slave-backup
Stop slave SQL thread and wait to start backup until
Slave_open_temp_tables in "SHOW STATUS" is zero. If there are no
open temporary tables, the backup will take place, otherwise the SQL
thread will be started and stopped until there are no open temporary
tables. The backup will fail if Slave_open_temp_tables does not
become zero after --safe-slave-backup-timeout seconds. The slave SQL
thread will be restarted when the backup finishes.
--safe-slave-backup-timeout
How many seconds --safe-slave-backup should wait for
Slave_open_temp_tables to become zero. (default 300)
--scpopt=SCP-OPTIONS
This option specifies the command line options to pass to scp when
the option --remost-host is specified. The option accepts a string
argument. If the option is not specified, the default options are
"-Cp -c arcfour".
--sshopt=SSH-OPTIONS
This option specifies the command line options to pass to ssh when
the option --remost-host is specified. The option accepts a string
argument.
--slave-info
This option is useful when backing up a replication slave server. It
prints the binary log position and name of the master server. It
also writes this information to the "xtrabackup_slave_info" file as
a "CHANGE MASTER" command. A new slave for this master can be set up
by starting a slave server on this backup and issuing a "CHANGE
MASTER" command with the binary log position saved in the
"xtrabackup_slave_info" file.
--socket=SOCKET
This option specifies the socket to use when connecting to the local
database server with a UNIX domain socket. The option accepts a
string argument. It is passed to the mysql child process without
alteration. See mysql --help for details.
--stream=STREAMNAME
This option specifies the format in which to do the streamed backup.
The option accepts a string argument. The backup will be done to
STDOUT in the specified format. Currently, the only supported
formats are tar and xbstream. This option is passed directly to
xtrabackup's --stream option.
--tables-file=FILE
This option specifies the file in which there are a list of names of
the form database. The option accepts a string argument.table, one
per line. The option is passed directly to xtrabackup's
--tables-file option.
--throttle=IOS
This option specifies a number of I/O operations (pairs of
read+write) per second. It accepts an integer argument. It is passed
directly to xtrabackup's --throttle option.
--tmpdir=DIRECTORY
This option specifies the location where a temporary file will be
stored. The option accepts a string argument. It should be used when
--remote-host or --stream is specified. For these options, the
transaction log will first be stored to a temporary file, before
streaming or copying to a remote host. This option specifies the
location where that temporary file will be stored. If the option is
not specifed, the default is to use the value of tmpdir read from
the server configuration.
--use-memory=B
This option accepts a string argument that specifies the amount of
memory in bytes for xtrabackup to use for crash recovery while
preparing a backup. Multiples are supported providing the unit (e.g.
1MB, 1GB). It is used only with the option --apply-log. It is passed
directly to xtrabackup's --use-memory option. See the xtrabackup
documentation for details.
--user=NAME
This option specifies the MySQL username used when connecting to the
server, if that's not the current user. The option accepts a string
argument. It is passed to the mysql child process without
alteration. See mysql --help for details.
--defaults-group=GROUP-NAME
This option specifies the group name in my.cnf which should be used.
This is needed for mysqld_multi deployments.
--version
This option displays the xtrabackup version and copyright notice and
then exits.
建立快速連結:
[root@nagios percona-xtrabackup-2.0.8]# mv /tmp/percona-xtrabackup-2.0.8 /usr/local/
[root@nagios percona-xtrabackup-2.0.8]# ln -s /usr/local/percona-xtrabackup-2.0.8/innobackupex /usr/bin/innobackupex
innobackupex innochecksum
[root@nagios ~]# innobackupex
[root@nagios ~]# innobackupex --help
Options:
--apply-log
Prepare a backup in BACKUP-DIR by applying the transaction log file
named "xtrabackup_logfile" located in the same directory. Also,
create new transaction logs. The InnoDB configuration is read from
2. 直接下載二進位制包(linux-generic)
[root@nagios tmp]# ll
total 118312
-rw-r--r-- 1 apache apache 243 Oct 12 00:00 downtime.tmp
-rw-r--r-- 1 root root 24325443 Oct 12 09:30 mysql-5.1.59.tar.gz
drwxr-xr-x 4 root root 4096 Sep 3 2013 percona-xtrabackup-2.0.8
-rw-r--r-- 1 root root 50735377 Oct 12 11:21 percona-xtrabackup-2.0.8-587.tar.gz
-rw-r--r-- 1 root root 11241809 Oct 10 15:21 percona-xtrabackup-2.0.8.tar.gz
drwxr-xr-x 33 497 497 4096 Jul 28 15:04 percona-xtrabackup-2.2.12
-rw-r--r-- 1 root root 34827353 Oct 10 15:20 percona-xtrabackup-2.2.12.tar.gz
[root@nagios percona-xtrabackup-2.0.8]# tar -xvf percona-xtrabackup-2.0.8-587.tar.gz
[root@nagios tmp]# cd percona-xtrabackup-2.0.8
[root@nagios percona-xtrabackup-2.0.8]# ll
total 8
drwxr-xr-x 2 root root 4096 Sep 3 2013 bin
drwxr-xr-x 4 root root 4096 Sep 3 2013 share
[root@nagios percona-xtrabackup-2.0.8]# cd bin
[root@nagios bin]# ll
total 118884
-rwxr-xr-x 1 root root 113912 Sep 3 2013 innobackupex
lrwxrwxrwx 1 root root 12 Oct 12 14:08 innobackupex-1.5.1 -> innobackupex
-rwxr-xr-x 1 root root 2258560 Sep 3 2013 xbstream
-rwxr-xr-x 1 root root 12557890 Sep 3 2013 xtrabackup
-rwxr-xr-x 1 root root 10667223 Sep 3 2013 xtrabackup_51
-rwxr-xr-x 1 root root 15720860 Sep 3 2013 xtrabackup_55
-rwxr-xr-x 1 root root 80404343 Sep 3 2013 xtrabackup_56
[root@nagios bin]# cp * /usr/bin
3. 備份
[root@nagios centreon_status]# innobackupex --defaults-file=/etc/my.cnf --user=root --password=123456 --database=centreon_status /backup/centreon_status/ > /backup/centreon_status/centreon_status.log 2>&1
[root@nagios centreon_status]# ll
total 44
drwxr-xr-x 6 root root 4096 Oct 13 15:01 2015-10-13_15-01-09
-rw-r--r-- 1 root root 40852 Oct 13 15:01 centreon_status.log
[root@nagios centreon_status]# cat centreon_status.log
.
.
innobackupex: Backup created in directory '/backup/centreon_status/2015-10-13_15-01-09'
innobackupex: MySQL binlog position: filename 'mysql-bin.000033', position 10324079
151013 15:01:52 innobackupex: completed OK!
4. 恢復
先停止資料庫:service mysqld stop
複製: [root@nagios centreon_status]# scp -rp 2015-10-13_15-01-09/ 192.168.9.235:/backup/centreon_status/
恢復
innobackupex --user=root --password --defaults-file=/etc/my.cnf --apply-log /data/back_data/db/
--apply-log選項的命令是準備在一個備份上啟動mysql服務
[root@testdb1 mysql]# innobackupex --copy-back /backup/centreon_status/2015-10-13_15-01-09/
--copy-back 選項的命令從備份目錄複製資料,索引,日誌到my.cnf文 件裡規定的初始位置
賦權 chown -R mysql.mysql /var/lib/mysql/*
重啟資料庫 service mysqld restart
刪除垃圾 cd /var/lib/mysql/ && rm xtrabackup*
Xtrabackup是一個對InnoDB做資料備份的工具,支援線上熱備份(備份時不影響資料讀寫),是商業備份工具InnoDB Hotbackup的一個很好的替代品。
Xtrabackup有兩個主要的工具:xtrabackup、innobackupex
(1)xtrabackup只能備份InnoDB和XtraDB兩種資料表,而不能備份MyISAM資料表
(2)innobackupex 則封裝了xtrabackup,是一個指令碼封裝,所以能同時備份處理innodb和myisam,但在處理myisam時需要加一個讀鎖
(3)Xtrabackup 2.1.x版本的支援MySQL 5.5 and 5.6 servers,Xtrabackup 2.0.x版本的支援MySQL 5.0, 5.1, 5.5 and 5.6 servers
官網下載地址:
/>
百度網盤下載地址:
/>
安裝文件:
/>
環境:
mysql Ver 14.14 Distrib 5.1.66, for redhat-linux-gnu (x86_64) using readline 5.1
1. 原始碼安裝
包安裝:
[root@nagios tmp]# yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bzr bison libtool ncurses-devel zlib-devel
[root@nagios tmp]# ll
total 10984
-rw-r--r-- 1 root root 11241809 Oct 10 15:21 percona-xtrabackup-2.0.8.tar.gz
[root@nagios tmp]# tar -xvf percona-xtrabackup-2.0.8.tar.gz
[root@nagios tmp]# mysql -V
mysql Ver 14.14 Distrib 5.1.66, for redhat-linux-gnu (x86_64) using readline 5.1
[root@nagios tmp]#
[root@nagios tmp]#
[root@nagios tmp]# cd percona-xtrabackup-2.0.8
[root@nagios percona-xtrabackup-2.0.8]# ll
total 172
-rw-r--r-- 1 root root 2396 Sep 3 2013 BUILD.txt
-rw-r--r-- 1 root root 2992 Sep 3 2013 BUILD-WIN.txt
-rw-r--r-- 1 root root 1695 Sep 3 2013 CMakeLists.txt
drwxr-xr-x 2 root root 4096 Oct 10 15:23 contrib
-rw-r--r-- 1 root root 19070 Sep 3 2013 COPYING
drwxr-xr-x 3 root root 4096 Oct 10 15:23 doc
-rwxr-xr-x 1 root root 113912 Sep 3 2013 innobackupex
drwxr-xr-x 2 root root 4096 Oct 10 15:23 patches
drwxr-xr-x 4 root root 4096 Oct 10 15:23 src
drwxr-xr-x 8 root root 4096 Oct 10 15:23 test
drwxr-xr-x 3 root root 4096 Oct 10 15:23 utils
-rw-r--r-- 1 root root 25 Sep 3 2013 VERSION
[root@nagios percona-xtrabackup-2.0.8]# cat BUILD.txt
================================
How to build XtraBackup on Linux
================================
Prerequisites
-------------
The following packages and tools must be installed to compile
Percona XtraBackup from source. These might vary from system to system.
In Debian-based distributions, you need to:
$ apt-get install build-essential flex bison automake autoconf bzr \
libtool cmake libaio-dev mysql-client libncurses-dev zlib1g-dev
In RPM-based distributions, you need to:
$ yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bzr \
bison libtool ncurses5-devel
Compiling with build.sh
-----------------------
Once you have all dependencies met, the compilation is straight-forward with
the bundled build.sh script in the utils/ directory of the distribution.
The script needs the codebase for which the building is targeted, you must
provide it with one of the following values or aliases:
================== ========= =============================================
Value Alias Server
================== ========= =============================================
innodb51_builtin 5.1 build against built-in InnoDB in MySQL 5.1
innodb51 plugin build against InnoDB plugin in MySQL 5.1
innodb55 5.5 build against InnoDB in MySQL 5.5
xtradb51 xtradb build against Percona Server with XtraDB 5.1
xtradb55 xtradb55 build against Percona Server with XtraDB 5.5
innodb56 5.6 build against InnoDB in MySQL 5.6
================== ========= =============================================
Note that the script must be executed from the base directory of Xtrabackup
sources, and that directory must contain the packages with the source code of
the codebase selected. This may appear cumbersome, but if the variable
AUTO_DOWNLOAD="yes" is set, the build.sh script will download all the source
code needed for the build.
At the base directory of the downloaded source code, if you execute
$ AUTO_DOWNLOAD="yes" ./utils/build.sh xtradb
and you go for a coffee, at your return XtraBackup will be ready to be used.
The xtrabackup binary will located in the "percona-xtrabackup/src" subdirectory.
After this you'll need to copy innobackupex and the corresponding xtrabackup
binary to some directory listed in the PATH environment variable, e.g. /usr/bin.
[root@nagios percona-xtrabackup-2.0.8]#
採用內網安裝,所以不用 AUTO_DOWNLOAD="yes"
先下載:mysql-5.1.59.tar.gz 官網安裝文件上有下載地址
/>
[root@nagios percona-xtrabackup-2.0.8]# ./utils/build.sh innodb51
Downloading sources
Put mysql-5.1.59.tar.gz in /tmp/percona-xtrabackup-2.0.8 or set environment variable AUTO_DOWNLOAD to "yes"
[root@nagios percona-xtrabackup-2.0.8]# cp /tmp/mysql-5.1.59.tar.gz /tmp/percona-xtrabackup-2.0.8
[root@nagios percona-xtrabackup-2.0.8]# ./utils/build.sh innodb51
Downloading sources
Preparing sources
。
。
。
安裝出來後,可以發現innodb備份工具。 innobackupex
[root@nagios percona-xtrabackup-2.0.8]# ll
total 23932
-rw-r--r-- 1 root root 2396 Sep 3 2013 BUILD.txt
-rw-r--r-- 1 root root 2992 Sep 3 2013 BUILD-WIN.txt
-rw-r--r-- 1 root root 1695 Sep 3 2013 CMakeLists.txt
drwxr-xr-x 2 root root 4096 Oct 12 09:45 contrib
-rw-r--r-- 1 root root 19070 Sep 3 2013 COPYING
drwxr-xr-x 3 root root 4096 Oct 12 09:45 doc
-rwxr-xr-x 1 root root 113912 Sep 3 2013 innobackupex
drwxrwxrwx 33 7155 wheel 4096 Oct 12 09:56 mysql-5.1
-rw-r--r-- 1 root root 24325443 Oct 12 09:45 mysql-5.1.59.tar.gz
drwxr-xr-x 2 root root 4096 Oct 12 09:45 patches
drwxr-xr-x 4 root root 4096 Oct 12 09:58 src
drwxr-xr-x 8 root root 4096 Oct 12 09:45 test
drwxr-xr-x 3 root root 4096 Oct 12 09:45 utils
-rw-r--r-- 1 root root 25 Sep 3 2013 VERSION
[root@nagios percona-xtrabackup-2.0.8]# ./innobackupex --help
Options:
--apply-log
Prepare a backup in BACKUP-DIR by applying the transaction log file
named "xtrabackup_logfile" located in the same directory. Also,
create new transaction logs. The InnoDB configuration is read from
the file "backup-my.cnf".
--compress
This option instructs xtrabackup to compress backup copies of InnoDB
data files. It is passed directly to the xtrabackup child process.
Try 'xtrabackup --help' for more details.
--compress-threads
This option specifies the number of worker threads that will be used
for parallel compression. It is passed directly to the xtrabackup
child process. Try 'xtrabackup --help' for more details.
--copy-back
Copy all the files in a previously made backup from the backup
directory to their original locations.
--databases=LIST
This option specifies the list of databases that innobackupex should
back up. The option accepts a string argument or path to file that
contains the list of databases to back up. The list is of the form
"databasename1[.table_name1] databasename2[.table_name2] . . .". If
this option is not specified, all databases containing MyISAM and
InnoDB tables will be backed up. Please make sure that --databases
contains all of the InnoDB databases and tables, so that all of the
innodb.frm files are also backed up. In case the list is very long,
this can be specified in a file, and the full path of the file can
be specified instead of the list. (See option --tables-file.)
--defaults-file=[MY.CNF]
This option specifies what file to read the default MySQL options
from. The option accepts a string argument. It is also passed
directly to xtrabackup's --defaults-file option. See the xtrabackup
documentation for details.
--defaults-extra-file=[MY.CNF]
This option specifies what extra file to read the default MySQL
options from before the standard defaults-file. The option accepts a
string argument. It is also passed directly to xtrabackup's
--defaults-extra-file option. See the xtrabackup documentation for
details.
--export
This option is passed directly to xtrabackup's --export option. It
enables exporting individual tables for import into another server.
See the xtrabackup documentation for details.
--extra-lsndir=DIRECTORY
This option specifies the directory in which to save an extra copy
of the "xtrabackup_checkpoints" file. The option accepts a string
argument. It is passed directly to xtrabackup's --extra-lsndir
option. See the xtrabackup documentation for details.
--galera-info
This options creates the xtrabackup_galera_info file which contians
the local node state at the time of the backup. Option should be
used when performing the backup of Percona-XtraDB-Cluster.
--help
This option displays a help screen and exits.
--host=HOST
This option specifies the host to use when connecting to the
database server with TCP/IP. The option accepts a string argument.
It is passed to the mysql child process without alteration. See
mysql --help for details.
--ibbackup=IBBACKUP-BINARY
This option specifies which xtrabackup binary should be used. The
option accepts a string argument. IBBACKUP-BINARY should be the
command used to run XtraBackup. The option can be useful if the
xtrabackup binary is not in your search path or working directory.
If this option is not specified, innobackupex attempts to determine
the binary to use automatically. By default, "xtrabackup" is the
command used. However, when option --copy-back is specified,
"xtrabackup_51" is the command used. And when option --apply-log is
specified, the binary is used whose name is in the file
"xtrabackup_binary" in the backup directory, if that file exists.
--include=REGEXP
This option is a regular expression to be matched against table
names in databasename.tablename format. It is passed directly to
xtrabackup's --tables option. See the xtrabackup documentation for
details.
--incremental
This option tells xtrabackup to create an incremental backup, rather
than a full one. It is passed to the xtrabackup child process. When
this option is specified, either --incremental-lsn or
--incremental-basedir can also be given. If neither option is given,
option --incremental-basedir is passed to xtrabackup by default, set
to the first timestamped backup directory in the backup base
directory.
--incremental-basedir=DIRECTORY
This option specifies the directory containing the full backup that
is the base dataset for the incremental backup. The option accepts a
string argument. It is used with the --incremental option.
--incremental-dir=DIRECTORY
This option specifies the directory where the incremental backup
will be combined with the full backup to make a new full backup. The
option accepts a string argument. It is used with the --incremental
option.
--log-copy-interval
This option specifies time interval between checks done by log
copying thread in milliseconds.
--incremental-lsn
This option specifies the log sequence number (LSN) to use for the
incremental backup. The option accepts a string argument. It is used
with the --incremental option. It is used instead of specifying
--incremental-basedir. For databases created by MySQL and Percona
Server 5.0-series versions, specify the LSN as two 32-bit integers
in high:low format. For databases created in 5.1 and later, specify
the LSN as a single 64-bit integer.
--move-back
Move all the files in a previously made backup from the backup
directory to the actual datadir location. Use with caution, as it
removes backup files.
--no-lock
Use this option to disable table lock with "FLUSH TABLES WITH READ
LOCK". Use it only if ALL your tables are InnoDB and you DO NOT CARE
about the binary log position of the backup. This option shouldn't
be used if there are any DDL statements being executed or if any
updates are happening on non-InnoDB tables (this includes the system
MyISAM tables in the mysql database), otherwise it could lead to an
inconsistent backup. If you are considering to use --no-lock because
your backups are failing to acquire the lock, this could be because
of incoming replication events preventing the lock from succeeding.
Please try using --safe-slave-backup to momentarily stop the
replication slave thread, this may help the backup to succeed and
you then don't need to resort to using this option.
--no-timestamp
This option prevents creation of a time-stamped subdirectory of the
BACKUP-ROOT-DIR given on the command line. When it is specified, the
backup is done in BACKUP-ROOT-DIR instead.
--parallel=NUMBER-OF-THREADS
This option specifies the number of threads the xtrabackup child
process should use to back up files concurrently. The option accepts
an integer argument. It is passed directly to xtrabackup's
--parallel option. See the xtrabackup documentation for details.
--password=WORD
This option specifies the password to use when connecting to the
database. It accepts a string argument. It is passed to the mysql
child process without alteration. See mysql --help for details.
--port=PORT
This option specifies the port to use when connecting to the
database server with TCP/IP. The option accepts a string argument.
It is passed to the mysql child process. It is passed to the mysql
child process without alteration. See mysql --help for details.
--redo-only
This option should be used when preparing the base full backup and
when merging all incrementals except the last one. This option is
passed directly to xtrabackup's --apply-log-only option. This forces
xtrabackup to skip the "rollback" phase and do a "redo" only. This
is necessary if the backup will have incremental changes applied to
it later. See the xtrabackup documentation for details.
--remote-host=HOSTNAME
This option is DEPRECATED and will be removed in Percona XtraBackup
2.1. In Percona XtraBackup 2.0 and later, you should use streaming
backups instead. This option specifies the remote host on which the
backup files will be created, by using an ssh connection. The option
accepts a string argument.
--rsync
Uses the rsync utility to optimize local file transfers. When this
option is specified, innobackupex uses rsync to copy all non-InnoDB
files instead of spawning a separate cp for each file, which can be
much faster for servers with a large number of databases or tables.
This option cannot be used together with --remote-host or --stream.
--safe-slave-backup
Stop slave SQL thread and wait to start backup until
Slave_open_temp_tables in "SHOW STATUS" is zero. If there are no
open temporary tables, the backup will take place, otherwise the SQL
thread will be started and stopped until there are no open temporary
tables. The backup will fail if Slave_open_temp_tables does not
become zero after --safe-slave-backup-timeout seconds. The slave SQL
thread will be restarted when the backup finishes.
--safe-slave-backup-timeout
How many seconds --safe-slave-backup should wait for
Slave_open_temp_tables to become zero. (default 300)
--scpopt=SCP-OPTIONS
This option specifies the command line options to pass to scp when
the option --remost-host is specified. The option accepts a string
argument. If the option is not specified, the default options are
"-Cp -c arcfour".
--sshopt=SSH-OPTIONS
This option specifies the command line options to pass to ssh when
the option --remost-host is specified. The option accepts a string
argument.
--slave-info
This option is useful when backing up a replication slave server. It
prints the binary log position and name of the master server. It
also writes this information to the "xtrabackup_slave_info" file as
a "CHANGE MASTER" command. A new slave for this master can be set up
by starting a slave server on this backup and issuing a "CHANGE
MASTER" command with the binary log position saved in the
"xtrabackup_slave_info" file.
--socket=SOCKET
This option specifies the socket to use when connecting to the local
database server with a UNIX domain socket. The option accepts a
string argument. It is passed to the mysql child process without
alteration. See mysql --help for details.
--stream=STREAMNAME
This option specifies the format in which to do the streamed backup.
The option accepts a string argument. The backup will be done to
STDOUT in the specified format. Currently, the only supported
formats are tar and xbstream. This option is passed directly to
xtrabackup's --stream option.
--tables-file=FILE
This option specifies the file in which there are a list of names of
the form database. The option accepts a string argument.table, one
per line. The option is passed directly to xtrabackup's
--tables-file option.
--throttle=IOS
This option specifies a number of I/O operations (pairs of
read+write) per second. It accepts an integer argument. It is passed
directly to xtrabackup's --throttle option.
--tmpdir=DIRECTORY
This option specifies the location where a temporary file will be
stored. The option accepts a string argument. It should be used when
--remote-host or --stream is specified. For these options, the
transaction log will first be stored to a temporary file, before
streaming or copying to a remote host. This option specifies the
location where that temporary file will be stored. If the option is
not specifed, the default is to use the value of tmpdir read from
the server configuration.
--use-memory=B
This option accepts a string argument that specifies the amount of
memory in bytes for xtrabackup to use for crash recovery while
preparing a backup. Multiples are supported providing the unit (e.g.
1MB, 1GB). It is used only with the option --apply-log. It is passed
directly to xtrabackup's --use-memory option. See the xtrabackup
documentation for details.
--user=NAME
This option specifies the MySQL username used when connecting to the
server, if that's not the current user. The option accepts a string
argument. It is passed to the mysql child process without
alteration. See mysql --help for details.
--defaults-group=GROUP-NAME
This option specifies the group name in my.cnf which should be used.
This is needed for mysqld_multi deployments.
--version
This option displays the xtrabackup version and copyright notice and
then exits.
建立快速連結:
[root@nagios percona-xtrabackup-2.0.8]# mv /tmp/percona-xtrabackup-2.0.8 /usr/local/
[root@nagios percona-xtrabackup-2.0.8]# ln -s /usr/local/percona-xtrabackup-2.0.8/innobackupex /usr/bin/innobackupex
innobackupex innochecksum
[root@nagios ~]# innobackupex
[root@nagios ~]# innobackupex --help
Options:
--apply-log
Prepare a backup in BACKUP-DIR by applying the transaction log file
named "xtrabackup_logfile" located in the same directory. Also,
create new transaction logs. The InnoDB configuration is read from
2. 直接下載二進位制包(linux-generic)
[root@nagios tmp]# ll
total 118312
-rw-r--r-- 1 apache apache 243 Oct 12 00:00 downtime.tmp
-rw-r--r-- 1 root root 24325443 Oct 12 09:30 mysql-5.1.59.tar.gz
drwxr-xr-x 4 root root 4096 Sep 3 2013 percona-xtrabackup-2.0.8
-rw-r--r-- 1 root root 50735377 Oct 12 11:21 percona-xtrabackup-2.0.8-587.tar.gz
-rw-r--r-- 1 root root 11241809 Oct 10 15:21 percona-xtrabackup-2.0.8.tar.gz
drwxr-xr-x 33 497 497 4096 Jul 28 15:04 percona-xtrabackup-2.2.12
-rw-r--r-- 1 root root 34827353 Oct 10 15:20 percona-xtrabackup-2.2.12.tar.gz
[root@nagios percona-xtrabackup-2.0.8]# tar -xvf percona-xtrabackup-2.0.8-587.tar.gz
[root@nagios tmp]# cd percona-xtrabackup-2.0.8
[root@nagios percona-xtrabackup-2.0.8]# ll
total 8
drwxr-xr-x 2 root root 4096 Sep 3 2013 bin
drwxr-xr-x 4 root root 4096 Sep 3 2013 share
[root@nagios percona-xtrabackup-2.0.8]# cd bin
[root@nagios bin]# ll
total 118884
-rwxr-xr-x 1 root root 113912 Sep 3 2013 innobackupex
lrwxrwxrwx 1 root root 12 Oct 12 14:08 innobackupex-1.5.1 -> innobackupex
-rwxr-xr-x 1 root root 2258560 Sep 3 2013 xbstream
-rwxr-xr-x 1 root root 12557890 Sep 3 2013 xtrabackup
-rwxr-xr-x 1 root root 10667223 Sep 3 2013 xtrabackup_51
-rwxr-xr-x 1 root root 15720860 Sep 3 2013 xtrabackup_55
-rwxr-xr-x 1 root root 80404343 Sep 3 2013 xtrabackup_56
[root@nagios bin]# cp * /usr/bin
3. 備份
[root@nagios centreon_status]# innobackupex --defaults-file=/etc/my.cnf --user=root --password=123456 --database=centreon_status /backup/centreon_status/ > /backup/centreon_status/centreon_status.log 2>&1
[root@nagios centreon_status]# ll
total 44
drwxr-xr-x 6 root root 4096 Oct 13 15:01 2015-10-13_15-01-09
-rw-r--r-- 1 root root 40852 Oct 13 15:01 centreon_status.log
[root@nagios centreon_status]# cat centreon_status.log
.
.
innobackupex: Backup created in directory '/backup/centreon_status/2015-10-13_15-01-09'
innobackupex: MySQL binlog position: filename 'mysql-bin.000033', position 10324079
151013 15:01:52 innobackupex: completed OK!
4. 恢復
先停止資料庫:service mysqld stop
複製: [root@nagios centreon_status]# scp -rp 2015-10-13_15-01-09/ 192.168.9.235:/backup/centreon_status/
恢復
innobackupex --user=root --password --defaults-file=/etc/my.cnf --apply-log /data/back_data/db/
--apply-log選項的命令是準備在一個備份上啟動mysql服務
[root@testdb1 mysql]# innobackupex --copy-back /backup/centreon_status/2015-10-13_15-01-09/
--copy-back 選項的命令從備份目錄複製資料,索引,日誌到my.cnf文 件裡規定的初始位置
賦權 chown -R mysql.mysql /var/lib/mysql/*
重啟資料庫 service mysqld restart
刪除垃圾 cd /var/lib/mysql/ && rm xtrabackup*
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1814211/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 在 Ubuntu 上使用原始碼安裝 OpenRestyUbuntu原始碼REST
- MySQL 原始碼安裝及yum的使用MySql原始碼
- LAMP原始碼安裝+wordpress安裝LAMP原始碼
- nginx原始碼安裝Nginx原始碼
- 原始碼安裝postgresql原始碼SQL
- 原始碼安裝openresty原始碼REST
- 原始碼安裝GO原始碼Go
- Nginx 原始碼安裝Nginx原始碼
- mysql原始碼安裝MySql原始碼
- zabbix原始碼安裝原始碼
- 原始碼安裝lamp原始碼LAMP
- 原始碼安裝MySQL原始碼MySql
- 原始碼安裝Nginx原始碼Nginx
- Linux使用原始碼來安裝MySQL 5.7Linux原始碼MySql
- 使用原始碼安裝MYSQL 5.5.9版本原始碼MySql
- 【推薦 - 原始碼安裝】nginx - 安裝原始碼Nginx
- yum安裝與原始碼安裝比較原始碼
- linux 非root使用者原始碼安裝Linux原始碼
- MySQL 5.7.28 原始碼安裝MySql原始碼
- docker原始碼安裝NginxDocker原始碼Nginx
- macbook 原始碼安裝 redisMac原始碼Redis
- macbook 原始碼安裝 nginxMac原始碼Nginx
- Centos原始碼安裝NginxCentOS原始碼Nginx
- Redis 4.0原始碼安裝Redis原始碼
- mysql 5.1原始碼安裝MySql原始碼
- mysql-原始碼安裝MySql原始碼
- 原始碼安裝python原始碼Python
- MYSQL 5.6.27原始碼安裝MySql原始碼
- PostgreSQL 10.12 安裝系列 - 原始碼安裝SQL原始碼
- Mysql for Linux安裝配置之—— 原始碼安裝MySqlLinux原始碼
- 連網安裝mysql與原始碼安裝mysqlMySql原始碼
- PostgreSQL-原始碼安裝(一)SQL原始碼
- 原始碼安裝Nginx和PHP原始碼NginxPHP
- 原始碼包安裝過程原始碼
- 原始碼安裝PHP的坑原始碼PHP
- paramiko 2.4.1原始碼安裝原始碼
- 原始碼編譯安裝Redis原始碼編譯Redis
- EOS原始碼分析(1)安裝原始碼