我已经在Kubernetes平台上设置了一个vert.x / hazelcast集群:
Hazelcast群集本身正在正常运行。我可以看到该集群由两个成员组成:
[100.116.0.36]:5701 [dev] [3.12]
Members {size:2, ver:8} [
Member [100.122.0.1]:5701 - 4d42a914-a6a5-4d65-897d-835eb5f5da4d
Member [100.116.0.36]:5701 - be0010b5-1a0e-4359-bc94-70078fe4f2d4 this
]
我还使用了Hazelcast提供的共享地图,该地图在两个吊舱之间可以很好地同步。
Vert.x本身正在记录以下警告:
Connecting to server localhost:41635 failedConnection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:325)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:634)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:460)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Connecting to server localhost:37251 failedConnection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:325)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:634)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:460)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
这些消息可能不会直接链接到vert.x,但是在本地模式下启动时它们会消失。
我还使用千分尺设置了监视,并且vert.x并未为vertx_eventbus_bytesWritten
提供任何值,如下所示:https://vertx.io/docs/vertx-micrometer-metrics/java/
因此,我很确定vert.x仅将这些消息发送给本地使用者是因为这些警告。
在群集模式下设置vert.x的方式如下:
VertxOptions vertxOptions = new VertxOptions();
vertxOptions.getEventBusOptions().setClustered(true);
vertxOptions.setClusterManager(new HazelcastClusterManager(hazelcastInstance)); // the hazelcast instance itself is setup by spring boot which i'm using for dependency injection
Vertx.rxClusteredVertx(vertxOptions).doOnSuccess((result -> {
LOGGER.info("Clustered vertx setup complete. Deploying vertices....");
// ...
})).doOnError((throwable -> {
LOGGER.error("Failed to setup clustered verx.", throwable);
}));
不提供任何错误日志。
对这里出什么问题有任何想法吗?非常感谢。
答案 0 :(得分:0)
如果手动创建VertxOptions
,则必须设置clusterHost
设置:
vertxOptions.getEventBusOptions().setClusterHost("the-pod-address")
集群主机默认为localhost
,这就是集群通信失败的原因。