我就静静地看着你,不说话~

CentOS-Docker安装Elasticsearch(单点)

下载镜像

$ docker pull elasticsearch:7.6.0

运行镜像

$ docker run --restart=always --name elasticsearch -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.0

安装kibana

$ docker run --restart=unless-stopped --name kibana --link elasticsearch:elasticsearch -d -p 5601:5601 kibana:7.6.0

安装elasticsearch-head

docker run --restart=unless-stopped --name es-head --link elasticsearch:elasticsearch -d -p 9100:9100 mobz/elasticsearch-head:5

处理跨域

进入容器内部
$ docker exec -it elasticsearch bash

修改配置文件(追加设置)

$ vi config/elasticsearch.yml

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

 

安装分词插件(可选)

进入容器内部
$ docker exec -it elasticsearch bash

安装IK分词

$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.0/elasticsearch-analysis-ik-7.6.0.zip

安装拼音分词

$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v7.6.0/elasticsearch-analysis-pinyin-7.6.0.zip

安装结巴分词(非官方支持)

参考: https://github.com/sing1ee/elasticsearch-jieba-plugin

 

退出容器,重启es

$ docker restart elasticsearch

 

ES测试地址

http://localhost:9200

 

es-head测试地址

http://localhost:9100

解决es-head查询报错

$ docker cp es-head:/usr/src/app/_site/vendor.js /home/

编辑vendor.js两处

6886行
contentType: "application/x-www-form-urlencoded
改成
contentType: "application/json;charset=UTF-8"

7574行
var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
改成
var inspectData = s.contentType === "application/json;charset=UTF-8" &&

$ docker cp /home/vendor.js es-head:/usr/src/app/_site/

$ docker restart es-head

posted @ 2020-08-03 19:07  自由人生™  阅读(128)  评论(0编辑  收藏  举报