xtrabackup安装
安装一些perl依赖包
[root@59-Mysql-Test bin]# yum install perl-Time-HiRes
[root@59-Mysql-Test bin]# yum install perl-DBI-MySQL
[root@59-Mysql-Test bin]# yum -y install perl-DBD-MySQL.x86_64
[root@59-Mysql-Test bin]# yum install perl-Time-HiRes
[root@59-Mysql-Test bin]# yum install perl-IO-Socket-SSL
[root@59-Mysql-Test bin]# yum install perl-DBD-MySQL
解压安装percona-xtrabackup
[root@59-Mysql-Test bin]# cp percona-xtrabackup-2.1.8-733-Linux-x86_64.tar.gz /usr/src/
[root@59-Mysql-Test bin]# cd /usr/src/
[root@59-Mysql-Test bin]# tar zxvf percona-xtrabackup-2.1.8-733-Linux-x86_64.tar.gz
[root@59-Mysql-Test bin]# cd percona-xtrabackup-2.1.8-Linux-x86_64/
[root@59-Mysql-Test bin]# cp /usr/src/percona-xtrabackup-2.1.8-Linux-x86_64/bin/xtrabackup_55 /usr/bin/
创建备份目录
[root@59-Mysql-Test bin]# mkdir -p /dbbackup
执行备份
[root@59-Mysql-Test bin]# /usr/src/percona-xtrabackup-2.1.8-Linux-x86_64/bin/innobackupex --user=root --password=pvKsOsH7Of1AQ --defaults-file=/data0/mysql/3306/my.cnf --socket=/tmp/mysql.sock /dbbackup/
主库应用一下备份集日志
[root@59-Mysql-Test mysql]# /usr/src/percona-xtrabackup-2.1.8-Linux-x86_64/bin/innobackupex --apply-log /data/backup/2015-08-07_11-17-04/
查看主库的binlog和fileNU
[root@userdb2 2015-08-07_12-48-23]# cd /dbbackup/2015-08-07_12-48-23/
[root@userdb2 2015-08-07_12-48-23]# cat xtrabackup_binlog_info
binlog.000659 496466064
copy备份集至备库
[root@59-Mysql-Test mysql]# scp -r /data/backup/2015-08-07_11-17-04/ 192.168.20.60:/root
将备份集里粘贴到备库指定的basedir路径下,并修改相应的权限
[root@60-Mysql-Test 2015-08-07_11-17-04]# cp -r * /var/lib/mysql
[root@60-Mysql-Test mysql]# chmod 755 *
[root@60-Mysql-Test mysql]# chmod 755 -R *
[root@60-Mysql-Test mysql]# chown -R mysql:mysql *
启动Mysql备库,并配置slave,
[root@60-Mysql-Test mysql]# service mysql start
配置数据库信息
[root@60-Mysql-Test mysql]# mysql -u root -p
mysql> stop slave; #关闭同步进程
mysql> change master to master_host='192.168.20.59',master_user='nkuser',master_password='test123',master_log_file='File' ,master_log_pos=Position;
#配置同步信息,其中File和Position是xtrabackup_binlog_info中看到的值
mysql> slave start; #开启同步进程
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.20.59
Master_User: bkuser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysqlbin59.000001
Read_Master_Log_Pos: 7219
Relay_Log_File: 60-Mysql-Test-relay-bin.000002
Relay_Log_Pos: 6903
Relay_Master_Log_File: mysqlbin59.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 7219
Relay_Log_Space: 7084
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 2c8117cd-2945-11e5-9aa4-5254009b5ae4
Master_Info_File: /var/lib/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
安装一些perl依赖包
[root@59-Mysql-Test bin]# yum install perl-Time-HiRes
[root@59-Mysql-Test bin]# yum install perl-DBI-MySQL
[root@59-Mysql-Test bin]# yum -y install perl-DBD-MySQL.x86_64
[root@59-Mysql-Test bin]# yum install perl-Time-HiRes
[root@59-Mysql-Test bin]# yum install perl-IO-Socket-SSL
[root@59-Mysql-Test bin]# yum install perl-DBD-MySQL
解压安装percona-xtrabackup
[root@59-Mysql-Test bin]# cp percona-xtrabackup-2.1.8-733-Linux-x86_64.tar.gz /usr/src/
[root@59-Mysql-Test bin]# cd /usr/src/
[root@59-Mysql-Test bin]# tar zxvf percona-xtrabackup-2.1.8-733-Linux-x86_64.tar.gz
[root@59-Mysql-Test bin]# cd percona-xtrabackup-2.1.8-Linux-x86_64/
[root@59-Mysql-Test bin]# cp /usr/src/percona-xtrabackup-2.1.8-Linux-x86_64/bin/xtrabackup_55 /usr/bin/
创建备份目录
[root@59-Mysql-Test bin]# mkdir -p /dbbackup
执行备份
[root@59-Mysql-Test bin]# /usr/src/percona-xtrabackup-2.1.8-Linux-x86_64/bin/innobackupex --user=root --password=pvKsOsH7Of1AQ --defaults-file=/data0/mysql/3306/my.cnf --socket=/tmp/mysql.sock /dbbackup/
主库应用一下备份集日志
[root@59-Mysql-Test mysql]# /usr/src/percona-xtrabackup-2.1.8-Linux-x86_64/bin/innobackupex --apply-log /data/backup/2015-08-07_11-17-04/
查看主库的binlog和fileNU
[root@userdb2 2015-08-07_12-48-23]# cd /dbbackup/2015-08-07_12-48-23/
[root@userdb2 2015-08-07_12-48-23]# cat xtrabackup_binlog_info
binlog.000659 496466064
copy备份集至备库
[root@59-Mysql-Test mysql]# scp -r /data/backup/2015-08-07_11-17-04/ 192.168.20.60:/root
将备份集里粘贴到备库指定的basedir路径下,并修改相应的权限
[root@60-Mysql-Test 2015-08-07_11-17-04]# cp -r * /var/lib/mysql
[root@60-Mysql-Test mysql]# chmod 755 *
[root@60-Mysql-Test mysql]# chmod 755 -R *
[root@60-Mysql-Test mysql]# chown -R mysql:mysql *
启动Mysql备库,并配置slave,
[root@60-Mysql-Test mysql]# service mysql start
配置数据库信息
[root@60-Mysql-Test mysql]# mysql -u root -p
mysql> stop slave; #关闭同步进程
mysql> change master to master_host='192.168.20.59',master_user='nkuser',master_password='test123',master_log_file='File' ,master_log_pos=Position;
#配置同步信息,其中File和Position是xtrabackup_binlog_info中看到的值
mysql> slave start; #开启同步进程
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.20.59
Master_User: bkuser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysqlbin59.000001
Read_Master_Log_Pos: 7219
Relay_Log_File: 60-Mysql-Test-relay-bin.000002
Relay_Log_Pos: 6903
Relay_Master_Log_File: mysqlbin59.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 7219
Relay_Log_Space: 7084
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 2c8117cd-2945-11e5-9aa4-5254009b5ae4
Master_Info_File: /var/lib/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29320885/viewspace-1768027/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29320885/viewspace-1768027/