1、创建3个node节点并授权,es集群至少需要3个节点,防止脑裂
# 创建node目录 mkdir -p /data/es/data/node1/data mkdir -p /data/es/data/node2/data mkdir -p /data/es/data/node3/data # 授权node目录 chmod 777 /data/es/data/node1/data chmod 777 /data/es/data/node2/data chmod 777 /data/es/data/node3/data
2、修改 sysctl.conf 文件
# 修改sysctl.conf,解决 max virtual memory areas vm.max_map_count [65530] is too low 问题 vi /etc/sysctl.conf # 在最后添加一行 vm.max_map_count=655300 # 使文件生效 sysctl -p /etc/sysctl.conf
3、创建docker-compose.yaml
version: '2.2' services: es01: image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 container_name: es01 environment: - node.name=es01 - cluster.name=es-cluster - discovery.seed_hosts=es02,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" ulimits: memlock: soft: -1 hard: -1 volumes: - /data/es/data/node1/data:/usr/share/elasticsearch/data - /data/es/ik:/usr/share/elasticsearch/plugins/ik ports: - 9201:9200 networks: - elastic es02: image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 container_name: es02 environment: - node.name=es02 - cluster.name=es-cluster - discovery.seed_hosts=es01,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" ulimits: memlock: soft: -1 hard: -1 volumes: - /data/es/data/node2/data:/usr/share/elasticsearch/data - /data/es/ik:/usr/share/elasticsearch/plugins/ik ports: - 9202:9200 networks: - elastic es03: image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 container_name: es03 environment: - node.name=es03 - cluster.name=es-cluster - discovery.seed_hosts=es01,es02 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" ulimits: memlock: soft: -1 hard: -1 volumes: - /data/es/data/node3/data:/usr/share/elasticsearch/data - /data/es/ik:/usr/share/elasticsearch/plugins/ik ports: - 9203:9200 networks: - elastic networks: elastic: driver: bridge
4、启动es集群
# 启动 docker-compose up -d # 查看启动状态 docker ps -a # 查看日志命令,es01代表其中一个node节点 docker logs es01
标签:compose,name,cluster,elasticsearch,es01,docker,data,es From: https://www.cnblogs.com/awks/p/18659499