--master-data 的作用

  1. Use this option to dump a master replication server to produce a dump file that can be used to set up another server as a slave of the master. It causes the dump output to   
  2.   
  3. include a CHANGE MASTER TO statement that indicates the binary log coordinates (file name and position) of the dumped server. These are the master server coordinates from which   
  4.   
  5. the slave should start replicating.  
  6. If the option value is 2, the CHANGE MASTER TO statement is written as an SQL comment, and thus is informative only; it has no effect when the dump file is reloaded. If the   
  7.   
  8. option value is 1, the statement takes effect when the dump file is reloaded. If the option value is not specified, the default value is 1.  
  9.   
  10. mysqldump导出数据时,当这个参数的值为1的时候,mysqldump出来的文件就会包括CHANGE MASTER TO这个语句,CHANGE MASTER TO后面紧接着就是file和position的记录,在slave上导入数据时就会执  
  11.   
  12. 行这个语句,salve就会根据指定这个文件位置从master端复制binlog。默认情况下这个值是1  
  13. 当这个值是2的时候,chang master to也是会写到dump文件里面去的,但是这个语句是被注释的状态。  
  14.   
  15.   
  16. master-data参数在建立slave数据库的时候会经常用到,因为这是一个比较好用的参数,默认值为1,默认情况下,会包含change master to,这个语句包含file和position的记录始位置。master-  
  17.   
  18. data=2的时候,在mysqldump出来的文件包含CHANGE MASTER TO这个语句,处于被注释状态  
  19.    
  20. dump出文件  
  21. [root@aeolus1 c_learn]# mysqldump -uroot test --single-transaction --master-data=2 >master-data.sql  
  22. 过滤出change master to信息  
  23. [root@aeolus1 c_learn]# grep -i "change master to" master-data.sql   
  24. -- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000012', MASTER_LOG_POS=107;  
  25.   
  26.   
  27.   
  28. 然后修改   
  29.   
  30. change master to  master_host='xx.xx.xx.xx',  
  31. master_user='repl',  
  32. master_password='repl',  
  33. master_port=3306,  
  34. master_log_file='mysql-bin.000012',  
  35. master_log_pos=107;  
  36.    
  37.   
  38.    
  39. 然后slave从库执行  
  40.    
  41.   
  42. mysql> change master to  master_host='xx.xx.xx.xx',  
  43. master_user='repl',  
  44. master_password='repl',  
  45. master_port=3306,  
  46. master_log_file='mysql-bin.000012',  
  47. master_log_pos=107;  

转载于:https://www.cnblogs.com/yingdiblog/p/7245406.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值