elasticsearch-secure-nodes/install.sh

raw link view readme
1 export OCTET=$1
2 export COUNT=$2
3 export NAME=$3
4
5 export OFFSET=$(($COUNT+3))
6
7 yum install java-1.8.0-openjdk.x86_64 -y
8
9 rpm --import http://packages.elastic.co/GPG-KEY-elasticsearch
10
11 cat > /etc/yum.repos.d/elasticsearch.repo << EOF
12 [elasticsearch-2.1]
13 name=Elasticsearch repository for 2.x packages
14 baseurl=http://packages.elastic.co/elasticsearch/2.x/centos
15 gpgcheck=1
16 gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
17 enabled=1
18 EOF
19
20 yum install elasticsearch -y
21
22 systemctl start firewalld
23 systemctl enable firewalld
24 sed "s/\"80\"/\"9200\"/;s/WWW (HTTP)/Elasticsearch/;/.*/d" /usr/lib/firewalld/services/http.xml > /etc/firewalld/services/elasticsearch.xml
25 sed "s/\"80\"/\"9300-9400\"/;s/WWW (HTTP)/Elasticsearch Node/;/.*/d" /usr/lib/firewalld/services/http.xml > /etc/firewalld/services/elasticsearch-node.xml
26 firewall-cmd --permanent --zone=public --add-interface=eth0
27 firewall-cmd --permanent --add-service=elasticsearch --zone=public
28 firewall-cmd --reload
29
30 rm -f /var/tmp/firewall-update.sh
31 for n in $(seq 3 $OFFSET);
32 do echo firewall-cmd --permanent --add-rich-rule=\'rule family=\"ipv4\" source address=\"10.$OCTET.0.$n/16\" service name=\"elasticsearch-node\" accept\' --zone=public >> /var/tmp/firewall-update.sh
33 done
34 cat /var/tmp/firewall-update.sh
35 chmod +x /var/tmp/firewall-update.sh
36 /var/tmp/firewall-update.sh
37 rm -f /var/tmp/firewall-update.sh
38
39 firewall-cmd --reload
40
41 export PUBLIC_IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
42
43 cat > /etc/elasticsearch/elasticsearch.yml << EOF
44 cluster.name: my-search-cluster
45 node.name: search-$NAME
46 network.host: $PUBLIC_IP
47 #transport.publish_host: MY_PUBLIC_AZURE_IP_HERE
48 discovery.zen.ping.multicast.enabled: false
49 discovery.zen.ping.unicast.hosts: [$(for n in $(seq 3 $OFFSET); do echo "\"10.$OCTET.0.$n\""; done | tr '\n', ',' | sed "s/,$//")]
50 EOF
51
52 systemctl start elasticsearch
53 systemctl enable elasticsearch
54
55 cd /usr/share/elasticsearch
56 bin/plugin install mobz/elasticsearch-head
57
58 wget https://linux.azure.david.betz.space/raw/elasticsearch-secure-nodes/setup_data_generation.sh -O /root/setup_data_generation.sh
59 chmod +x /root/setup_data_generation.sh
60