Add Elasticsearch cluster configuration (#146)

This commit is contained in:
AlfonsoRBJ
2019-04-25 15:52:05 +02:00
committed by Jesús Linares
parent 3d8d612298
commit 3f75dbdd39
6 changed files with 67 additions and 5 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# Wazuh App Copyright (C) 2019 Wazuh Inc. (License GPLv2)
elastic_config_file="/usr/share/elasticsearch/config/elasticsearch.yml"
# If Elasticsearch cluster is enable
if [[ $ELASTIC_CLUSTER == "true" ]]
then
# Set the cluster.name and discovery.zen.minimun_master_nodes variables
sed -i 's:cluster.name\: "docker-cluster":cluster.name\: "'$CLUSTER_NAME'":g' $elastic_config_file
sed -i 's:discovery.zen.minimum_master_nodes\: 1:discovery.zen.minimum_master_nodes\: '$CLUSTER_NUMBER_OF_MASTERS':g' $elastic_config_file
# Add the cluster configuration
echo "
#cluster node
node:
master: ${CLUSTER_NODE_MASTER}
data: ${CLUSTER_NODE_DATA}
ingest: ${CLUSTER_NODE_INGEST}
name: ${CLUSTER_NODE_NAME}
max_local_storage_nodes: ${CLUSTER_MAX_NODES}
bootstrap:
memory_lock: ${CLUSTER_MEMORY_LOCK}
discovery:
zen:
ping.unicast.hosts: ${CLUSTER_DISCOVERY_SERVICE}
" >> $elastic_config_file
fi
+2
View File
@@ -43,6 +43,8 @@ fi
# Run load settings script.
./config_cluster.sh
./load_settings.sh &
# Execute elasticsearch
+10 -5
View File
@@ -3,11 +3,7 @@
set -e
if [ "x${ELASTICSEARCH_URL}" = "x" ]; then
el_url="http://elasticsearch:9200"
else
el_url="${ELASTICSEARCH_URL}"
fi
el_url=${ELASTICSEARCH_URL}
if [ "x${WAZUH_API_URL}" = "x" ]; then
wazuh_url="https://wazuh"
@@ -94,5 +90,14 @@ curl -XPUT "$el_url/_cluster/settings" -H 'Content-Type: application/json' -d'
}
'
# Set cluster delayed timeout when node falls
curl -X PUT "$el_url/_all/_settings" -H 'Content-Type: application/json' -d'
{
"settings": {
"index.unassigned.node_left.delayed_timeout": "'"$CLUSTER_DELAYED_TIMEOUT"'"
}
}
'
echo "Elasticsearch is ready."