首页 文章

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

提问于
浏览
1

我用以下配置创建了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

    在每个节点的 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
    

相关问题