About
How to interact with the Zookeeper service/server
Articles Related
Prerequisites
Management
Start
Command line
Start Zookeeper in its own terminal.
- From a zookeeper archive
bin/zkServer.sh start
- From a kafka archive
./bin/zookeeper-server-start ./etc/kafka/zookeeper.properties
You can add a feedback with the netcat wait function
wait_for_service "zookeeper" $ZOOKEEPER_PORT
cd - > /dev/null
From a Kafka Installation
Docker
docker run -d \
--net=host \
--name=zookeeper \
-e ZOOKEEPER_CLIENT_PORT=32181 \
confluentinc/cp-zookeeper:latest
where run create a new container:
- confluentinc/cp-zookeeper:latest is the confluentinc/cp-zookeeper image with the latest version.
- name is the name of the container
- –net=host to use the host networking
- -e ZOOKEEPER_CLIENT_PORT=32181 pass a required environment variable for running ZooKeeper.
Check
- In the logs: A message shows that the ZooKeeper service is listening at the port you passed in the run as ZOOKEEPER_CLIENT_PORT docker config
docker logs zookeeper | grep -i binding
[2016-07-24 05:15:35,453] INFO binding to port 0.0.0.0/0.0.0.0:32181 (org.apache.zookeeper.server.NIOServerCnxnFactory)
- or via a stat command
- or via a netcat function that check the status of the tcp connection on the port.
Command
Dump
running on port 2181 with Network - netcat (nc, ncat)
echo dump | nc localhost 2181
Example of output
SessionTracker dump:
Session Sets (4):
0 expire at Mon Apr 13 12:42:02 UTC 2020:
0 expire at Mon Apr 13 12:42:04 UTC 2020:
0 expire at Mon Apr 13 12:42:06 UTC 2020:
1 expire at Mon Apr 13 12:42:08 UTC 2020:
0x171738a8b950000
ephemeral nodes dump:
Sessions with Ephemerals (1):
0x171738a8b950000:
/brokers/ids/0
/controller
stat
echo stat | c:/nmap/ncat 127.0.0.1 2181
Zookeeper version: 3.4.3-1240972, built on 02/06/2012 10:48 GMT
Clients:
/127.0.0.1:34144[1](queued=0,recved=1360,sent=1364)
/172.17.0.1:53990[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/12
Received: 1451
Sent: 1455
Outstanding: 0
Zxid: 0xde
Mode: standalone
Node count: 133