Apache Zookeeper Maintenance Tasks

Edge for Private Cloud v. 4.16.09

Four-Letter Commands

Apache ZooKeeper has a number of "four-letter commands" that can be helpful in determining the current status of ZooKeeper voter and observer nodes. These commands can be invoked using "nc", "telnet" or another utility that has the ability to send commands to a specific port. Details on the four-letter commands can be found at:

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

Removing Old Snapshot Files

Apache ZooKeeper automatically performs periodic maintenance to remove old snapshot files which accumulate as updates to the system are made. The following settings in /opt/apigee/apigee-zookeeper/conf/zoo.cfg control this process:

## The number of snapshots to retain in dataDir:
autopurge.snapRetainCount=5

# Purge task interval in hours.
# Set to "0" to disable auto purge feature.
autopurge.purgeInterval=120

To set these properties to different values:

  1. Edit /opt/apigee/customer/application/zookeeper.properties to set the following properties. If that file does not exist, create it.
  2. Set the following properties in zookeeper.properties:
    # Set the snapshot count. In this example set it to 10:
    conf_zoo_autopurge.snapretaincount=10

    # Set the purge interval. In this example, set is to 240 hours:
    conf_zoo_autopurge.purgeinterval=240
  3. Make sure the file is owned by the "apigee" user:
    > chown apigee:apigee /opt/apigee/customer/application/zookeeper.properties
  4. Restart ZooKeeper by using the command:
    $ /opt/apigee/apigee-service/bin/apigee-service apigee-zookeeper restart

Log File Maintenance

Apache Zookeeper log files are kept in /opt/apigee/var/log/zookeeper. Normally, log file maintenance should not be required, but if you find that there are an excessive number of ZooKeeper logs or that the logs are very large you can modify ZooKeeper’s log4j properties to set the maximum file size and file count.

  1. Edit /opt/apigee/customer/application/zookeeper.properties to set the following properties. If that file does not exist, create it.
  2. Set the following properties in zookeeper.properties:
    conf_log4j_log4j.appender.rollingfile.maxfilesize=10MB # max file size
    conf_log4j_log4j.appender.rollingfile.maxbackupindex=50 # max open files
  3. Make sure the file is owned by the "apigee" user:
    > chown apigee:apigee /opt/apigee/customer/application/zookeeper.properties
  4. Restart ZooKeeper by using the command:
    $ /opt/apigee/apigee-service/bin/apigee-service apigee-zookeeper restart