如何使用python驱动程序连接到远程cassandra服务器

7bsow1i6  于 2021-06-13  发布在  Cassandra
关注(0)|答案(1)|浏览(325)

我正在尝试使用python驱动程序连接到cassandra:

from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider

auth_provider = PlainTextAuthProvider(username='yyyy',password='zzzzz')
cluster = Cluster(['xx.xx.xx.xx'], control_connection_timeout=10,  port=9042,auth_provider=auth_provider)
session = cluster.connect()

错误:

NoHostAvailable: ('Unable to connect to any servers', {'xx.xx.xx.xx:9042': ConnectionRefusedError(111, "Tried connecting to [('xx.xx.xx.xx ', 9042)]. Last error: Connection refused")})

我还在yaml文件中设置了rpc地址:0.0.0.0

anhgbhbe

anhgbhbe1#

很可能是左舷 9042 绑定到节点的专用ip,因为您设置了:

rpc_address: 0.0.0.0

你需要设置 rpc_address 到节点的公共ip或可由应用程序服务器远程访问的ip。通常,您应该:

listen_address: private_ip
rpc_address: public_ip

如果有帮助的话,我在这篇文章中提供了一些额外的细节--https://community.datastax.com/questions/6019/. 干杯!

相关问题