linux docker 安装elasticsearch设置密码,和安装Ik分词器

linux docker 安装elasticsearch设置密码,和安装Ik分词器

直接进入主题

1.拉取镜像

docker pull docker.elastic.co/elasticsearch/elasticsearch::版本号

2.创建并运行容器

docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:版本号

3.进入容器,修改config目录下的

docker exec -it es bash
cd config
vim elasticsearch.yml
3.1添加以下配置信息
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

3.2重启容器

exit
docker restart es
3.3启动设置密码命令的命令 (接下来就会让你输入密码注意不要输入弱口令密码)
docker exec -it es bash
cd bin
elasticsearch-setup-passwords interactive
exit
docker restart es

4.如果你要重新修改密码

这里会让你输入旧的密码即可

exit
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://47.254.19.211:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "new_password" }'

5.安装ik分词器

docker exec -it es bash
cd bin
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v版本号/elasticsearch-analysis-ik-版本号.zip
exit
docker restart es

大功告成!!!!

你可能感兴趣的:(Linux服务器运维,elasticsearch,docker,es)