问题

我在aws ec2上设置了一个Hazelcast-Get集群,然后在指令here .我使用了hazelcast-aws模型,以便节点可以自动发现对方.集群正在建立并运行:

 [2019-09-26 22:26:26.288] [INFO   ] com.hazelcast.config.AbstractConfigLocator - Using configuration file at /home/ec2-user/hazelcast-jet-3.1/config/hazelcast.xml
[2019-09-26 22:26:26.416] [INFO   ] com.hazelcast.instance.AddressPicker - [LOCAL] [jet] [3.1] Interfaces is enabled, trying to pick one address matching to one of: [172.31.*.*]
[2019-09-26 22:26:26.416] [INFO   ] com.hazelcast.instance.AddressPicker - [LOCAL] [jet] [3.1] Prefer IPv4 stack is true, prefer IPv6 addresses is false
[2019-09-26 22:26:26.425] [INFO   ] com.hazelcast.instance.AddressPicker - [LOCAL] [jet] [3.1] Picked [172.31.33.212]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true
[2019-09-26 22:26:26.460] [INFO   ] com.hazelcast.system - [172.31.33.212]:5701 [jet] [3.1] Hazelcast Jet 3.1 (20190624 - 000ced7) starting at [172.31.33.212]:5701
 

它还成功地找到了它的同行:

 [2019-09-26 22:26:26.664] [INFO   ] com.hazelcast.spi.impl.operationservice.impl.BackpressureRegulator - [172.31.33.212]:5701 [jet] [3.1] Backpressure is disabled
[2019-09-26 22:26:27.103] [INFO   ] com.hazelcast.instance.Node - [172.31.33.212]:5701 [jet] [3.1] Activating Discovery SPI Joiner
[2019-09-26 22:26:27.297] [INFO   ] com.hazelcast.jet.impl.metrics.JetMetricsService - [172.31.33.212]:5701 [jet] [3.1] Configuring metrics collection, collection interval=5 seconds, retention=5 seconds, publishers=[Management Center Publisher, JMX Publisher]
[2019-09-26 22:26:27.343] [INFO   ] com.hazelcast.jet.impl.JetService - [172.31.33.212]:5701 [jet] [3.1] Setting number of cooperative threads and default parallelism to 36
[2019-09-26 22:26:27.345] [INFO   ] com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl - [172.31.33.212]:5701 [jet] [3.1] Starting 36 partition threads and 19 generic threads (1 dedicated for priority tasks)
[2019-09-26 22:26:27.354] [INFO   ] com.hazelcast.internal.diagnostics.Diagnostics - [172.31.33.212]:5701 [jet] [3.1] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
[2019-09-26 22:26:27.364] [INFO   ] com.hazelcast.core.LifecycleService - [172.31.33.212]:5701 [jet] [3.1] [172.31.33.212]:5701 is STARTING
[2019-09-26 22:26:27.772] [INFO   ] com.hazelcast.nio.tcp.TcpIpConnector - [172.31.33.212]:5701 [jet] [3.1] Connecting to /172.31.47.40:5701, timeout: 10000, bind-any: true
[2019-09-26 22:26:27.782] [INFO   ] com.hazelcast.nio.tcp.TcpIpConnection - [172.31.33.212]:5701 [jet] [3.1] Initialized new cluster connection between /172.31.33.212:47065 and /172.31.47.40:5701
[2019-09-26 22:26:33.786] [INFO   ] com.hazelcast.internal.cluster.ClusterService - [172.31.33.212]:5701 [jet] [3.1]

Members {size:2, ver:6} [
        Member [172.31.47.40]:5701 - 3ba123c0-e98b-47dc-9bf5-34944d2c53a2
        Member [172.31.33.212]:5701 - 0127e9a7-80b1-4c5d-a122-2da5aa7fa042 this
]
 

除了我的客户端(不是aws)无法连接到集群之外,一切看起来都很好.我所做的只是运行单词计数示例.唯一的区别是,不是让客户端和服务器在同一个JVM中运行,我想将任务提交给我设置的集群.我用(按照指令)替换了JetInstance jet = Jet.newJetInstance();:

         ClientConfig clientConfig = new ClientConfig();

        ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig();
        clientConfig.getGroupConfig().setName("jet");
        networkConfig.getAwsConfig().setEnabled(true)
                .setProperty("access-key", "abc")
                .setProperty("secret-key", "cde")
                .setProperty("region", "us-west-2")
                .setProperty("security-group-name", "eee")
                .setProperty("hz-port", "5701")
                .setProperty("use-public-ip", "true");

        JetInstance jet = Jet.newJetClient(clientConfig);
 

我可以告诉客户端正在寻找正确的端点:

 INFO: hz.client_0 [jet] [3.0] [3.12] Trying to connect to cluster with name: jet
Sep 26, 2019 3:40:55 PM com.hazelcast.client.connection.nio.ClusterConnectorService
INFO: hz.client_0 [jet] [3.0] [3.12] Trying to connect to [172.31.47.40]:5701 as owner member
Sep 26, 2019 3:41:00 PM com.hazelcast.client.connection.nio.ClusterConnectorService
WARNING: hz.client_0 [jet] [3.0] [3.12] Exception during initial connection to [172.31.47.40]:5701: com.hazelcast.core.HazelcastException: java.net.SocketTimeoutException
Sep 26, 2019 3:41:00 PM com.hazelcast.client.connection.nio.ClusterConnectorService
INFO: hz.client_0 [jet] [3.0] [3.12] Trying to connect to [172.31.33.212]:5701 as owner member
Sep 26, 2019 3:41:05 PM com.hazelcast.client.connection.nio.ClusterConnectorService
WARNING: hz.client_0 [jet] [3.0] [3.12] Exception during initial connection to [172.31.33.212]:5701: com.hazelcast.core.HazelcastException: java.net.SocketTimeoutException
 

我已经使用两个ec2实例将5701添加到安全组的入站规则中. 要调试,我运行了几个网络命令来查看端口5701是否打开:

 [[email protected] ~]$ sudo lsof -i -P -n | grep LISTEN
rpcbind   5428      rpc    8u  IPv4  50298      0t0  TCP *:111 (LISTEN)
rpcbind   5428      rpc   11u  IPv6  50301      0t0  TCP *:111 (LISTEN)
master    5897     root   13u  IPv4  40255      0t0  TCP 127.0.0.1:25 (LISTEN)
sshd      6115     root    3u  IPv4  41329      0t0  TCP *:22 (LISTEN)
sshd      6115     root    4u  IPv6  41331      0t0  TCP *:22 (LISTEN)
java     43020 ec2-user   10u  IPv6 118393      0t0  TCP *:5701 (LISTEN)
 
 [[email protected] ~]$ sudo lsof -i:5701
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    43020 ec2-user   10u  IPv6 118393      0t0  TCP *:5701 (LISTEN)
java    43020 ec2-user   45u  IPv6 152973      0t0  TCP ip-172-31-33-212.us-west-2.compute.internal:52599->ip-172-31-47-40.us-west-2.compute.internal:5701 (ESTABLISHED)
 

我对网络的了解有限.我无法弄清楚问题是什么.我注意到一件事是,当客户端尝试连接到私有ipv4地址时,端口是为ipv6打开的.

  最佳答案

Marko是对的(查看问题的评论).这看起来像一些AWS网络约束.我在我的ec2框之一上使用端口5701设置netcat服务器.我无法使用nc从我的笔记本电脑连接到端口,但能够从同一个VPC中的另一个ec2连接到它.然后我对端口80进行了同样的实验.我可以从我的笔记本电脑和同一个VPC的ec2实例连接到端口.看起来只允许AWS之外的实例连接到几个众所周知的ec2实例.

无论如何,我通过在端口80上运行hazelcast服务器来解冻自己.这对我来说并不理想,但更方便的是从我的IDE尝试一些hazelcast-jet特性,而不是将测试代码部署到ec2.

  相同标签的其他问题

amazon-ec2hazelcast-jet