xtrabackup是Percona公司CTO Vadim參與開發(fā)的一款基于InnoDB的在線熱備工具,具有開源,免費,支持在線熱備,備份恢復(fù)速度快,占用磁盤空間小等特點,并且支持不同情況下的多種備份形式。xtrabackup的官方下載地址為http://www.percona.com/software/percona-xtrabackup。
創(chuàng)新互聯(lián)響應(yīng)式網(wǎng)站特點就是不管在電腦、平板還是手機上,H5網(wǎng)站設(shè)計都會根據(jù)屏幕尺寸自動調(diào)節(jié)大小、圖片分辨率,并且融入一定的動畫特效,讓網(wǎng)站看起來非常的美觀大方。從網(wǎng)站需求對接到網(wǎng)站制作設(shè)計、從代碼編寫到項目上線運維,技術(shù)人員全程跟蹤,快速響應(yīng)
xtrabackup包含兩個主要的工具,即xtrabackup和innobackupex,二者區(qū)別如下:
(1)xtrabackup只能備份innodb和xtradb兩種引擎的表,而不能備份myisam引擎的表;
(2)innobackupex是一個封裝了xtrabackup的Perl腳本,支持同時備份innodb和myisam,但在對myisam備份時需要加一個全局的讀鎖。還有就是myisam不支持增量備份。
1.備份過程
innobackupex備份過程如下圖:
(圖1 innobackupex備份過程,本文中所有圖都是google所得)
在圖1中,備份開始時首先會開啟一個后臺檢測進程,實時檢測MySQL redo的變化,一旦發(fā)現(xiàn)redo中有新的日志寫入,立刻將日志記入后臺日志文件xtrabackup_log中。之后復(fù)制innodb的數(shù)據(jù)文件和系統(tǒng)表空間文件ibdata1,待復(fù)制結(jié)束后,執(zhí)行flush tables with read lock操作,復(fù)制.frm,MYI,MYD,等文件(執(zhí)行flush tableswith read lock的目的是為了防止數(shù)據(jù)表發(fā)生DDL操作,并且在這一時刻獲得binlog的位置)最后會發(fā)出unlock tables,把表設(shè)置為可讀可寫狀態(tài),最終停止xtrabackup_log。
2.全備恢復(fù)
這一階段會啟動xtrabackup內(nèi)嵌的innodb實例,回放xtrabackup日志xtrabackup_log,將提交的事務(wù)信息變更應(yīng)用到innodb數(shù)據(jù)/表空間,同時回滾未提交的事務(wù)(這一過程類似innodb的實例恢復(fù))?;謴?fù)過程如下圖:
(圖2 innobackupex 恢復(fù)過程)
3.增量備份
innobackupex增量備份過程中的"增量"處理,其實主要是相對innodb而言,對myisam和其他存儲引擎而言,它仍然是全拷貝(全備份)
"增量"備份的過程主要是通過拷貝innodb中有變更的"頁"(這些變更的數(shù)據(jù)頁指的是"頁"的LSN大于xtrabackup_checkpoints中給定的LSN)。增量備份是基于全備的,第一次增備的數(shù)據(jù)必須要基于上一次的全備,之后的每次增備都是基于上一次的增備,最終達到一致性的增備。增量備份的過程如下,和全備的過程很類似,區(qū)別僅在第2步。
( 圖 3 innobackupex增量備份過程)
4.增量備份恢復(fù)
和全備恢復(fù)類似,也需要兩步,一是數(shù)據(jù)文件的恢復(fù),如圖4,這里的數(shù)據(jù)來源由3部分組成:全備份,增量備份和xtrabackup log。二是對未提交事務(wù)的回滾,如圖5所示:
( 圖4 innobackupex 增量備份恢復(fù)過程1)
( 圖5 innobackupex增量備份恢復(fù)過程2)
5.innobackupex使用示例
(1)安裝使用xtrabackup,安裝比較簡單,我們使用二進制編譯好的就行了,這種工具無需源碼編譯,因為沒有什么功能需要特殊定制。
[root@MySQL01 ~]# wget http://www.percona.com/redir/downloads/XtraBackup/LATEST/binary/Linux/x86_64/percona-xtrabackup-2.1.8-733-Linux-x86_64.tar.gz
[root@MySQL-01 ~]# tar xf percona-xtrabackup-2.1.8-733-Linux-x86_64.tar.gz -C /usr/local/ [root@MySQL-01 ~]# mv /usr/local/percona-xtrabackup-2.1.8-Linux-x86_64/ /usr/local/xtrabackup [root@MySQL-01 ~]# echo "export PATH=\$PATH:/usr/local/xtrabackup/bin" >> /etc/profile [root@MySQL-01 ~]# source /etc/profile
(2)全量備份
創(chuàng)建備份用戶:
mysql> create user 'backup'@'%' identified by 'hello';
Query OK, 0 rows affected (0.01 sec) mysql> grant reload,lock tables,replication client,create tablespace,super on *.* to 'backup'@'%'; Query OK, 0 rows affected (0.00 sec) 進行全備份 備份數(shù)據(jù)存放在/data/backup/下面,innobackupex會自動創(chuàng)建一個文件夾,是當(dāng)前系統(tǒng)的時間戳 mysql> select * from peng.t1; +------+-------+ | id | name | +------+-------+ | 1 | peng | | 2 | atlas | +------+-------+ 2 rows in set (0.00 sec) 測試數(shù)據(jù)就是peng庫中的t1表 [root@MySQL-01 ~]# xtrabackup: Creating suspend file '/data/backup/2014-04-07_23-05-04/xtrabackup_log_copied' with pid '57608' xtrabackup: Transaction log of lsn (5324782783) to (5324782783) was copied. 140407 23:06:14 innobackupex: All tables unlocked innobackupex: Backup created in directory '/data/backup/2014-04-07_23-05-04' innobackupex: MySQL binlog position: filename 'mysqlbin.000014', position 2983 140407 23:06:14 innobackupex: Connection to database server closed 140407 23:06:14 innobackupex: completed OK! 上面的過程中處理過程,主要看最后是否提示innobackupex completed ok,可以看見備份成功。我們看看/data/backup目錄下產(chǎn)生了什么! [root@MySQL-01 backup]# pwd /data/backup [root@MySQL-01 backup]# ll total 4 drwxr-xr-x 12 root root 4096 Apr 7 23:06 2014-04-07_23-05-04 [root@MySQL-01 backup]# cd 2014-04-07_23-05-04/ [root@MySQL-01 2014-04-07_23-05-04]# ll total 845888 -rw-r--r-- 1 root root 261 Apr 7 23:05 backup-my.cnf drwx------ 2 root root 4096 Apr 7 23:06 employees drwx------ 2 root root 4096 Apr 7 23:06 host -rw-r----- 1 root root 866123776 Apr 7 23:05 ibdata1 drwx------ 2 root root 4096 Apr 7 23:06 menagerie drwxr-xr-x 2 root root 4096 Apr 7 23:06 mysql drwxr-xr-x 2 root root 4096 Apr 7 23:06 performance_schema drwx------ 2 root root 4096 Apr 7 23:06 sakila drwx------ 2 root root 4096 Apr 7 23:06 test drwx------ 2 root root 4096 Apr 7 23:06 world_innodb drwxr-xr-x 2 root root 4096 Apr 7 23:06 world_myisam -rw-r--r-- 1 root root 13 Apr 7 23:06 xtrabackup_binary -rw-r--r-- 1 root root 24 Apr 7 23:06 xtrabackup_binlog_info -rw-r----- 1 root root 95 Apr 7 23:06 xtrabackup_checkpoints -rw-r----- 1 root root 2560 Apr 7 23:06 xtrabackup_logfile drwx------ 2 root root 4096 Apr 7 23:06 peng 可以看見有對應(yīng)數(shù)據(jù)庫的名字,比如peng,還有一個以時間戳命名的目錄。我們看看對應(yīng)文件里面的內(nèi)容,這幾個比較重要: [root@MySQL-01 2014-04-07_23-05-04]# cat xtrabackup_checkpoints backup_type = full-backuped from_lsn = 0 to_lsn = 5324782783 last_lsn = 5324782783 compact = 0 [root@MySQL-01 2014-04-07_23-05-04]# cat xtrabackup_binlog_info mysql-bin.000014 2983
可以看見相關(guān)文件記錄了LSN,日志偏移量,還可以看見這次是全備份,相信聰明的童鞋們一眼就看懂了。^_^
刪除數(shù)據(jù)庫,然后恢復(fù)全備(線上不要這樣搞)
mysql> drop database peng; Query OK, 1 row affected (0.04 sec)
恢復(fù)全備
恢復(fù)備份到mysql的數(shù)據(jù)文件目錄,這一過程要先關(guān)閉mysql數(shù)據(jù)庫,重命名或者刪除原數(shù)據(jù)文件目錄都可以,再創(chuàng)建一個新的數(shù)據(jù)文件目錄,將備份數(shù)據(jù)復(fù)制到新的數(shù)據(jù)文件目錄下,賦權(quán),修改權(quán)限,啟動數(shù)據(jù)庫。
[root@MySQL-01 ~]# /etc/init.d/mysqld stop Shutting down MySQL..... [ OK ] [root@MySQL-01 ~]# mv /data/mysql /data/mysql_bak [root@MySQL-01 ~]# mkdir /data/mysql
[root@MySQL-01 ~]# innobackupex --apply-log /data/backup/2014-04-07_23-05-04/ xtrabackup: starting shutdown with innodb_fast_shutdown = 1 140407 23:22:36 InnoDB: Starting shutdown... 140407 23:22:40 InnoDB: Shutdown completed; log sequence number 5324784 140 140407 23:22:40 innobackupex: completed OK! 以上對應(yīng)的目錄就是innobackupex全備份自己創(chuàng)建的目錄。 [root@MySQL-01 ~]# innobackupex: Starting to copy InnoDB log files innobackupex: in '/data/backup/2014-04-07_23-05-04' innobackupex: back to original InnoDB log directory '/data/mysql' innobackupex: Copying '/data/backup/2014-04-07_23-05-04/ib_logfile1' to '/data/mysql/ib_logfile1' innobackupex: Copying '/data/backup/2014-04-07_23-05-04/ib_logfile0' to '/data/mysql/ib_logfile0' innobackupex: Finished copying back files. 140407 23:27:38 innobackupex: completed OK! 可以看見已經(jīng)成功恢復(fù),修改數(shù)據(jù)目錄權(quán)限,啟動mysql,效驗數(shù)據(jù)是否正常,查看peng庫下面的t1表中的數(shù)據(jù)。 [root@MySQL-01 ~]# chown -R mysql.mysql /data/mysql [root@MySQL-01 ~]# /etc/init.d/mysqld start Starting MySQL................. [ OK ] mysql> use peng
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select * from t1; +------+-------+ | id | name | +------+-------+ | 1 | peng | | 2 | atlas | +------+-------+ 2 rows in set (0.00 sec)
發(fā)現(xiàn)數(shù)據(jù)已經(jīng)成功恢復(fù)。
(3)增量備份
在進行增量備份時,首先要進行一次全量備份,第一次增量備份是基于全備的,之后的增量備份是基于上一次的增量備份,以此類推。
全備份放在/data/backup/full,增量備份放在/data/backup/incremental
[root@MySQL-01 ~]# tree /data/backup/
/data/backup/ ├── full └── incremental 2 directories, 0 files 廢話少說,咱們先來一次全備份 [root@MySQL-01 ~]# innobackupex: Backup created in directory '/data/backup/full/2014-04-07_23-37-20' innobackupex: MySQL binlog position: filename 'mysqlbin.000001', position 107 140407 23:38:29 innobackupex: Connection to database server closed 140407 23:38:29 innobackupex: completed OK! 為了測試效果,我們在t1表中插入數(shù)據(jù) mysql> select * from t1; +------+-------+ | id | name | +------+-------+ | 1 | peng | | 2 | atlas | +------+-------+ 2 rows in set (0.00 sec) mysql> insert into t1 select 1,'love sql'; Query OK, 1 row affected (0.01 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from t1; +------+----------+ | id | name | +------+----------+ | 1 | peng | | 2 | atlas | | 1 | love sql | +------+----------+ 3 rows in set (0.00 sec) 現(xiàn)在來一次增量備份1 [root@MySQL-01 ~]# innobackupex: Backup created in directory '/data/backup/incremental/2014-04-07_23-42-46' innobackupex: MySQL binlog position: filename 'mysqlbin.000001', position 301 140407 23:43:25 innobackupex: Connection to database server closed 140407 23:43:25 innobackupex: completed OK! 我們看看增量備份的大小以及文件內(nèi)容 [root@MySQL-01 ~]# du -sh /data/backup/full/2014-04-07_23-37-20/ 1.2G /data/backup/full/2014-04-07_23-37-20/ [root@MySQL-01 ~]# du -sh /data/backup/incremental/2014-04-07_23-42-46/ 3.6M /data/backup/incremental/2014-04-07_23-42-46/ 看見增量備份的數(shù)據(jù)很小吧,就是備份改變的數(shù)據(jù)而已。 [root@MySQL-01 2014-04-07_23-42-46]# pwd /data/backup/incremental/2014-04-07_23-42-46 [root@MySQL-01 2014-04-07_23-42-46]# cat xtrabackup_checkpoints from_lsn = 5324784718 to_lsn = 5324785066 last_lsn = 5324785066 compact = 0 上面已經(jīng)明顯說明是增量備份了,該工具很人性化吧,呵呵 我們再次向t1表插入數(shù)據(jù),然后創(chuàng)建增量備份2 mysql> select * from t1; +------+----------+ | id | name | +------+----------+ | 1 | peng | | 2 | atlas | | 1 | love sql | +------+----------+ 3 rows in set (0.00 sec) mysql> insert into t1 select 1,'mysql dba'; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from t1; +------+-----------+ | id | name | +------+-----------+ | 1 | peng | | 2 | atlas | | 1 | love sql | | 1 | mysql dba | +------+-----------+ 4 rows in set (0.00 sec) 創(chuàng)建增量備份2(這次是基于上次的增量備份哦) [root@MySQL-01 ~]# innobackupex: Backup created in directory '/data/backup/incremental/2014-04-07_23-51-15' innobackupex: MySQL binlog position: filename 'mysqlbin.000001', position 496 140407 23:51:55 innobackupex: Connection to database server closed 140407 23:51:55 innobackupex: completed OK! [root@MySQL-01 ~]# ls -ltr /data/backup/full/ total 4 drwxr-xr-x 12 root root 4096 Apr 7 23:38 2014-04-07_23-37-20 [root@MySQL-01 ~]# ls -ltr /data/backup/incremental/ total 8 drwxr-xr-x 12 root root 4096 Apr 7 23:43 2014-04-07_23-42-46 drwxr-xr-x 12 root root 4096 Apr 7 23:51 2014-04-07_23-51-15 (4)增量備份恢復(fù) 增量備份的恢復(fù)大體為3個步驟 恢復(fù)完全備份(注意這里一定要加--redo-only參數(shù),該參數(shù)的意思是只應(yīng)用xtrabackup日志中已提交的事務(wù)數(shù)據(jù),不回滾還未提交的數(shù)據(jù)) [root@MySQL-01 ~]# xtrabackup: starting shutdown with innodb_fast_shutdown = 1 140407 23:59:43 InnoDB: Starting shutdown... 140407 23:59:43 InnoDB: Shutdown completed; log sequence number 5324784718 140407 23:59:43 innobackupex: completed OK! 將增量備份1應(yīng)用到完全備份 [root@MySQL-01 ~]# innobackupex: Copying '/data/backup/incremental/2014-04-07_23-42-46/mysql/func.frm' to '/data/backup/full/2014-04-07_23-37-20/mysql/func.frm' innobackupex: Copying '/data/backup/incremental/2014-04-07_23-42-46/mysql/help_relation.frm' to '/data/backup/full/2014-04-07_23-37-20/mysql/help_relation.frm' innobackupex: Copying '/data/backup/incremental/2014-04-07_23-42-46/mysql/help_category.MYD' to '/data/backup/full/2014-04-07_23-37-20/mysql/help_category.MYD' innobackupex: Copying '/data/backup/incremental/2014-04-07_23-42-46/mysql/ndb_binlog_index.frm' to '/data/backup/full/2014-04-07_23-37-20/mysql/ndb_binlog_index.frm' 140408 00:02:07 innobackupex: completed OK! 將增量備份2應(yīng)用到完全備份(注意恢復(fù)最后一個增量備份時需要去掉--redo-only參數(shù),回滾xtrabackup日志中那些還未提交的數(shù)據(jù)) [root@MySQL-01 ~]# innobackupex: Copying '/data/backup/incremental/2014-04-07_23-51-15/mysql/help_relation.frm' to '/data/backup/full/2014-04-07_23-37-20/mysql/help_relation.frm' innobackupex: Copying '/data/backup/incremental/2014-04-07_23-51-15/mysql/help_category.MYD' to '/data/backup/full/2014-04-07_23-37-20/mysql/help_category.MYD' innobackupex: Copying '/data/backup/incremental/2014-04-07_23-51-15/mysql/ndb_binlog_index.frm' to '/data/backup/full/2014-04-07_23-37-20/mysql/ndb_binlog_index.frm' 140408 00:04:33 innobackupex: completed OK! 把所有合在一起的完全備份整體進行一次apply操作,回滾未提交的數(shù)據(jù): [root@MySQL-01 ~]# xtrabackup: starting shutdown with innodb_fast_shutdown = 1 140408 0:06:32 InnoDB: Starting shutdown... 140408 0:06:36 InnoDB: Shutdown completed; log sequence number 5324785676 140408 00:06:36 innobackupex: completed OK! 把恢復(fù)完的備份復(fù)制到數(shù)據(jù)庫目錄文件中,賦權(quán),然后啟動mysql數(shù)據(jù)庫,檢測數(shù)據(jù)正確性 [root@MySQL-01 ~]# /etc/init.d/mysqld stop Shutting down MySQL. [ OK ] [root@MySQL-01 ~]# mv /data/mysql /data/mysql_bak [root@MySQL-01 ~]# mkdir /data/mysql [root@MySQL-01 ~]# innobackupex: Starting to copy InnoDB log files innobackupex: in '/data/backup/full/2014-04-07_23-37-20' innobackupex: back to original InnoDB log directory '/data/mysql'innobackupex: Copying '/data/backup/full/2014-04-07_23-37-20/ib_logfile1' to '/data/mysql/ib_logfile1' innobackupex: Copying '/data/backup/full/2014-04-07_23-37-20/ib_logfile0' to '/data/mysql/ib_logfile0' innobackupex: Finished copying back files. 140408 00:12:42 innobackupex: completed OK! [root@MySQL-01 ~]# chown -R mysql.mysql /data/mysql [root@MySQL-01 ~]# /etc/init.d/mysqld start Starting MySQL.... [ OK ]
查看數(shù)據(jù)是否正確
mysql> select * from t1;
+------+-----------+
| id | name |
+------+-----------+
| 1 | peng |
| 2 | atlas |
| 1 | love sql |
| 1 | mysql dba |
+------+-----------+
4 rows in set (0.00 sec)
(5)克隆slave
在日常工作中,我們有時候需要在線添加從庫,比如線上有一主一從兩個數(shù)據(jù)庫,但是由于業(yè)務(wù)的需要,一臺從庫的讀取無法滿足現(xiàn)在的需求,這樣就需要我們在線添加從庫,由于出于安全考慮,我們通常需要在從庫上進行在線克隆slave。
克隆slave時,常用參數(shù)--slave-info和--safe-slave-backup。
--slave-info會將master的binlog文件名和偏移量位置保存到xtrabackup_slave_info文件中
--safe-slave-backup會暫停slave的SQL線程直到?jīng)]有打開的臨時表的時候開始備份。備份結(jié)束后SQL線程會自動啟動,這樣操作的目的主要是確保一致性的復(fù)制狀態(tài)。
下面的例子,將介紹一主一從情況下在線搭建新的從庫,環(huán)境如下:
master 192.168.0.10 #主庫
slave 192.168.0.20 #從庫
newslave 192.168.0.100 # 新的從庫
在上述示例中,newslave即為要新搭建的從庫。在老的從庫上面進行備份:
[root@MySQL-02 ~]# innobackupex: Backup created in directory '/data/cloneslave' innobackupex: MySQL binlog position: filename 'mysql-bin.000022', position 107 innobackupex: MySQL slave binlog position: master host '192.168.0.10', filename 'mysql-bin.000006', position 732 140413 23:25:13 innobackupex: completed OK! 這里的/data/cloneslave 目錄要不存在,如果存在是會報錯的。 查看目錄下生成的文件: [root@MySQL-02 ~]# ll /data/cloneslave/ total 26668 -rw-r--r-- 1 root root 261 Apr 13 23:24 backup-my.cnf -rw-r--r-- 1 root root 27262976 Apr 13 23:24 ibdata1 drwxr-xr-x 2 root root 4096 Apr 13 23:25 mysql drwxr-xr-x 2 root root 4096 Apr 13 23:25 performance_schema drwxr-xr-x 2 root root 4096 Apr 13 23:25 sakila drwxr-xr-x 2 root root 4096 Apr 13 23:25 world_innodb -rw-r--r-- 1 root root 13 Apr 13 23:25 xtrabackup_binary -rw-r--r-- 1 root root 23 Apr 13 23:25 xtrabackup_binlog_info -rw-r--r-- 1 root root 79 Apr 13 23:25 xtrabackup_checkpoints -rw-r--r-- 1 root root 2560 Apr 13 23:25 xtrabackup_logfile -rw-r--r-- 1 root root 72 Apr 13 23:25 xtrabackup_slave_info drwxr-xr-x 2 root root 4096 Apr 13 23:25 peng 查看xtrabackup_slave_info文件內(nèi)容,這個內(nèi)容就是為搭建從庫時需要change master to的參數(shù): [root@MySQL-02 ~]# cat /data/cloneslave/xtrabackup_slave_info CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000006', MASTER_LOG_POS=732 在老的slave服務(wù)器上進行還原,即192.168.0.20 [root@MySQL-02 ~]# xtrabackup: starting shutdown with innodb_fast_shutdown = 1 140413 23:30:37 InnoDB: Starting shutdown... 140413 23:30:37 InnoDB: Shutdown completed; log sequence number 12981048 140413 23:30:37 innobackupex: completed OK! 將還原的文件復(fù)制到新的從庫newslave,即192.168.0.100 [root@MySQL-02 data]# rsync -avprP -e ssh /data/cloneslave/ 192.168.0.100:/data/mysql/ 在主庫master上添加對新從庫newslave的授權(quán): mysql> grant replication slave on *.* to 'repl'@'192.168.0.100' identified by '123456'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.02 sec) 拷貝老的從庫的配置文件到新的從庫newslave,并且修改server-id參數(shù),修改完畢后,啟動新的從庫; [root@MySQL-02 data]# scp /etc/my.cnf 192.168.0.100:/etc/ root@192.168.0.100's password: my.cnf 100% 4881 4.8KB/s 00:00 [root@newslave mysql]# egrep 'log-slave|^server-id|skip_slave' /etc/my.cnf server-id = 3 skip_slave_start log-slave-updates=1 [root@newslave mysql]# chown -R mysql.mysql . [root@newslave mysql]# /etc/init.d/mysqld restart Shutting down MySQL. [ OK ] Starting MySQL.. [ OK ] 查找老的從庫備份后生成的xtrabackup_slave_info文件,提取其中的master_log_file和master_log_pos信息,然后在新的從庫上進行change master to操作: 在新的從庫上進行同步: mysql> CHANGE MASTER TO MASTER_HOST='192.168.0.10',MASTER_USER='repl', MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql-bin.000006', MASTER_LOG_POS=732; Query OK, 0 rows affected (0.09 sec) 啟動io線程和sql線程,并觀察復(fù)制是否正常: mysql> start slave; Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.0.10 Master_User: repl Master_Port: 3306 Connect_Retry: 2 Master_Log_File: mysql-bin.000006 Read_Master_Log_Pos: 1309 Relay_Log_File: MySQL-02-relay-bin.000002 Relay_Log_Pos: 830 Relay_Master_Log_File: mysql-bin.000006 Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: peng.% Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 1309 Relay_Log_Space: 989 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: 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 1 row in set (0.00 sec)
查看主庫,發(fā)現(xiàn)已經(jīng)有兩個線程(Binlog Dump)
mysql> show processlist\G
*************************** 1. row ***************************
Id: 8 User: slave Host: 192.168.0.20:44251 db: NULL Command: Binlog Dump Time: 1088 State: Master has sent all binlog to slave; waiting for binlog to be updated Info: NULL *************************** 2. row *************************** Id: 9 User: root Host: localhost db: peng Command: Query Time: 0 State: NULL Info: show processlist *************************** 3. row *************************** Id: 10 User: repl Host: 192.168.0.100:45844 db: NULL Command: Binlog Dump Time: 124 State: Master has sent all binlog to slave; waiting for binlog to be updated Info: NULL3 rows in set (0.00 sec)
正常工作,到此在線克隆slave就結(jié)束啦。