Configure ZooKeeper

Configuration files

ZooKeeper has three main configuration files stored in the etc/zookeeper/conf/ directory. You can edit them manually, by connecting to the ZooKeeper component host and using a text editor, or via the Arenadata Cluster Manager (ADCM).

When editing manually, make sure you updated the configuration file on all hosts with ZooKeeper components.

NOTE

ZooKeeper supports dynamic reconfiguration. This feature enables changing the configuration without restarting the server, but it might interfere with the ADCM.

This article doesn’t cover the advanced configuration options. For more information about them, see the ZooKeeper Administrator’s Guide.

zoo.cfg

The zoo.cfg configuration file contains the main ZooKeeper settings. If ZooKeeper has been installed via ADCM, it already contains the minimal configuration parameters. If ZooKeeper has been installed manually, you have to configure the following parameters for a minimal configuration:

  • clientPort — the port for client connections to ZooKeeper. For SSL connections, configure the secureClientPort property. clientPort specifies the port for regular connections, while the secureClientPort property specifies the port for SSL connections. When both are specified, it enables the mixed-mode.

  • dataDir — the location for ZooKeeper to store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database.

  • tickTime — the length of a single tick, which is the basic time unit used by ZooKeeper, as measured in milliseconds. It is used to regulate heartbeats, and timeouts. For example, the minimum session timeout will be two ticks.

See more details about main zoo.cfg properties in the Main section of ZooKeeper settings. For information on other properties, see the zoo.cfg section.

zookeeper-env.sh

The zookeeper-env.sh file is used to define configuration parameters related to a ZooKeeper operating environment, such as Java_HOME.

You can also configure properties of other configuration files by setting environmental variables in zookeeper-env.sh.

For more information on zookeeper-env.sh contents, see the zookeeper-env.sh section of ZooKeeper settings.

log4j.properties

The log4j.properties configuration file contains logging settings. For more information on how to configure it, see the Logging in ZooKeeper article.

Change configuration via ADCM

To configure ZooKeeper using ADCM:

  1. On the Clusters page, select the desired cluster.

  2. Go to the Services tab and click at ZooKeeper.

  3. Find the desired property on the service configuration page or navigate to the Components page. Additional properties can be revealed by toggling the Show advanced option.

  4. Make the necessary changes and click Save.

  5. In the Actions drop-down menu, select Restart, make sure the Apply configs from ADCM option is set to true, and click Run.

Recommendations

Here’s a list of things to avoid and some additional configuration options that can improve your cluster’s performance:

  • When deploying many applications interfacing to a single ZooKeeper server, you might want to apply an optional chroot suffix to the connection string. This will run the client commands while interpreting all paths relative to this root (similar to the Unix chroot command). The example connection string: 127.0.0.1:4545/app/a.

  • To avoid the fsync warnings in the ZooKeeper log, set up a dedicated disk for the dataLogDir directory that is separate from the dataDir directory. Set the dataLogDir parameter in the zoo.cfg file.

  • For a better performance, put the transaction log (dataDir) on a dedicated device. If the transaction log is placed on a busy device, it will adversely affect performance.

  • Keep the servers list consistent between the clients and the ZooKeeper servers.

Found a mistake? Seleсt text and press Ctrl+Enter to report it