1. 程式人生 > >設定mysql從庫延遲主庫一小時

設定mysql從庫延遲主庫一小時

便於資料恢復,設定從庫延遲主庫1個小時


此圖借用李磊的 直接上圖了 非本人筆記

1.png

 CHANGE MASTER TO MASTER_DELAY = 1800;單位為秒


[[email protected] ~]# 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:



[[email protected] ~]# 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: 
[
[email protected]
 ~]#



SQL_Delay:正數表明slave有延遲了。
SQL_Remaining_Delay:整數表明延遲時間。
Slave_SQL_Running_State:表明sql執行緒狀態。