设置mysql从库延迟主库一小时

便于数据恢复,设置从库延迟主库1个小时


此图借用李磊的 直接上图了 非本人笔记

1.png

 CHANGE MASTER TO MASTER_DELAY = 1800;单位为秒


[root@backup ~]# mysql -uroot -p123456  -e "show slave status \G"|grep  -i sql
mysql: [Warning] Using a password on the command line interface can be insecure.
              Master_Log_File: mysql-bin.000008
        Relay_Master_Log_File: mysql-bin.000008
            Slave_SQL_Running: Yes
               Last_SQL_Errno: 0
               Last_SQL_Error: 
             Master_Info_File: /home/nflow/data/backup/mysql/data/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
     Last_SQL_Error_Timestamp:



[root@backup ~]# mysql -uroot -p123456  -e "show slave status \G"|grep  -i sql
mysql: [Warning] Using a password on the command line interface can be insecure.
              Master_Log_File: mysql-bin.000008
        Relay_Master_Log_File: mysql-bin.000008
            Slave_SQL_Running: Yes
               Last_SQL_Errno: 0
               Last_SQL_Error: 
             Master_Info_File: /home/nflow/data/backup/mysql/data/master.info
                    SQL_Delay: 1800       #代表延迟同步1800s      
          SQL_Remaining_Delay: 1775            #从1800 每秒减一个
      Slave_SQL_Running_State: Waiting until MASTER_DELAY seconds after master executed event
     Last_SQL_Error_Timestamp: 
[root@backup ~]#



SQL_Delay:正数表明slave有延迟了。
SQL_Remaining_Delay:整数表明延迟时间。
Slave_SQL_Running_State:表明sql线程状态。

猜你喜欢

转载自blog.51cto.com/wsxxsl/2313907