Cassandra:GossipingPropertyFileSnitch:插入表时出现NoHostAvailable异常

时间:2016-10-21 12:21:57

标签: cassandra database-replication

我创建了2个以下配置的cassandra集群 节点1:
cassandra-topology.properties:

192.168.1.177=DC1:RAC1
192.168.1.134=DC2:RAC2

cassandra.yml:

cluster_name: 'TestCluster'
num_tokens: 256  
listen_address:  
rpc_address: localhost 
- seeds: "192.168.1.177,192.168.1.134"  
endpoint_snitch: GossipingPropertyFileSnitch

节点2:
cassandra-topology.properties:

192.168.1.177=DC1:RAC1  
127.0.0.1=DC2:RAC2 # Also tried 192.168.1.134 ip

cassandra.yml:

 cluster_name: 'TestCluster'  
    num_tokens: 256 
    listen_address:  
    rpc_address: localhost 
    - seeds: "192.168.1.177"  
    endpoint_snitch: GossipingPropertyFileSnitch 

我可以使用'nodetool status'命令查看这两个节点是否正常运行。我创建的Keyspace如下:

 > CREATE  KEYSPACE testReplication WITH replication = {'class':  NetworkTopologyStrategy', 'DC1' : '2', 'DC2' : '2'};

我也可以创建复制到两个节点的表,但是当我尝试在表上'INSERT'或'SELECT'时cqlsh给出'NoHostAvailable:', 但是system.log没有显示任何相关内容。

任何帮助将不胜感激 感谢。

1 个答案:

答案 0 :(得分:0)

在每个节点的cassandra.yaml中,将您的节点IP设置为rpc_address:listen_address:,并尝试为每个节点(DC1和DC2)设置seeds:。同样对于cassandra-topology.properties,为每个节点添加相同的配置。因此,例如,您的Node-1配置将如下所示:

cluster_name: 'TestCluster'
num_tokens: 256  
listen_address: 192.168.1.177
rpc_address: 192.168.1.177
- seeds: "192.168.1.177,192.168.1.134"  
endpoint_snitch: GossipingPropertyFileSnitch

对于每个节点,cassandra-topology.properties

192.168.1.177=DC1:RAC1
192.168.1.134=DC2:RAC2