Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit bf4c3e3

Browse files
author
Chris Wiechmann
committed
Merge branch 'develop'
2 parents a7dcced + 7060fd4 commit bf4c3e3

File tree

7 files changed

+143
-28
lines changed

7 files changed

+143
-28
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,20 @@ When Elasticsearch is finally started:
509509
```
510510
Status YELLOW is expected when running Elasticsearch on a single node, as it can achieve the desired replicas. You may use Kibana Development tools or curl to get additional information.
511511

512+
### vm.max_map_count is too low
513+
```
514+
ERROR: [1] bootstrap checks failed
515+
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
516+
```
517+
Run the following to set it temporarly:
518+
`sudo sysctl -w vm.max_map_count=262144`
519+
Or the following:
520+
```
521+
1. sudo vi /etc/sysctl.conf
522+
2. add vm.max_map_count=262144
523+
3. sudo service sysctl restart
524+
```
525+
512526
#### No results from Elasticsearch
513527
If you don't get any results from ElasticSearch for valid queries it might be a missing template configuration for the logstash-openlog index. Elastic-Search is doing by default a dynamic template mapping that is trying to figure out field types. However, for some of the fields the mapping must be overwritten. Therefore make sure so to include the sample mapping file: `configs/openlog_index_template.json` is used by your Logstash process. See `configs/logstash.conf` as an example.
514528
The template mapping is pre-configured when using the docker-compose configuration.

elasticsearch/docker-compose.es01.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ services:
33
# Elasticsearch node 1
44
elasticsearch1:
55
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION}
6+
# Custom entrypoint to configured ES based on given ELASTICSEARCH_HOSTS
7+
entrypoint: /usr/share/elasticsearch/scripts/custom-entrypoint.sh
68
container_name: elasticsearch1
79
environment:
810
- "ES_JAVA_OPTS=${ES_JAVA_OPTS}"
911
- cluster.name=${ELASTICSEARCH_CLUSTERNAME}
1012
- node.name=elasticsearch1
11-
- network.publish_host=${ELASTICSEARCH_HOST1}
12-
- transport.port=${ELASTICSEARCH_HOST1_TRANSPORT}
13+
- ELASTICSEARCH_HOSTS=${ELASTICSEARCH_HOSTS}
1314
- xpack.security.enabled=true
1415
- xpack.security.http.ssl.enabled=true
1516
- xpack.security.http.ssl.key=/usr/share/elasticsearch/${ELASTICSEARCH_KEY}
@@ -20,6 +21,10 @@ services:
2021
- xpack.security.transport.ssl.key=/usr/share/elasticsearch/${ELASTICSEARCH_KEY}
2122
- xpack.security.transport.ssl.certificate=/usr/share/elasticsearch/${ELASTICSEARCH_CRT}
2223
- xpack.security.transport.ssl.certificate_authorities=/usr/share/elasticsearch/${ELASTICSEARCH_CA}
24+
# Activate the following parameters for advanced setup
25+
#- network.publish_host=${ELASTICSEARCH_PUBLISH_HOST1}
26+
#- http.port=${ELASTICSEARCH_HOST1_HTTP}
27+
#- transport.port=${ELASTICSEARCH_HOST1_TRANSPORT}
2328
ulimits:
2429
memlock:
2530
soft: -1
@@ -38,11 +43,12 @@ services:
3843
target: /usr/share/elasticsearch/data
3944
- ${PWD}/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
4045
- ${PWD}/certificates:/usr/share/elasticsearch/config/certificates
46+
- ${PWD}/elasticsearch/scripts:/usr/share/elasticsearch/scripts
4147
networks:
4248
- elastic
4349
ports:
44-
- 9200:9200
45-
- ${ELASTICSEARCH_HOST1_TRANSPORT}:${ELASTICSEARCH_HOST1_TRANSPORT}
50+
- ${ELASTICSEARCH_HOST1_HTTP:-9200}:${ELASTICSEARCH_HOST1_HTTP:-9200}
51+
- ${ELASTICSEARCH_HOST1_TRANSPORT:-9300}:${ELASTICSEARCH_HOST1_TRANSPORT:-9300}
4652
logging:
4753
options:
4854
max-file: "5"
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
version: '3.7'
22
services:
3-
# Extend Elasticsearch node 1 configuration with second and third node
43
elasticsearch1:
54
environment:
6-
- cluster.initial_master_nodes=elasticsearch1
5+
- initCluster=true

elasticsearch/docker-compose.es02.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ services:
33
# Elasticsearch node 2
44
elasticsearch2:
55
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION}
6+
# Custom entrypoint to configured ES based on given ELASTICSEARCH_HOSTS
7+
entrypoint: /usr/share/elasticsearch/scripts/custom-entrypoint.sh
68
container_name: elasticsearch2
79
environment:
810
- "ES_JAVA_OPTS=${ES_JAVA_OPTS}"
911
- cluster.name=${ELASTICSEARCH_CLUSTERNAME}
1012
- node.name=elasticsearch2
11-
- network.publish_host=${ELASTICSEARCH_HOST2}
12-
- transport.port=${ELASTICSEARCH_HOST2_TRANSPORT}
13-
- discovery.seed_hosts=${ELASTICSEARCH_HOST1}:${ELASTICSEARCH_HOST1_TRANSPORT}
13+
- ELASTICSEARCH_HOSTS=${ELASTICSEARCH_HOSTS}
1414
- xpack.security.enabled=true
1515
- xpack.security.http.ssl.enabled=true
1616
- xpack.security.http.ssl.key=/usr/share/elasticsearch/${ELASTICSEARCH_KEY}
@@ -21,6 +21,10 @@ services:
2121
- xpack.security.transport.ssl.key=/usr/share/elasticsearch/${ELASTICSEARCH_KEY}
2222
- xpack.security.transport.ssl.certificate=/usr/share/elasticsearch/${ELASTICSEARCH_CRT}
2323
- xpack.security.transport.ssl.certificate_authorities=/usr/share/elasticsearch/${ELASTICSEARCH_CA}
24+
# Activate the following parameters for advanced setup
25+
#- network.publish_host=${ELASTICSEARCH_PUBLISH_HOST2}
26+
#- http.port=${ELASTICSEARCH_HOST2_HTTP}
27+
#- transport.port=${ELASTICSEARCH_HOST2_TRANSPORT}
2428
ulimits:
2529
memlock:
2630
soft: -1
@@ -39,11 +43,12 @@ services:
3943
target: /usr/share/elasticsearch/data
4044
- ${PWD}/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
4145
- ${PWD}/certificates:/usr/share/elasticsearch/config/certificates
46+
- ${PWD}/elasticsearch/scripts:/usr/share/elasticsearch/scripts
4247
networks:
4348
- elastic
4449
ports:
45-
- 9201:9201
46-
- ${ELASTICSEARCH_HOST2_TRANSPORT}:${ELASTICSEARCH_HOST2_TRANSPORT}
50+
- ${ELASTICSEARCH_HOST1_HTTP:-9201}:${ELASTICSEARCH_HOST1_HTTP:-9201}
51+
- ${ELASTICSEARCH_HOST1_TRANSPORT:-9301}:${ELASTICSEARCH_HOST1_TRANSPORT:-9301}
4752
logging:
4853
options:
4954
max-file: "5"

elasticsearch/docker-compose.es03.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ services:
33
# Elasticsearch node 3
44
elasticsearch3:
55
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION}
6+
# Custom entrypoint to configured ES based on given ELASTICSEARCH_HOSTS
7+
entrypoint: /usr/share/elasticsearch/scripts/custom-entrypoint.sh
68
container_name: elasticsearch3
79
environment:
810
- "ES_JAVA_OPTS=${ES_JAVA_OPTS}"
911
- cluster.name=${ELASTICSEARCH_CLUSTERNAME}
1012
- node.name=elasticsearch3
11-
- network.publish_host=${ELASTICSEARCH_HOST3}
12-
- transport.port=${ELASTICSEARCH_HOST3_TRANSPORT}
13-
- discovery.seed_hosts=${ELASTICSEARCH_HOST1}:${ELASTICSEARCH_HOST1_TRANSPORT}, ${ELASTICSEARCH_HOST2}:${ELASTICSEARCH_HOST2_TRANSPORT}
13+
- ELASTICSEARCH_HOSTS=${ELASTICSEARCH_HOSTS}
1414
- xpack.security.enabled=true
1515
- xpack.security.http.ssl.enabled=true
1616
- xpack.security.http.ssl.key=/usr/share/elasticsearch/${ELASTICSEARCH_KEY}
@@ -21,6 +21,10 @@ services:
2121
- xpack.security.transport.ssl.key=/usr/share/elasticsearch/${ELASTICSEARCH_KEY}
2222
- xpack.security.transport.ssl.certificate=/usr/share/elasticsearch/${ELASTICSEARCH_CRT}
2323
- xpack.security.transport.ssl.certificate_authorities=/usr/share/elasticsearch/${ELASTICSEARCH_CA}
24+
# Activate the following parameters for advanced setup
25+
#- network.publish_host=${ELASTICSEARCH_PUBLISH_HOST3}
26+
#- http.port=${ELASTICSEARCH_HOST3_HTTP}
27+
#- transport.port=${ELASTICSEARCH_HOST3_TRANSPORT}
2428
ulimits:
2529
memlock:
2630
soft: -1
@@ -39,11 +43,12 @@ services:
3943
target: /usr/share/elasticsearch/data
4044
- ${PWD}/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
4145
- ${PWD}/certificates:/usr/share/elasticsearch/config/certificates
46+
- ${PWD}/elasticsearch/scripts:/usr/share/elasticsearch/scripts
4247
networks:
4348
- elastic
4449
ports:
45-
- 9202:9202
46-
- ${ELASTICSEARCH_HOST3_TRANSPORT}:${ELASTICSEARCH_HOST3_TRANSPORT}
50+
- ${ELASTICSEARCH_HOST1_HTTP:-9202}:${ELASTICSEARCH_HOST1_HTTP:-9202}
51+
- ${ELASTICSEARCH_HOST1_TRANSPORT:-9302}:${ELASTICSEARCH_HOST1_TRANSPORT:-9302}
4752
logging:
4853
options:
4954
max-file: "5"
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash -e
2+
3+
# This script is using the given ELASTICSEARCH_HOSTS to populate required parameters
4+
# to setup a Multi-Node Elasticsearch cluster.
5+
# If parameters (network.publish_host, http.port, transport.port) are already
6+
# given externally they are used with precedence.
7+
8+
# Get the number of the Elasticsearch node based on the node.name (e.g. elasticsearch2)
9+
nodeBasename=`echo node.name | awk 'match(ENVIRON[$0], /([a-zA-Z]*)([0-9]{1,})/, v) { print v[1] }'`
10+
nodeNumber=`echo node.name | awk 'match(ENVIRON[$0], /([a-zA-Z]*)([0-9]{1,})/, v) { print v[2] }'`
11+
12+
count=1
13+
params=""
14+
seedHosts=""
15+
initialMasterNodes=""
16+
for host in ${ELASTICSEARCH_HOSTS//,/ }
17+
do
18+
# Use all nodes as initial master node, when initializing the cluster
19+
# It is assumed, that node-names are sequentially counted elasticsearch1, elasticsearch2, ...
20+
if [ "${initCluster}" = "true" ]; then
21+
if [ "${initialMasterNodes}" == "" ]; then
22+
initialMasterNodes="-E cluster.initial_master_nodes=${nodeBasename}${count}"
23+
else
24+
initialMasterNodes="${initialMasterNodes},${nodeBasename}${count}"
25+
fi
26+
fi
27+
# Use all declared hosts as seed hosts if
28+
# Seeds hosts are not given externally and the standard transport ports are used
29+
discoverySeedHosts=`echo discovery.seed_hosts | awk '{print ENVIRON[$0]}'`
30+
discoveryTransportPort=`echo transport.port | awk '{print ENVIRON[$0]}'`
31+
if [ -z "${discoverySeedHosts}" -a -z "${discoveryTransportPort}" ]
32+
then
33+
# Get the hostname and transport from the URL
34+
discoverPublishHostname=`echo $host | awk 'match($0, /https?:\/\/(.*)\:(\d*)/, v) { print v[1] }'`
35+
discoveryTransportPort=`echo $host | awk 'match($0,/https?:\/\/(.*)\:[0-9]{2}([0-9]{2})/, v) { print 93v[2] }'`
36+
if [ "${seedHosts}" == "" ]; then
37+
seedHosts="-E discovery.seed_hosts=${discoverPublishHostname}:${discoveryTransportPort}"
38+
else
39+
seedHosts="${seedHosts},${discoverPublishHostname}:${discoveryTransportPort}"
40+
fi
41+
fi
42+
43+
if [ "${count}" == "${nodeNumber}" ]; then
44+
echo "Setting up Elasticsearch node: ${nodeNumber}"
45+
publishHost=`echo network.publish_host | awk '{print ENVIRON[$0]}'`
46+
if [ -z "${publishHost}" ]; then
47+
publishHost=`echo $host | awk 'match($0, /https?:\/\/(.*)\:(\d*)/, v) { print v[1] }'`
48+
params="$params -E network.publish_host=${publishHost}"
49+
echo "Set network.publish_host=${publishHost} based on given host: ${host}"
50+
else
51+
echo "network.publish_host=${publishHost} taken from envionment variable"
52+
fi
53+
54+
httpPort=`echo http.port | awk '{print ENVIRON[$0]}'`
55+
if [ -z "${httpPort}" ]
56+
then
57+
httpPort=`echo $host | awk 'match($0,/https?:\/\/(.*)\:([0-9]*)/, v) { print v[2] }'`
58+
params="$params -E http.port=${httpPort}"
59+
echo "Set http.port=${httpPort} based on given host: ${host}"
60+
else
61+
echo "http.port=${httpPort} taken from envionment variable"
62+
fi
63+
64+
transportPort=`echo transport.port | awk '{print ENVIRON[$0]}'`
65+
if [ -z "${transportPort}" ]
66+
then
67+
transportPort=`echo $host | awk 'match($0,/https?:\/\/(.*)\:[0-9]{2}([0-9]{2})/, v) { print 93v[2] }'`
68+
params="$params -E transport.port=${transportPort}"
69+
echo "Set transport.port=${transportPort} based on given host: ${host}"
70+
else
71+
echo "transport.port=${transportPort} taken from envionment variable"
72+
fi
73+
fi
74+
count=`expr $count + 1`
75+
done
76+
77+
# Finally call the original Docker-Entrypoint
78+
/usr/local/bin/docker-entrypoint.sh elasticsearch ${params} ${seedHosts} ${initialMasterNodes}

env-sample

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,25 @@ API_MANAGER_PASSWORD=changeme
112112
################################################################################################
113113
# Configure Multi-Node ES-Cluster
114114
################################################################################################
115-
# The following parameters are used by the elaticsearch/docker-compose.es<N>.yml files and only
116-
# required if you are running Elasticsearch based on Docker-Compose.
117-
# If you using an external Elasticsearch cluster, these parameters are not used.
118-
ELASTICSEARCH_HOST1=elasticsearch1
119-
ELASTICSEARCH_HOST2=elasticsearch2
120-
ELASTICSEARCH_HOST3=elasticsearch3
121-
122-
# Ports are different just to be able to start multiple Elasticsearch containers on one host.
123-
ELASTICSEARCH_HOST1_TRANSPORT=9300
124-
ELASTICSEARCH_HOST2_TRANSPORT=9301
125-
ELASTICSEARCH_HOST3_TRANSPORT=9302
115+
# The following parameters are used to build and configure the Elasticsearch cluster.
116+
# If you don't set this parameters the cluster is configured based on the configured
117+
# ELASTICSEARCH_HOSTS.
118+
#
119+
# The publish host is used for internal cluster communication between each node. If must be
120+
# set to a host that is reachable from other nodes.
121+
# ELASTICSEARCH_PUBLISH_HOST1=elasticsearch1
122+
# ELASTICSEARCH_PUBLISH_HOST2=elasticsearch2
123+
# ELASTICSEARCH_PUBLISH_HOST3=elasticsearch3
124+
125+
# The ES REST-API listen socket and used to map the port outside of the docker container.
126+
# ELASTICSEARCH_HOST1_HTTP=9200
127+
# ELASTICSEARCH_HOST2_HTTP=9201
128+
# ELASTICSEARCH_HOST3_HTTP=9202
129+
130+
# The ES Transport protocol listen socket and used to map the port outside of the docker container.
131+
# ELASTICSEARCH_HOST1_TRANSPORT=9300
132+
# ELASTICSEARCH_HOST2_TRANSPORT=9301
133+
# ELASTICSEARCH_HOST3_TRANSPORT=9302
126134

127135
################################################################################################
128136
# Optional / Advanced parameters
@@ -220,7 +228,7 @@ ELASTICSEARCH_CLUSTERNAME=axway-apim-elasticsearch
220228
# ----------------------------------------------------------------------------------------------
221229
# Define the version of the Elastic-Stack to use. Based on this version Docker images are pulled
222230
# Used-By: Elasticsearch, Filebeat, Kibana, Logstash
223-
ELASTIC_VERSION=7.9.0
231+
ELASTIC_VERSION=7.9.2
224232

225233
################################################################################################
226234
# Certificates and Certificate authorities

0 commit comments

Comments
 (0)