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