docker-compose集成elasticsearch7.17.14+kibana7.17.14

1.docker和compose版本必须要高

2.准备ik分词器(elasticsearch-analysis-ik-7.17.14),下面会用到

https://github.com/infinilabs/analysis-ik/releases?page=2

3.配置es-compose.yml(切记映射容器内路径不能更改,es和kibana服务自动生成的路径)

bash 复制代码
services:
#es服务
  elasticsearch:
    image: elasticsearch:7.17.14
    restart: always
    #hostname: es1
    container_name: elasticsearch
    volumes:
      - /home/planetflix/elasticsearch/data:/usr/share/elasticsearch/data
      - /home/planetflix/elasticsearch/logs:/usr/share/elasticsearch/logs
      - /home/planetflix/elasticsearch/plugins:/usr/share/elasticsearch/plugins
      - /home/planetflix/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    environment:
      TZ: America/New_York
      discovery.type: single-node
      ES_JAVA_OPTS: "-Xmx2000m -Xms2000m"
      LANG: en_US.UTF-8
    ulimits:        
      memlock:
        soft: -1    
        hard: -1    
    ports:
      - 9200:9200     #java、集群通信端口
      - 9300:9300     #http通信端口
    networks:
      - es_net
#es可视化工具
  kibana:
    image: kibana:7.17.14
    container_name: kibana
    environment:
      TZ: America/New_York
      LANG: en_US.UTF-8
    restart: always
    volumes:
      - /home/planetflix/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
      - /home/planetflix/kibana/logs:/usr/share/kibana/logs
    ports:
      - "5601:5601"
    depends_on:
      - elasticsearch
    links:
      - elasticsearch
    networks:
      - es_net

4.配置elasticsearch.yml

bash 复制代码
cluster.name: "elasticsearch"
http.port: 9200
network.host: 0.0.0.0
# 开启es跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,Content-Type
# 设置密码 https://www.elastic.co/guide/en/elasticsearch/reference/7.14/security-minimal-setup.html
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

5.配置kibana.yml

bash 复制代码
#Default Kibana configuration for docker target
server.name: kibana
server.publicBaseUrl: "http://服务器ip或域名:5601"
server.host: '0.0.0.0'
elasticsearch.hosts: ['http://elasticsearch:9200']
elasticsearch.username: 'elastic'
elasticsearch.password: '123456'
# # 语言
i18n.locale: "zh-CN"

6.启动服务,初始化密码

1.启动es和kibana

bash 复制代码
docker-compose -f es-compose.yml --compatibility up -d elasticsearch
docker-compose -f es-compose.yml --compatibility up -d kibana
bash 复制代码
docker exec -it es容器 /bin/bash

2.进入bin目录,执行命令,回车后密码全部一致,只需要重启kibana即可

bash 复制代码
elasticsearch-setup-passwords interactive -u 'http://elasticsearch:9200'

7.访问es和kibana服务

8.配置分词器

将上面下载到的elasticsearch-analysis-ik-7.17.14.tar放入以上es-compose.yml里面配置路径

/home/planetflix/elasticsearch/plugins下面解析重命名为ik

使用docker-compose重启es服务

9.使用kibana开发者工具测试

进入kibana页面点击Management目录>开发工具

相关推荐
Java陈序员8 小时前
轻量强大!一款现代化的 Kubernetes 集群管理与监控工具!
云原生·容器·kubernetes
爱吃橘子橙子柚子1 天前
3CPU性能排查总结(超详细)【Linux性能优化】
运维·cpu
Sheffield2 天前
Docker的跨主机服务与其对应的优缺点
linux·网络协议·docker
Sheffield2 天前
Alpine是什么,为什么是Docker首选?
linux·docker·容器
马艳泽2 天前
win10下运行Start Broker and Proxy报错解决
docker
舒一笑3 天前
程序员效率神器:一文掌握 tmux(服务器开发必备工具)
运维·后端·程序员
NineData3 天前
数据库管理工具NineData,一年进化成为数万+开发者的首选数据库工具?
运维·数据结构·数据库
用户13573999256603 天前
Windows 从 0 搭建 WSL2 原生 AI 开发环境:Codex + Docker + VSCode
docker
vi_h3 天前
在 macOS 上通过 Docker 安装并运行 Ollama(详细可执行教程)
macos·docker·ollama
黑心老魔3 天前
通过 Docker 创建开发环境
docker·开发环境