问题描述
我尝试从Python连接到我的本地Cassandra实例时获取了一个异常。我可以连接到Cassandra没有使用cqlsh的问题。我运行的版本是ubuntu上的Cassandra 3.01:
I am obtaining an exception when trying to connect to my local instance of Cassandra from Python. I can connect to Cassandra with no problems using cqlsh. The version I am running is Cassandra 3.01 on ubuntu:
cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.1 | CQL spec 3.3.1 | Native protocol v4]
我获得的异常如下:
ERROR:cassandra.cluster:Control connection failed to connect, shutting down Cluster:
Traceback (most recent call last):
File "cassandra/cluster.py", line 840, in cassandra.cluster.Cluster.connect (cassandra/cluster.c:11146)
File "cassandra/cluster.py", line 2088, in cassandra.cluster.ControlConnection.connect (cassandra/cluster.c:36955)
File "cassandra/cluster.py", line 2123, in cassandra.cluster.ControlConnection._reconnect_internal (cassandra/cluster.c:37811)
NoHostAvailable: ('Unable to connect to any servers', {'127.0.0.1': InvalidRequest(u'code=2200 [Invalid query] message="unconfigured table schema_keyspaces"',), 'localhost': InvalidRequest(u'code=2200 [Invalid query] message="unconfigured table schema_keyspaces"',)
我检查了我的cassandra.yaml文件看起来不错:
I have checked my cassandra.yaml file and it looks ok:
egrep 'rpc_port:|native_transport_port:' /etc/cassandra/cassandra.yaml
native_transport_port: 9042
rpc_port: 9160
还有什么我可以看看吗?建议是最受欢迎的。
Anything else I can look at ? Suggestions are most welcome.
推荐答案
看起来您正尝试使用旧版本的cqlsh连接到3.0.1服务器
It looks like you are attempting to connect to a 3.0.1 server using an older install of cqlsh or you are (somehow) using an older python driver.
您得到的错误讯息:
(u'code=2200 [Invalid query] message="unconfigured table schema_keyspaces"',)
表示客户端驱动程序正在尝试从早于3.0的 schema_keyspaces
表获取表元数据。此信息现在保存在 system_schema.keyspaces
表中。
indicates that the client driver is attempting to get table metadata from the schema_keyspaces
table which pre-dates 3.0. This information is now held in the system_schema.keyspaces
table.
这篇关于NoHostAvailable异常连接到Cassandra从python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!