Smart客户端连接到Hazelcast K8S群集时失败,使用NodePort公开服务

发布于 2025-02-04 12:57:58 字数 4063 浏览 1 评论 0原文

我是使用以下命令来创建的:

HAZELCAST_VERSION=latest
kubectl apply -f https://raw.githubusercontent.com/hazelcast/hazelcast-kubernetes/master/rbac.yaml
kubectl create service nodeport hz-hazelcast-0 --tcp=5701:5701 --node-port=31001
kubectl run hz-hazelcast-0 --image=hazelcast/hazelcast:$HAZELCAST_VERSION --port=5701 -l "app=hz-hazelcast-0,role=hazelcast"
kubectl create service nodeport hz-hazelcast-1 --tcp=5701:5701 --node-port=31002
kubectl run hz-hazelcast-1 --image=hazelcast/hazelcast:$HAZELCAST_VERSION --port=5701 -l "app=hz-hazelcast-1,role=hazelcast"
kubectl create service nodeport hz-hazelcast --tcp=5701:5701 --node-port=31000 -o yaml --dry-run=client | kubectl set selector --local -f - "role=hazelcast" -o yaml | kubectl create -f -

对于我的python客户端,我启用了use_public_ipsmart_routing gragonments。借助Smart客户端,客户端可以成功发现Hazelcast成员,但无法设置连接。

    hz_client = hz.HazelcastClient(
        cluster_name="dev",
        cluster_members=["10.xx.xx.xx:31001", "10.xx.xx.xx:31002"],
        use_public_ip=True,
        smart_routing=True,
        client_name='hz.client_0',
        lifecycle_listeners=[
            lambda state: print("Lifecycle event >>>", state),
        ],
        # connection_timeout=120
    )
DEBUG:hazelcast.reactor:Starting Reactor Thread
INFO:hazelcast.lifecycle:HazelcastClient 5.1 is STARTING
Lifecycle event >>> STARTING
INFO:hazelcast.lifecycle:HazelcastClient 5.1 is STARTED
Lifecycle event >>> STARTED
INFO:hazelcast.connection:Trying to connect to Address(host=10.xx.xx.xx, port=31001)
DEBUG:hazelcast.reactor:Connected to Address(host=10.xx.xx.xx, port=31001)
INFO:hazelcast.lifecycle:HazelcastClient 5.1 is CONNECTED
Lifecycle event >>> CONNECTED
INFO:hazelcast.connection:Authenticated with server Address(host=10.244.1.41, port=5701):b711733c-1a61-49da-8220-3a1fcfe41322, server version: 5.1.1, local address: Address(host=10.xx.xx.xx, port=42818)
DEBUG:hazelcast.cluster:Resetting the member list version
DEBUG:hazelcast.cluster:Handling new snapshot with membership version: 2, member string: 

Members [2] {
        Member [10.244.1.41]:5701 - b711733c-1a61-49da-8220-3a1fcfe41322
        Member [10.244.1.42]:5701 - e0ad91b4-bc8f-4118-9170-9e8b3c28947b
}

INFO:hazelcast.cluster:

Members [2] {
        Member [10.244.1.41]:5701 - b711733c-1a61-49da-8220-3a1fcfe41322
        Member [10.244.1.42]:5701 - e0ad91b4-bc8f-4118-9170-9e8b3c28947b
}

DEBUG:hazelcast.partition:Handling new partition table with version: 1
DEBUG:hazelcast.partition:Partition view event coming from a new connection. Old: None, new: Connection(id=0, live=True, remote_address=Address(host=10.244.1.41, port=5701))
INFO:hazelcast.connection:Connection(id=1, live=False, remote_address=None) closed. Reason: Connection timed out
DEBUG:hazelcast.connection:Destroying Connection(id=1, live=False, remote_address=None), but it has no remote address, hence nothing is removed from the connection dictionary
DEBUG:hazelcast.invocation:Got exception for request OutboundMessage(message_type=256, correlation_id=3, retryable=True), error: TargetDisconnectedError
INFO:hazelcast.client:Client started
DEBUG:hazelcast.invocation:Client is not connected to target: e0ad91b4-bc8f-4118-9170-9e8b3c28947b
DEBUG:hazelcast.invocation:Client is not connected to target: e0ad91b4-bc8f-4118-9170-9e8b3c28947b
DEBUG:hazelcast.invocation:Client is not connected to target: e0ad91b4-bc8f-4118-9170-9e8b3c28947b
INFO:hazelcast.connection:Connection(id=2, live=False, remote_address=None) closed. Reason: Connection timed out
DEBUG:hazelcast.connection:Destroying Connection(id=2, live=False, remote_address=None), but it has no remote address, hence nothing is removed from the connection dictionary
DEBUG:hazelcast.invocation:Got exception for request OutboundMessage(message_type=256, correlation_id=8, retryable=True), error: TargetDisconnectedError

I created by cluster using the following commands:

HAZELCAST_VERSION=latest
kubectl apply -f https://raw.githubusercontent.com/hazelcast/hazelcast-kubernetes/master/rbac.yaml
kubectl create service nodeport hz-hazelcast-0 --tcp=5701:5701 --node-port=31001
kubectl run hz-hazelcast-0 --image=hazelcast/hazelcast:$HAZELCAST_VERSION --port=5701 -l "app=hz-hazelcast-0,role=hazelcast"
kubectl create service nodeport hz-hazelcast-1 --tcp=5701:5701 --node-port=31002
kubectl run hz-hazelcast-1 --image=hazelcast/hazelcast:$HAZELCAST_VERSION --port=5701 -l "app=hz-hazelcast-1,role=hazelcast"
kubectl create service nodeport hz-hazelcast --tcp=5701:5701 --node-port=31000 -o yaml --dry-run=client | kubectl set selector --local -f - "role=hazelcast" -o yaml | kubectl create -f -

And for my python client, I enabled the use_public_ip and smart_routing arguments. With the Smart Client, client can successfully discover hazelcast members but fail to set up the connection.

    hz_client = hz.HazelcastClient(
        cluster_name="dev",
        cluster_members=["10.xx.xx.xx:31001", "10.xx.xx.xx:31002"],
        use_public_ip=True,
        smart_routing=True,
        client_name='hz.client_0',
        lifecycle_listeners=[
            lambda state: print("Lifecycle event >>>", state),
        ],
        # connection_timeout=120
    )
DEBUG:hazelcast.reactor:Starting Reactor Thread
INFO:hazelcast.lifecycle:HazelcastClient 5.1 is STARTING
Lifecycle event >>> STARTING
INFO:hazelcast.lifecycle:HazelcastClient 5.1 is STARTED
Lifecycle event >>> STARTED
INFO:hazelcast.connection:Trying to connect to Address(host=10.xx.xx.xx, port=31001)
DEBUG:hazelcast.reactor:Connected to Address(host=10.xx.xx.xx, port=31001)
INFO:hazelcast.lifecycle:HazelcastClient 5.1 is CONNECTED
Lifecycle event >>> CONNECTED
INFO:hazelcast.connection:Authenticated with server Address(host=10.244.1.41, port=5701):b711733c-1a61-49da-8220-3a1fcfe41322, server version: 5.1.1, local address: Address(host=10.xx.xx.xx, port=42818)
DEBUG:hazelcast.cluster:Resetting the member list version
DEBUG:hazelcast.cluster:Handling new snapshot with membership version: 2, member string: 

Members [2] {
        Member [10.244.1.41]:5701 - b711733c-1a61-49da-8220-3a1fcfe41322
        Member [10.244.1.42]:5701 - e0ad91b4-bc8f-4118-9170-9e8b3c28947b
}

INFO:hazelcast.cluster:

Members [2] {
        Member [10.244.1.41]:5701 - b711733c-1a61-49da-8220-3a1fcfe41322
        Member [10.244.1.42]:5701 - e0ad91b4-bc8f-4118-9170-9e8b3c28947b
}

DEBUG:hazelcast.partition:Handling new partition table with version: 1
DEBUG:hazelcast.partition:Partition view event coming from a new connection. Old: None, new: Connection(id=0, live=True, remote_address=Address(host=10.244.1.41, port=5701))
INFO:hazelcast.connection:Connection(id=1, live=False, remote_address=None) closed. Reason: Connection timed out
DEBUG:hazelcast.connection:Destroying Connection(id=1, live=False, remote_address=None), but it has no remote address, hence nothing is removed from the connection dictionary
DEBUG:hazelcast.invocation:Got exception for request OutboundMessage(message_type=256, correlation_id=3, retryable=True), error: TargetDisconnectedError
INFO:hazelcast.client:Client started
DEBUG:hazelcast.invocation:Client is not connected to target: e0ad91b4-bc8f-4118-9170-9e8b3c28947b
DEBUG:hazelcast.invocation:Client is not connected to target: e0ad91b4-bc8f-4118-9170-9e8b3c28947b
DEBUG:hazelcast.invocation:Client is not connected to target: e0ad91b4-bc8f-4118-9170-9e8b3c28947b
INFO:hazelcast.connection:Connection(id=2, live=False, remote_address=None) closed. Reason: Connection timed out
DEBUG:hazelcast.connection:Destroying Connection(id=2, live=False, remote_address=None), but it has no remote address, hence nothing is removed from the connection dictionary
DEBUG:hazelcast.invocation:Got exception for request OutboundMessage(message_type=256, correlation_id=8, retryable=True), error: TargetDisconnectedError

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文