当 cassandra 出现 运行 并且正在监听但 cqlsh 无法连接时,我应该尝试什么?

What should I try when cassandra appears to be running and listening but cqlsh can't connect?

我是 Cassandra 的新手,正在试用。尽管 Cassandra 显然 运行 并且正在聆听(根据 lsof),但我无法连接到它。 sudo systemctl status cassandr 还报告 active (running)

$ sudo lsof -Pnl +M -i4 
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
(omitting unrelated services - nothing here about cassandra)

$ sudo lsof -Pnl +M -i6
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd      752        0    4u  IPv6  16234      0t0  TCP *:22 (LISTEN)
java    23659      300   68u  IPv6 158110      0t0  TCP 127.0.0.1:7199 (LISTEN)
java    23659      300   69u  IPv6 158122      0t0  TCP 127.0.0.1:36921 (LISTEN)
java    23659      300   84u  IPv6 158212      0t0  TCP 127.0.0.1:9160 (LISTEN)
java    23659      300  151u  IPv6 158205      0t0  TCP 127.0.0.1:7000 (LISTEN)



$ sudo nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Owns (effective)  Host ID                               Token                                    Rack
UN  127.0.0.1  125.98 KiB  100.0%            e0bbc831-8686-43a6-b99c-8ea5596c8581  3840369556391221198                      rack1

对于可能正在阅读本文的 Nix 用户(对于非 Nix 用户也很容易理解),我的配置是:

  services.cassandra = {
    enable = true;
    listenAddress = "127.0.0.1";
    rpcAddress = "127.0.0.1";
  };

我得到的错误是:

$ cqlsh 127.0.0.1 9160
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9160)]. Last error: Connection refused")})

在通过 cqlsh 连接时尝试使用 native_transport_port 9042 而不是 rpc_port 9160。

cqlsh 127.0.0.1 9042

如果您仍然遇到此错误,请按照 link this and this

检查您的 Cassandra 配置

我应该检查一下 nixpks 问题跟踪器,因为我发现了 answer there;我需要:

extraConfig = {
  start_native_transport = true;
};