感謝此老兄:《手把手教你搭建一個 Elasticsearch 集群》
前提准備
安裝kibana-6.7.0: 《Elasticsearch-6.7.0系列(三)5601端口 kibana——ES的UI界面》
升級前ES的license
升級之前訪問:http://192.168.10.110:9200/_xpack 其中security一項內容如下:
security description "Security for the Elastic Stack" available false enabled true
在kibana中升級license
在 Kibana 中訪問 Management -> Elasticsearch -> License Management,點擊右側的升級 License 按鈕,可以免費試用 30 天的高級 License,升級完成之后kibana頁面會顯示如下:
修改ES配置文件
elasticsearch-6.7.0/config/elasticsearch.yml 添加如下配置:
xpack.security.enabled: true xpack.ml.enabled: true xpack.license.self_generated.type: trial //表示試用的意思
設置集群密碼
./bin/elasticsearch-setup-passwords interactive 設置集群密碼:
總共修改了6個用戶的密碼:elastic、kibana、apm_system、logstash_system、beats_system、remote_monitoring_user。
修改kibana配置文件
vim kibana-6.7.0-linux-x86_64/config/kibana.yml,設置正確的ES訪問用戶名密碼:
elasticsearch.username: "elastic" elasticsearch.password: "123456"
修改配置之后,記得重啟ES!!! 以及,kibana!!!
ES啟動時,license信息由原來的:
[2019-06-08T07:11:26,598][INFO ][o.e.l.LicenseService ] [MiIzYdB] license [33b7d4ab-ee0c-4a48-9f18-30c9e11ec47a] mode [basic] - valid
變為trial試用期:
019-06-08T04:12:13,998][INFO ][o.e.l.LicenseService ] [node-130] license [cf9606b3-5e36-4fdd-9469-587ddb323a62] mode [trial] - valid
ES集群訪問使用密碼
再訪問http://192.168.10.110:9200/_xpack 其中security一項內容如下:
security
description "Security for the Elastic Stack" available true //已經從false變為true了,表示security設置成功 enabled true
此時訪問ES: http://192.168.10.110:9200 需要用戶名和密碼了:
訪問kibana: http://192.168.10.110:5601 也需要用戶名密碼了:
PS:記住這個license只有30天試用期,時間到了之后要么購買,要么重新安裝ES(網上說重裝可行)。