sudo docker pull elasticsearch:7.12.0
sudo docker images
mkdir /home/zx/es_docker
cd es_docker
mkdir logs config plugins data
chmod -R 777 es_docker
http.host: 0.0.0.0
# Uncomment the following lines for a production cluster deployment
#transport.host: 0.0.0.0
#inimum_master_nodes: 1
#Password config
# 开启密码验证
abled: true
s.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
##不添加无法使用head插件连接es,连接时在http:ip:port/?auth_user=elastic&auth_password=密码
s.allow-headers: Content-Type,Accept,Authorization, x-requested-with
由于是yml文件配置,所以host后面的冒号,必须空格后才能输入0.0.0.0。也就是后面的ip地址前面需要空格。
sudo docker run --privileged=true --name elasticsearch -p 9200:9200 -p 9300:9300 -e pe=single-node" -e ES_JAVA_OPTS="-Xms84m -Xmx512m" -v /home/zx/es_docker/l:/usr/share/elasticsearch/l -v /home/zx/es_docker/data:/usr/share/elasticsearch/data -v /home/zx/es_docker/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:7.12.0
sudo docker run --privileged=true #授予逻辑卷访问权--name elasticsearch -p 9200:9200 #端口映射配置 -p 9300:9300 -e pe=single-node" #非集群模式-e ES_JAVA_OPTS="-Xms84m -Xmx512m" #内存大小-v /home/zx/es_docker/l:/usr/share/elasticsearch/l #挂载逻辑卷,绑定elasticsearch的配置文件-v /home/zx/es_docker/data:/usr/share/elasticsearch/data #挂载逻辑卷,绑定elasticsearch的数据目录-v /home/zx/es_docker/plugins:/usr/share/elasticsearch/plugins #挂载逻辑卷,绑定elasticsearch的件目录-d elasticsearch:7.12.0
sudo docker ps -a
sudo docker logs elasticsearch
sudo docker exec -it elasticsearch bash
cd /bin
elasticsearch-setup-passwords interactive #此步为手动设置密码#以下不是命令
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]yEnter password for [elastic]: #在这里设置密码,注意最少六位,下面也一样
Reenter password for [elastic]:
Passwords do not match.
Try again.
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana]:
Reenter password for [kibana]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
docker pull mobz/elasticsearch-head:5
sudo docker run -d --name es-head -p 9100:9100 docker.io/mobz/elasticsearch-head:5
执行docker命令后,也可以使用docker ps -a来查看是否成功启动。不过更好的方式是和es服务链接上。
因此接下来首先需要修改es的config目录的配置文件l,在其后面增加两行语句:
abled: true
s.allow-origin: "*"
##不添加无法使用head连接es,连接时在http:ip:port/?auth_user=elastic&auth_password=密码
s.allow-headers: Content-Type,Accept,Authorization, x-requested-with#主要目的就是允许跨域请求。#由于修改了配置文件,所以需要重启一下es的服务。直接运行如下语句:
docker restart elasticsearch
输入
ip:port/?auth_user=elastic&auth_password=密码
curl -u elastic -H "Content-Type: application/json" -X POST "localhost:9200/_xpack/security/user/elastic/_password" --data '{"password":"新密码"}'
本文发布于:2024-02-02 15:53:02,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170686038144836.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |