Skip to content

Instantly share code, notes, and snippets.

@ekoontz
Created January 10, 2011 20:40
Show Gist options
  • Save ekoontz/773429 to your computer and use it in GitHub Desktop.
Save ekoontz/773429 to your computer and use it in GitHub Desktop.
zookeeper with SASL: demonstration session
ekoontz@ekoontz:~/zookeeper$ bin/zkCli.sh -server 192.168.56.1:2181
Connecting to 192.168.56.1:2181
2011-01-10 12:37:04,471 [myid:] - INFO [main:Environment@97] - Client environment:zookeeper.version=3.4.0--1, built on 01/09/2011 19:31 GMT
2011-01-10 12:37:04,474 [myid:] - INFO [main:Environment@97] - Client environment:host.name=192.168.0.104
2011-01-10 12:37:04,474 [myid:] - INFO [main:Environment@97] - Client environment:java.version=1.6.0_22
2011-01-10 12:37:04,475 [myid:] - INFO [main:Environment@97] - Client environment:java.vendor=Apple Inc.
2011-01-10 12:37:04,475 [myid:] - INFO [main:Environment@97] - Client environment:java.home=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
2011-01-10 12:37:04,475 [myid:] - INFO [main:Environment@97] - Client environment:java.class.path=bin/../build/classes:bin/../build/lib/netty-3.2.2.Final.jar:bin/../build/lib/log4j-1.2.15.jar:bin/../build/lib/jline-0.9.94.jar:bin/../zookeeper-*.jar:bin/../lib/*.jar:bin/../src/java/lib/ivy-2.1.0.jar:bin/../conf:
2011-01-10 12:37:04,475 [myid:] - INFO [main:Environment@97] - Client environment:java.library.path=.:/Users/ekoontz/Library/Java/Extensions:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
2011-01-10 12:37:04,476 [myid:] - INFO [main:Environment@97] - Client environment:java.io.tmpdir=/var/folders/Z4/Z4hb0nhlFYOWHGwBlQj88k+++TI/-Tmp-/
2011-01-10 12:37:04,476 [myid:] - INFO [main:Environment@97] - Client environment:java.compiler=<NA>
2011-01-10 12:37:04,476 [myid:] - INFO [main:Environment@97] - Client environment:os.name=Mac OS X
2011-01-10 12:37:04,476 [myid:] - INFO [main:Environment@97] - Client environment:os.arch=x86_64
2011-01-10 12:37:04,476 [myid:] - INFO [main:Environment@97] - Client environment:os.version=10.6.5
2011-01-10 12:37:04,476 [myid:] - INFO [main:Environment@97] - Client environment:user.name=ekoontz
2011-01-10 12:37:04,476 [myid:] - INFO [main:Environment@97] - Client environment:user.home=/Users/ekoontz
2011-01-10 12:37:04,477 [myid:] - INFO [main:Environment@97] - Client environment:user.dir=/Users/ekoontz/zookeeper
2011-01-10 12:37:04,478 [myid:] - INFO [main:ZooKeeper@379] - Initiating client connection, connectString=192.168.56.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@11a06e38
2011-01-10 12:37:04,518 [myid:] - INFO [main-SendThread():ClientCnxn$SendThread@954] - Opening socket connection to server /192.168.56.1:2181
Welcome to ZooKeeper!
2011-01-10 12:37:04,535 [myid:] - INFO [main-SendThread(ekoontz:2181):ClientCnxn$SendThread@897] - Socket connection established to ekoontz/192.168.56.1:2181, initiating session
JLine support is enabled
2011-01-10 12:37:04,620 [myid:] - INFO [main-SendThread(ekoontz:2181):ClientCnxn$SendThread@1129] - Session establishment complete on server ekoontz/192.168.56.1:2181, sessionid = 0x12d71a545010000, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: 192.168.56.1:2181(SASL_INITIAL) 0]
[zk: 192.168.56.1:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: 192.168.56.1:2181(CONNECTED) 1] create /mynode nodecontents sasl:testclient:cdwra
Created /mynode
[zk: 192.168.56.1:2181(CONNECTED) 2] getAcl /mynode
'sasl,'testclient
: cdrwa
[zk: 192.168.56.1:2181(CONNECTED) 3] get /mynode
nodecontents
cZxid = 0x2
ctime = Mon Jan 10 12:37:32 PST 2011
mZxid = 0x2
mtime = Mon Jan 10 12:37:32 PST 2011
pZxid = 0x2
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 12
numChildren = 0
[zk: 192.168.56.1:2181(CONNECTED) 4] create /notmynode notmynodecontents sasl:otheruser:cdrwa
Created /notmynode
[zk: 192.168.56.1:2181(CONNECTED) 5] getAcl /notmynode
'sasl,'otheruser
: cdrwa
[zk: 192.168.56.1:2181(CONNECTED) 6] get /notmynode
Exception in thread "main" org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth for /notmynode
at org.apache.zookeeper.KeeperException.create(KeeperException.java:104)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:42)
at org.apache.zookeeper.ZooKeeper.getData(ZooKeeper.java:1028)
at org.apache.zookeeper.ZooKeeper.getData(ZooKeeper.java:1057)
at org.apache.zookeeper.ZooKeeperMain.processZKCmd(ZooKeeperMain.java:747)
at org.apache.zookeeper.ZooKeeperMain.processCmd(ZooKeeperMain.java:631)
at org.apache.zookeeper.ZooKeeperMain.executeLine(ZooKeeperMain.java:403)
at org.apache.zookeeper.ZooKeeperMain.run(ZooKeeperMain.java:361)
at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:291)
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment