Astyanax 1.56.37连接到在Debian上运行的Cassandra 1.2.6:
当快速连续执行多个插入到仅包含位于10.10.1.141的一个节点的Cassandra集群时,在看似随机的点上,我将在控制台中看到以下内容:
- AddHost: 127.0.0.1
- RemoveHost: 10.10.1.141
在我收到此密钥空间后,每次尝试连接到此密钥空间都会失败并显示相同的消息。
这是我的配置:
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster("Titan Cluster")
.forKeyspace(keyspaceName)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE)
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
.setTargetCassandraVersion("1.2")
)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
.setPort(9160)
.setMaxConnsPerHost(50)
.setSeeds("10.10.1.141:9160")
.setConnectTimeout(2000)
.setSocketTimeout(30000)
.setMaxTimeoutWhenExhausted(10000)
.setMaxTimeoutCount(3)
.setTimeoutWindow(10000)
.setLatencyAwareBadnessThreshold(10)
.setLatencyAwareUpdateInterval(1000)
.setLatencyAwareResetInterval(10000)
.setLatencyAwareWindowSize(100)
)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
后续尝试context.start()
答案 0 :(得分:3)
我也面临同样的问题,我在不同的机器上运行我的Cassandra和应用程序(Cassandra客户端)。
AddHost: 10.10.1.141
AddHost: 127.0.0.1
RemoveHost: 10.10.1.141
当我查看我的Cassandra戒指状态时,我注意到Cassandra的地址为127.0.0.1
,而不是10.10.1.141
root@10.10.1.141:/opt/dsc-cassandra$ **bin/nodetool ring**
Address Rack Status State Load Owns Token
127.0.0.1 rack1 Up Normal 169.87 KB 100.00% -9217929600007243236
127.0.0.1 rack1 Up Normal 169.87 KB 100.00% -9140762708880451456
127.0.0.1 rack1 Up Normal 169.87 KB 100.00% -8952943573583903866
127.0.0.1 rack1 Up Normal 169.87 KB 100.00% -8891950316930533160*
在conf/cassandra.yaml
中,我为listen_address
指定了主机名而不是IP地址。 cassandra将主机名恢复为localhost(127.0.0.1
)而不是实际的IP(10.10.1.141
)。
将listen_address
更改为实际IP后,客户端已成功建立连接。
listen_address:10.10.1.141
答案 1 :(得分:0)
我在Windows上的VirtualBox上运行Cassandra,所以IP类似于168.192.0.14,对我来说,使用NodeDiscoveryType.NONE阻止了断开连接:
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster(clusterName)
.forKeyspace(keyspaceName)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.NONE)
)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
.setPort(9160)
.setMaxConnsPerHost(3)
.setSeeds("192.168.0.14:9160")
)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
Keyspace keyspace = context.getClient();