21.6.15

Experiencing ZooKeeper in Docker

Build a Docker Image for ZK Server

Installing ZK server is simple, so as building a docker image for it. You can simple use the Dockerfile from the following github project:


I create a very simple one for just using Standalone ZK server:


It is good enough for developing zk clients.

Using nc Command from a Client Container

The simplest way to try a zk Server is to use the "nc" command.

Step1: Run a container with --link to the zk Server

docker run -t -i --name zkc --link zk:zk ubuntu:14.04 /bin/bash

Step2: Use the four-letter-word command to test the zk Server

http://zookeeper.apache.org/doc/r3.4.6/zookeeperAdmin.html#sc_zkCommands

Using zkCli.sh from Client Containers

Although the four-letter-commands are convenient, they are just for quickly testing the server. zkCli is the shell command line tool to explore the server more.

Step1: Install zk binary

curl -fsSL http://mirrors.sonic.net/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz | tar -C /opt -xz 

But you can actually run the zk Server image as a client container.

$./bin/zkCli.sh -server zk:2181

[zk: zk:2181(CONNECTED) 0] \h
ZooKeeper -server host:port cmd args
connect host:port
get path [watch]
ls path [watch]
set path data [version]
rmr path
delquota [-n|-b] path
quit 
printwatches on|off
create [-s] [-e] path data acl
stat path [watch]
close 
ls2 path [watch]
history 
listquota path
setAcl path acl
getAcl path
sync path
redo cmdno
addauth scheme auth
delete path [version]
setquota -n|-b val path








No comments: