2014-03-03 56 views
0

設置密鑰空間時,我在使用datastax的Cassandra的python驅動程序時出現錯誤。這裏是我的代碼到錯誤: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: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 

任何見解將不勝感激:)

+2

你真的有兩個節點的那'''weathertest'''? –

+0

我也會確保你在密鑰空間名稱上匹配任何大小寫。 –

回答

0

使用cqlsh檢查並確認您的密鑰空間。

密鑰空間在你的腳本和一個你正在試圖連接不同:

cqlsh> DESCRIBE keyspaces; 
相關問題