【问题标题】:Astyanax Cassandra driver removes host unexpectedly during batch insertingAstyanax Cassandra 驱动程序在批量插入期间意外删除主机
【发布时间】:2013-08-18 00:23:35
【问题描述】:

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() 的后续尝试连接失败

【问题讨论】:

    标签: cassandra astyanax


    【解决方案1】:

    我也遇到了同样的问题,我的 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

    【讨论】:

      【解决方案2】:

      我在 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();
      

      【讨论】:

        猜你喜欢
        • 2015-05-18
        • 2016-01-22
        • 2018-08-03
        • 2016-10-06
        • 2020-04-26
        • 2011-10-20
        • 2013-04-12
        • 2015-01-04
        • 2020-12-21
        相关资源
        最近更新 更多