【问题标题】:How to fix Apache Cassandra connection issues?如何修复 Apache Cassandra 连接问题?
【发布时间】:2020-01-10 01:25:32
【问题描述】:

我尝试使用 cqlsh

访问 Apache Cassandra

但它返回错误

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

【问题讨论】:

  • 您是否对 Cassandra 配置文件进行了任何更改?您是否使用身份验证进行连接?

标签: database cassandra cqlsh


【解决方案1】:

有多种选择:

a) 使用在您的 cassandra.yaml 文件中定义的 IP 地址在密钥 listen_address

# cat cassandra.yaml | grep listen_address:
listen_address: 172.1.2.3
# cqlsh 172.1.2.3
Connected to keyspace1 at 172.1.2.3:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.

b) 如果您使用的是 linux,则命令 hostname 会对此有所帮助:

# cqlsh $(hostname)
Connected to keyspace1 at test-c-ca5d61df000b73cb4:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.

c) 使用nodetool status从集群中获取任何 IP 地址

# nodetool status
Datacenter: us-east-vpc
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address        Load       Tokens       Owns (effective)  Host ID                               
Rack
UN  172.1.2.3  4.7 GiB    256          33.1%             655da17a-xxxx-xxxx-xxxx-xxxxxxxxxxxx  1d
UN  172.1.4.5  4.94 GiB   256          33.5%             23f18c46-xxxx-xxxx-xxxx-xxxxxxxxxxxx  1c
UN  172.1.6.8  4.74 GiB   256          33.4%             f8ad0b6a-xxxx-xxxx-xxxx-xxxxxxxxxxxx  1a
# cqlsh 172.1.6.8
Connected to keyspace1 at 172.1.6.8:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.

【讨论】:

    【解决方案2】:

    如果更改了默认端口,则需要检查 cassandra.yaml 中配置的 rpc_address 和 listen_address,然后使用端口运行 cqlsh 命令。您将能够连接 cassandra 服务器。

    【讨论】:

      猜你喜欢
      • 2016-02-22
      • 2022-06-11
      • 2017-10-19
      • 2018-11-28
      • 2018-11-14
      • 2020-06-02
      • 1970-01-01
      • 2013-05-12
      相关资源
      最近更新 更多