国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > MySQL > 正文

安全刪除mysql主從復(fù)制二進(jìn)制日志詳解

2024-07-24 12:38:06
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

mysql主從設(shè)置之后如果操作不當(dāng)刪除A服務(wù)器B服務(wù)器上的數(shù)據(jù)會(huì)自動(dòng)同步一并刪除,如果這樣刪除錯(cuò)了就等于你沒(méi)有備份數(shù)據(jù)庫(kù)了,下面我來(lái)給大家介紹安全刪除mysql主從復(fù)制二進(jìn)制日志,大家可參考參考.

具體方法:刪除日志之前,先檢查主從服務(wù)器當(dāng)前使用的日志文件,首先登錄,要?jiǎng)h除日志的服務(wù)器的 mysql 終端.

#mysql -u root -pxxxxx

檢查復(fù)制主服務(wù)器狀態(tài):

  1. Mysql>show master status 
  2.  
  3. +------------------+-----------+--------------+----------------------------------------+ 
  4. | File             | Position  | Binlog_Do_DB | Binlog_Ignore_DB                       | 
  5. +------------------+-----------+--------------+----------------------------------------+ 
  6. | mysql-bin.000097 | 541677824 | www      | test,mysql,information_schema | 
  7. +------------------+-----------+--------------+----------------------------------------+ 

復(fù)制主服務(wù)器當(dāng)前正在使用的日志文件是:mysql-bin.000097,檢查復(fù)制從服務(wù)器狀態(tài):

  1. Mysql>show slave statusG 
  2.  
  3. *************************** 1. row *************************** 
  4.                Slave_IO_State: Waiting for master to send event 
  5.                   Master_Host: 202.102.152.3 
  6.                   Master_User: replication 
  7.                   Master_Port: 3306 
  8.                 Connect_Retry: 60 
  9.               Master_Log_File: mysql-bin.000103 
  10.           Read_Master_Log_Pos: 675107897 
  11.                Relay_Log_File: www-relay-bin.000443 
  12.                 Relay_Log_Pos: 675097929 
  13.         Relay_Master_Log_File: mysql-bin.000103 
  14.              Slave_IO_Running: Yes 
  15.             Slave_SQL_Running: Yes 
  16.               Replicate_Do_DB: www 
  17.           Replicate_Ignore_DB: test,mysql,information_schema 
  18.            Replicate_Do_Table:  --Vevb.com 
  19.        Replicate_Ignore_Table: 
  20.       Replicate_Wild_Do_Table: 
  21.   Replicate_Wild_Ignore_Table: 
  22.                    Last_Errno: 0 
  23.                    Last_Error: 
  24.                  Skip_Counter: 0 
  25.           Exec_Master_Log_Pos: 675107897 
  26.               Relay_Log_Space: 675098125 
  27.               Until_Condition: None 
  28.                Until_Log_File: 
  29.                 Until_Log_Pos: 0 
  30.            Master_SSL_Allowed: No 
  31.            Master_SSL_CA_File: 
  32.            Master_SSL_CA_Path: 
  33.               Master_SSL_Cert: 
  34.             Master_SSL_Cipher: 
  35.                Master_SSL_Key: 
  36.         Seconds_Behind_Master: 0 
  37. Master_SSL_Verify_Server_Cert: No 
  38.                 Last_IO_Errno: 0 
  39.                 Last_IO_Error: 
  40.                Last_SQL_Errno: 0 
  41.                Last_SQL_Error: 

復(fù)制從服務(wù)器當(dāng)前正在使用的復(fù)制主服務(wù)器日志文件是:mysql-bin.000103,當(dāng)前正在使用的日志文件是000097,我需要做的是刪除00095號(hào)之前的所有日志(預(yù)留出最近幾天的日志).

Mysql>purge master logs to ‘mysql-bin.000095;

#ll /usr/local/mysql/var/

從結(jié)果中發(fā)現(xiàn),編號(hào)000097之前的所有日志都已經(jīng)刪除,如果還有其他服務(wù)器需要清理日志,重新按上面的順序進(jìn)行就可以.

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 游戏| 克山县| 荆门市| 巧家县| 博野县| 易门县| 名山县| 灵武市| 如皋市| 华容县| 文水县| 太白县| 柏乡县| 米易县| 紫阳县| 山东省| 庆阳市| 潮安县| 垦利县| 合山市| 苏尼特左旗| 江口县| 英超| 万载县| 万山特区| 宁津县| 太仆寺旗| 临沧市| 连城县| 资兴市| 余江县| 富平县| 霞浦县| 卢龙县| 黄浦区| 察雅县| 甘洛县| 黑山县| 军事| 崇信县| 达州市|