HDP 同步异常解决手册
一、数据源连接问题
1. MySQL相关问题
1.1 连接认证异常
错误信息: Read split MySqlBinlogSplit{splitId='binlog-split', ...} error due to Unable to connect to the MySQL database at 124.71.177.180:3306 with user 'root': unexpected sequence #1.
问题原因:
- 客 户端数据库连接数不足
- 网络抖动导致连接不稳定
- 数据库负载过高
解决方案:
- 清理数据库中的空闲连接
- 扩充数据库的最大连接数限制
- 检查网络连接的稳定性,确保无丢包和高延迟
1.2 版本兼容问题
错误信息: Synchronizing error: Public Key Retrieval is not allowed
问题原因:
- Flink CDC与MySQL 8.0的认证方式不兼容
- sha256_password认证方式需要通过TLS或RSA公钥加密保护密码
解决方案:
-
更改MySQL用户的认证方式: ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; FLUSH PRIVILEGES;
-
在my.ini文件中添加配置: [mysqld] default_authentication_plugin=mysql_native_password
1.3 主键索引问题
错误信息: Specified key was too long; max key length is 767 bytes
问题原因:
- MySQL 5.6中InnoDB存储引擎对索引长度限制为767字节
- utf8mb4字符集下varchar(255)会超出限制:
- utf8mb4每个字符占4字节
- varchar(255) * 4 = 1020字节 > 767字节限制
解决方案:
- 减少varchar字段长度:
- 将主键字段长度从255修改为191或更小
- 191 * 4 = 764字节 < 767字节限制
- 或更改字符集: ALTER TABLE table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
1.4 数据同步配置问题
错误信息: 开启同步任务后数据不同步
问题原因:
- binlog未开启
- binlog格式配置不正确
- binlog保留时间不足
解决方案:
-
检查并开启binlog: SHOW VARIABLES LIKE 'log_bin';
-
设置正确的binlog格式: SET GLOBAL binlog_format = 'ROW';
-
调整binlog保留时间: SET GLOBAL expire_logs_days = 7;
1.5 主从复制错误
错误信息: A slave with the same server_uuid/server_id as this slave has connected to the master
问题原因:
- 多个从库使用相同的server_uuid或server_id
- 主从同步配置冲突
- 复制连接未正常关闭
解决方案:
-
确保从库配置唯一性:
- 检查并修改server_id
- 验证server_uuid唯一性
-
重置复制状态: STOP SLAVE; RESET SLAVE; START SLAVE;