1. 程式人生 > >elasticsearch6.3.1 啟用x-pack

elasticsearch6.3.1 啟用x-pack

前言

elasticsearch6.3.1安裝包中已經集成了x-pack外掛,無需使用elasticsearch-plugin install來安裝x-pack,我們需要做的是使x-pack工作

步驟:

1、執行elasticsearch

2、啟用trial license(30天試用)

curl -H "Content-Type:application/json" -XPOST  http://192.168.36.61:9200/_xpack/license/start_trial?acknowledge=true


可以看到elasticsearch控制檯顯示license 已變為trial

3、設定使用者名稱密碼

命令:bin/elasticsearch-setup-passwords interactive

修改密碼方式:

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

4、elasticsearch.yml中開啟安全驗證配置

此時訪問http://192.168.36.61:9200 並不需要輸入賬號密碼,需elasticsearch.yml中新增如下配置:

 xpack.security.enabled: true

head外掛訪問

首先在elasticsearch.yml中新增配置:

 http.cors.enabled: true
 http.cors.allow-origin: "*"
 http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type