Cassandra-Cli拒绝连接

时间:2013-04-14 19:36:26

标签: java connection cassandra cassandra-0.7

我正在尝试连接到cassandra。我安装了最新的稳定版本apache-cassandra-1.2.4并将其解压缩到我的桌面上。当我运行cassandra时,它可以很好地监听thrift客户端并显示以下内容:

sudo cassandra -f

日志:

 INFO 15:30:34,646 Cassandra version: 1.0.12
 INFO 15:30:34,646 Thrift API version: 19.20.0
 INFO 15:30:34,646 Loading persisted ring state
 INFO 15:30:34,650 Starting up server gossip
 INFO 15:30:34,661 Enqueuing flush of Memtable-LocationInfo@1117603949(29/36 serialized/live bytes, 1 ops)
 INFO 15:30:34,661 Writing Memtable-LocationInfo@1117603949(29/36 serialized/live bytes, 1 ops)
 INFO 15:30:34,877 Completed flushing /var/lib/cassandra/data/system/LocationInfo-hd-54-Data.db (80 bytes)
 INFO 15:30:34,892 Starting Messaging Service on port 7000
 INFO 15:30:34,901 Using saved token 143186062733850112297005303551620336860
 INFO 15:30:34,903 Enqueuing flush of Memtable-LocationInfo@1282534304(53/66 serialized/live bytes, 2 ops)
 INFO 15:30:34,904 Writing Memtable-LocationInfo@1282534304(53/66 serialized/live bytes, 2 ops)
 INFO 15:30:35,102 Completed flushing /var/lib/cassandra/data/system/LocationInfo-hd-55-Data.db (163 bytes)
 INFO 15:30:35,106 Node localhost/127.0.0.1 state jump to normal
 INFO 15:30:35,107 Bootstrap/Replace/Move completed! Now serving reads.
 INFO 15:30:35,108 Will not load MX4J, mx4j-tools.jar is not in the classpath
 INFO 15:30:35,150 Binding thrift service to localhost/127.0.0.1:9160
 INFO 15:30:35,155 Using TFastFramedTransport with a max frame size of 15728640 bytes.
 INFO 15:30:35,160 Using synchronous/threadpool thrift server on localhost/127.0.0.1 : 9160
 INFO 15:30:35,168 Listening for thrift clients...

现在我运行:cassandra-cli -h localhost -p 9160,它会引发错误。我检查了端口是免费的,cassandra正在监听端口。 :

**

org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused
    at org.apache.thrift.transport.TSocket.open(TSocket.java:183)
    at org.apache.thrift.transport.TFramedTransport.open(TFramedTransport.java:81)
    at org.apache.cassandra.cli.CliMain.connect(CliMain.java:80)
    at org.apache.cassandra.cli.CliMain.main(CliMain.java:256)
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
    at java.net.Socket.connect(Socket.java:579)
    at org.apache.thrift.transport.TSocket.open(TSocket.java:178)
    ... 3 more
Exception connecting to localhost/9160. Reason: Connection refused.

**

3 个答案:

答案 0 :(得分:1)

我有同样的错误。现在,没关系。

主要问题是配置错误。

我的配置如下:

我的视觉机器ip是192.168.11.11。我的cassandra被安装到机器上。所以,我配置了thar

listen_address: 192.168.11.11
rpc_address: 0.0.0.0
broadcast_rpc_address: 192.168.11.11

没关系。

答案 1 :(得分:0)

cassandra-stress的文档似乎是粗略的。也许在适当的时候会纠正。截至目前,这个命令对我有用

./cassandra-stress write -node <IP_OF_NODE1>

一旦这个工作,我们可以尝试输入其他可选参数来调整我们的命令。

答案 2 :(得分:0)

选项1:

Run jps command under root user and kill CassandraDaemon if you will see it. After this you will start Cassandra again.

选项2:

Try to connect Cassandra with CQL 
  ./cqlsh 10.234.31.232 9042

最终检查:

An intermediate firewall is blocking the JVM from making the connection. 
An operating system firewall, or antivirus that is causing the problems as well.

我认为您安装在Windows中,看起来防火墙阻止了您的连接。