无法在云环境中的Verticle之间建立vert.x集群

时间:2017-11-28 16:01:53

标签: cloud hazelcast vert.x

无法在云环境中的Verticle之间建立vert.x集群

我在配置私有云环境中的vert.x eventbus时遇到了麻烦。

在实验室测试中,我尝试使用Hazelcast集群管理器制作两个Verticle来建立一个集群,每个管理器都运行在您自己的容器中。

原因是错误配置会导致问题,但我无法找到它。 在这个云上,不可能进行多播呼叫,然后我使用TCP IP发现策略。

最初的计划是制作一个" labatf-api" verticle(一个REST调用接收器),它将通过eventbus传播bussines处理,以便在" labatf-vtx"中执行。 verticle。

下面是配置" labatf-api"的集群片段的代码。 verticle:

Config hazelcastConfig = new Config();
NetworkConfig networkConfig = new NetworkConfig();

networkConfig
    .setPort(5701)
    .getJoin()
        .getMulticastConfig()
            .setEnabled(false);
networkConfig
    .getJoin()
        .getAwsConfig()
            .setEnabled(false);
networkConfig
    .getJoin()
        .getTcpIpConfig()
            .setEnabled(true)           
            .addMember("labatf-vtx:5701");

hazelcastConfig.setNetworkConfig(networkConfig);

ClusterManager mgr = new HazelcastClusterManager(hazelcastConfig);
VertxOptions options = new VertxOptions()
    .setClusterManager(mgr)
    .setEventBusOptions(new EventBusOptions()                           
            .setClusterPublicHost("labatf-api")
            .setClusterPublicPort(5701))
    .setClustered(true);

Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
        ...
    }
});

" labatf-api"垂直代码:

Config hazelcastConfig = new Config();
NetworkConfig networkConfig = new NetworkConfig();

networkConfig
    .setPort(5701)
    .getJoin()
        .getMulticastConfig()
            .setEnabled(false);
networkConfig
    .getJoin()
        .getAwsConfig()
            .setEnabled(false);
networkConfig
    .getJoin()
        .getTcpIpConfig()
            .setEnabled(true)           
            .addMember("labatf-api:5701");

hazelcastConfig.setNetworkConfig(networkConfig);

ClusterManager mgr = new HazelcastClusterManager(hazelcastConfig);
VertxOptions options = new VertxOptions()
    .setClusterManager(mgr)
    .setEventBusOptions(new EventBusOptions()                           
            .setClusterPublicHost("labatf-vtx")
            .setClusterPublicPort(5701))
    .setClustered(true);

Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
        ...
    }
});

请注意" labatf-api"和" labatf-vtx"是云环境中的模块名称,但它们也是服务IP的域名,它将平衡每个模块的容器副本之间的调用(如果存在)。

在启动Verticle容器后,每个模块发现另一个,但几秒钟之后连接被目标对等体中断,如下面的日志所示:

" labatf-api" verticle:

INFO:   [192.168.84.205]:5701 [dev] [3.9] Accepting socket connection from /192.168.80.253:52191
INFO:   [192.168.84.205]:5701 [dev] [3.9] Established socket connection between /192.168.84.205:5701 and /192.168.80.253:52191
WARNING:[192.168.84.205]:5701 [dev] [3.9] Wrong bind request from [192.168.80.253]:5701! This node is not the requested endpoint: [labatf-api]:5701
INFO: [192.168.84.205]:5701 [dev] [3.9] Connection[id=2, /192.168.84.205:5701->/192.168.80.253:52191, endpoint=null, alive=false, type=MEMBER] closed. Reason: Wrong bind request from [192.168.80.253]:5701! This node is not the requested endpoint: [labatf-api]:5701
INFO: [192.168.84.205]:5701 [dev] [3.9] Connection[id=5, /192.168.84.205:45323->labatf-vtx/10.36.232.241:5701, endpoint=[labatf-vtx]:5701, alive=false, type=MEMBER] closed. Reason: Connection closed by the other side

" labatf-vtx" verticle:

INFO: [192.168.80.253]:5701 [dev] [3.9] Accepting socket connection from /192.168.84.205:60711
INFO: [192.168.80.253]:5701 [dev] [3.9] Established socket connection between /192.168.80.253:5701 and /192.168.84.205:60711
WARNING: [192.168.80.253]:5701 [dev] [3.9] Wrong bind request from [192.168.84.205]:5701! This node is not the requested endpoint: [labatf-vtx]:5701
INFO: [192.168.80.253]:5701 [dev] [3.9] Connection[id=3, /192.168.80.253:5701->/192.168.84.205:60711, endpoint=null, alive=false, type=MEMBER] closed. Reason: Wrong bind request from [192.168.84.205]:5701! This node is not the requested endpoint: [labatf-vtx]:5701
INFO: [192.168.80.253]:5701 [dev] [3.9] Connection[id=4, /192.168.80.253:55987->labatf-api/10.36.212.47:5701, endpoint=[labatf-api]:5701, alive=false, type=MEMBER] closed. Reason: Connection closed by the other side

任何帮助都会很好!

1 个答案:

答案 0 :(得分:0)

您无法通过负载均衡器连接Hazelcast节点。 Hazelcast节点必须直接相互通信。我们不使用HTTP(S),而是使用基于TCP / IP的自定义协议。