zoukankan      html  css  js  c++  java
  • 17.1.1.4 Obtaining the Replication Master Binary Log Coordinates 得到复制master binary log 位置:

    17.1.1.4 Obtaining the Replication Master Binary Log Coordinates  得到复制master binary log 位置:
    
    
    你需要master的当前坐标在他的Binary log 为了配置slave slave开始复制处理在合适的点:
    
    如果你已经有存在的数据在你的master上,你需要同步你的slaves 在开始复制过程前,
    
    
    你必须停止处理语句在master上,然后得到他的当前的binary log 位置和dump 它的数据,
    
    在运行master 继续执行语句前。 如果你不停止语句的执行,data dump和master status信息你使用的不会匹配 你会借宿不一致性或者冲突的数据库在slave上
    
    
    要获得master binary log 位置信息,遵循下面的步骤:
    
    1.开始一个session 在master 上通过连接它,flush 所有的表和block 写语句通过执行FLUSH TABLES WITH READ LOCK statement:
    
    
    mysql> FLUSH TABLES WITH READ LOCK;
    
    
    对于InnoDB 表, FLUSH TABLES WITH READ LOCK 也堵塞COMMIT 操作
    
    
    警告:
    
      留着客户端 你执行e FLUSH TABLES statement  运行这样 read lock仍然有效,如果你退出client,lock是被释放:
    
    
    2.在master 的另外一个session,使用SHOW MASTER STATUS 语句来得到当前的binary log 文件名字和位置:
    
    
    mysql>  SHOW MASTER STATUS;
    +------------------+-----------+--------------+------------------+-------------------+
    | File             | Position  | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
    +------------------+-----------+--------------+------------------+-------------------+
    | mysql-bin.000016 | 399962594 |              |                  |                   |
    +------------------+-----------+--------------+------------------+-------------------+
    1 row in set (0.00 sec)
    
    
    mysql > SHOW MASTER STATUS;
    +------------------+----------+--------------+------------------+
    | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +------------------+----------+--------------+------------------+
    | mysql-bin.000003 | 73       | test         | manual,mysql     |
    +------------------+----------+--------------+------------------+
    
    
    文件列显示 log file 的名字 Position 显示file 的位置。
    
    在这个例子中,binary log 文件是mysql-bin.000003 和 position 是73.
    
    记录那些值, 你随后需要它们当你设置slave的时候。
    
    
    它们代表复制坐标 slave 应该开始处理新的更新从master
    
    
    如果master 先前运行没有启用 binary logging, log file name 和position 通过SHOW MASTER STATUS 显示
    
    
    或者mysqldump  --master-data 会是空的。
    
    
    你现在有信息你需要让slave开始读取从binary log 在正确的位置开始复制

  • 相关阅读:
    eclipse export runnable jar(导出可执行jar包) runnable jar可以执行的
    mave常用指令
    771. Jewels and Stones珠宝数组和石头数组中的字母对应
    624. Maximum Distance in Arrays二重数组中的最大差值距离
    724. Find Pivot Index 找到中轴下标
    605. Can Place Flowers零一间隔种花
    581. Shortest Unsorted Continuous Subarray连续数组中的递增异常情况
    747. Largest Number At Least Twice of Others比所有数字都大两倍的最大数
    643. Maximum Average Subarray I 最大子数组的平均值
    414. Third Maximum Number数组中第三大的数字
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350047.html
Copyright © 2011-2022 走看看