MacOS上基于Docker配置ElasticSearch+Kibana+IK分词器

版本

系统:MacOS ElasticSearch:7.6.0 kibana:7.5.1 IK:7.6.0

准备

  1. 需要电脑已经安装好Docker、docker-compose。
  2. 需要下载IK分词器zip压缩包。地址是: https://github.com/medcl/elasticsearch-analysis-ik/releases, 下载V7.6.0版本。

docker-compose 启动es和kibana

version: '2.2'
services:
  es01:
    image: elasticsearch:7.6.0
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=es-docker-cluster
      - cluster.initial_master_nodes=es01
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic

  kibana:
    image: kibana:7.5.1
    container_name: kibana
    restart: always
    ports:
      - "5601:5601"
    environment:
      I18N_LOCALE: zh-CN 
    networks:
      - elastic
    links:
      - es01:elasticsearch
volumes:
  data01:
    driver: local
networks:
  elastic:
    driver: bridge

添加Ik中文分词器

#进入容器内
docker exec -it es01 /bin/bash
# 安装unzip
yum install unzip
#创建文件夹
mkdir /usr/share/elasticsearch/plugins/ik
#新建一个窗口,拷贝本地的IK压缩包到docker容器内部,就是上一步建立的文件夹内
docker cp /Users/huangweixiang/Downloads/elasticsearch-analysis-ik-7.6.0.zip es01:usr/share/elasticsearch/plugins/ik
#解压
unzip elasticsearch-analysis-ik-7.6.0.zip
#删除压缩包
rm -rf elasticsearch-analysis-ik-7.6.0.zip

#重启es容器
docker restart es01

#查看容器状态,up状态就是正常的,exit状态就证明某个步骤错了,查看一下日志具体问题具体分析
docker ps -a

测试

访问两个地址:

localhost:9200 localhost:5601

Reference

https://juejin.im/post/5ca0d12c518825550b35be6d

https://blog.csdn.net/u012211603/article/details/90757253