Windows 11 中的 WSL2 ubuntu 22.04 上 Cassandra 的所有连接均被拒绝

Windows 11 中的 WSL2 ubuntu 22.04 上 Cassandra 的所有连接均被拒绝

我在 Windows 11 上的 wsl2 ubuntu 22.04 上安装了 cassandra 4。以下是安装过程。

$ sudo apt update -y
$ sudo apt upgrade -y
$ sudo apt install apt-transport-https gnupg2 -y
$ echo "deb https://debian.cassandra.apache.org 41x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
$ curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
$ sudo apt-get update
$ sudo apt install cassandra -y
$ sudo systemctl status cassandra  --> service is active

但是这些cqlsh命令nodetool会引发连接被拒绝错误。

$ cqlsh

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



$ nodetool status

nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused'

所以我修改了/etc/cassandra/cassandra.yaml文件。

rpc_address: 0.0.0.0
listen_address: localhost
broadcast_address: 1.2.3.4

但连接仍然被拒绝。以下是错误日志。

[1709282364953] INFO  (ls): Connection instance created for Cassandra Connection.
    ns: "conn-manager"
[1709282364970] ERROR (ls): Connecting error: {"code":-1,"data":{"driver":"Cassandra","driverOptions":{}},"name":"NoHostAvailableError"}
    ns: "conn-manager"
[1709282364971] ERROR (ls): Open connection error
    ns: "conn-manager"
[1709282364971] ERROR (ext): ERROR: Error opening connection All host(s) tried for query failed. First host tried, 127.0.0.1:9042: Error: connect ECONNREFUSED 127.0.0.1:9042
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
  errno: -4078,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 9042
}. See innerErrors., {"code":-1,"data":{"driver":"Cassandra","driverOptions":{}}}
    ns: "error-handler"

如何cqlsh在 WSL2 ubuntu 上打开端口 9042 并执行命令?我已经使用 ufw 命令打开了这些端口。如能得到任何回复,我将不胜感激。

相关内容