将要设置的密码进行base64编码
>>echo -n test:test | openssl dgst -binary -sha1 | openssl base64
>>V28q/NynI4JI3Rk54h0r8O5kMug=
[zk: localhost:2181] create /digest user
[zk: localhost:2181] setAcl /digest digest:test:V28q/NynI4JI3Rk54h0r8O5kMug==:rwadc
[zk: localhost:2181] getAcl /digest
[zk: localhost:2181] addauth digest user:passwd
SuperDigest超级管理员
superDigest设置的步骤
修改zkServer.sh,加入super权限设置
SUPER_ACL="-Dzookeeper.DigestAuthenticationProvider.superDigest=super:gG7s8t3oDEtIqF6DM9LlI/R+9Ss="
重新启动Zookeeper
# ./zkServer.sh restart
使用super:super进行认证:
[zk: localhost:2181] ls /test
Authentication is not valid : /test
[zk: localhost:2181) ] addauth digest super:super
[zk: localhost:2181) ] ls /test
[]
[zk: localhost:2181)] get /test