首页 文章

如何为远程连接配置cassandra

提问于
浏览
10

我正在尝试配置Cassandra Datastax Community Edition在Windows上进行远程连接,

Cassandra Server安装在Windows 7 PC上, With the local CQLSH it connects perfectly to the local server.

但当我尝试连接 with CQLSH from another PC in the same Network, i get this error message:

连接错误:('无法连接到任何服务器',{'MYHOST':错误(10061,“尝试连接到[('HOST_IP',9042)] . 上一个错误:无法 Build 连接,因为目标计算机主动拒绝了它“)})

所以我想知道如何正确配置(我应该在cassandra.yaml配置文件上做什么更改)Cassandra服务器允许远程连接 .

先感谢您!

3 回答

  • 8

    远程访问Cassandra是通过其Cassandra 2.0的旧货端口 . 在Cassandra 2.0.x中,默认的cqlsh监听端口是9160,由rpc_port参数在cassandra.yaml中定义 . 默认情况下,Cassandra 2.0.x及更早版本通过在cassandra.yaml文件中将start_rpc配置为true来启用Thrift .

    在Cassandra 2.1中,cqlsh实用程序使用本机协议 . 在使用Datastax python驱动程序的Cassandra 2.1中,默认的cqlsh监听端口是9042 .

    cassandra节点应绑定到服务器网卡的IP地址 - 它不应该是127.0.0.1或localhost,这是环回接口的IP,绑定到此将阻止直接远程访问 . 要配置绑定地址,请使用cassandra.yaml中的rpc_address参数 . 将其设置为0.0.0.0将侦听所有网络接口 .

    您是否检查过远程计算机是否可以连接到Cassandra节点?机器之间是否有防火墙?您可以尝试以下步骤来测试它:

    1) Ensure you can connect to that IP from the server you are on:

    $ ssh user@xxx.xxx.xx.xx

    2) Check the node's status and also confirm it shows the same IP:

    $ nodetool状态

    3) Run the command to connect with the IP (only specify the port if you are not using the default):

    $ cqlsh xxx.xxx.xx.xx

  • 8

    Kat的替代解决方案 . 使用Ubuntu 16.04

    • ssh到服务器 server_user@**.**.**.**

    • 如果正在运行则停止cassandra:

    • 检查是否正在运行 ps aux | grep cassandra

    • 如果正在运行,将输出一大块命令/标志,例如

    ubuntu 14018 4.6 70.1 2335692 712080 pts / 2 Sl 04:15 0:11 java -Xloggc:./../ logs / gc.log ........

    示例中的注释14018是进程ID

    • 使用 kill <process_id> 停止(在本例中为14018)

    • 编辑cassandra.yaml文件如下

    • rpc_address: 0.0.0.0

    • broadcast_rpc_address: **.**.**.** < - 您服务器的IP(不能设置为0.0.0.0)

    • 重启cassandra ./bin/cassandra -f (来自cassandra root)

    • 在本地计算机上打开另一个终端并通过 cqlsh **.**.**.** (您的服务器的IP)进行连接以进行测试 .

    ./bin/nodetool status 地址报告了我的本地主机IP(127.0.0.1),但cqlsh远程仍然可以工作 .

  • 16

    这个怎么样:

    在cassandra.yaml配置文件中进行以下更改:

    start_rpc: true
    
    rpc_address: 0.0.0.0
    
    broadcast_rpc_address: [node-ip]
    
    listen_address: [node-ip]
    
    seed_provider:
      - class_name: ...
        - seeds: "[node-ip]"
    

    参考:https://gist.github.com/andykuszyk/7644f334586e8ce29eaf8b93ec6418c4

相关问题