Deploy a 3-Node Elasticsearch 7.17.9 Cluster with Docker: Consolidated Test Environment Guide
This guide details the step-by-step deployment of a three-node Elasticsearch 7.17.9 cluster using Docker on existing test servers, including full YAML configurations, docker run commands, and network host mode setup to consolidate scattered test environments and reduce resource waste.
Background: Consolidating Test Elasticsearch Clusters
The company initiated a cloud resource consolidation effort to control annual IT costs. During the audit, multiple business units were found running self-hosted Elasticsearch test clusters on separate servers, causing resource waste. The decision was made to merge all test Elasticsearch instances into a single three-node cluster deployed via Docker on three existing test servers that already host StarRocks, ClickHouse, and Kafka clusters.
Deployment Architecture
Three test servers (192.168.10.10, 192.168.10.11, 192.168.10.12) each run one Elasticsearch node. The cluster name is es-test-cluster. Nodes are named els-node-0, els-node-1, and els-node-2. All nodes use the host network mode, share the same timezone (Asia/Shanghai), and mount host directories for data, logs, and configuration.
Node 1 Configuration (els-node-0, 192.168.10.10)
elasticsearch.yml
cluster.name: es-test-cluster
node.name: els-node-0
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
#plugin.path: /usr/share/elasticsearch/plugins
network.host: 192.168.10.10
http.port: 9200
discovery.type: zen
transport.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["192.168.10.10:9300", "192.168.10.11:9300", "192.168.10.11:9300"]
cluster.initial_master_nodes: ["els-node-0", "els-node-1", "els-node-2"]
gateway.recover_after_nodes: 1
indices.query.bool.max_clause_count: 8000
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: falseDocker Run Command
docker run -d --name els-node-0 --network host --env TZ=Asia/Shanghai \
-p 9200:9200 -p 9300:9300 \
-v /etc/hosts:/etc/hosts:rw \
-v /etc/localtime:/etc/localtime:ro \
-v /data/elatisearch/logs/:/usr/share/elasticsearch/logs/:rw \
-v /data/elatisearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:rw \
-v /data/elatisearch/data:/usr/share/elasticsearch/data:rw \
-e "ES_JAVA_OPTS=-Xms4g -Xmx4g" \
elasticsearch:7.17.9Node 2 Configuration (els-node-1, 192.168.10.11)
elasticsearch.yml
cluster.name: es-test-cluster
node.name: els-node-1
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
#plugin.path: /usr/share/elasticsearch/plugins
network.host: 192.168.10.11
http.port: 9200
discovery.type: zen
transport.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["192.168.10.10:9300", "192.168.10.11:9300", "192.168.10.11:9300"]
cluster.initial_master_nodes: ["els-node-0", "els-node-1", "els-node-2"]
gateway.recover_after_nodes: 1
indices.query.bool.max_clause_count: 8000
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: falseDocker Run Command
docker run -d --name els-node-1 --network host --env TZ=Asia/Shanghai \
-p 9200:9200 -p 9300:9300 \
-v /etc/hosts:/etc/hosts:rw \
-v /etc/localtime:/etc/localtime:ro \
-v /data/elatisearch/logs/:/usr/share/elasticsearch/logs/:rw \
-v /data/elatisearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:rw \
-v /data/elatisearch/data:/usr/share/elasticsearch/data:rw \
-e "ES_JAVA_OPTS=-Xms4g -Xmx4g" \
elasticsearch:7.17.9Node 3 Configuration (els-node-2, 192.168.10.12)
elasticsearch.yml
cluster.name: es-test-cluster
node.name: els-node-0
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
#plugin.path: /usr/share/elasticsearch/plugins
network.host: 192.168.10.12
http.port: 9200
discovery.type: zen
transport.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["192.168.10.10:9300", "192.168.10.11:9300", "192.168.10.11:9300"]
cluster.initial_master_nodes: ["els-node-0", "els-node-1", "els-node-2"]
gateway.recover_after_nodes: 1
indices.query.bool.max_clause_count: 8000
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: falseDocker Run Command
docker run -d --name els-node-2 --network host --env TZ=Asia/Shanghai \
-p 9200:9200 -p 9300:9300 \
-v /etc/hosts:/etc/hosts:rw \
-v /etc/localtime:/etc/localtime:ro \
-v /data/elatisearch/logs/:/usr/share/elasticsearch/logs/:rw \
-v /data/elatisearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:rw \
-v /data/elatisearch/data:/usr/share/elasticsearch/data:rw \
-e "ES_JAVA_OPTS=-Xms4g -Xmx4g" \
elasticsearch:7.17.9Key Configuration Notes
Network mode: Host network ( --network host) is used so containers directly use the host's network stack without isolation.
Timezone: Set to Asia/Shanghai via -e TZ=Asia/Shanghai and mounting /etc/localtime to keep time consistent with the host.
Heap size: Fixed at 4 GB ( -Xms4g -Xmx4g) via ES_JAVA_OPTS.
Security: X-Pack security and transport SSL are disabled ( false) for this test environment.
Discovery: Zen discovery with explicit discovery.seed_hosts and cluster.initial_master_nodes listing all three nodes.
CORS: Enabled with allow-origin: "*" for browser-based tool access.
This setup provides a consolidated, reproducible Elasticsearch test cluster that reuses existing server capacity and simplifies maintenance.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Lakehouse Research Base
Focused on technical sharing in the data field, covering a tech stack that includes Hadoop, Spark, Flink, Kafka, Fluss, Paimon, Iceberg, StarRocks, ClickHouse, ES, Milvus, and more. Welcome to follow.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
