我有简单的vagrant多机配置:
Vagrant.configure(2) do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.provision :shell, path: "vagrant/ubuntu-16.04/provision.sh"
config.vm.synced_folder "ed", "/var/www/html"
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
config.vm.define "node1", primary: true do |node|
node.vm.hostname = 'node1'
node.vm.network :private_network, ip: "192.168.56.101"
node.vm.network :forwarded_port, guest: 22, host: 10122, id: "ssh"
node.vm.provision :hosts, :sync_hosts => true
end
config.vm.define "node2" do |node|
node.vm.hostname = "node2"
node.vm.network :private_network, ip: "192.168.56.102"
node.vm.network :forwarded_port, guest: 22, host: 10123, id: "ssh"
node.vm.provision :hosts, :sync_hosts => true
end
end
在node1
我有php和node2
我有弹性搜索。
当我从curl localhost:9200
运行vagrant@node2
时,它有效,
但是当我尝试从curl 192.168.56.102:9200
运行vagrant@node1
时,它将无效,我收到错误:
curl: (7) Failed to connect to 192.168.56.102 port 9200: Connection refused
答案 0 :(得分:2)
根据您的评论,elasticsearch监听localhost。因此,它只能从当地访问。看你的输出:
netstat -anp | grep LISTEN | grep 9200
tcp6 0 0 127.0.0.1:9200 :::* LISTEN - tcp6 0 0 ::1:9200 :::* LISTEN
您必须将elasticsearch
端口绑定到您的IP地址才能从外部访问。
打开elasticsearch.yml
并将IP地址添加到network.host
选项。
network.host: "192.168.56.102"
之后重启elasticsearch
服务。
sudo service elasticsearch restart