客户端无法连接到 Hazelcast-jet ec2 集群
Client unable to connect to Hazelcast-jet ec2 clusters
我在 之后在 aws ec2 上设置了一个 Hazelcast-jet 集群。我使用了 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 上)无法连接到集群外,一切看起来都很好。我所做的只是 运行 word counting example. The only difference is that, instead of having both client and server run in the same JVM, I want to submit the task to the cluster I setup. I replaced the JetInstance jet = Jet.newJetInstance();
with (following instructions):
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
我已经将5701添加到两个ec2实例使用的安全组的入站规则中。
为了调试,我 运行 几个网络命令来查看端口 5701 是否打开:
[ec2-user@ip-172-31-33-212 ~]$ 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)
[ec2-user@ip-172-31-33-212 ~]$ 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.
我在
[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 上)无法连接到集群外,一切看起来都很好。我所做的只是 运行 word counting example. The only difference is that, instead of having both client and server run in the same JVM, I want to submit the task to the cluster I setup. I replaced the JetInstance jet = Jet.newJetInstance();
with (following instructions):
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
我已经将5701添加到两个ec2实例使用的安全组的入站规则中。 为了调试,我 运行 几个网络命令来查看端口 5701 是否打开:
[ec2-user@ip-172-31-33-212 ~]$ 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)
[ec2-user@ip-172-31-33-212 ~]$ 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.