码迷,mamicode.com
首页 > 数据库 > 详细

mysqldump中master-data和dump-slave的区别

时间:2016-07-21 00:48:47      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:

 

 

[mysql@db2 ~]$ mysqldump -A --master-data=2 > master2.sql

[mysql@db2 ~]$ mysqldump -A --dump-slave=2 > slave2.sql

[mysql@db2 ~]$ mysqldump -A --master-data=1 > master1.sql

[mysql@db2 ~]$ mysqldump -A --dump-slave=1 > slave1.sql

 

[mysql@db2 ~]$ diff master2.sql master1.sql

22c22
< -- CHANGE MASTER TO MASTER_LOG_FILE=‘mysql-bin2.000001‘, MASTER_LOG_POS=259;
---
> CHANGE MASTER TO MASTER_LOG_FILE=mysql-bin2.000001, MASTER_LOG_POS=335;
845c845
< -- Dump completed on 2012-03-13 18:09:46
---
> -- Dump completed on 2012-03-13 18:10:17

 

 

[mysql@db2 ~]$ diff slave2.sql slave1.sql
22c22
< -- CHANGE MASTER TO MASTER_LOG_FILE=‘mysql-bin.000007‘, MASTER_LOG_POS=107;
---
> CHANGE MASTER TO MASTER_LOG_FILE=mysql-bin.000007, MASTER_LOG_POS=107;
845c845
< -- Dump completed on 2012-03-13 18:09:59
---
> -- Dump completed on 2012-03-13 18:10:24

 

有上可知:
A. =1和=2的区别很明显,只是自动执行和手工执行的区别
B. --master-data用于在master端dump数据,用于建立slave
--dump-slave用户在slave端dump数据,建立新的slave,至少是第2个slave,也就是已经有A-->B,现在从B上导出数据建立A-->C的复制

 

这个不但可以用于建立slave,还可用于备份中,用于读binlog进行roll forward的起点

  

注意:

--master-data, It turns on --lock-all-tables, unless single-transaction also is specified

mysqldump中master-data和dump-slave的区别

标签:

原文地址:http://www.cnblogs.com/zengkefu/p/5690131.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!