ping cassandra on virtualbox guest from windows host

£可爱£侵袭症+ 提交于 2020-01-25 22:18:45

问题


I'm using virtual box to act as Linux guest to Cassandra DB, and I'm trying to access it through my windows host, however, i don't know what are the right configurations to do that.

on virtual box I'm using "host only networking" to communicate from windows.

Anyone knows how to do these configurations?


回答1:


Maybe, it's the network configuration of the guest. In VirtualBox environment, if you want communicate to the guest from the host, the network type of the VM must be "bridged networking" or "host only networking".

You can find more information here : https://www.virtualbox.org/manual/ch06.html.




回答2:


So you are trying to connect to Cassandra from Linux guest in your virtualbox? Or is it the other way around?

Anyways, whatever the direction make sure that you IP is reachable and that the Cassandra ports are open (start with 9042).




回答3:


Access Cassandra on Guest VM from Host OS

For future reference to myself and others, this worked for me for Cassandra v3.10:

http://grokbase.com/t/cassandra/user/14cpyy7bt8/connect-to-c-instance-inside-virtualbox

Once your Guest VM is provisioned with Cassandra, I had a host only network adapter set with IP 192.168.5.10.

Then had to modify /etc/cassandra/cassandra.yaml to set:

From

rpc_address: localhost

To

rpc_address: 192.168.5.10

Then run sudo service cassandra restart and give it 15 seconds...

Then on the guest VM or on the host the following worked:

cqlsh 192.168.5.10

Hope that helps someone.

Vagrantfile for reference

Note it doesn't work for multiple nodes in a cluster yet

# Adjustable settings
## Cassandra cluster settings
mem_mb = "3000"
cpu_count = "2"
server_count = 1
network = '192.168.5.'
first_ip = 10

servers = []
seeds = []
cassandra_tokens = []
(0..server_count-1).each do |i|
  name = 'cassandra-node' + (i + 1).to_s
  ip = network + (first_ip + i).to_s
  seeds << ip
  servers << {'name' => name,
              'ip' => ip,
              'provision_script' => "sleep 15; sudo sed -i -e 's/^rpc_address: localhost/rpc_address: #{ip}/g' /etc/cassandra/cassandra.yaml; sudo service cassandra restart;",
              'initial_token' => 2**127 / server_count * i}
end

# Configure VM server
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "ubuntu/xenial64"
  servers.each do |server|

    config.vm.define server['name'] do |x|
      x.vm.provider :virtualbox do |v|
        v.name = server['name']
        v.customize ["modifyvm", :id, "--memory", mem_mb]
        v.customize ["modifyvm", :id, "--cpus"  , cpu_count  ]
      end
      x.vm.network :private_network, ip: server['ip']
      x.vm.hostname = server['name']
      x.vm.provision "shell", path: "provision.sh"
      x.vm.provision "shell", inline: server['provision_script']

    end
  end
end

provision.sh

# install Java and a few base packages
add-apt-repository ppa:openjdk-r/ppa
apt-get update
apt-get install vim curl zip unzip git python-pip -y -q

# Java install - adjust if needed
# apt-get install openjdk-7-jdk -y -q
apt-get install openjdk-8-jdk -y -q

# Install Cassandra 
echo "deb http://www.apache.org/dist/cassandra/debian 310x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
sudo apt-get update
sudo apt-get install cassandra -y
sudo service cassandra start


来源:https://stackoverflow.com/questions/41144884/ping-cassandra-on-virtualbox-guest-from-windows-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!