赞
踩
提示:以下是本篇文章正文内容,下面案例可供参考
docker pull elasticsearch:7.10.1
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
#注意:http.host: 0.0.0.0 冒号后有一空格。
echo "http.host: 0.0.0.0" >>/mydata/elasticsearch/config/elasticsearch.yml
#文件夹赋权
chmod -R 777 /mydata/elasticsearch/
docker run --name elasticsearch -p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx128m" \
-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.10.1
-e “discovery.type=single-node”:单例模式
-e ES_JAVA_OPTS=“-Xms64m -Xmx128m”:配置内存大小
docker update elasticsearch --restart=always
docker exec -it elasticsearch /bin/bash
cd /usr/share/elasticsearch/plugins/
提示:我用方法一报javax.net.ssl.SSLException异常了,所以采用方法二
提示:ik分词器版本要和elasticsearch版本一致
方法一:
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.10.1/elasticsearch-analysis-ik-7.10.1.zip
方法二:
- 先使用
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.10.1/elasticsearch-analysis-ik-7.10.1.zip
下载压缩包;- 上传到Liunx服务器,
/mydata/elasticsearch/ik
目录下;- 将Ik压缩包拷贝到docker容器内,语法:docker cp /Linux目录 容器名/ID:docker容器内部路径,执行以下命令:
docker cp /mydata/elasticsearch/ik/elasticsearch-analysis-ik-7.10.1.zip elasticsearch:/usr/share/elasticsearch
- 安装插件,执行下面命令
elasticsearch-plugin install file:/usr/share/elasticsearch/elasticsearch-analysis-ik-7.10.1.zip
exit
docker restart elasticsearch
docker pull mobz/elasticsearch-head:5
docker run -d -p 9100:9100 docker.io/mobz/elasticsearch-head:5
docker exec -it elasticsearch /bin/bash
vim ./config/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
docker restart elasticsearch
# 1. 查看elasticsearch版本
docker images
# 2. 拉取kibana镜像
docker pull kibana:7.10.1
# 1. 方法一
docker run -di --name kibana -p 5601:5601 --link elasticsearch:elasticsearch --restart=always kibana:7.10.1
或
# 2. 方法二
docker run -di --name kibana -p 5601:5601 -e ELASTICSEARCH_URL=http://XXX.XXX.XXX.XXX:9200 --restart=always kibana:7.10.1
- –restart=always: 开机启动
- –link:elasticsearch和kibana在同一docker下 --link 后面可以直接写elasticsearch:elasticsearch的容器名
- -e ELASTICSEARCH_URL=http://ES的IP:9200: 设置Kibana连接的Elasticsearch的地址
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。