共計 1455 個字符,預計需要花費 4 分鐘才能閱讀完成。
本篇內容主要講解“Mysql 自動處理同步報錯代碼分享”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓丸趣 TV 小編來帶大家學習“Mysql 自動處理同步報錯代碼分享”吧!
export LANG=zh_CN
./root/.bash_profilev_dir=/usr/local/Mysql/bin/v_user=rootv_passwd=123456v_log=/home/logsv_times=10if [-d ${v_log} then echo ${v_log} has existed before. else mkdir ${v_log}fiecho ${v_log}/slave_status.logecho ${v_log}/slave_status_error.logcount=1while truedo Seconds_behind_master=$(${v_dir}Mysql -u${v_user} -p${v_passwd} -e show slave status\G; | awk -F : /Seconds_behind_master/{print $2} )if [${Seconds_behind_master}!= NULL then echo slave is ok! ${v_dir}Mysql -u${v_user} -p${v_passwd} -e show slave status\G; ${v_log}/slave_status.log breakelse echo ${v_log}/slave_status_error.log date ${v_log}/slave_status_error.log echo ${v_log}/slave_status_error.log ${v_dir}Mysql -u${v_user} -p${v_passwd} -e show slave status\G; ${v_log}/slave_status_error.log ${v_dir}Mysql -u${v_user} -p${v_passwd} -e show slave status\G; |egrep Delete_rows /dev/null 2 1 if [$?=0];then ${v_dir}Mysql -u${v_user} -p${v_passwd} -e stop slave;SET GLOBAL sql_slave_skip_counter=1;start slave; else ${v_dir}Mysql -u${v_user} -p${v_passwd} -e show slave status\G; |grep Last_SQL_Error break fi let count++ if [$count -gt ${v_times}];then break else ${v_dir}Mysql -u${v_user} -p${v_passwd} -e show slave status\G; ${v_log}/slave_status_error.log sleep 2 continue fifidone
到此,相信大家對“Mysql 自動處理同步報錯代碼分享”有了更深的了解,不妨來實際操作一番吧!這里是丸趣 TV 網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
正文完