栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

docker-compose 安装elasticsearch + kibana

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

docker-compose 安装elasticsearch + kibana

准备工作 1. 创建目录
# 创建目录
#es
mkdir -p /opt/apps/es/elasticsearch/config
mkdir -p /opt/apps/es/elasticsearch/data
mkdir -p /opt/apps/es/elasticsearch/plugins

# kibana
mkdir -p /opt/apps/es/kibana/config


2.创建配置文件    

vi /opt/apps/es/elasticsearch/config/elasticsearch.yml

http.port: 9200
http.host: 0.0.0.0

http.cors.enabled: true
http.cors.allow-origin: "*"

vi /opt/apps/es/kibana/config/elasticsearch.yml

server.name: kibana
# kibana的主机地址 0.0.0.0可表示监听所有IP
server.host: "0.0.0.0"
# kibana访问es的URL
elasticsearch.hosts: [ "http://localhost:9200" ]
#elasticsearch.username: 'kibana'
#elasticsearch.password: '123456'
# 显示登陆页面
#xpack.monitoring.ui.container.elasticsearch.enabled: true
# 语言
#i18n.locale: "zh-CN"

3.docker-compose

vi /opt/apps/es/docker-compose.yml

version: '3'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
    container_name: elasticsearch
    environment:
      - "discovery.type=single-node"
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    volumes:
      - ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./elasticsearch/data:/usr/share/elasticsearch/data 
      - ./elasticsearch/plugins:/usr/share/elasticsearch/plugins
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200:9200
      - 9300:9300
    restart: always
    network_mode: 'host'
  kibana:
    image: docker.elastic.co/kibana/kibana:7.9.3
    volumes:
      - ./kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
    environment:
      - ELASTICSEARCH_URL=http://localhost:9200
    ports:
      - 5601:5601
    restart: always
    network_mode: 'host'

4. 编写重启命令

vi /opt/apps/es/restart.sh

echo "===prepare docker registry==="
docker-compose stop
echo "===starting new docker-compose==="
docker-compose up -d
echo "===complete==="
5. 增加文件夹权限
chmod -R 777 /opt/apps/es/elasticsearch/data
6. 启动 es 和 kibana
sh /opt/apps/es/restart.sh
7. 访问

es:   http://ip:9200/

kibana:  http://ip:5601/

8. 安装IK分词器
# 进到es plugins的目录
cd /opt/apps/es/elasticsearch/plugins/

# 创建ik 目录
mkdir ik

# 进到ik
cd /opt/apps/es/elasticsearch/plugins/ik

# 下载分词器
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.9.3/elasticsearch-analysis-ik-7.9.3.zip

# 解压分词器
unzip elasticsearch-analysis-ik-7.9.3.zip

#重启es
docker restart 容器id


 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/706069.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号