报错行:
Cluster cluster = Cluster.builder().addContactPoint(node).build();
错误信息:
Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1 ([/127.0.0.1] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:186)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:81)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:794)
at com.datastax.driver.core.Cluster$Manager.access$100(Cluster.java:721)
at com.datastax.driver.core.Cluster.<init>(Cluster.java:82)
at com.datastax.driver.core.Cluster.<init>(Cluster.java:67)
at com.datastax.driver.core.Cluster$Builder.build(Cluster.java:690)
at SimpleClient.connect(SimpleClient.java:9)
at SimpleClient.main(SimpleClient.java:23)
诊断步骤:
- telnent 127.0.0.1 9160,thrift服务端口OK
- 顺着源码走,查询无法连接127.0.0.1 9042端口
- telnent 127.0.0.1 9042,不通
- 打开cassandra.yaml,修改start_native_transport值,从false-> true
- 重启cassandra服务
- 问题解决
--end