我在Cassandra集群中有两个IP节点:端口aa.aaa.a.aaa:9043(节点)和xx.xxx.x.xxx:9043。当我尝试使用以下配置连接时** PoolingOptions poolingOptions = new PoolingOptions(); poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL,2) .setMaxConnectionsPerHost(HostDistance.LOCAL,4) .setCoreConnectionsPerHost(HostDistance.REMOTE,2) .setMaxConnectionsPerHost(HostDistance.REMOTE,4) .setMaxRequestsPerConnection(HostDistance.LOCAL,200) .setMaxRequestsPerConnection(HostDistance.REMOTE,200);
cluster = Cluster.builder()
.addContactPointsWithPorts(socketAddressList)
.withPoolingOptions(poolingOptions)
.withRetryPolicy(DefaultRetryPolicy.INSTANCE)
.withLoadBalancingPolicy(new TokenAwarePolicy(new DCAwareRoundRobinPolicy())).build();
Session session = cluster.connect(cassandraDB);**
我得到以下异常 16/01/14 09:52:45 INFO core.NettyUtil:没有在类路径中找到Netty的原生epoll传输,默认为NIO。 16/01/14 09:52:46 WARN core.Cluster:***您在联系点列出了/xx.xxx.x.xxx:9043,但在启动时无法访问* 16/01/14 09:52:47 INFO policies.DCAwareRoundRobinPolicy:使用数据中心名称' name'对于DCAwareRoundRobinPolicy(如果这不正确,请使用DCAwareRoundRobinPolicy构造函数提供正确的数据中心名称)ent.Futures $ CombinedFuture setExceptionAndMaybeLog 严重:输入未来失败。 com.datastax.driver.core.TransportException:[/ xxx.xxx.x.xxx:9042]无法连接 at com.datastax.driver.core.Connection $ 1.operationComplete(Connection.java:156) at com.datastax.driver.core.Connection $ 1.operationComplete(Connection.java:139) at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:680) at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:603) at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:563) 在io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:424) at io.netty.channel.nio.AbstractNioChannel $ AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:268) at io.netty.channel.nio.AbstractNioChannel $ AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:284) 在io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) 在io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) 在io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) at io.netty.util.concurrent.SingleThreadEventExecutor $ 2.run(SingleThreadEventExecutor.java:111) 在java.lang.Thread.run(Thread.java:745) 引起:java.net.ConnectException:拒绝连接:/xx.xxx.x.xxx:9042 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:744) 在io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:224) at io.netty.channel.nio.AbstractNioChannel $ AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:281) ......还有6个
16/01/14 09:52:47错误core.Session:创建池到/xx.xxx.x.xxx:9042时出错 com.datastax.driver.core.TransportException:[/ xxx.xxx.x.xxx:9042]无法连接 at com.datastax.driver.core.Connection $ 1.operationComplete(Connection.java:156) at com.datastax.driver.core.Connection $ 1.operationComplete(Connection.java:139) at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:680) at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:603) at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:563) 在io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:424) at io.netty.channel.nio.AbstractNioChannel $ AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:268) at io.netty.channel.nio.AbstractNioChannel $ AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:284) 在io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) 在io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) 在io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) at io.netty.util.concurrent.SingleThreadEventExecutor $ 2.run(SingleThreadEventExecutor.java:111) 在java.lang.Thread.run(Thread.java:745) 引起:java.net.ConnectException:拒绝连接: /xx.xxx.x.xxx:9042 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:744) 在io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:224) at io.netty.channel.nio.AbstractNioChannel $ AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:281) **
我的问题是:
cassandra版本:Cassandra 2.2.1
答案 0 :(得分:0)
为什么它尝试连接端口9042,而没有我在代码和配置文件中使用此端口?
9042 是CQL二进制协议的默认端口。
您能否向我们展示您传递给集群构建器的变量 socketAddressList 的内容?
您是否有任何理由使用端口 9043 而不是默认 9042 端口?