diff --git a/elasticsearch.yml b/elasticsearch.yml index d5602b7..42dd65b 100644 --- a/elasticsearch.yml +++ b/elasticsearch.yml @@ -30,7 +30,7 @@ xpack.security.authc.password_hashing.algorithm: bcrypt # ----------------------------------- Memory ---------------------------------- # Memory locking to prevent swapping -bootstrap.memory_lock: true +bootstrap.memory_lock: false # ---------------------------------- HTTP/REST API --------------------------- http.cors.enabled: true @@ -58,15 +58,18 @@ thread_pool.search.queue_size: 1000 # I/O optimization bootstrap.system_call_filter: false -# Default index settings -index.number_of_shards: 1 -index.number_of_replicas: 0 +# ---------------------------------- Index Templates --------------------------- +# Instead of setting index settings directly (which is not allowed), +# we configure index templates that will be applied to new indices. +# Elasticsearch will automatically apply these templates to new indices. -# Merge settings for better indexing performance -index.merge.scheduler.max_thread_count: 1 -index.merge.policy.floor_segment: 2mb -index.merge.policy.max_merge_at_once: 4 -index.merge.policy.segments_per_tier: 8 +# The following settings MUST be removed from this file: +# - index.number_of_shards +# - index.number_of_replicas +# - index.merge.scheduler.max_thread_count +# - index.merge.policy.floor_segment +# - index.merge.policy.max_merge_at_once +# - index.merge.policy.segments_per_tier # Set processors based on container configuration processors: ${PROCESSORS:1} \ No newline at end of file diff --git a/start.sh b/start.sh index 1651cc3..cd43baf 100644 --- a/start.sh +++ b/start.sh @@ -184,6 +184,54 @@ configure_elasticsearch() { chmod 755 /app/data /app/data/config } +# Create index template with optimized settings +create_index_template() { + echo "Creating default index template with optimized settings..." + + # Wait a moment to ensure Elasticsearch is fully operational + sleep 5 + + # Define the template JSON + template_json=$(cat < /dev/null + + if [ $? -eq 0 ]; then + echo "Index template created successfully." + else + echo "Warning: Failed to create index template. Default settings may not be applied to new indices." + fi +} + # Set system limits - be more tolerant of container restrictions set_system_limits() { echo "Setting system limits for Elasticsearch..." @@ -278,6 +326,9 @@ start_elasticsearch() { cd $ES_HOME echo "y" | ES_JAVA_HOME=/app/data/jdk bin/elasticsearch-reset-password -u elastic -b -p "$ELASTIC_PASSWORD" --url "http://localhost:9200" || true + # Create index template with the settings we removed from elasticsearch.yml + create_index_template + # Create credentials file cat > /app/data/credentials.txt << EOL Elasticsearch credentials: