tikv获取catalog报错

【 TiDB 使用环境】生产环境 /测试/ Poc
【 TiDB 版本】5.4.1
【遇到的问题】想通过CDCClient实时同步tidb,调用TiSession.create(tiConfiguration).getCatalog()时报错
Exception in thread “main” java.lang.RuntimeException: org.tikv.common.exception.GrpcException: retry is exhausted.
at com.aliyun.qijun.App.main(App.java:91)
Caused by: org.tikv.common.exception.GrpcException: retry is exhausted.
at org.tikv.common.util.ConcreteBackOffer.logThrowError(ConcreteBackOffer.java:235)
at org.tikv.common.util.ConcreteBackOffer.doBackOffWithMaxSleep(ConcreteBackOffer.java:220)
at org.tikv.common.util.ConcreteBackOffer.doBackOff(ConcreteBackOffer.java:160)
at org.tikv.common.operation.PDErrorHandler.handleRequestError(PDErrorHandler.java:82)
at org.tikv.common.policy.RetryPolicy.callWithRetry(RetryPolicy.java:97)
at org.tikv.common.AbstractGRPCClient.callWithRetry(AbstractGRPCClient.java:89)
at org.tikv.common.PDClient.getTimestamp(PDClient.java:160)
at org.tikv.common.TiSession.getTimestamp(TiSession.java:320)
at org.tikv.common.TiSession.createSnapshot(TiSession.java:326)
at org.tikv.common.catalog.Catalog.(Catalog.java:44)
at org.tikv.common.TiSession.getCatalog(TiSession.java:357)
at com.aliyun.qijun.App.main(App.java:89)
Caused by: org.tikv.shade.io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: deadline exceeded after 0.199831333s. [buffered_nanos=201331500, waiting_for_connection]
at org.tikv.shade.io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:287)
at org.tikv.shade.io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:268)
at org.tikv.shade.io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:175)
at org.tikv.common.AbstractGRPCClient.lambda$callWithRetry$0(AbstractGRPCClient.java:92)
at org.tikv.common.policy.RetryPolicy.callWithRetry(RetryPolicy.java:88)
… 7 more
【复现路径】做过哪些操作出现的问题

  1. tidb在一台阿里云ecs上通过tiup cluster搭建,包括1 tidb,1 tikv,1 pd,1 tiflash,数据库相关功能正常,http://<公网ip>:2379/dashboard也可以正常打开
  2. 通过下列代码去连接时在session.getCatalog()时抛出上述的异常,pd 2379端口,tikv 20160 20180端口都已打开,我把这部分代码打成jar包到部署tidb的ecs上去执行时(同样通过公网ip)就可以执行
    TiConfiguration tiConfiguration = TiConfiguration.createDefault(“http://公网ip:2379”);
    TiSession session = TiSession.create(tiConfiguration);
    TiTableInfo table = null;
    try {
    Catalog catalog = session.getCatalog();
    table = catalog.getTable(“test”, “test_1024_1”);
    } catch (Exception e) {
    throw new RuntimeException(e);
    }
    【问题现象及影响】
    【附件】

不知道有没有碰到类似问题的大佬

本地没办法调试了,网络延迟太大了,会导致超时的…

jar 上传到 ECS 上执行可以,因为同网络,延迟很小

规整下环境还是有必要的

坐等答案学习

可是我通过tiConfiguration.setTimeout(20000L);设置超时时间也会报错
Caused by: org.tikv.shade.io.grpc.StatusRuntimeException: UNAVAILABLE: Keepalive failed. The connection is likely gone
at org.tikv.shade.io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:287)
at org.tikv.shade.io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:268)
at org.tikv.shade.io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:175)
at org.tikv.common.AbstractGRPCClient.lambda$callWithRetry$0(AbstractGRPCClient.java:92)
at org.tikv.common.policy.RetryPolicy.callWithRetry(RetryPolicy.java:88)
… 7 more
我感觉可能是公网/内网ip的问题,我单步进去TiSession发现ip成了内网ip

PD 只会记录内网节点的信息,没错的 :cowboy_hat_face:

可尝试用 TiCDC 来实时同步 TiDB 数据库,https://docs.pingcap.com/zh/tidb/stable/ticdc-overview

破案了,部署的yaml文件里各个组件的host也都用公网ip就可以了(之前用的是内网ip :no_mouth:

感谢楼上两位大佬

此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。