zoukankan      html  css  js  c++  java
  • mysql --master-data 参数

    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 
    
    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 
    
    the slave should start replicating.
    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 
    
    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.
    
    mysqldump导出数据时,当这个参数的值为1的时候,mysqldump出来的文件就会包括CHANGE MASTER TO这个语句,CHANGE MASTER TO后面紧接着就是file和position的记录,在slave上导入数据时就会执
    
    行这个语句,salve就会根据指定这个文件位置从master端复制binlog。默认情况下这个值是1
    当这个值是2的时候,chang master to也是会写到dump文件里面去的,但是这个语句是被注释的状态。
    
    
    master-data参数在建立slave数据库的时候会经常用到,因为这是一个比较好用的参数,默认值为1,默认情况下,会包含change master to,这个语句包含file和position的记录始位置。master-
    
    data=2的时候,在mysqldump出来的文件包含CHANGE MASTER TO这个语句,处于被注释状态
     
    dump出文件
    [root@aeolus1 c_learn]# mysqldump -uroot test --single-transaction --master-data=2 >master-data.sql
    过滤出change master to信息
    [root@aeolus1 c_learn]# grep -i "change master to" master-data.sql 
    -- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000012', MASTER_LOG_POS=107;
    
    
    
    然后修改 
    
    change master to  master_host='xx.xx.xx.xx',
    master_user='repl',
    master_password='repl',
    master_port=3306,
    master_log_file='mysql-bin.000012',
    master_log_pos=107;
     
    
     
    然后slave从库执行
     
    
    mysql> change master to  master_host='xx.xx.xx.xx',
    master_user='repl',
    master_password='repl',
    master_port=3306,
    master_log_file='mysql-bin.000012',
    master_log_pos=107;
    

  • 相关阅读:
    GuozhongCrawler系列教程 (1) 三大PageDownloader
    数据库中表的复杂查询&分页
    AngularJs 在控制器中过滤
    【iOS开发-79】利用Modal方式实现控制器之间的跳转
    leetCode(51):Valid Palindrome
    Eclipse上开发IBM Bluemix应用程序
    POJ 2104 K-th Number 静态主席树(裸
    BZOJ 3210 花神的浇花集会 计算几何- -?
    [易飞]一张领料单单身仓库"飞了"引起的思考
    Hbuilder开发app实战-识岁06-face++的js实现【完结】
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351629.html
Copyright © 2011-2022 走看看