我嘗試啓動elasticsearch並在Vagrantfile上配置其模式。 但是,當我在Vagrantfile上使用curl放置架構json文件時,雖然elasticsearch已成功啓動,但會發生「連接被拒絕」錯誤。捲曲到Elasticsearch「連接被拒絕」Vagrantfile
捲曲-X PUT http://192.168.33.20:9200/test --data二進制@/synced_folder/schema.json
[錯誤消息]
0curl:(7)無法連接到192.168.33.20:9200;連接被拒絕
※vagrant up結束後,該命令成功。具體...
須藤SSH 192.168.33.20
和
捲曲-X PUT http://192.168.33.20:9200/test --data二進制@/synced_folder /模式。 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"
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'),看看它是否有幫助 –
謝謝!我首先認爲「firewalld」是其原因,並嘗試過它,但這不是原因。 – masataka
請問您可以檢查telnet 192.168.33.20 9200'響應嗎?這聽起來像港口不可訪問。 –