代码拉取完成,页面将自动刷新
同步操作将从 mo-shan/script 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
# File Name: skip_mysql_repl_error_for_gtid.sh
# Author: moshan
# mail: mo_shan@yeah.net
# Created Time: 2019-04-18 09:05:42
# Function:
#########################################################################
debug="${1}"
mysql_admin_user="moshan"
mysql_admin_pass="xxxxxx"
mysql_host="192.168.x.x"
mysql_port="3306"
mysql_comm="mysql -u${mysql_admin_user} -p${mysql_admin_pass} -h${mysql_host} -P${mysql_port}"
gtid_str="38f8425e-9182-5934-b32a-7e4317fe4a04"
log_file="${HOME}/info.log"
echo -e "\033[32m[$(date "+%F %H:%M:%S")] [INFO] log file \"${log_file}\"\033[0m"
while :
do
error_gtid_num=$(${mysql_comm} -e "show slave status\\G"|grep "Worker .* failed executing transaction"|tail -1|awk -F"${gtid_str}" '{print $2}'|awk -F"'" '{print $1}')
[ "$(wc -l < gtid)x" == "0x" ] && continue
if [ "${debug}x" == "x" ]
then
${mysql_comm} -e "show slave status\\G"
skip_befor_binlog=$(${mysql_comm} -e "show slave status\\G" 2>/dev/null|grep -v "Relay_Master_Log_File:"|grep "Master_Log_File:"|awk '{print $2}')
skip_befor_pos=$(${mysql_comm} -e "show slave status\\G" 2>/dev/null|grep "Read_Master_Log_Pos:"|awk '{print $2}')
skip_befor_gtid_num=$(${mysql_comm} -e "show master status\\G" 2>/dev/null|grep -A 1000 "Executed_Gtid_Set:"|sed 's/Executed_Gtid_Set: //'|sort|tr -d "\n")
echo -e "\033[32m[$(date "+%F %H:%M:%S")] [INFO] skip_befor_binlog_pos:${skip_befor_binlog}:${skip_befor_pos}\033[0m"|tee -a ${log_file}
echo -e "\033[32m[$(date "+%F %H:%M:%S")] [INFO] skip_befor_gtid_num:${skip_befor_gtid_num}\033[0m"|tee -a ${log_file}
echo "set gtid_next='${gtid_str}:${error_gtid_num}';begin;commit;SET SESSION GTID_NEXT = AUTOMATIC;start slave;"|${mysql_comm}
${mysql_comm} -e "show slave status\\G"
elif [ "${debug}x" == "debugx" ]
then
echo "stop slave;set gtid_next='${gtid_str}:${error_gtid_num}';begin;commit;SET SESSION GTID_NEXT = AUTOMATIC;start slave;"
exit
fi
done
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。