我正在使用vagrant设置3节点集群。我有机器启动并运行但是当我尝试从一个节点到另一个节点进行通信时,我拒绝连接。
我的流浪文件是:
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
v.memory = 2048
v.cpus = 2
end
N = 3
(1..N).each do |machine_id|
config.vm.define "node-#{machine_id}" do |machine|
machine.vm.hostname = "node-#{machine_id}"
machine.vm.network "private_network", ip: "192.168.77.#{20+machine_id}"
# Only execute once the Ansible provisioner,
# when all the machines are up and ready.
if machine_id == N
machine.vm.provision :ansible do |ansible|
# Disable default limit to connect to all the machines
ansible.limit = "all"
ansible.playbook = "playbook.yml"
end
end
end
end
config.vm.define "node-1" do |first|
first.vm.network "forwarded_port", guest: 9200, host: 19201
first.vm.network "forwarded_port", guest: 9300, host: 19301
end
end
节点之间的ping工作正常,但是当我尝试访问另一个节点的应用程序时,它没有响应。如果我尝试通过私有IP(192.168.77.21-23)调用当前节点上的应用程序
编辑:
问题似乎与绑定有关。在盒子里面,我明白了:
vagrant@node-3 ~]$ netstat -nltp
(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp6 0 0 :::111 :::* LISTEN -
tcp6 0 0 127.0.0.1:9200 :::* LISTEN -
tcp6 0 0 ::1:9200 :::* LISTEN -
tcp6 0 0 127.0.0.1:9300 :::* LISTEN -
tcp6 0 0 ::1:9300 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN -
在盒子外面,我有这个:
netstat -nltp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:2222 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:2200 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:2201 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:19201 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:19301 0.0.0.0:* LISTEN -