forked from wazuh/wazuh-docker
Fixed cluster configuration
This commit is contained in:
@@ -3,39 +3,36 @@
|
|||||||
|
|
||||||
elastic_config_file="/usr/share/elasticsearch/config/elasticsearch.yml"
|
elastic_config_file="/usr/share/elasticsearch/config/elasticsearch.yml"
|
||||||
|
|
||||||
|
remove_single_node_conf(){
|
||||||
|
if grep -Fq "discovery.type" $1; then
|
||||||
|
sed -i '/discovery.type\: /d' $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# If Elasticsearch cluster is enable
|
# If Elasticsearch cluster is enable, then set up the elasticsearch.yml
|
||||||
if [[ $ELASTIC_CLUSTER == "true" ]]
|
if [[ $ELASTIC_CLUSTER == "true" && $CLUSTER_NODE_MASTER != "" && $CLUSTER_NODE_DATA != "" && $CLUSTER_NODE_INGEST != "" ]];then
|
||||||
then
|
|
||||||
|
|
||||||
# Set the cluster.name and discovery.zen.minimun_master_nodes variables
|
remove_single_node_conf $elastic_config_file
|
||||||
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
|
# Remove the old configuration
|
||||||
echo "
|
sed -i '/# cluster node/,/# end cluster config/d' $elastic_config_file
|
||||||
#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:
|
# Add the current cluster configuration
|
||||||
memory_lock: ${CLUSTER_MEMORY_LOCK}
|
cat > $elastic_config_file << EOF
|
||||||
|
# cluster node
|
||||||
|
network.host: 0.0.0.0
|
||||||
|
node.name: $CLUSTER_NODE_NAME
|
||||||
|
node.master: $CLUSTER_NODE_MASTER
|
||||||
|
|
||||||
cluster.initial_master_nodes:
|
cluster.initial_master_nodes:
|
||||||
- '${CLUSTER_INITIAL_MASTER_NODES}'
|
- $CLUSTER_INITIAL_MASTER_NODES
|
||||||
|
# end cluster config"
|
||||||
" >> $elastic_config_file
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >> $elastic_config_file <<'EOF'
|
|
||||||
cluster.initial_master_nodes:
|
|
||||||
- 'elasticsearch'
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# echo 'discovery.type: single-node'
|
# If the cluster is disabled, then set a single-node configuration
|
||||||
|
else
|
||||||
|
sed -i '/# cluster node/,/# end cluster config/d' $elastic_config_file
|
||||||
|
# If it's not already configured
|
||||||
|
remove_single_node_conf $elastic_config_file
|
||||||
|
echo "discovery.type: single-node" >> $elastic_config_file
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user