Can't connect to cassandra node from different host

后端 未结 8 1329
無奈伤痛
無奈伤痛 2020-12-05 11:35

I have a cassandra node at a machine. When I access cqlsh from the same machne it works properly.

But when I tried to connect to it\'s cqlsh using \"192.x.x.x\" from

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 11:57

    I had the same issue, I was not allowed to listen to 0.0.0.0 and Cassandra was running on a VM with Bridged network. The solution I found was to let the VM SSH to itself, port forwarding the port on the bridged network interface to localhost:

    ssh -L 192.168.x.x:9042:127.0.0.1:9042 myvmuser@localhost
    

    Since the IP of the bridged network card would change (depending on which developers machine it was run) the ssh-command had to first get the IP, this snipped worked for that:

    ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
    

    Also, as this should happen on boot you have to create a SSH key for the vm-user and trust it via .ssh/authorized_keys.

提交回复
热议问题