我尝试启动elasticsearch并在Vagrantfile上配置它的模式。但是,当我将使用curl的模式json文件放在Vagrantfile上时,虽然elasticsearch已经成功启动,但“连接拒绝”错误还是会发生。
curl -X http://192.168.33.20:9200/test --数据-二进制@/synced_文件夹/schema.json
错误信息
0curl:(7)连接192.168.33.20:9200失败;连接被拒绝
※在迷航结束后,这个命令就成功了。具体来说..。
sudo ssh 192.168.33.20
和
curl -X http://192.168.33.20:9200/test --数据-二进制@/synced_文件夹/schema.json
没有错误,并且成功地配置了模式。
{“确认”:真}
但是,我想配置关于“流浪汉向上”进程的架构。为什么“连接拒绝”错误会发生在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"
endscript.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"}}}}}发布于 2016-03-08 15:51:02
我可以解决这个问题。我发现elasticsearch实际上在服务启动后几秒钟就开始了。因此,我将等待进程添加到shell脚本中。谢谢!
while true;
do
echo "waiting Elasticsearch..."
curl -X -s GET http://192.168.33.20:9200
if [ $? -eq "0" ]; then
echo "Elasticsearch started!"
break
fi
sleep 1s
donehttps://stackoverflow.com/questions/35647531
复制相似问题