作者:姚嵩,外星人。
爱可生开源社区出品,原创内容未经授权不得随意使用,转载请联系小编并注明来源。
本文约 800 字,预计阅读需要 15 分钟。
在黑屏搭建完 Binlog Server 后,在通过 ODP 登陆业务租户执行 show master status
报错。
MySQL [(none)]> SHOW MASTER STATUS;
ERROR 10102 (HY000): OBProxy connect binlog service failed
从报错信息上看,OBProxy 连不上 Binlog Service 服务。
可能原因有:
binlog_service_ip
指定了错误的 Binlog Service,导致连不上。本次遇到的不在上述范围内(此处来个苦涩的微笑 😏)。
登录报错的 ODP 节点,查看具体的报错信息。
cd /home/admin/obproxy/log/
grep 'SHOW MASTER STATUS' obproxy_error.log # 注意 SQL 的大小写要和实际运行的 SQL 匹配
查看 SQL 执行对应的 trace ID,严格区分 SQL 关键字的大小写。
2025-08-20 20:11:28.412550,odp_4_3_5_0,,,,ob_4_3_5_2:tnt_binlog:,OB_MYSQL,,,OB_MYSQL_COM_QUERY,SHOW,failed,-4016,SHOW MASTER STATUS,5000311us,0us,0us,0us,Y0-00007F9173F016A0,,10.186.65.4:22106,,0,,Internal error,
通过时间和 trace ID 查找具体的报错。
sed -n '/\[2025-08-20 20:11:28/,$p' obproxy.log | grep Y0-00007F9173F016A0 | less
[2025-08-20 20:11:28.412003] INFO [PROXY] handle_timeout (ob_mysql_proxy.cpp:375) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] MysqlProxyCont active timeout(this=0x7f91738af540)
[2025-08-20 20:11:28.412026] WDIAG [PROXY] handle_client_resp (ob_table_entry_cont.cpp:599) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] fail to get table entry from remote(name={cluster_name:"ob_4_3_5_2", tenant_name:"tnt_binlog", database_name:"oceanbase", package_name:"", table_name:"__all_binlog_dummy"}, ret=-4016)
[2025-08-20 20:11:28.412040] INFO [PROXY] handle_lookup_remote (ob_table_entry_cont.cpp:873) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] can not find table entry, empty result(names={cluster_name:"ob_4_3_5_2", tenant_name:"tnt_binlog", database_name:"oceanbase", package_name:"", table_name:"__all_binlog_dummy"}, newest_table_entry=NULL)
[2025-08-20 20:11:28.412047] WDIAG [PROXY] do_lookup_binlog_entry_remote (ob_table_entry_cont.cpp:1202) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] fail to find available hostname or ip(binlog_service_ip=10.186.65.46:2983, used_hostname_ip_count=1, ret=-4016)
[2025-08-20 20:11:28.412052] WDIAG [PROXY] do_lookup_binlog_entry_remote (ob_table_entry_cont.cpp:1261) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] fail to get valid binlog service addr(addr=, ret=-4016)
[2025-08-20 20:11:28.412054] WDIAG [PROXY] main_handler (ob_table_entry_cont.cpp:345) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] fail to do lookup binlog service entry(ret=-4016)
[2025-08-20 20:11:28.412079] WDIAG [PROXY.SM] state_binlog_location_lookup (ob_mysql_sm.cpp:11701) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] cannot get binlog service ip(ret=-10102)
[2025-08-20 20:11:28.412081] WDIAG [PROXY.TXN] handle_bl_lookup (ob_mysql_transact.cpp:9067) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] [ObMysqlTransact::handle_bl_lookup] fail to lookup binlog location, will disconnect(ret=-4016)
[2025-08-20 20:11:28.412089] INFO [PROXY.SM] setup_error_transfer (ob_mysql_sm.cpp:9924) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] setup_error_transfer, try to build error packet for diagnosis(sql_cmd=3, internal_state=14)
[2025-08-20 20:11:28.412102] INFO [PROXY.SM] setup_internal_transfer (ob_mysql_sm.cpp:10100) [30087][Y0-00007F9173F016A0] [lt=0] [dc=0] INTERNAL_ERROR, will disconnect(sm_id=3197)
发现找不到 Binlog Service ip,binlog_service_ip=10.186.65.46:2983。
以 root@sys
登陆 ODP,查看 ODP 上配置的 binlog_service_ip
。
MySQL [(none)]> show proxyconfig like 'binlog_service_ip';
+-------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+-------------+---------------+-------+--------------+
| name | value | info | need_reboot | visible_level | range | config_level |
+-------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+-------------+---------------+-------+--------------+
| binlog_service_ip | 10.186.65.52:2983 | binlog service ip/hostname list, format ip1:sql_port1;hostname2:sql_port2, separate with ';'. prefer to use the forward | false | SYS | | LEVEL_VIP |
+-------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+-------------+---------------+-------+--------------+
1 row in set (0.00 sec)
发现 binlog_service_ip
中指定的 Binlog Server 服务地址和日志中记录的实际使用的 binlog_service_ip
并不相符。
而且实际使用的 10.186.65.46:2983
是以前通过白屏 OCP 配置的 Binlog Service 地址,当前该主机已经关机了。
手动修改 ODP 中 Binlog Server 服务地址。
cd /home/admin/obproxy/etc/
sqlite3 proxyconfig_v1.db
.header on
.mode column
select tenant_name, cluster_name, name, value, config_level from proxy_config where name='binlog_service_ip' ;
```sql
tenant_name cluster_name name value config_level
----------- ------------ ----------------- ----------------- ------------
tnt_binlog ob_4_3_5_2 binlog_service_ip 10.186.65.46:2983 LEVEL_TENANT
binlog_service_ip 10.186.65.52:2983 LEVEL_GLOBAL
发现 binlog_service_ip
存在两条记录,其中实际使用的 10.186.65.46:2983
对应的租户名和集群名,和报错时的登陆的租户和集群信息一致,config_level
为 LEVEL_TENANT 租户级别。
update proxy_config set value='10.186.65.52:2983'
where name='binlog_service_ip' and tenant_name='tnt_binlog' and cluster_name='ob_4_3_5_2';
binlog_service_ip
的值为 Binlog Server1 的地址);binlog_service_ip
的值为 Binlog Server2 的地址);我们发现使用不同的 Binlog Server + 相同的 ODP 为相同的租户配置 Binlog 服务时就会出现上述的问题。
测试发现删除 Binlog 任务时,ODP 配置文件中的租户级别的 binlog_service_ip
条目并不会被删除。
如果是有其他的 Binlog Server 和当前这个存在 租户级别的 binlog_service_ip
条目的 ODP 为条目对应的租户创建 binlog 任务,此时就会使用条目对应的旧的 binlog_service_ip
,这可能并不是用户所期望的。
本文关键字:#OceanBase #ODP #Binlog