-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-elasticsearch.sh
executable file
·62 lines (54 loc) · 1.51 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
#!/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
PLUGIN_INSTALL_CMD=""
PLUGINS_STR=`echo ${PLUGINS} | sed -e 's/\n/ /g'`
if [ -n "${PLUGINS_STR}" ]; then
ARRAY=(${PLUGINS_STR})
for i in "${ARRAY[@]}"
do
PLUGIN_INSTALL_CMD+="elasticsearch-plugin install --batch ${i} && "
done
fi
docker network create elastic
NODES=${NODES-1}
for (( node=1; node<=$NODES; node++ ))
do
port=$((9200 + $node - 1))
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" \
--ulimit nofile=65536:65536 \
--ulimit memlock=-1:-1 \
--publish "${port}:9200" \
--detach \
--network=elastic \
--name="es${node}" \
--entrypoint="" \
docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION} \
/bin/sh -vc "${PLUGIN_INSTALL_CMD} /usr/local/bin/docker-entrypoint.sh"
done
docker run \
--network elastic \
--rm \
appropriate/curl \
--max-time 120 \
--retry 120 \
--retry-delay 1 \
--retry-connrefused \
--show-error \
--silent \
http://es1:9200
sleep 10
echo "Elasticsearch up and running"