Cassandra - 无法通过cqlsh

时间:2018-03-05 09:59:32

标签: bash cassandra cqlsh

我在通过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',)})

对我来说并不是那么明显为什么&#39;与......的联系已经关闭&#39;如果连接到rpc_address但是&#39; Connectiong被拒绝&#39;连接到localhost时。 有谁知道这种问题的原因? 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}

1 个答案:

答案 0 :(得分:1)

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