Skip to content

Zookeeper management helpers for importing, exporting and purging of zk data

Notifications You must be signed in to change notification settings

gengmao/zookeeper-util

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Zookeeper Utilities

The zookeeper utilities are meant to help automating some administrative tasks with zookeeper test instances.
All operations implicitly exclude the /zookeeper path. Please try not to use with production instances.

  • export (read) data from a running zk instance into a file
    • keep the data editable
  • import (write) a full (or partial) export off of another zk instance
  • purge (delete) all data from a running zk instance

There is only one executable (zkutil) that understands the three commands specified above with the following options:

Usage: zkutil <dump|import|purge> -c host:port [options]
dump
zkutil dump -h
Usage: zk_dump.rb [options] -c <host:port>
    -c, --connectstring host:port    the server to connect to
    -s, --separator sep              separator /path[::]data
    -p, --start_path path            path to dump, defaults to '/'
    -v, --verbose                    Output more information
    -h, --help                       Display this screen

Will print a text representation to STDOUT (which you can redirect into a dump file) looking like this:

/
/conf
/conf/entries
/conf/entries/00
/conf/entries/00/host1::192.168.1.211
/conf/entries/00/host2::192.168.1.213
...
import

Can either import from a file or take alternatively path + data as parameters

zkutil import -h
Usage: zk_import.rb [options] -c <host:port> -p /some/path -n somedata
       or
       zk_import.rb -c <host:port> -f </some/file/name>
    -c, --connectstring host:port    defaults to 
    -s, --separator sep              separator /path[::]data
    -p, --path path                  path to create or delete
    -n, --node_data <data>           data to add to the node, if creating
    -d, --delete                     Output more information
    -f, --file FILE                  the import file to read from
    -v, --verbose                    Output more information
    -h, --help                       Display this screen
purge

Delete all data from the path.

zkutil purge -h
Usage: zk_purge.rb [options] -c <host:port>
    -c, --connectstring host:port    defaults to 
    -p, --path path                  path to purge, defaults to '/'
    -v, --verbose                    Output more information
    -h, --help                       Display this screen
Docker

A Dockerfile is added to easy package and use this tool. You can checkout this repo and build a docker image like this:

$ docker build -t gengmao/zookeeper-util .
Sending build context to Docker daemon 17.85 MB
Step 0 : FROM java:openjdk-8
 ---> c1ccce98b537
Step 1 : COPY usr /usr
 ---> Using cache
 ---> ce7c545aa779
Step 2 : ADD https://s3.amazonaws.com/jruby.org/downloads/1.7.22/jruby-complete-1.7.22.jar /usr/share/java/zookeeper-util/
Downloading [==================================================>] 23.72 MB/23.72 MB
 ---> Using cache
 ---> c2e854f67dc7
Step 3 : ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
 ---> Using cache
 ---> 0e4583859950
Step 4 : ENTRYPOINT /usr/bin/zkutil
 ---> Using cache
 ---> da8f8a8c682d
Successfully built da8f8a8c682d

Then you can use the image like this:

$ docker run -it gengmao/zookeeper-util
Usage: zkutil <dump|import|purge> -c host:port [options]

About

Zookeeper management helpers for importing, exporting and purging of zk data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 92.9%
  • Shell 7.1%