elasticsearch/install.sh

raw link view readme
1 yum install java-1.8.0-openjdk.x86_64 -y
2
3 rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
4
5 cat > /etc/yum.repos.d/elasticsearch.repo << EOF
6 [elasticsearch-5.x]
7 name=Elasticsearch repository for 5.x packages
8 baseurl=https://artifacts.elastic.co/packages/5.x/yum
9 gpgcheck=1
10 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
11 enabled=1
12 autorefresh=1
13 type=rpm-md
14 EOF
15
16 yum install elasticsearch -y
17
18 sed "s/\"80\"/\"9200\"/;s/WWW (HTTP)/Elasticsearch/;/.*/d" /usr/lib/firewalld/services/http.xml > /etc/firewalld/services/elasticsearch.xml
19 firewall-cmd --permanent --zone=public --add-interface=eth0
20 firewall-cmd --permanent --add-service=elasticsearch --zone=public
21 firewall-cmd --reload
22
23 export PUBLIC_IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
24
25 cat > /etc/elasticsearch/elasticsearch.yml << EOF
26 cluster.name: my-search-cluster
27 node.name: search01
28 network.host: $PUBLIC_IP
29 EOF
30
31 systemctl start elasticsearch
32 systemctl enable elasticsearch
33