Cassandra - 无法通过cqlsh连接

问题描述 投票:0回答:1

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

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连接不起作用。我已尝试连接到localhost和节点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但是“Connectiong denied”,则打印“连接到...已关闭”的原因并不是那么明显。有谁知道这种问题的原因? 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}
bash cassandra cqlsh
1个回答
1
投票

发现了这个问题。你将rpc_port设置为9042.我认为你将rpc与native(cql)混淆了。 Rpc是在以后的版本中不推荐使用的旧接口。我建议将start_rpc设置为false并将rpc_port设置回其默认值:9160。

© www.soinside.com 2019 - 2024. All rights reserved.