拉取镜像
docker pull elasticsearch:7.4.2
docker pull kibana:7.4.2
创建存储数据的目录
mkdir -p /home/lab1018/docker_volume/elasticsearch/config
mkdir -p /home/lab1018/docker_volume/elasticsearch/data
mkdir -p /home/lab1018/docker_volume/elasticsearch/plugins
# 随便外网都可以访问它
cd /home/lab1018/docker_volume/elasticsearch/config
echo "http.host: 0.0.0.0" >> /home/lab1018/docker_volume/elasticsearch/config/elasticsearch.yml
后台运行容器并映射配置文件
# -e ES_JAVA_OPTS="-Xms64m -Xmx512m" \ 一定要加上,不让内存就那个啥了.... 自己学习测试64-128m够了,公司起码32G...
docker run --name es -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx512m" \
-v /home/lab1018/docker_volume/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/lab1018/docker_volume/elasticsearch/data:/usr/share/elasticsearch/data \
-v /home/lab1018/docker_volume/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.4.2
# kibana的安装
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://YourIp:9200 -p 5601:5601 \
-d kibana:7.4.2
测试是否成功,访问 http://YourIp:9200/
和
http://YourIp:5601/app/kibana
Ik分词器
进入已经启动成功的elasticsearch容器。
docker exec -it elasticsearch /bin/bash
安装
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.4.2/elasticsearch-analysis-ik-7.4.2.zip