【问题标题】:Cassandra: GossipingPropertyFileSnitch: NoHostAvailable exception while inserting into tableCassandra:GossipingPropertyFileSnitch:插入表时出现 NoHostAvailable 异常
【发布时间】:2016-10-22 13:04:12
【问题描述】:

我创建了具有以下配置的 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'};

我还可以创建复制到两个节点的表,但是当我尝试在表上“插入”或“选择”时,cqlsh 给出了“NoHostAvailable:”, 但 system.log 没有显示任何内容。

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

【问题讨论】:

    标签: cassandra database-replication


    【解决方案1】:

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

    【讨论】:

    • 按照您的步骤操作,仍然出现 NoHostAvailable 错误,但这次 nodetool status 在两台机器上只显示一个节点。
    • 您遇到的错误是您的复制策略的原因。在 DC1 和 DC2 中,复制因子为 2,但每个 DC 中都有可用的单个节点。对于复制因子 2,您需要至少有 2 个节点。通常我们执行复制因子 2,而 DC 中有 3 个节点可用。但对于 2 节点 DC,复制工厂将起作用。
    猜你喜欢
    • 2017-02-15
    • 2013-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-31
    • 2022-01-25
    • 2017-02-20
    • 1970-01-01
    相关资源
    最近更新 更多