mysql主从复制,经常会遇到错误而导致slave端复制中断,这个时候一般就需要人工干预,跳过错误才能继续跳过错误有两种方式:
1.跳过指定数量的事务:
mysql>slave stop; mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1 #跳过一个事务 mysql>slave start
2.修改mysql的配置文件,通过slave_skip_errors参数来跳所有错误或指定类型的错误
vi /etc/my.cnf
slave-skip-errors=1062,1053,1146 #跳过指定error no类型的错误 slave-skip-errors=all #跳过所有错误
shell记录master状态 /usr/bin/mysql -uroot -e "SHOW master STATUS\G" > /data/master.log
mysql> CHANGE MASTER TO -> MASTER_HOST='master_host_name', -> MASTER_USER='replication_user_name', -> MASTER_PASSWORD='replication_password', -> MASTER_LOG_FILE='recorded_log_file_name', -> MASTER_LOG_POS=recorded_log_position;