目 录CONTENT

文章目录

Docker部署Es笔记

不争
2024-01-02 / 0 评论 / 0 点赞 / 52 阅读 / 2840 字

Docker部署Es笔记

1.创建ES集成IK分词器(本地虚拟机)

docker run -itd --name es --net host -v /home/gz/data/ik:/usr/share/elasticsearch/plugins/ik -e "discovery.type=single-node" -e "network.host=192.168.127.8" docker.elastic.co/elasticsearch/elasticsearch:7.17.7

net host

  • 不用暴露端口
  • 使用宿主机的网络
  • 网络性能发挥到极致

服务器

docker run -d \
   --name es\
    -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
    -e "discovery.type=single-node" \
    -v es-data:/usr/share/elasticsearch/data \
    -v /home/gz/data/es/ik:/usr/share/elasticsearch/plugins/ik \
    --privileged \
    --network itmentu-net \
    -p 9200:9200 \
    -p 9300:9300 \
docker.elastic.co/elasticsearch/elasticsearch:7.17.7

2.启动kibana

docker run -itd --name kb -p 5601:5601 -e "ELASTICSEARCH_HOSTS=http://154.204.60.38:9200" docker.elastic.co/kibana/kibana:7.17.7

访问:ip:5601

image-20231011200326552

3.集群部署

解除内存限制

vi /etc/sysctl.conf
vm.max_map_count=262144
sysctl -w vm.max_map_count=262144

创建docker-compose.yml文件

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.7
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es02
      - cluster.initial_master_nodes=es01,es02
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data01:/usr/share/elasticsearch/data
      - /home/gz/data/es/plugins:/usr/share/elasticsearch/plugins/
    ports:
      - 9200:9200
    networks:
      - es
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.7
    container_name: es02
    environment:
      - node.name=es02
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01
      - cluster.initial_master_nodes=es01,es02
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data02:/usr/share/elasticsearch/data
      - /home/gz/data/es/plugins:/usr/share/elasticsearch/plugins/
    networks:
      - es
volumes:
  data01:
    driver: local
  data02:
    driver: local
networks:
  es:
    driver: bridge

启动docker compose

docker compose up -d

查看启动日志

docker compose logs -f

0

评论区