数据库主从过程出错

开始 134出现主从1206错误

Last_IO_Errno: 1236
 Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from position > file size; the first event 'mysql-bin.000124' at 927763888, the last event read from './mysql-bin.000124' at 4, the last byte read from './mysql-bin.000124' at 4.'
 
我从网上找的方法
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000124', MASTER_LOG_POS=927763888;
不行,然后我又在主数据库中读取binlog文件
从而用一下命令
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000124', MASTER_LOG_POS=4;  
才行。这句命令的意思是从mysql-bin.000124的4位置开始执行主从同步。
但是我这值得这个点,太靠前了,从而引起了一系列的主从问题,让我修改了一下午也没有修改好。在一次修改中,发现进程没反应了,kill也不行 于是我就重启了mysql 发现重启不了
由此我经历了一次mysql的洗礼
看日志发现磁盘满了,我就删文件,由于产生了很好mysql-relay-bin.000001文件,眼花了,就把所有的bin-log文件都删了,就更不能启动了,于是又删了mysql-bin.index,才能启动,但是由于原来的bin-log文件都没了,也就不能再继续原来的主从了,只能从现在的位置开始新的主从,相当于重新设置主从  就是在主数据库中执行 show master status \G 
然后在从数据库中执行 
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000124', MASTER_LOG_POS=xxxxxxxx;
主从启动,由于字符集的原来产生了一些错误,实在是多,跳过好多次,于是就在配置文件、etc/my.cnf中设置slave-skip-errors = 1062跳过主从1062错误   才可以正常主从。但产生的后果是中间修复主从时间内的数据没有同步
于是要进行主从一致性检查 修复
安装percona-toolkit
 
  
 
  
/usr/local/percona-toolkit-2.2.16/bin/pt-table-checksum --user='root' --password='xxxxxx' --host=192.168.168.xxx --port=3306  --replicate=UserCenter.checksums   --nocheck-replication-
filters
 
/usr/local/percona-toolkit-2.2.16/bin/pt-table-sync  --print --replicat=UserCenter.checksums --sync-to-master h=192.168.168.xxx,P=3306,u=root,p=xxxxxx --charset=utf8
 
/usr/local/percona-toolkit-2.2.16/bin/pt-table-sync  --execute --replicat=UserCenter.checksums --sync-to-master h=192.168.168.xxx,P=3306,u=root,p=xxxxxx --charset=utf8    (从本地到192.168.168.xxx)
 别看我这只有三句命令,但是原来一直报错也设置了半天才设置好
中间报过字符集错误
 
  
Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
11-27T14:40:02 DBI connect(';host=192.168.168.xxx;port=3306;mysql_read_default_group=client','root',...) failed: Can't initialize character set utf8mb4 (path: /usr/share/mysql/charsets/) at /usr/local/percona-toolkit-2.2.16/bin/pt-table-checksum line 1581
在mysql的配置文件中client部分把原来的utf8mb4给注释掉就可以了。
但还是有个别数据没有同步,

转载于:https://www.cnblogs.com/cuizhipeng/p/5043018.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值