我这边用的是一台虚拟机三个不同的端口搭建的
1、master节点的docker-compose文件和配置文件
version: '3'
services:
es:
image: elasticsearch:8.3.3
container_name: es-node1
environment:
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
- "http.host=0.0.0.0"
volumes:
- /home/mydocker/es/elasticsearch-node-1/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
# - /home/mydocker/es/elasticsearch-node-1/data:/usr/share/elasticsearch/data
# - /home/mydocker/es/elasticsearch-node-1/plugins/ik:/usr/share/elasticsearch/plugins/ik
ports:
- 9200:9200
- 9300:9300
elasticsearch.yml文件
cluster.name: es-cluster
node.name: es-node1
network.host: 0.0.0.0
network.publish_host: 172.20.10.8
http.port: 9200
transport.port: 9300
node.roles: [master,data]
cluster.initial_master_nodes: ["es-node1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
action.destructive_requires_name: false
discovery.seed_hosts: ["172.20.10.8:9300","172.20.10.8:9301","172.20.10.8:9302"]
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false #关闭使用ssl证书
xpack.security.transport.ssl.verification_mode: none
#xpack.security.transport.ssl.keystore.path: /elasticsearch8.2/config/certs/elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: /elasticsearch8.2/config/certs/elastic-certificates.p12
ingest.geoip.downloader.enabled: false
2、节点2的docker-compose文件和配置文件
cluster.name: es-cluster
node.name: es-node2
network.host: 0.0.0.0
http.port: 9201
transport.port: 9301
network.publish_host: 172.20.10.8
node.roles: [master,data]
cluster.initial_master_nodes: ["es-node1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
action.destructive_requires_name: false
discovery.seed_hosts: ["172.20.10.8:9300","172.20.10.8:9301","172.20.10.8:9302"]
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
xpack.security.transport.ssl.verification_mode: none
#xpack.security.transport.ssl.keystore.path: /elasticsearch8.2/config/certs/elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: /elasticsearch8.2/config/certs/elastic-certificates.p12
ingest.geoip.downloader.enabled: false
配置文件
version: '3'
services:
es:
image: elasticsearch:8.3.3
container_name: es-node2
environment:
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
- "http.host=0.0.0.0"
volumes:
- /home/mydocker/es/elasticsearch-node-2/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
# - /home/mydocker/es/elasticsearch-node-2/data:/usr/share/elasticsearch/data
# - /home/mydocker/es/elasticsearch-node-2/plugins/ik:/usr/share/elasticsearch/plugins/ik
ports:
- 9201:9201
- 9301:9301
3、节点3的docker-compose文件和配置文件
cluster.name: es-cluster
node.name: es-node3
network.host: 0.0.0.0
http.port: 9202
transport.port: 9302
network.publish_host: 172.20.10.8
node.roles: [data]
cluster.initial_master_nodes: ["es-node1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
action.destructive_requires_name: false
discovery.seed_hosts: ["172.20.10.8:9300","172.20.10.8:9301","172.20.10.8:9302"]
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
xpack.security.transport.ssl.verification_mode: none
#xpack.security.transport.ssl.keystore.path: /elasticsearch8.2/config/certs/elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: /elasticsearch8.2/config/certs/elastic-certificates.p12
ingest.geoip.downloader.enabled: false
配置文件
version: '3'
services:
es:
image: elasticsearch:8.3.3
container_name: es-node3
environment:
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
- "http.host=0.0.0.0"
volumes:
- /home/mydocker/es/elasticsearch-node-3/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
# - /home/mydocker/es/elasticsearch-node-2/data:/usr/share/elasticsearch/data
# - /home/mydocker/es/elasticsearch-node-2/plugins/ik:/usr/share/elasticsearch/plugins/ik
ports:
- 9202:9202
- 9302:9302
4、如果觉得麻烦,可以把三个compose文件合成一个,我这边这么弄是喜欢这种方式看日志。本文章只是简单的介绍一下8版本的一些配置参数跟7版本有些不一样。