elasticsearch shield(5.0以下版本 权限认证)

elasticsearch 5.0以下的版本要用到权限控制的话需要使用shield。下载地址: https://www.elastic.co/downloads/shield
5.0以上的版本则可以使用X-Pack,shield现在只是x-pack的一部分。x-pack包含了Shield, Watcher, Marvel, Graph, reporting。下载地址:https://www.elastic.co/downloads/x-pack

elasticsearch shield安装和配置
elasticsearch 和 shield的版本需要一致
安装方式
1.在线。
进入到elasticsearch的bin目录,执行
plugin install license
plugin install shield
2.离线,下载好对应版本的shield
https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/license/2.4.0/license-2.4.0.zip
https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/shield/2.4.0/shield-2.4.0.zip
下载的文件不要放到elasticplugin的目录下
执行命令:
plugin install file:///path/to/file/license-2.4.0.zip
plugin install file:///path/to/file/shield-2.4.0.zip
路径必须是绝对路径,例如 plugin install file:///e:softelasticsearchlicense-2.4.0.zip
重启完es后就有权限认证了。

添加用户
安装完上面的两个插件后,bin目录下会多一个shield目录。
cd 进入shield目录。执行 esusers useradd [username] -r admin (username:用户名,-r admin 是指定角色为admin)
然后按照提示输入密码
查看用户
esusers list (列出所有用户及角色)
修改密码
esusers passwd gavin (修改用户gavin的密码)
删除用户
esusers userdel gavin (删除用户gavin)
给用户添加角色
esusers roles gavin -a admin (给用户xiangyang添加admin的角色)
命令帮助
esusers -h

原文地址:https://www.cnblogs.com/gavinYang/p/11199699.html