xtrabackup 不用lock tables來複製備庫
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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 複製全解析 Part 11 使用xtrabackup建立MySQL複製MySql
- [zt] 高階複製、流複製(Streams)、備庫區別
- 利用percona-xtrabackup快速搭建MySQL資料庫主從複製MySql資料庫
- MySQL 5.5使用Xtrabackup線上搭建複製環境MySql
- 【Mysql】FLUSH TABLES WITH READ LOCKMySql
- mysql表鎖與lock tablesMySql
- 配置xtrabackup備份mysql資料庫MySql資料庫
- 使用Xtrabackup備份mysql資料庫MySql資料庫
- MySQL 5.5 LOCK TABLES 和 UNLOCK TABLES 語句介紹MySql
- (轉)使用Xtrabackup備份MySQL資料庫MySql資料庫
- 【Xtrabackup】Xtrabackup全備、增量備份及恢復示例
- 使用XtraBackup搭建mysql主從複製的操作步驟MySql
- mysql關於FLUSH TABLES和FLUSH TABLES WITH READ LOCK的理解MySql
- 【Xtrabackup】Xtrabackup備份基礎知識
- Redis主備複製Redis
- (轉)使用Xtrabackup備份MySQL資料庫(續)MySql資料庫
- MySQL:xtrabackup備份MySql
- XtraBackup備份MySQLMySql
- Centos-Mysql複製備份還原資料庫CentOSMySql資料庫
- oracle sqldeveloper選擇性複製備份資料庫OracleSQLDeveloper資料庫
- 【PG流複製】Postgresql流複製主備切換SQL
- pg流複製備份
- mysql資料庫xtrabackup壓縮備份測試MySql資料庫
- 建立MySQL資料庫備份的好工具:XtraBackupMySql資料庫
- 使用 xtrabackup 進行MySQL資料庫物理備份MySql資料庫
- Oracle備份與恢復系列(四)複製資料庫 續 手工複製資料庫的最簡操作Oracle資料庫
- 資料庫複製(一)–複製介紹資料庫
- xtrabackup備份mysql innodbMySql
- 分散式Redis主備複製分散式Redis
- mysql主從複製(冷備)MySql
- 資料備份與複製
- 資料庫複製資料庫
- 複製資料庫資料庫
- 資料庫外來鍵,用是不用?資料庫
- XtraBackup不停機不鎖表做MySQL主從複製的試驗MySql
- 華為GaussDB T資料庫主備物理複製搭建過程資料庫
- 使用者管理的熱備份方式複製資料庫資料庫
- XtraBackup實踐(一)備份