博客是我工作的好帮手,遇到困难就来博客找资料
分类: 系统运维
2017-03-05 14:36:34
XtraBackup介绍:
其最新版的软件可从 获得
xtrabackup是Percona公司CTO Vadim参与开发的一款基于InnoDB的在线热备工具,具有开源,免费,支持在线热备,备份恢复速度快,占用磁盘空间小等特点,并且支持不同情况下的多种备份形式。xtrabackup的官方下载地址为。
xtrabackup包含两个主要的工具,即xtrabackup和innobackupex,二者区别如下:
(1)xtrabackup只能备份innodb和xtradb两种引擎的表,而不能备份myisam引擎的表;
(2)innobackupex是一个封装了xtrabackup的Perl脚本,支持同时备份innodb和myisam,但在对myisam备份时需要加一个全局的读锁。还有就是myisam不支持增量备份。
在线热备份工具,备份过程中不锁库表,
只备份表记录,不备份表结构
表的存储引擎必须是InnoDB/XtraDB
必须先有一次完全备份,这样再执行备份时才知道那些数据是新产生。
安装XtraBackup: perl(DBD::mysql) perl(Time::HiRes) 先安装两个依赖包
rpm -q perl-Time-HiRes
rpm -ivh percona-xtrabackup-2.1.6-702.rhel6.x86_64.rpm
提供2个备份命令:
xtrabackup:C程序,支持InnoDB/XtraDB
innobackupex:以Perl脚本封装xtrabackup,还支持MyISAM
xtrabackup_56 命令语法格式:
(完全备份 完全恢复 增量备份 增量恢复)
————————————
xtrabackup_56 <选项>
--backup 备份数据
--prepare 恢复数据
--target-dir=目录名 指定备份文件存储的目录
--datadir=/var/lib/mysql 指定数据库目录的位置
--incremental-basedir=目录名 增量备份时,指定上一次备份文件存储的目录
--incremental-dir=目录名 增量恢复数据时,指定使用恢复文件所在的目录
————————————————————————————————————————————————————————
实验操作:(首先对库做一个完全备份,当增加数据时,做一个增量备份序号1,再增加数据,再做一个增量备份2,再增加数据,再做一个增量备3,再增加数据, 完全备份+增量备份)
(恢复:先恢复完全备份,再恢复增量备份,按顺序从最开始的一个一个恢复,这里恢复的是xtrabackup_checkpoints 中所对应的序列号,最后所有恢复完再把备份文件拷贝会对应数据库目录下,重启服务)
【 注意这个只能恢复一次 一次性】
1.先备份:完全备份+增量备份
db1.a 5 -> 999 完全备份
xtrabackup_56 --backup --datadir=/var/lib/mysql --target-dir=/allbak
10 -> 301 第1次增量备份
xtrabackup_56 --backup --datadir=/var/lib/mysql --target-dir=/new1 --incremental-basedir=/allbak
8 -> 801 第2次增量备份
xtrabackup_56 --backup --datadir=/var/lib/mysql --target-dir=/new2 --incremental-basedir=/new1
3 -> 777 第3次增量备份
xtrabackup_56 --backup --datadir=/var/lib/mysql --target-dir=/new3 --incremental-basedir=/new2
2.xtrabackup恢复数据的步骤:
1)准备恢复数据 ,先恢复完全备份,再恢复增量备份
xtrabackup_56 --prepare --datadir=/var/lib/mysql --target-dir=/allbak
xtrabackup_56 --prepare --datadir=/var/lib/mysql --target-dir=/allbak --incremental-dir=/new1
xtrabackup_56 --prepare --datadir=/var/lib/mysql --target-dir=/allbak --incremental-dir=/new2
xtrabackup_56 --prepare --datadir=/var/lib/mysql --target-dir=/allbak --incremental-dir=/new3
2) 把备份文件拷贝回对应的数据库目录下
[root@stu ~]# cp /allbak/bbsdb/a.ibd /var/lib/mysql/bbsdb/
cp:是否覆盖"/var/lib/mysql/bbsdb/a.ibd"? y
[root@stu ~]#
3) 重启数据库服务
service mysql restart
4) 查看恢复是否成功
select * from bbsdb.a;
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
__________________________________________________________________________
[root@host ~]# cd /var/lib/mysql
[root@host mysql]# ls
auto.cnf ib_logfile0 performance_schema
host.tedu.cn.err ib_logfile1 python
host.tedu.cn.pid mysql RPM_UPGRADE_HISTORY
ibdata1 mysql.sock RPM_UPGRADE_MARKER-LAST
__________________________________________________________________________
事务日志 /var/lib/mysql/
ib_logfile0
ib_logfile1 ---sql命令
idbata1 记录数据信息
xtrabackup_checkpoints lsn序列号对应文件
xtrabackup_logfile 序列号所对应的sql命令文件
备份过程
在增量备份时,如何知道在所有记录中,哪些记录是新产生的
在增量备份时:如何知道有新数据写入,有写入的话也要把新数据备份上
(1)安装使用xtrabackup,安装比较简单,我们使用二进制编译好的就行了,这种工具无需源码编译,因为没有什么功能需要特殊定制。
[root@MySQL01 ~]# wget
[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)全量备份
创建备份用户:
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)
进行全备份
备份数据存放在/data/backup/下面,innobackupex会自动创建一个文件夹,是当前系统的时间戳
mysql> select * from peng.t1;
+------+-------+
| id | name |
+------+-------+
| 1 | peng |
| 2 | atlas |
+------+-------+
2 rows in set (0.00 sec)
测试数据就是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目录下产生了什么!
[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
可以看见有对应数据库的名字,比如peng,还有一个以时间戳命名的目录。我们看看对应文件里面的内容,这几个比较重要:
[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
mysql> drop database peng;
Query OK, 1 row affected (0.04 sec)
恢复全备
恢复备份到mysql的数据文件目录,这一过程要先关闭mysql数据库,重命名或者删除原数据文件目录都可以,再创建一个新的数据文件目录,将备份数据复制到新的数据文件目录下,赋权,修改权限,启动数据库。
[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!
以上对应的目录就是innobackupex全备份自己创建的目录。
[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!
可以看见已经成功恢复,修改数据目录权限,启动mysql,效验数据是否正常,查看peng库下面的t1表中的数据。
[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)
发现数据已经成功恢复。
(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!
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)
现在来一次增量备份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!
我们看看增量备份的大小以及文件内容
[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/
看见增量备份的数据很小吧,就是备份改变的数据而已。
[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
上面已经明显说明是增量备份了,该工具很人性化吧,呵呵
我们再次向t1表插入数据,然后创建增量备份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)
创建增量备份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)增量备份恢复
增量备份的恢复大体为3个步骤
恢复完全备份(注意这里一定要加--redo-only参数,该参数的意思是只应用xtrabackup日志中已提交的事务数据,不回滚还未提交的数据)
[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应用到完全备份
[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应用到完全备份(注意恢复最后一个增量备份时需要去掉--redo-only参数,回滚xtrabackup日志中那些还未提交的数据)
[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操作,回滚未提交的数据:
[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!
把恢复完的备份复制到数据库目录文件中,赋权,然后启动mysql数据库,检测数据正确性
[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 ]
查看数据是否正确
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
在日常工作中,我们有时候需要在线添加从库,比如线上有一主一从两个数据库,但是由于业务的需要,一台从库的读取无法满足现在的需求,这样就需要我们在线添加从库,由于出于安全考虑,我们通常需要在从库上进行在线克隆slave。
克隆slave时,常用参数--slave-info和--safe-slave-backup。
--slave-info会将master的binlog文件名和偏移量位置保存到xtrabackup_slave_info文件中
--safe-slave-backup会暂停slave的SQL线程直到没有打开的临时表的时候开始备份。备份结束后SQL线程会自动启动,这样操作的目的主要是确保一致性的复制状态。
下面的例子,将介绍一主一从情况下在线搭建新的从库,环境如下:
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文件内容,这个内容就是为搭建从库时需要change master to的参数:
[root@MySQL-02 ~]# cat /data/cloneslave/xtrabackup_slave_info
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000006', MASTER_LOG_POS=732
在老的slave服务器上进行还原,即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!
将还原的文件复制到新的从库newslave,即192.168.0.100
[root@MySQL-02 data]# rsync -avprP -e ssh /data/cloneslave/ 192.168.0.100:/data/mysql/
在主库master上添加对新从库newslave的授权:
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参数,修改完毕后,启动新的从库;
[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线程,并观察复制是否正常:
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)
查看主库,发现已经有两个线程(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就结束啦。