I try to start elasticsearch and configure its schema on Vagrantfile. But, when I put schema json file using curl on Vagrantfile, “connection refused” error happens, though elasticsearch has started successfully.
curl -X PUT http://192.168.33.20:9200/test --data-binary @/synced_folder/schema.json
[error message]
0curl: (7) Failed connect to 192.168.33.20:9200; Connection refused
※After vagrant up has finished, this command is successful. concretely...
sudo ssh 192.168.33.20
and
curl -X PUT http://192.168.33.20:9200/test --data-binary @/synced_folder/schema.json
It’s no error and schema is configured successfully.
{"acknowledged":true}
But, I want to configure schema on "vagrant up" process. Why does "connection refused" error happen on Vagrantfile?
[Vagrantfile]
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-7.1"
config.vm.box_url = "https://atlas.hashicorp.com/bento/boxes/centos-7.1"
config.vm.network :private_network, ip: "192.168.33.20"
config.vm.synced_folder "./", "/synced_folder"
config.vm.provision "shell", path: "./script.sh"
end
[script.sh]
#!/bin/sh
#install java
yum -y install java
#install and start elasticsearch
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
cp /synced_folder/elasticsearch.repo /etc/yum.repos.d
yum -y install elasticsearch
sed -i '/# network.host: 192.168.0.1/a\network.host: 192.168.33.20' /etc/elasticsearch/elasticsearch.yml
cd /usr/share/elasticsearch
#Japanese morphological analysis plugin
bin/plugin install analysis-kuromoji
service elasticsearch start
#configure index
curl -X PUT http://192.168.33.20:9200/test --data-binary @/synced_folder/schema.json
[/synced_folder/schema.json]
{"mappings":{"comment_data":{"properties":{"comment":{"type":"string","store":"yes","index":"analyzed"},"date":{"type":"date","store":"yes"},"vps":{"type":"float","store":"yes"}}}}}
sudo systemctl disable firewalld
) and see if it helps – Frederic Henritelnet 192.168.33.20 9200
response? It sounds like the port is not accessible. – Arun Prakashtelnet 192.168.33.20 9200
. The response console isTrying 192.168.33.20... Connected to 192.168.33.20. Escape character is '^]'.
.It looks successful. – masataka