我有Cassandra 3。在我的Linux机器上。我试着用https://github.com/tschellenbach/Stream-Framework
连接到它from stream_framework.feeds.cassandra import CassandraFeed
我可以从命令行cqlsh' and using
DBeaver GUI '在端口9042连接到Cassandra。
当我尝试使用以上导入运行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
Btw, 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我只得到一个主机列出:
0:0:0:0:0:0:0:1
是IPv6而不是IPv4?
我发现问题了。Stream-Framework for Cassandra Protocol默认设置为2
https://github.com/tschellenbach/Stream-Framework/blob/master/stream_framework/default_settings.py L23
更改为4
后,测试和应用程序连接到Cassandra实例。
编辑
更改在主项目的settings.py
。这样的:
CASSANDRA_DRIVER_KWARGS = {
'protocol_version': 4
}