Sriram Subramanian
Sriram Subramanian

Reputation: 2753

How do one read the Zookeeper transaction log?

Are there any existing tools that help to read the Zookeeper transaction log? By default, it is in binary format and I would like to read it in human readable form.

Upvotes: 23

Views: 15470

Answers (5)

Oliver
Oliver

Reputation: 381

I don't know if you have solved this question.

cd /your/zookeeper/directory/

If you want to read snapshots, use:

java -cp zookeeper-3.4.6.jar:lib/log4j-1.2.16.jar:lib/slf4j-log4j12-1.6.1.jar:lib/slf4j-api-1.6.1.jar org.apache.zookeeper.server.SnapshotFormatter version-2/snapshot.xxx

If you want to read logs, use:

java -cp zookeeper-3.4.6.jar:lib/log4j-1.2.16.jar:lib/slf4j-log4j12-1.6.1.jar:lib/slf4j-api-1.6.1.jar org.apache.zookeeper.server.LogFormatter version-2/log.xxx

Upvotes: 38

filimonov
filimonov

Reputation: 1744

Since zookeeper version 3.6 there are tools to read transaction log and snapshots in zookeeper distribution:

For transaction log:

bin/zkTxnLogToolkit.sh --dump /datalog/version-2/log.f3aa6 

For snapshots:

./zkSnapShotToolkit.sh -d /data/zkdata/version-2/snapshot.fa01000186d

See the details in official docs

Upvotes: 1

Arvanitis Christos
Arvanitis Christos

Reputation: 267

You can enable ZooKeeper audit logs for ZooKeeper 3.6.o and upwards. To enable audit logs configure audit.enable=true in conf/zoo.cfg.

One thing to keep in mind is that logs from different servers of the same ensemble should be aggregated because each one of them includes operations that where executed only form clients connected to this particular server.

Full information here: https://zookeeper.apache.org/doc/r3.6.1/zookeeperAuditLogs.html

Upvotes: 0

xref
xref

Reputation: 1761

Building on the previous two answers, using Zookeeper 3.5.6: from the /path/to/zookeeper/lib dir which contains all the ZK and supporting jars run:

java -cp * org.apache.zookeeper.server.LogFormatter /path/to/zookeeper/transaction/logs/version-2/log.xxx

Upvotes: 1

Vikas Vishwakarma
Vikas Vishwakarma

Reputation: 71

You can use something like this

java -cp $ZOOKEEPER_CLASSPATH org.apache.zookeeper.server.LogFormatter [zookeeper log file path]

Upvotes: 7

Related Questions