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

1220阅读 0评论2013-07-02 dba_life
分类:Mysql/postgreSQL

[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

上一篇:dmidecode命令使用方法
下一篇: Shell while read命令完成用户的交互输入