Cassandra在不同的港口创建带主机的游泳池

问题描述 投票:0回答:1

我在服务器上的Kubernetes上运行了10个Cassandra节点,在端口10023上暴露了服务的1个联系点。

但是,当数据存储驱动程序尝试与群集的其他节点建立连接时,它使用公开的端口而不是默认端口,并且我收到以下错误:

com.datastax.driver.core.ConnectionException: [/10.210.1.53:10023] Pool was closed during initialization

有没有办法暴露一个单一的联系点,让它与标准端口(9042)上的其他节点通信?

我检查了datastax文档是否有任何相关的但我没有找到太多。

这就是我连接到群集的方式

Cluster.Builder builder = Cluster.builder();
        builder.addContactPoints(address)
                .withPort(Integer.valueOf(10023))
                .withCredentials(user, password)
                .withMaxSchemaAgreementWaitSeconds(600)
                .withSocketOptions(
                        new SocketOptions()
                                .setConnectTimeoutMillis(Integer.valueOf(timeout))
                                .setReadTimeoutMillis(Integer.valueOf(timeout))
                ).build();
        Cluster cluster = builder.withoutJMXReporting().build();
        Session session = cluster.connect();
cassandra port connection-pooling host
1个回答
0
投票

驱动程序联系第一个节点后,它会获取有关群集的信息,并使用此信息,此信息包括Cassandra侦听的端口。

要实现您想要做的事情,您需要Cassandra在相应的端口上进行侦听 - 这是通过native_transport_portcassandra.yaml参数配置的。

此外,默认情况下,Cassandra驱动程序将尝试连接到群集中的所有节点,因为它使用DCAware / TokenAware load balancing policy。如果只想使用一个节点,则需要使用WhiteListPolicy而不是默认策略。但从性能的角度来看并不是最优的。

我建议你重新考虑一下如何将Cassandra暴露给客户。

© www.soinside.com 2019 - 2024. All rights reserved.