Docker安装ElasticSearch
docker compose 安装直接看步骤三:新建索引
1、安装elasticsearch
(1)下载elasticsearch和kibana
docker pull elasticsearch:7.9.1
docker pull kibana:7.9.1
(2)配置
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
echo "http.host: 0.0.0.0" >/mydata/elasticsearch/config/elasticsearch.yml
# 设置为 777 权限
chmod -R 777 /mydata/elasticsearch/
(3)启动Elastic search
docker run --name elasticsearch --restart=always -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.9.1
(4)启动kibana(打开kibana的页面时,请一定不要使用ie浏览器,这个很重要!!!)
docker run --name kibana --restart=always --link elasticsearch:elasticsearch -p 5601:5601 -d kibana:7.9.1
2、安装IK
IK项目地址:https://github.com/medcl/elasticsearch-analysis-ik
首先需要说明的是,IK插件必须和 ElasticSearch 的版本一致,否则不兼容。
本系统采用的ElasticSearch版本为7.9.1
安装
-
方法1:在线安装
#进入容器 docker exec -it elasticsearch /bin/bash#下载 elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.9.1/elasticsearch-analysis-ik-7.9.1.zip#退出并重新启动ElasticSearch exit docker restart elasticsearch
-
方法2:离线安装
从 https://github.com/medcl/elasticsearch-analysis-ik/releases 下载压缩包,然后在ES的plugins目录创建analysis-ik子目录,把压缩包的内容复制到这个目录里面即可。最终plugins/analysis-ik/目录里面的内容:
plugins/analysis-ik/
config
commons-codec-1.9.jar
commons-logging-1.2.jar
elasticsearch-analysis-ik-6.2.4.jar
httpclient-4.5.2.jar
httpcore-4.4.4.jar
plugin-descriptor.properties
然后重启 ElasticSearch。可参考https://www.cnblogs.com/szwdun/p/10664348.html