使用 maxwell 导致的复制故障

周五下班前同事要一个权限账号搭建 maxwell,结果导致复制环境不同步。

故障现象

收到报警,当前复制环境复制不同步。看了下报错很诡异

190801 18:16:04 [ERROR] Slave SQL: Error 'Character set '#45' is not a compiled character set and is not specified in the '/usr/local/mysql/share/charsets/Index.xml' file' on query. Default database: 'maxwell'. Query: 'CREATE DATABASE IF NOT EXISTS `maxwell`', Error_code: 22
190801 18:16:04 [Warning] Slave: Character set '#45' is not a compiled character set and is not specified in the '/usr/local/mysql/share/charsets/Index.xml' file Error_code: 22

 大体看了下是个字符集问题,因为当天急着赶火车,一直没时间好好看这个问题,今天办完事,从火车站直接跑到公司处理下这个故障。

定位

出现这个问题的原因是因为 slave 用了5.1的老版本 mysql,在这个版本中出现了从 master 中携带过来的“意外”字符集,而 slave 这个5.1的版本还没出现这种字符集。去 master 看了下当时的binlog ,确实是,

# at 399078
#190801 18:16:06 server id 11243327  end_log_pos 399183         Query   thread_id=86609906      exec_time=0     error_code=0
SET TIMESTAMP=1564654566/*!*/;
SET @@session.sql_mode=2097152/*!*/;
/*!\C utf8mb4 *//*!*/;
SET @@session.character_set_client=45,@@session.collation_connection=45,@@session.collation_server=33/*!*/;
CREATE DATABASE IF NOT EXISTS `maxwell`
/*!*/;
# at 399183
#190801 18:16:06 server id 11243327  end_log_pos 399821         Query   thread_id=86609906      exec_time=0     error_code=0
use maxwell/*!*/;
SET TIMESTAMP=1564654566/*!*/;
CREATE TABLE IF NOT EXISTS `schemas` (
  id int unsigned auto_increment NOT NULL primary key,
  binlog_file varchar(255),
  binlog_position int unsigned,
  last_heartbeat_read bigint null default 0,
  gtid_set varchar(4096),
  base_schema_id int unsigned NULL default NULL,
  deltas mediumtext charset 'utf8' NULL default NULL,
  server_id int unsigned,
  position_sha char(40) CHARACTER SET latin1 DEFAULT NULL,
  charset varchar(255),
  version smallint unsigned not null default 0,
  deleted tinyint(1) not null default 0,
  UNIQUE KEY `position_sha` (`position_sha`)
)

从 /*!\C utf8mb4 *//*!*/;
SET @@session.character_set_client=45,@@session.collation_connection=45,@@session.collation_server=33/*!*/;

可以看出,客户端字符集被设置成了utf8mb4,而这种字符集在 slave 的 5.1 版本中根本就没有。导致同步失败。

修复

针对这种问题,除了升级 slave 没有其他办法,而我们这个 slave 因为历史原因,难以升级。

转载于:https://my.oschina.net/xxj123go/blog/3083088

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值