es配置用户认证

es版本:6.3.2

查看许可状态



可以看到是basic,需要启用 trial license

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

然后在elasticsearch.yml文件中增加如下配置:

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

重启es,然后执行.\elasticsearch-setup-passwords.bat interactive设置密码。
如果没加xpack的配置,直接设置密码会报错,如下:

Unexpected response code [403] from calling GET http://*.*.*.*:9200/_xpack/security/_authenticate?pretty
It doesn't look like the X-Pack security feature is available on this Elasticsearch node.
Please check if you have installed a license that allows access to X-Pack Security feature.

ERROR: X-Pack Security is not available.

执行.\curl.exe http://:测试连接,报错,连接失败。
然后再执行.\curl.exe http://: -u elastic:连接成功。
或者也可以直接浏览器访问http://:验证结果。

你可能感兴趣的:(es配置用户认证)