docker安装elasticsearch,elasticsearch-head
安装elasticsearch
1、执行命令:docker pull elasticsearch:8.11.1
2、执行命令:docker run --name elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -d elasticsearch:8.11.1
3、执行命令:docker exec -it elastic /bin/bash
4、执行命令:cd bin
5、执行命令:elasticsearch-setup-passwords interactive
6、设置所有用户的用户名
7、执行命令:docker restart elastic
8、进入https://localhost:9200查看是否可以访问
添加中文分词ik
1、下载对应版本Releases · medcl/elasticsearch-analysis-ik · GitHub
2、解压文件到ik目录
3、上传文件到容器:docker cp d:\soft\ik elastic:\usr\share\elasticsearch\plugins\
4、重启:docker restart elastic
安装elasticsearch-head
1、docker pull mobz/elasticsearch-head:5
2、docker run --name elastic-head -p 9100:9100 -d mobz/elasticsearch-head:5
3、复制配置文件到本地修改:docker cp elastic:/usr/share/elasticsearch/config/elasticsearch.yml d:/
4、在文件末尾添加
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
5、上传文件:docker cp d:\elasticsearch.yml elastic:/usr/share/elasticsearch/config/
6、重启:docker restart elastic
7、连接:http://localhost:9100/?auth_user=elastic&auth_password=xxxxx