Cassandra - 无法通过 cqlsh 连接

Cassandra - unable to connect via cqlsh

我在通过 clqsh 连接到 cassandra 时遇到问题。我在 CentOS7 上部署了一个由 3 个节点组成的集群。我可以看到节点正在相互连接。节点工具状态输出如下:

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)        Host ID     Rack
UN  ${SEED2} 226.47 KiB     1            60,3%                 <hash>     rack1
UN  ${SEED}  190.77 KiB     1            50,9%                 <hash>     rack1
UN  ${IP}    157.62 KiB     1            88,7%                 <hash>    rack1

但是通过 cqlsh 连接不起作用。我已经尝试连接到本地主机和节点 IP。这是 cqlsh 命令的输出:

[root@node02 default.conf]# 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")})
[root@node02 default.conf]# cqlsh ${IP}
connection error: ('Unable to connect to any servers', {'${IP}': 
ConnectionShutdown('Connection to ${IP} was closed',)})

为什么在连接到 rpc_address 时打印 'Connection to ... was closed' 而在连接到本地主机时打印 'Connectiong refused' 对我来说不是很明显。 有谁知道这种问题的原因? cassandra.yaml 文件如下:

# Cassandra storage config YAML

cluster_name: '${NAME}'
hinted_handoff_enabled: true
authenticator: org.apache.cassandra.auth.AllowAllAuthenticator
data_file_directories:
    - /var/lib/cassandra/data
commitlog_directory: /var/lib/cassandra/commitlog
hints_directory: /var/lib/cassandra/hints

key_cache_size_in_mb: 2    
key_cache_save_period: 14400    
row_cache_size_in_mb: 0    
row_cache_save_period: 0

saved_caches_directory: /var/lib/cassandra/saved_caches    
commitlog_sync: periodic
commitlog_sync_period_in_ms: 10000

concurrent_reads: 32
concurrent_writes: 32

storage_port: 7000
ssl_storage_port: 7001

rpc_port: 9042
start_rpc: true
rpc_keepalive: true    
rpc_server_type: sync

request_scheduler: org.apache.cassandra.scheduler.NoScheduler
index_interval: 128

listen_address: ${IP}
rpc_address: ${IP}
seed_provider:
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          - seeds: ${IP},${SEED}

发现问题。您将 rpc_port 设置为 9042。我认为您将 rpc 与本机 (cql) 混淆了。 Rpc 是在更高版本中弃用的旧接口。我建议将 start_rpc 设置为 false 并将 rpc_port 设置回默认值:9160.