【发布时间】:2014-09-23 06:26:18
【问题描述】:
我正在尝试从 python 连接到 cassandra,我已将 cassandra 安装为 pip install pycassa。当我尝试连接到 cassandra 时,我收到以下异常
from pycassa.pool import ConnectionPool
pool = ConnectionPool('Keyspace1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/pycassa/pool.py", line 382, in __init__
self.fill()
File "/usr/lib/python2.7/site-packages/pycassa/pool.py", line 442, in fill
conn = self._create_connection()
File "/usr/lib/python2.7/site-packages/pycassa/pool.py", line 431, in _create_connection
(exc.__class__.__name__, exc))
pycassa.pool.AllServersUnavailable: An attempt was made to connect to each of the servers twice, but none of the attempts succeeded. The last failure was TTransportException: Could not connect to localhost:9160
我正在使用 python 2.7。 有什么问题,不胜感激。
【问题讨论】:
-
您的 cassandra.yaml 中的
listen_address设置为什么? -
@BryceAtNetwork23,监听地址默认为
localhost:9160 -
您不应将端口指定为
listen_address的一部分。 -
对于仍在寻找示例代码的任何人,我在这里发布了一个:github.com/hardikvasa/database-journal