我的 Linux 机器上有 Cassandra 3.x。我尝试使用https://github.com/tschellenbach/Stream-Framework连接到它
from stream_framework.feeds.cassandra import CassandraFeed
我可以从命令行连接到 Cassandracqlsh' and using
我可以从端口 9042 上的命令行 DBeaver GUI
当我尝试使用上述导入运行 Django 时,出现此错误:
cassandra.cluster.NoHostAvailable:
('Unable to connect to any servers',
{'::1': error(111, "Tried connecting to [('::1', 9042, 0, 0)].
Last error: Connection refused"),
'127.0.0.1': error(111,
"Tried connecting to [('127.0.0.1', 9042)].
Last error: Connection refused")})
编辑 3 当所有设置都为默认值时,我也得到
DriverException('ProtocolError returned from
server while using explicitly set client protocol_version 2',)})
我四处寻找解决方案并更改
/etc/cassandra/cassandra.yaml
为:
rpc_address: 0.0.0.0 #from localhost
rpc_port: 9042 #from 9160
listen_address: 127.0.0.1 #from localhost
但它没有帮助。
关于如何解决它的任何想法?
编辑
我把事情变成了默认设置和netstat -nat | grep 9042
tcp 0 0 127.0.0.1:56524 127.0.0.1:9042 ESTABLISHED
tcp 0 0 127.0.0.1:56528 127.0.0.1:9042 ESTABLISHED
tcp 0 0 127.0.0.1:56522 127.0.0.1:9042 ESTABLISHED
tcp 0 0 127.0.0.1:56558 127.0.0.1:9042 ESTABLISHED
tcp 0 0 127.0.0.1:56516 127.0.0.1:9042 ESTABLISHED
tcp 0 0 127.0.0.1:56514 127.0.0.1:9042 ESTABLISHED
tcp 0 0 127.0.0.1:56560 127.0.0.1:9042 ESTABLISHED
tcp 0 0 127.0.0.1:56530 127.0.0.1:9042 ESTABLISHED
tcp6 0 0 127.0.0.1:9042 :::* LISTEN
tcp6 0 0 127.0.0.1:9042 127.0.0.1:56516 ESTABLISHED
tcp6 0 0 127.0.0.1:9042 127.0.0.1:56514 ESTABLISHED
tcp6 0 0 127.0.0.1:9042 127.0.0.1:56528 ESTABLISHED
tcp6 0 0 127.0.0.1:9042 127.0.0.1:56558 ESTABLISHED
tcp6 0 0 127.0.0.1:9042 127.0.0.1:56524 ESTABLISHED
tcp6 0 0 127.0.0.1:9042 127.0.0.1:56560 ESTABLISHED
tcp6 0 0 127.0.0.1:9042 127.0.0.1:56522 ESTABLISHED
tcp6 0 0 127.0.0.1:9042 127.0.0.1:56530 ESTABLISHED
顺便说一句,nodetool status
退货
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 157.61 KB 256 100.0% 3b13b3f2-968d-4f53-8e9b-1aa4ae271c66 rack1
编辑 2
我不确定这是否是某种线索,但是当我使用 DBeaver 连接到 Cassandra 时,我只列出了一个主机:
0:0:0:0:0:0:0:1
是 IPv6 而不是 IPv4?