无法在vagrant上获取Cassandra远程访问 [英] Can't get Cassandra remote access on vagrant

查看:1009
本文介绍了无法在vagrant上获取Cassandra远程访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用vagrant / puppet来配置带有Apache Cassandra的虚拟机。本地访问(通过 cqlsh )可以正常工作,但不能远程访问。

I am using vagrant/puppet to configure a VM with Apache Cassandra. Local access (via cqlsh) works, but not remote access.

Vagrantfile

Here is my 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会更容易/

I could show you my puppet file, but I think it would be easier/clearer to share the cassandra.yaml it generated.

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虚拟。

From my host machine (Windows), I can ping the virtual.

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

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

But when I try to access this Cassandra instance in my .NET project (on host) using the following code...

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

..我得到这个异常。

..I get this exception.

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)

是什么?

UPDATE

我从头开始,创建一个空的vagrant vm(无配置)并手动安装Cassandra。同样的事情发生了。但是,当我从一个private_network切换到一个具有桥接/ DHCP的public_network时,它工作。

I started over from scratch, creating an empty vagrant vm (no provisioning) and manually installed Cassandra. The same thing is happening. However, when I switched from a "private_network" to a "public_network" with bridged/DHCP, it worked.

我想说的端口没有打开private_network,但我已经安装了其他服务(RabbitMQ / Postgres),他们工作出了一个问题。那么,为什么Cassandra不使用private_network?

I want to say that the ports aren't open with "private_network", but I have installed other services (RabbitMQ/Postgres) and they work with out an issue. So, why is Cassandra not working with the "private_network"?

推荐答案

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

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

请注意, code> vagrant ssh 您在提示之前会看到一些信息,包括:

Notice that when you use vagrant ssh you are shown some info prior the prompt which includes:

IP address for eth1: 192.168.33.10

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

Edit your /etc/cassandra/cassandra.yml file (lines ~482/483) to be:

# rpc_address: localhost
rpc_interface: eth1

ie注释掉 rpc_address ,而是指定由vagrant指定的 rpc_interface ,则:

i.e. comment out the rpc_address and instead specify the rpc_interface as given by vagrant, then:

sudo service cassandra restart

这篇关于无法在vagrant上获取Cassandra远程访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆