Cassandra表示正在监听9042端口,但无法连接

时间:2019-07-28 13:58:33

标签: cassandra cqlsh

我已经在本地计算机上运行了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")})

怎么了?另外,用netstat -tulpn命令也看不到9042端口。

2 个答案:

答案 0 :(得分:0)

我假设您已在cassandra.yaml的listen_address中指定了一些IP。试试这个

cqlsh {listen_address}

答案 1 :(得分:0)

cqlsh localhost 9042 

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