thispassage is referenced, appreciated.
ZooKeeper installation:
- Download from this site
- Install java-sdk-v1.6
- Configure the zoo.cfg following the zoo.template.cfg in conf/
add the parameters according to the link and the first site stated. (except the datadir part)
Add datadir and datalog as the referenced said - Add a file named myid in the datadir and insert order of machine startring from 1 to 255 and nothing else (e.g. server.1=10.0.2.50:2888:3888)
- Start by bin/zkServer.sh start (|stop|start-foreground|status)
- install the same thing as stated in 1~4, but start bin/zkCli.sh -server 10.0.2.50:2181
- Done
to share my_data between clients..
create /zk_test my_data
get /zk_test
delete /zk_test
wondering what zk is?
quote
- ZooKeeper is a high-performance coordination service for distributed applications. It exposes common services - such as naming, configuration management, synchronization, and group services - in a simple interface so you don't have to write them from scratch. You can use it off-the-shelf to implement consensus, group management, leader election, and presence protocols. And you can build on it for your own, specific needs.
!quote
Some notes
- If need to send info from server to clients, the server can also login zookeeper as a client, and add znodes.
- Using daemontools to supervise zookeeper’s server. Not sure..
- Check server’s status and other info: usage: echo conf|nc localhost 2181
conf
New in 3.3.0: Print details about serving configuration.
cons
New in 3.3.0: List full connection/session details for all clients connected to this server. Includes information on numbers of packets received/sent, session id, operation latencies, last operation performed, etc...
crst
New in 3.3.0: Reset connection/session statistics for all connections.
dump
Lists the outstanding sessions and ephemeral nodes. This only works on the leader.
envi
Print details about serving environment
ruok
Tests if server is running in a non-error state. The server will respond with imok if it is running. Otherwise it will not respond at all.
A response of "imok" does not necessarily indicate that the server has joined the quorum, just that the server process is active and bound to the specified client port. Use "stat" for details on state wrt quorum and client connection information.
srst
Reset server statistics.
srvr
New in 3.3.0: Lists full details for the server.
stat
Lists brief details for the server and connected clients.
wchs
New in 3.3.0: Lists brief information on watches for the server.
wchc
New in 3.3.0: Lists detailed information on watches for the server, by session. This outputs a list of sessions(connections) with associated watches (paths). Note, depending on the number of watches this operation may be expensive (ie impact server performance), use it carefully.
wchp
New in 3.3.0: Lists detailed information on watches for the server, by path. This outputs a list of paths (znodes) with associated sessions. Note, depending on the number of watches this operation may be expensive (ie impact server performance), use it carefully.