Mysql主从错误处理
slave关键字段说明
- 错误问题分类
- 错误代码1032/1062
临时处理办法:
mysql> stop slave;
mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1 #跳过一个事务
mysql>start slave
跳过所有1032/1062错误:
my.cnf配置文件添加如下内容
slave-skip-errors=1032,1062
永久处理办法:
分析当前slave上的sql线程执行日志文件和位置偏移量,并重放该SQL
Mysqlbinglo -vvv --base64-output=decode-row --stop-position=”95369” mysql-bin.0004 |tail -n 20
- relay-log日志文件损坏
通过重新指定binlog位置点
Change master to master_host='192.168.5.36',master_user='repl',master_password='root1234',master_log_file='mysql-bin.029740',master_log_pos=0;
- 跨数据版本主从错误处理
关于192.168.5.36 5.5版本mysql主从到5.6版本mysql错误
问题1:
Error: Table "mysql"."innodb_table_stats" not found
Recalculation of persistent statistics requested for table "xxxx"."xxxxxx" but the required persistent statistics storage is not present or is corrupted. Using transient stats instead
处理办法:
1 创建5.6版本的mysql临时数据库
docker run -dit --name testtemp -v /data/testtemdbpm:/var/lib/mysql registry.youkeshu.com:5000/mysql:56v5.
2 拷贝临时数据库的表结构到从库,重建这些表
innodb_index_stats
innodb_table_stats
slave_master_info
slave_relay_log_info
slave_worker_info
--------------------------------------
问题2:
[ERROR] Native table 'performance_schema'.'setup_consumers' has the wrong structure
升级information_schema;
处理办法:
修复myisam表结构
mysql_upgrade -u root -p