1

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]

The exception I obtain is below:

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"',)

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.

femibyte
  • 3,317
  • 7
  • 34
  • 59

2 Answers2

4

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.

The error message you are getting:

(u'code=2200 [Invalid query] message="unconfigured table 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.

mikea
  • 6,537
  • 19
  • 36
  • Thanks, that seems to be the case. I am using anaconda and this is the driver I have installed : cassandra-driver 2.7.1 nppy27_0 petercable I suppose I should upgrade. Do you know whether the 3.0.0 will be backward compatible and can connect to a Cassandra 2.x* instance? – femibyte Jan 07 '16 at 13:12
  • Yes, it will. Drivers are backward compatible but not necessarily forward compatible. You might want to set the protocol version in this case. – mikea Jan 07 '16 at 14:30
0

Use pip install --upgrade cassandra-driver to upgrade cassandra-driver.

You could type python -c 'import cassandra; print cassandra.__version__' to confirm the version of this driver.

niaomingjian
  • 3,472
  • 8
  • 43
  • 78