公司最近使用es 本地搭一套走起。
docker如果没有可以自行下载(https://www.runoob.com/docker/centos-docker-install.html)
一、es安装
1、下载es
docker pull docker.elastic.co/elasticsearch/elasticsearch:5.5.3 (注意版本、最好和公司的一致)
2、启动镜像
docker run -d --name es -p 9200:9200 -p 9300:9300 -e “discovery.type=single-node” docker.elastic.co/elasticsearch/elasticsearch:5.5.3
3、http://localhost:9200/ 搞定。。
4、用户名密码?
或许你正在疑惑为什么要用户名密码。因为在下载es时,这个镜像自带了x-pack 插件。
插件x-pack默认密码 :
用户名 | 密码 |
---|---|
elastic | changeme |
kibana | changeme |
logstash_system | changeme |
**
二、插件安装
插件可以在plugins目录下看到
1、docker exec -it es /bin/bash
2、cd plugins
1、elasticsearch-head安装
- 拉取镜像 docker pull mobz/elasticsearch-head:5
- 运行 docker run -d --name es_admin -p 9100:9100 mobz/elasticsearch-head:5
- http://localhost:9100/ 如果安装了x-pack http://localhost:9100/?auth_user=elastic&auth_password=changeme
**
2、ik分词器安装
下载ik分词器 注意版本 (https://github.com/medcl/elasticsearch-analysis-ik/releases?after=v5.5.3) 可以找这个网站上找对应的
- 进入命令行 docker exec -it es /bin/bash
- 下载 elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.3/elasticsearch-analysis-ik-5.5.3.zip
- 重启 docker restart es
三、其他问题
1、跨域问题
- docker exec -it es /bin/bash
- 进入配置文件夹 cd config
- 修改配置文件 vi elasticsearch.yml
- 加入跨域配置
http.cors.enabled: true
http.cors.allow-origin: “*”
2、如果版本安装错误怎么办 卸载
我公司用的5.5.3 刚开始下载了个6X
elasticsearch6以后不允许一个索引下创建多个类型 所以尴尬。。。。卸载之
卸载 https://www.cnblogs.com/satanmagician/p/9870366.html