cassandra说正在监听端口9042,但无法连接

eagi6jfj  于 2021-06-14  发布在  Cassandra
关注(0)|答案(2)|浏览(602)

我在本地机器上运行Cassandra。
我已经开始了 sudo service cassandra start . 然后在下面检查日志 var/log/cassandra/system-log 上面写着:

INFO  [main] 2019-07-28 13:13:17,226 Server.java:162 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...
INFO  [main] 2019-07-28 13:13:17,270 CassandraDaemon.java:501 - Not starting RPC server as requested. Use JMX (StorageService->startRPCServer()) or nodetool (enablethrift) to start it
INFO  [SharedPool-Worker-1] 2019-07-28 13:13:27,133 ApproximateTime.java:44 - Scheduling approximate time-check task with a precision of 10 milliseconds
INFO  [OptionalTasks:1] 2019-07-28 13:13:27,298 CassandraRoleManager.java:339 - Created default superuser role 'cassandra'

然后我试着和 cqlsh 在终端上写着: Connection error: ('Unable to connect to any servers', {'127.0.0.1:9042': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")}) 怎么了?我也看不到9042端口 netstat -tulpn 命令。

cnjp1d6j

cnjp1d6j1#

cqlsh localhost 9042

如果不更改cassandra.yml文件,这将起作用。

aelbi1ox

aelbi1ox2#

转到/etc/cassandra/cassandra-env.sh
取消注解 # JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>" 把它改成

JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname==localhost"

将listen\u address和broadcast\u rpc\u address设置为本地ip(从ifconfig获取ip地址)。
重新启动Cassandra。

相关问题