1、安装es和ik分词器
创建映射目录并赋予权限:
mkdir -p /docker_data/elasticsearch/conf
mkdir -p /docker_data/elasticsearch/data
mkdir -p /docker_data/elasticsearch/plugins
chmod -R 777 /docker_data/elasticsearch
编写配置文件:
vi /docker_data/elasticsearch/conf/elasticsearch.yml
http.host: 0.0.0.0
xpack.security.enabled: true
上传ik分词器并解压至/docker_data/elasticsearch/plugins/ik
下载地址:https://gitcode.com/medcl/elasticsearch-analysis-ik/tags
运行es
docker run --name elasticsearch --restart=always \
-p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms128m -Xmx256m" \
-v /docker_data/elasticsearch/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /docker_data/elasticsearch/data:/usr/share/elasticsearch/data \
-v /docker_data/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:6.5.0
进入容器内,配置用户名密码:
docker exec -it elasticsearch /bin/bash
./bin/elasticsearch-setup-passwords interactive
2、安装kibana
mkdir -p /docker_data/kibana/config
编写配置文件:
vi /docker_data/kibana/conf/kibana.yml
---
# Default Kibana configuration from kibana-docker.
server.name: kibana
server.host: "0"
elasticsearch.url: http://192.168.0.114:9200
xpack.monitoring.ui.container.elasticsearch.enabled: true
# 用户密码
elasticsearch.username: "elastic"
elasticsearch.password: "你设置的密码"
http.host: 0.0.0.0
xpack.security.enabled: true
运行kibana:
docker run -d --name kibana --restart=always -p 5601:5601 -v /docker_data/kibana/config:/usr/share/kibana/config docker.elastic.co/kibana/kibana:6.5.0