Docker部署elasticsearch集群
1、集群架构
IP | hostname | ES节点 | ES镜像 |
---|
10.1.1.19 | es1 | es01 | elasticsearch:7.14.2 | 10.1.1.20 | es2 | es02 | elasticsearch:7.14.2 | 10.1.1.21 | es3 | es03 | elasticsearch: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
|