代码
ap = PlainTextAuthProvider(username='cassandra',password='cassandra')
cass_contact_points=['localhost']
cluster = Cluster(['localhost'],auth_provider=ap)
session = cluster.connect('dbsi')
输出:
连接回溯(最近一次调用):文件"C:/Users/rvcsp/PycharmProjects/untitled25/hotel.py",行9,在会话= cluster.connect('dbsi')文件"C:\Users\rvcsp\AppData\Roaming\Python\Python36\site-packages\cassandra\cluster.py",行1270,在
self.control_connection.connect()文件self.control_connection.connect行2773,在connect self._set_new_connection(self._reconnect_internal())文件"C:\Users\rvcsp\AppData\Roaming\Python\Python36\site-packages\cassandra\cluster.py",行2816中,在_reconnect_internal raise NoHostAvailable("Unable to connect to any servers",errors) cassandra.cluster.NoHostAvailable:('Unable to connect to any servers',{'::1':ConnectionRefusedError(10061,“尝试连接到('::1',9042,0,0) )。最后一个错误:无法建立连接,因为目标计算机主动拒绝了它“),'127.0.0.1':ConnectionRefusedError(10061,”尝试连接到('127.0.0.1',9042)。最后一个错误:无法建立连接,因为目标计算机主动拒绝“)})
发布于 2018-07-09 02:52:42
检查一下:
localhost
和端口9042cqlsh -u cassandra -p cassandra localhost
连接的端口9042
https://stackoverflow.com/questions/51234115
复制相似问题