elasticsearch入门到放弃之x-pack安全认证
2019-07-03 本文已影响2人
zhaoyunxing
基于docker构建的代码地址:https://github.com/zhaoyunxing92/docker-case/tree/develop/elasticsearch 可以直接使用,我下面也是按照这个写的这个文档
相关文章
为什么开启x-pack
肯定是为了安全啊,再者我就是因为开启了x-pack
后跟spring boot整合出现了问题,后面到spring boot了我再细说,先看怎么开启和配置吧,下面是默认你看过了elasticsearch入门到放弃之搭建,如果没有就先看下
启动服务
docker-compose -f es-cluster.yml up -d
开启tral license
不想使用curl或者有
postman
的可以导入es.postman.json文件,并且设置下url
变量就可以使用
curl -H "Content-Type:application/json" -XPOST http://127.0.0.1:9200/_xpack/license/start_trial?acknowledge=true
控制台成功日志
[2019-07-01T11:26:33,611][INFO ][o.e.l.LicenseService ] [node-data-1] license [8c9e65ae-a727-4fa3-ab05-f690cf882a87] mode [trial] - valid
进入容器设置密码
# docker 进入容器
docker exec -it es1 /bin/bash
# 修改密码
[root@g50 elasticsearch]# bin/elasticsearch-setup-passwords interactive
elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user 等密码一起修改的
修改elasticsearch.yml配置
xpack.security.enabled: true
可以先开启,elasticsearch入门到放弃之搭建我是先开启的
xpack.security.enabled: true
docker重启服务
docker-compose -f es-cluster.yml restart
到这里x-pack就算开启了地址了访问:http://127.0.0.1:9201发现需要密码了
修改密码
postman需要设置
Authorization
选择Basic Auth
并且填写用户名密码
curl -XPUT --user elastic:容器设置的密码 'http://127.0.0.1:9201/_xpack/security/user/elastic/_password' -H "Content-Type:application/json" -d '{ "password" : "111111" }'
最后
如果你想了解更多的文章可以微信搜索zhaoyx92
,或者扫码关注.别抱有太高期望,更新很慢的
