无法在流浪者身上获得Cassandra远程访问

时间:2015-08-09 17:44:51

标签: cassandra vagrant remote-access datastax

我正在使用vagrant / puppet来配置Apache Cassandra的VM。本地访问(通过cqlsh)有效,但不能远程访问。

这是我的Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  config.vm.box = 'ubuntu/trusty32'

  config.vm.define "dev" do |dev|
    dev.vm.hostname = "devbox"
    dev.vm.network :private_network, ip: "192.168.10.200"
  end

  config.vm.provision "puppet" do |puppet|
    puppet.module_path = "puppet/modules"
    puppet.manifests_path = "puppet/manifests"
    puppet.manifest_file = "default.pp"
  end

  config.vm.provider "virtualbox" do |v|
    v.memory = 4096
    v.cpus = 2
  end

  config.ssh.forward_agent = true

end

我可以告诉你我的木偶文件,但我认为分享它生成的cassandra.yaml会更容易/更清楚。

https://gist.github.com/theonlylawislove/de34477b2cb34f106fa4

在盒子上......

vagrant@devbox:~$ cqlsh
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
vagrant@devbox:~$ cqlsh 192.168.10.200
Connected to Test Cluster at 192.168.10.200:9042.
[cqlsh 5.0.1 | Cassandra 2.2.0 | CQL spec 3.3.0 | Native protocol v4]
Use HELP for help.
cqlsh>

从我的主机(Windows),我可以ping虚拟。

Pinging 192.168.10.200 with 32 bytes of data:
Reply from 192.168.10.200: bytes=32 time<1ms TTL=128
Reply from 192.168.10.200: bytes=32 time<1ms TTL=128
Reply from 192.168.10.200: bytes=32 time<1ms TTL=128
Reply from 192.168.10.200: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.10.200:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

但是当我尝试使用以下代码访问我的.NET项目(在主机上)中的这个Cassandra实例时...

var cluster = Cluster.Builder().AddContactPoint("192.168.10.200").Build();
var session = cluster.Connect("test");

..我得到了这个例外。

An exception of type 'Cassandra.NoHostAvailableException' occurred in Cassandra.dll but was not handled in user code

Additional information: None of the hosts tried for query are available (tried: 192.168.10.200:9042)

是什么给出了?

更新

我从头开始,创建一个空的流浪者vm(没有配置)并手动安装Cassandra。同样的事情正在发生。但是,当我使用桥接/ DHCP从“private_network”切换到“public_network”时,它可以工作。

我想说端口没有打开“private_network”,但是我已经安装了其他服务(RabbitMQ / Postgres),但他们没有解决问题。那么,为什么Cassandra不使用“private_network”?

1 个答案:

答案 0 :(得分:0)

确保您的Vagrantfile正在使用private_network,如:

config.vm.network "private_network", ip: "192.168.33.10"

请注意,当您使用vagrant ssh时,会在提示之前显示一些信息,其中包括:

IP address for eth1: 192.168.33.10

将您的/etc/cassandra/cassandra.yml文件(第~482 / 483行)编辑为:

# rpc_address: localhost
rpc_interface: eth1

即。注释掉rpc_address,然后指定由vagrant给出的rpc_interface,然后:

sudo service cassandra restart
相关问题