2014-01-30 61 views
1

如何手動複製主故障情況?如何在mysql中手動複製主故障的情況

我有2個服務器,充當主和從複製對方。我想要做的是複製主故障的情況,即當主服務器出現故障時,主服務器發生連續寫入時。我正在使用perl腳本訪問主服務器並將值插入到主服務器中的表中。我怎麼能手動突然停止插入數據到主服務器,因爲它會在主站突然關閉時發生。

+0

爲什麼您需要手動執行某些操作?一旦失去與數據庫的連接,插入是否會失敗? – ThisSuitIsBlackNot

+2

殺死mysql進程? – dwjv

+0

我正在嘗試在主站和從站之間同步數據的項目上工作,如果主站出現故障。但爲了做測試,我需要從perl程序手動殺死一個服務器(主)。我不確定,怎麼做。你有沒有建議如何從perl程序中殺死一臺服務器? – Shweta

回答

1

我會做以下...

1)如果服務器運行UNIX操作系統。

 The perl command would be .. 

       system ("ps -ef | grep username| awk '{ print $2 }' | xargs kill -9") ; 

      This would kill all the proceeses in your unix server and return to your perl script. Pl note that if you do not want to return to your perl script , use exec command instead of system. Also note that if you are running a database , it would be a better idea to kill your database processes first. 

2)如果你正在運行的Windows Server

 The perl command would be .. 

       system ("taskkill /f /fi username") ; 

這會殺了你的用戶的Windows Server強制所有proceeses並返回到您的perl腳本。

    Hope This helps