新安装了Apache版本3.7
安装是成功的,我可以访问cqlsh没有任何问题。
dpmuser@LOGDPM01 01 bin$ cqlsh连接到测试集群,地址为127.0.0.1:9042。cqlsh 5.0.1 x Cassandra 3.7 x CQL规范3.4.2本机协议v4
但是当我试图通过DataStax卡桑德拉客户端连接时,我点击的是NoHostAvailableException。
下面是我尝试过的示例代码
import com.datastax.driver.core.*;
public class DBHitTEst {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Session session = null;
Cluster cluster = Cluster.builder()
.addContactPoints("127.0.0.1").withPort(9042)
.build();
System.out.println("Connecting to cluster ...");
session = cluster.connect();
System.out.print("Connected !"+session);
}}下面显示的控制台中的异常。
SLF4J:未能加载类"org.slf4j.impl.StaticLoggerBinder“。SLF4J:默认为无操作(NOP)记录器实现SLF4J:有关更多详细信息,请参见http://www.slf4j.org/codes.html#StaticLoggerBinder。连接到集群..。2017年8月10日7:58:23 AM io.netty.channel.ChannelInitializer channelRegistered警告:初始化通道失败。结束: id: 0x7d2724c5 io.netty.util.AttributeKey.valueOf(Ljava/lang/String;)Lio/netty/util/AttributeKey;:com.datastax.driver.core.Message.(Message.java:39) at com.datastax.driver.core.Connection$Initializer.initChannel(Connection.java:1425)。。。线程"main“com.datastax.driver.core.exceptions.NoHostAvailableException:中的异常所有主机尝试查询失败(尝试: /127.0.0.1:9042 (com.datastax.driver.core.exceptions.TransportException: /127.0.0.1:9042无法连接)在com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:232) at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79)在com.datastax.driver.core.Cluster$Manager.negotiateProtocolVersionAndConnect(Cluster.java:1600) at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1518) at com.datastax.driver.core.Cluster.init(Cluster.java:159) at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:330) at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:305) at com.datastax.driver.core.Clustercom.cassandra.db.executables.DBHitTEst.main(DBHitTEst.java:14) .connect(Cluster.java:247)
库参考
cassandra-driver-core-3.3.0.jar
guava-23.0.jar
log4j-api-2.8.2.jar
metrics-core-3.0.2.jar
netty-all-4.0.9.Final.jar
slf4j-api-1.7.25.jar重要的秘密是cassandra.yaml
start_rpc: false
start_native_transport: true
native_transport_port: 9042
rpc_address: localhost
rpc_port: 9160
listen_address: localhost
seeds: "127.0.0.1"其他系统详情
[dpmuser@LOGDPM01 conf]$ hostname
LOGDPM01
[dpmuser@LOGDPM01 conf]$ more /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[dpmuser@LOGDPM01 conf]$ ping LOGDPM01
PING LOGDPM01 (10.0.2.15) 56(84) bytes of data.
64 bytes from LOGDPM01 (10.0.2.15): icmp_seq=1 ttl=64 time=0.055 ms运行centos VM.Kindly让我知道我哪里错了?
发布于 2017-08-11 12:25:36
库错配正在抛出我在控制台中观察到的警告。
警告:初始化通道失败。结束: id: 0x7d2724c5 io.netty.util.AttributeKey.valueOf(Ljava/lang/String;)Lio/netty/util/AttributeKey;:com.datastax.driver.core.Message.(Message.java:39) at com.datastax.driver.core.Connection$Initializer.initChannel(Connection.java:1425)。。。
在从Cassandra的lib文件夹中选择正确的库时,安装直接对问题进行排序。
https://stackoverflow.com/questions/45613590
复制相似问题