zookeeper权限问题
对cdrwa的说明如上,网上一些博客乱写误导
参考链接:http://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html
这是在使用zkcli.sh进行操作时的输入;
使用java api进行调用如下:
@Test public void setAcl() throws Exception{ ZkClient zkclient = new ZkClient("localhost:2181"); List<ACL> acls = new ArrayList<ACL>(); Id id = new Id("digest", DigestAuthenticationProvider.generateDigest("zk:pwd?")); ACL acl = new ACL(ZooDefs.Perms.ALL, id); acls.add(acl); zkclient.create("/test4", "test3", acls, CreateMode.PERSISTENT); zkclient.close(); } @Test public void getAclData(){ ZkClient zkclient = new ZkClient("localhost:2181"); zkclient.addAuthInfo("digest", "zk:pwd?".getBytes()); String res = zkclient.readData("/test4"); System.out.println(res); zkclient.close(); }