繁体   English   中英

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

[英]How can we connect to remote Cassandra server with python driver

我正在尝试使用 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

端口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/ 干杯!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM