当cassandra似乎正在运行并正在监听但cqlsh无法连接时,我该怎么办?

时间:2019-02-11 19:18:15

标签: cassandra nixos

我是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")})

2 个答案:

答案 0 :(得分:1)

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

cqlsh 127.0.0.1 9042

如果仍然出现此错误,请按照链接thisthis检查您的Cassandra配置

答案 1 :(得分:0)

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

extraConfig = {
  start_native_transport = true;
};