java Cassandra-cli 无法连接到远程 cassandra 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11659001/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cassandra-cli cant connect to remote cassandra server
提问by Chander Shivdasani
I have a cassandra server running on a server(serv1). cassandra-cli can connect to it when run on serv1. However, when i try to connect to it through some other server(serv2), i get the following exception:
我有一个 cassandra 服务器在服务器(serv1)上运行。cassandra-cli 在 serv1 上运行时可以连接到它。但是,当我尝试通过其他服务器(serv2)连接到它时,出现以下异常:
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.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at org.apache.thrift.transport.TSocket.open(TSocket.java:178)
... 3 more
Exception connecting to jckstore/9160. Reason: Connection refused.
I looked in cassandra.yaml and found that the property "listen_address" is configured to "localhost" and using 0.0.0.0 is severely discouraged. I tried to change localhost to serv2, ip address of serv1 but nothing worked. Even commenting out didnt help.
我查看了 cassandra.yaml,发现属性“listen_address”被配置为“localhost”,并且严重不鼓励使用 0.0.0.0。我试图将localhost更改为serv2,serv1的IP地址但没有任何效果。即使注释掉也无济于事。
Is there a way i can make my cassandra server listen on all the ip's without using 0.0.0.0
有没有办法让我的 cassandra 服务器在不使用 0.0.0.0 的情况下监听所有 ip
回答by Chander Shivdasani
I was able to solve the problem as following:
我能够解决问题如下:
- changing the rpc_address property in cassandra.yaml to 0.0.0.0 instead of localhost.
- set the broadcast_rpc_address property in cassandra.yaml to a value other than 0.0.0.0
- 将 cassandra.yaml 中的 rpc_address 属性更改为 0.0.0.0 而不是 localhost。
- 将 cassandra.yaml 中的 broadcast_rpc_address 属性设置为 0.0.0.0 以外的值
Then I can access.
然后我就可以访问了。
回答by Mohit
Cassandra cli uses thrift to connect to Cassandra. The rpc_address decides how the thrift clients can connect to Cassandra. Setting it to 0.0.0.0 will work, but setting it to the hostname of the server and then using the same hostname to connect will also work.
Cassandra cli 使用 thrift 连接到 Cassandra。rpc_address 决定了 thrift 客户端如何连接到 Cassandra。将其设置为 0.0.0.0 将有效,但将其设置为服务器的主机名,然后使用相同的主机名进行连接也将有效。
回答by Sthe
I also had the same problem, and I was constantly surprised because it was configured correctly. In the end, I found out it was permission issues:
我也遇到了同样的问题,我经常感到惊讶,因为它配置正确。最后,我发现这是权限问题:
chown -R cassandra: /var/lib/cassandra
chown -R cassandra: /var/log/cassandra
Hope it helps :-)
希望能帮助到你 :-)
回答by Syed Yusuf
I had the same problem. I fixed this by updating the snappy temp dir VM option to point to the right directory.
我有同样的问题。我通过更新 snappy temp dir VM 选项以指向正确的目录来解决此问题。
VM_OPTS="$JVM_OPTS -Dorg.xerial.snappy.tempdir=/home/users/local/user/cassandra_home/snap
Hope this helps!
希望这可以帮助!
回答by Aung Htet
I also had the same problem "Connection refused". Changing the rpc_address from "localhost" to the same hostname as listen_address worked for me.
我也有同样的问题“连接被拒绝”。将 rpc_address 从“localhost”更改为与 listen_address 对我来说有效的相同主机名。
回答by Terry
I also had the same problem "Connection refused". Changing start_rpc: to true fixed it for me.
我也有同样的问题“连接被拒绝”。将 start_rpc: 更改为 true 为我修复了它。