基於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
,或者掃碼關注.別抱有太高期望,更新很慢的