Docker部署elasticsearch集群

1、集群架构

IPhostnameES节点ES镜像
10.1.1.19es1es01elasticsearch:7.14.2
10.1.1.20es2es02elasticsearch:7.14.2
10.1.1.21es3es03elasticsearch:7.14.2

2、安装docker

3、配置环境(三个节点都要做)

(1)创建挂载目录

# 三个目录分别对应配置文件、数据和日志目录
mkdir /elk/{config,data,logs}

(2)修改权限

chown -R 1000:1000 /elk

(3)调高JVM线程数限制数量

在centos窗口中,修改配置sysctl.conf

vim /etc/sysctl.conf

加入如下内容:

vm.max_map_count=262144 

启用配置:

sysctl -p

4、创建/elk/config/es.yml配置文件:

es01:

cluster.name: my-elasticsearch
node.name: es-node1
network.bind_host: 0.0.0.0
network.publish_host: 10.1.1.19
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true 
node.data: true  
cluster.initial_master_nodes: ["es-node1","es-node2","es-node3"]
discovery.zen.ping.unicast.hosts: ["10.1.1.19:9300","10.1.1.20:9300","10.1.1.21:9300"]
discovery.zen.minimum_master_nodes: 2

es02:

cluster.name: my-elasticsearch
node.name: es-node2
network.bind_host: 0.0.0.0
network.publish_host: 10.1.1.20
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true 
node.data: true  
cluster.initial_master_nodes: ["es-node1","es-node2","es-node3"]
discovery.zen.ping.unicast.hosts: ["10.1.1.19:9300","10.1.1.20:9300","10.1.1.21:9300"]
discovery.zen.minimum_master_nodes: 2

es03:

cluster.name: my-elasticsearch
node.name: es-node3
network.bind_host: 0.0.0.0
network.publish_host: 10.1.1.21
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true 
node.data: true  
cluster.initial_master_nodes: ["es-node1","es-node2","es-node3"]
discovery.zen.ping.unicast.hosts: ["10.1.1.19:9300","10.1.1.20:9300","10.1.1.21:9300"]
discovery.zen.minimum_master_nodes: 2

5、启动es节点

es01:

docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -d \
-p 9200:9200 -p 9300:9300 \
-v /elk/config/es.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /elk/data/:/usr/share/elasticsearch/data \
-v /elk/logs/:/usr/share/elasticsearch/logs \
--name es01 elasticsearch:7.14.2

es02:

docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -d \
-p 9200:9200 -p 9300:9300 \
-v /elk/config/es.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /elk/data/:/usr/share/elasticsearch/data \
-v /elk/logs/:/usr/share/elasticsearch/logs \
--name es02 elasticsearch:7.14.2

es03:

docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -d \
-p 9200:9200 -p 9300:9300 \
-v /elk/config/es.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /elk/data/:/usr/share/elasticsearch/data \
-v /elk/logs/:/usr/share/elasticsearch/logs \
--name es03 elasticsearch:7.14.2
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐