elasticsearch
version: '3'
services:
elasticsearch-1:
image: swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/elasticsearch:8.8.0
restart: always
ports:
- 9211:9200
- 9300:9300
privileged: true
environment:
- node.name=es01 # 节点名称,唯一
- network.host=0.0.0.0 # 节点IP,单节点时候可以不需要
- network.publish_host=172.18.41.8 # 发布地址
- cluster.name=vpclub-log # 集群名称,集群一致
- cluster.initial_master_nodes=es01,es02,es03 # 集群节点成员
- discovery.seed_hosts=elasticsearch-2,elasticsearch-3 # 从指定主机发现
- xpack.security.enabled=false # xpack 安全设置
- xpack.security.http.ssl.enabled=false # xpack 安全设置
# - discovery.type=single-node # 单节点
- ES_JAVA_OPTS=-Xms512m -Xmx512m
volumes:
- ./data1:/usr/share/elasticsearch/data
extra_hosts:
- "elasticsearch-1:172.18.41.8"
- "elasticsearch-2:172.18.41.2"
- "elasticsearch-3:172.18.41.3"
# networks:
# - elasticsearch-bridge
elasticsearch-2:
image: swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/elasticsearch:8.8.0
restart: always
ports:
- 9211:9211
- 9300:9300
privileged: true
environment:
- node.name=es02 # 节点名称,唯一
- network.host=0.0.0.0 # 节点IP,单节点时候可以不需要
- network.publish_host=172.18.41.2 # 发布地址
- cluster.name=vpclub-log # 集群名称,集群一致
- cluster.initial_master_nodes=es01,es02,es03 # 集群节点成员
- discovery.seed_hosts=elasticsearch-1,elasticsearch-3 # 从指定主机发现
- xpack.security.enabled=false # xpack 安全设置
- xpack.security.http.ssl.enabled=false # xpack 安全设置
# - discovery.type=single-node # 单节点
- ES_JAVA_OPTS=-Xms512m -Xmx512m
volumes:
- ./data2:/usr/share/elasticsearch/data
extra_hosts:
- "elasticsearch-1:172.18.41.8"
- "elasticsearch-2:172.18.41.2"
- "elasticsearch-3:172.18.41.3"
# networks:
# - elasticsearch-bridge
elasticsearch-3:
image: swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/elasticsearch:8.8.0
restart: always
ports:
- 9211:9211
- 9300:9300
privileged: true
environment:
- node.name=es03 # 节点名称,唯一
- network.host=0.0.0.0 # 节点IP,单节点时候可以不需要
- network.publish_host=172.18.41.3 # 发布地址
- cluster.name=vpclub-log # 集群名称,集群一致
- cluster.initial_master_nodes=es01,es02,es03 # 集群节点成员
- discovery.seed_hosts=elasticsearch-2,elasticsearch-1 # 从指定主机发现
- xpack.security.enabled=false # xpack 安全设置
- xpack.security.http.ssl.enabled=false # xpack 安全设置
# - discovery.type=single-node # 单节点
- ES_JAVA_OPTS=-Xms512m -Xmx512m
volumes:
- ./data3:/usr/share/elasticsearch/data
extra_hosts:
- "elasticsearch-1:172.18.41.8"
- "elasticsearch-2:172.18.41.2"
- "elasticsearch-3:172.18.41.3"
# networks:
# - elasticsearch-bridge
networks:
elasticsearch-bridge :
external:
name: elasticsearch-bridge
# docker network create --subnet=172.19.1.1/24 --gateway 172.19.1.1 elasticsearch-bridge
# groupadd elasticsearch # 增加用户组
# useradd elasticsearch -g elasticsearch -p codingwhy$@ # 增加用户
# chown -R elasticsearch:elasticsearch data1/ # 修改权限
# chmod 755 data1/ # 修改权限
# vi /etc/sysctl.conf
# vm.max_map_count=262144 # 设置进程拥有的内存大小,永久生效
# sysctl -w vm.max_map_count=262144 # 设置进程拥有的内存大小,一次生效
测试服务状态
# curl localhost:9200/_cluster/health?pretty
{
"cluster_name" : "wuxue-ny",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}