-
Create the folder "
data
": "/opt/zookeeper/data
"
$ mkdir /opt/zookeeper/data
-
Create the folder "
data-log
": "/opt/zookeeper/data-log
"
$ mkdir /opt/zookeeper/data-log
-
Create the log folder: "
/opt/zookeeper/logs
"
$ mkdir /opt/zookeeper/logs
-
Copy the file "
/opt/zookeeper/conf/zoo_sample.cfg
" to "/opt/zookeeper/conf/zoo.cfg
"
$ cp /opt/zookeeper/conf/zoo_sample.cfg /opt/zookeeper/conf/zoo.cfg
-
Define the property "
dataDir
" in the file "/opt/zookeeper/conf/zoo.cfg
": dataDir=/opt/zookeeper/data
-
Define the property "
dataLogDir
" in the file "/opt/zookeeper/conf/zoo.cfg
": dataLogDir=/opt/zookeeper/data-log
Make sure that the directories and the files are created and updated using the user that will run ZooKeeper (you can also use:
sudo -u mtitek mkdir data).
Example: ZooKeeper configuration file "zoo.cfg
"
# The number of milliseconds of each tick.
tickTime=2000
# The number of ticks that the initial synchronization phase can take.
initLimit=10
# The number of ticks that can pass between sending a request and getting an acknowledgement.
syncLimit=5
# The port at which the clients will connect.
clientPort=2181
# The port address at which the clients will connect.
clientPortAddress=0.0.0.0
# The directory where the snapshot data is stored.
dataDir=/opt/zookeeper/data
# The directory the transaction log of updates is stored.
dataLogDir=/opt/zookeeper/data-log
Notes:
-
If you run ZooKeeper in a cluster mode,
the
clientPort
and clientPortAddress
configuration parameters should be part of the ZooKeeper instances configuration (see Installation - ZooKeeper Cluster).
-
(On Windows) if not already the case, you have to double-quote the path
"%JAVA_HOME%"\bin\java.exe
in the file "%ZK_HOME%\bin\zkEnv.cmd
"
-
(On Windows) if not already the case, you have to double-quote the path "
%JAVA%
" in the file "%ZK_HOME%\bin\zkServer.cmd
"
Other configuration you might want to setup in file "
zoo.cfg
"
# The maximum number of client connections. Increase this if you need to handle more clients.
maxClientCnxns=60
# The number of snapshots to retain in dataDir.
autopurge.snapRetainCount=3
# Purge task interval in hours. Set to "0" to disable auto purge feature.
autopurge.purgeInterval=1
You can optionally configure the
JAVA_HOME environment variable:
$ vi /opt/zookeeper/conf/java.env
export JAVA_HOME=/opt/jdk-23.0.2