我在阿里云的一台服务器上部署了 Debezium,用来获取 MongoDB sharded cluster 的日志实现 CDC,但是 Debezium 出现了连接不上的错误。
2021-07-13 02:40:09,047 INFO MongoDB|dish|snapshot Exception in monitor thread while connecting to server 172.18.69.198:27122 [org.mongodb.driver.cluster]
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70)
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:143)
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:188)
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:144)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
at java.base/java.net.Socket.connect(Socket.java:609)
at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:78)
at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79)
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65)
... 4 more
我在那台服务器上登录进 MongoDB,执行sh.status()
,其结果如下图所示。
也就是说“部署 Debezium 的那台服务器连接不上 replica set 中的成员”,那么怎样才能让服务器能够连接上 replica set 中的成员呢?
联系了阿里云那边的人,它们说没办法解决。我现在使用Change Streams — MongoDB Manual实现CDC。