設置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線程狀態。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章