elasticsearch
version: '3'
services:
elasticsearch-1:
image: swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/elasticsearch:8.8.0
restart: always
container_name: elasticsearch-1
privileged: true
ports:
- 9211:9200
- 9300:9300
environment:
- node.name=es01 # 节点名称,唯一
- network.host=0.0.0.0 # 节点IP,单节点时候可以不需要
- network.publish_host=172.16.2.106 # 发布地址
- 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.16.2.106"
- "elasticsearch-2:172.16.2.107"
- "elasticsearch-3:172.16.2.108"
networks:
- elasticsearch-bridge
elasticsearch-2:
image: swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/elasticsearch:8.8.0
restart: always
container_name: elasticsearch-2
privileged: true
ports:
- 9211:9200
- 9300:9300
environment:
- node.name=es02 # 节点名称,唯一
- network.host=0.0.0.0 # 节点IP,单节点时候可以不需要
- network.publish_host=172.16.2.107 # 发布地址
- 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.16.2.106"
- "elasticsearch-2:172.16.2.107"
- "elasticsearch-3:172.16.2.108"
networks:
- elasticsearch-bridge
elasticsearch-3:
image: swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/elasticsearch:8.8.0
restart: always
privileged: true
container_name: elasticsearch-3
ports:
- 9211:9200
- 9300:9300
environment:
- node.name=es03 # 节点名称,唯一
- network.host=0.0.0.0 # 节点IP,单节点时候可以不需要
- network.publish_host=172.16.2.108 # 发布地址
- 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.16.2.106"
- "elasticsearch-2:172.16.2.107"
- "elasticsearch-3:172.16.2.108"
networks:
- elasticsearch-bridge
networks:
elasticsearch-bridge:
external:
name: elasticsearch-bridge
测试服务状态
# 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
}
# 查看集群信息
# curl localhost:9211/_cluster/health?pretty
# curl localhost:9211/_cat/nodes?v
# curl localhost:9211/_cat/indices?v