python cassandra驱动程序设置键空间错误

时间:2014-03-03 20:30:23

标签: python cassandra datastax-enterprise

在设置密钥空间时,使用python驱动程序为数据存储区的Cassandra收到错误。这是我的代码,直到错误:

from cassandra.cluster import Cluster
from cassandra.query import SimpleStatement
cluster = Cluster(['some.IP.addr'])
session = cluster.connect()
session.set_keyspace('demodb')

这是我的错误:

Traceback (most recent call last):
  File "./forecasts.py", line 115, in <module>
    main()
  File "./forecasts.py", line 51, in main
    session.set_keyspace(KEYSPACE)
  File "build/bdist.linux-x86_64/egg/cassandra/cluster.py", line 1255, in set_keyspace
  File "build/bdist.linux-x86_64/egg/cassandra/cluster.py", line 995, in execute
  File "build/bdist.linux-x86_64/egg/cassandra/cluster.py", line 2195, in result
cassandra.connection.ConnectionException: Failed to set keyspace on all hosts:
[InvalidRequest(u'code=2200 [Invalid query] message="Keyspace \'weathertest\' does not exist"',), InvalidRequest(u'code=2200 [Invalid query] message="Keyspace \'weathertest\' doe
s not exist"',)]

这是DEBUG级别的日志:

DEBUG:root:
debugging is turned on
INFO:root:info is turned on

DEBUG:cassandra.pool:Host 10.10.0.51 is now marked up
DEBUG:cassandra.cluster:[control connection] Opening new connection to 10.10.0.51
DEBUG:cassandra.connection:Not sending options message for new connection(29704848) to 10.10.0.51 because compression is disabled and a cql version was not specified
DEBUG:cassandra.io.libevreactor:Starting libev event loop
DEBUG:cassandra.connection:Got ReadyMessage on new connection (29704848) from 10.10.0.51
DEBUG:cassandra.cluster:[control connection] Established new connection <LibevConnection(29704848) 10.10.0.51:9042>, registering watchers and refreshing schema and topology
DEBUG:cassandra.cluster:[control connection] Refreshing node list and token map
DEBUG:cassandra.cluster:[control connection] Found new host to connect to: 10.10.0.50
INFO:cassandra.cluster:New Cassandra host 10.10.0.50 added
DEBUG:cassandra.cluster:Adding or renewing pools for new host 10.10.0.50 and notifying listeners
DEBUG:cassandra.cluster:Done preparing queries for new host 10.10.0.50
DEBUG:cassandra.pool:Host 10.10.0.50 is now marked up
DEBUG:cassandra.cluster:[control connection] Fetched ring info, rebuilding metadata
DEBUG:cassandra.cluster:[control connection] Waiting for schema agreement
DEBUG:cassandra.cluster:[control connection] Schemas match
DEBUG:cassandra.cluster:[control connection] Fetched schema, rebuilding metadata
DEBUG:cassandra.cluster:Control connection created
DEBUG:cassandra.pool:Initializing new connection pool for host 10.10.0.51
DEBUG:cassandra.pool:Initializing new connection pool for host 10.10.0.50
DEBUG:cassandra.connection:Not sending options message for new connection(139755014785552) to 10.10.0.51 because compression is disabled and a cql version was not specified
DEBUG:cassandra.connection:Not sending options message for new connection(29756880) to 10.10.0.50 because compression is disabled and a cql version was not specified
DEBUG:cassandra.connection:Got ReadyMessage on new connection (139755014785552) from 10.10.0.51
DEBUG:cassandra.connection:Got ReadyMessage on new connection (29756880) from 10.10.0.50
DEBUG:cassandra.connection:Not sending options message for new connection(29754064) to 10.10.0.51 because compression is disabled and a cql version was not specified
DEBUG:cassandra.connection:Got ReadyMessage on new connection (29754064) from 10.10.0.51
DEBUG:cassandra.connection:Not sending options message for new connection(29754640) to 10.10.0.50 because compression is disabled and a cql version was not specified
DEBUG:cassandra.pool:Finished initializing new connection pool for host 10.10.0.51
DEBUG:cassandra.cluster:Added pool for host 10.10.0.51 to session
DEBUG:cassandra.connection:Got ReadyMessage on new connection (29754640) from 10.10.0.50
DEBUG:cassandra.pool:Finished initializing new connection pool for host 10.10.0.50
DEBUG:cassandra.cluster:Added pool for host 10.10.0.50 to session
INFO:root:setting keyspace...
DEBUG:cassandra.io.libevreactor:Closing connection (139755014785552) to 10.10.0.51
DEBUG:cassandra.io.libevreactor:Closing connection (29754064) to 10.10.0.51
DEBUG:cassandra.io.libevreactor:Closing connection (29756880) to 10.10.0.50
DEBUG:cassandra.io.libevreactor:Closing connection (29754640) to 10.10.0.50
DEBUG:cassandra.cluster:Shutting down Cluster Scheduler
DEBUG:cassandra.io.libevreactor:Closing connection (29704848) to 10.10.0.51
DEBUG:cassandra.cluster:Not executing scheduled task due to Scheduler shutdown

任何见解都将非常感谢:)

1 个答案:

答案 0 :(得分:0)

使用cqlsh检查并确认您的密钥空间。

脚本中的键空间和您尝试连接的键空间不同:

cqlsh> DESCRIBE keyspaces;