我在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);
}));不提供任何错误日志。
对这里出了什么问题有什么想法吗?会非常感激的。
发布于 2019-06-03 08:45:17
如果手动创建VertxOptions,则必须设置clusterHost设置:
vertxOptions.getEventBusOptions().setClusterHost("the-pod-address")集群主机默认为localhost,这就是集群通信失败的原因。
https://stackoverflow.com/questions/56416243
复制相似问题