forked from elastic/elastic-github-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-elasticsearch.sh
executable file
·99 lines (90 loc) · 3 KB
/
run-elasticsearch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
set -euxo pipefail
if [[ -z $STACK_VERSION ]]; then
echo -e "\033[31;1mERROR:\033[0m Required environment variable [STACK_VERSION] not set\033[0m"
exit 1
fi
MAJOR_VERSION=`echo ${STACK_VERSION} | cut -c 1`
docker network create elastic
for (( node=1; node<=${NODES-1}; node++ ))
do
port_com=$((9300 + $node - 1))
UNICAST_HOSTS+="es$node:${port_com},"
done
for (( node=1; node<=${NODES-1}; node++ ))
do
port=$((PORT + $node - 1))
port_com=$((9300 + $node - 1))
if [ "x${MAJOR_VERSION}" == 'x5' ]; then
docker run \
--rm \
--env "node.name=es${node}" \
--env "cluster.name=docker-elasticsearch" \
--env "cluster.routing.allocation.disk.threshold_enabled=false" \
--env "bootstrap.memory_lock=true" \
--env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
--env "xpack.security.enabled=false" \
--env "http.port=${port}" \
--ulimit nofile=262144:262144 \
--ulimit memlock=-1:-1 \
--publish "${port}:${port}" \
--detach \
--network elastic \
--name="es${node}" \
docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
elif [ "x${MAJOR_VERSION}" == 'x6' ]; then
docker run \
--rm \
--env "node.name=es${node}" \
--env "cluster.name=docker-elasticsearch" \
--env "cluster.routing.allocation.disk.threshold_enabled=false" \
--env "bootstrap.memory_lock=true" \
--env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
--env "xpack.security.enabled=false" \
--env "xpack.license.self_generated.type=basic" \
--env "discovery.zen.ping.unicast.hosts=${UNICAST_HOSTS}" \
--env "discovery.zen.minimum_master_nodes=${NODES}" \
--env "http.port=${port}" \
--ulimit nofile=65536:65536 \
--ulimit memlock=-1:-1 \
--publish "${port}:${port}" \
--publish "${port_com}:${port_com}" \
--detach \
--network=elastic \
--name="es${node}" \
docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
elif [ "x${MAJOR_VERSION}" == 'x7' ] || [ "x${MAJOR_VERSION}" == 'x8' ]; then
docker run \
--rm \
--env "node.name=es${node}" \
--env "cluster.name=docker-elasticsearch" \
--env "cluster.initial_master_nodes=es1" \
--env "discovery.seed_hosts=es1" \
--env "cluster.routing.allocation.disk.threshold_enabled=false" \
--env "bootstrap.memory_lock=true" \
--env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
--env "xpack.security.enabled=false" \
--env "xpack.license.self_generated.type=basic" \
--env "http.port=${port}" \
--ulimit nofile=65536:65536 \
--ulimit memlock=-1:-1 \
--publish "${port}:${port}" \
--detach \
--network=elastic \
--name="es${node}" \
docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
fi
done
docker run \
--network elastic \
--rm \
appropriate/curl \
--max-time 120 \
--retry 120 \
--retry-delay 1 \
--retry-connrefused \
--show-error \
--silent \
http://es1:$PORT
sleep 10
echo "Elasticsearch up and running"