无法连接到任何服务器

时间:2018-04-27 13:26:16

标签: cassandra debian cqlsh

我失去了与Cassandra服务器的连接,我无法恢复它。

当我运行时:sudo service cassandra status我可以看到服务正在运行:

● cassandra.service - LSB: distributed storage system for structured data
   Loaded: loaded (/etc/init.d/cassandra; generated; vendor preset: enabled)
   Active: active (exited) since Fri 2018-04-27 13:06:21 UTC; 4min 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 18479 ExecStop=/etc/init.d/cassandra stop (code=exited, status=0/SUCCESS)
  Process: 18539 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/cassandra.service

Apr 27 13:06:21 serveur-1 systemd[1]: Starting LSB: distributed storage system for structured data...
Apr 27 13:06:21 serveur-1 systemd[1]: Started LSB: distributed storage system for structured data.

但是当我运行> cqlsh时,我得到了以下内容:

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

3 个答案:

答案 0 :(得分:1)

检查Cassandra是否真的通过环回接口接受连接。

查看cassandra.yamllisten_addresslisten_interface属性

下的# cat /etc/cassandra/cassandra.yaml | grep listen ... listen_address: 172.17.0.2 ... 内容
cqlsh

如果您看到非本地地址,则# cqlsh 172.17.0.2 可能需要通过另一个接口连接到您的Cassandra实例。尝试此命令(通过在配置中使用相同的IP替换IP:

# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:7199          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:9042            0.0.0.0:*               LISTEN
tcp        0      0 localhost:38899         0.0.0.0:*               LISTEN
tcp        0      0 20f1802:afs3-fileserver 0.0.0.0:*               LISTEN
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path

您可以使用以下命令检查允许哪些主机访问您的Cassandra服务

0.0.0.0

<td class='tabledit-view-mode' style='cursor: pointer; background-color: #DEE1E8;'> <span class='tabledit-span' style='display: inline;'>YOUR CELL DATA</span> <input name='VAR_NAME' disabled='' class='tabledit-input form-control input-sm' style='display: none;' type='text' value='YOUR CELL DATA'></td> 表示我的Cassandra实例允许从环回和以太网接口连接。

答案 1 :(得分:1)

删除目录/var/lib/cassandra/commitlog的内容并重新启动cassandra解决了我的问题!

答案 2 :(得分:0)

从commitlog删除所有内容,它将起作用。