码迷,mamicode.com
首页 > 其他好文 > 详细

docker-compose安装elasticsearch

时间:2020-06-04 16:51:21      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:blog   查看   services   dep   yml   from   xms   pac   cas   

单节点安装

创建es.yml,内容如下:

version: ‘3‘
services:
  elasticsearch:
    image: elasticsearch:6.6.2
    container_name: elasticsearch
    environment:
      - cluster.name=elasticsearch-cluster
      - node.name=node0
      - node.master=true
      - node.data=true
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ports:
    - 9200:9200
    - 9300:9300

启动容器:
docker-compose -f es.yml up -d

  • -f 指定文件
  • -d 后台运行

查看日志:
docker-compose -f elasticsearch

创建带ik插件镜像

创建es-ik.yml,内容如下:

FROM elasticsearch:6.6.2
ENV VERSION=6.6.2

# https://github.com/medcl/elasticsearch-analysis-ik/releases
ADD https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v${VERSION}/elasticsearch-analysis-ik-$VERSION.zip /tmp/
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install -b file:///tmp/elasticsearch-analysis-ik-$VERSION.zip

RUN rm -rf /tmp/*

创建镜像:
docker build -t es-ik:6.6.2 -f es-ik.yml .

  • -t 指定名字和标签
  • -f 指定文件
  • . 指定上下文环境,不要漏掉

查看镜像:
docker image ls

技术图片

集群安装

创建esclu.yml,集成kibana管理.内容如下:

version: ‘3‘
services:
  elasticsearch_n0:
    image: elasticsearch:6.6.2 # 或者使用es-ik:6.6.2镜像↑
    container_name: elasticsearch_n0
    privileged: true
    environment:
      - cluster.name=elasticsearch-cluster
      - node.name=node0
      - node.master=true
      - node.data=true
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch_n0,elasticsearch_n1,elasticsearch_n2"
      - "discovery.zen.minimum_master_nodes=2"
    ports:
      - 9200:9200
      - 9300:9300
  elasticsearch_n1:
    image: elasticsearch:6.6.2
    container_name: elasticsearch_n1
    privileged: true
    environment:
      - cluster.name=elasticsearch-cluster
      - node.name=node1
      - node.master=true
      - node.data=true
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch_n0,elasticsearch_n1,elasticsearch_n2"
      - "discovery.zen.minimum_master_nodes=2"
    ports:
      - 9201:9200
      - 9301:9300
  elasticsearch_n2:
    image: elasticsearch:6.6.2
    container_name: elasticsearch_n2
    privileged: true
    environment:
      - cluster.name=elasticsearch-cluster
      - node.name=node2
      - node.master=true
      - node.data=true
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch_n0,elasticsearch_n1,elasticsearch_n2"
      - "discovery.zen.minimum_master_nodes=2"
    ports:
      - 9202:9200
      - 9302:9300
  kibana:
    image: kibana:6.6.2
    container_name: kibana
    environment:
      - SERVER_NAME=kibana
      - ELASTICSEARCH_URL=http://elasticsearch_n0:9200
      - XPACK_MONITORING_ENABLED=true
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch_n0

启动容器:
docker-compose -f esclu.yml up -d

查看启动

使用elasticsearch-headkibana都可以

elasticsearch-head

elasticsearch-head最简单操作,安装chrom插件,免去其他多余操作.输入 http://192.168.183.220:9200/ 连接即可

技术图片

kibana

访问 http://192.168.183.220:5601/ 找到DEV TOOLS

技术图片

参考:

docker-compose安装elasticsearch

标签:blog   查看   services   dep   yml   from   xms   pac   cas   

原文地址:https://www.cnblogs.com/linyufeng/p/13044543.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!