Extract the content of "
apache-zookeeper-3.9.3-bin.tar.gz
" file to three locations of your choice:
► /opt/zookeeper-i1
► /opt/zookeeper-i2
► /opt/zookeeper-i3
$ tar -xf apache-zookeeper-3.9.3-bin.tar.gz -C /opt/
$ cp -r /opt/apache-zookeeper-3.9.3-bin/ /opt/zookeeper-i1/
$ cp -r /opt/apache-zookeeper-3.9.3-bin/ /opt/zookeeper-i2/
$ mv /opt/apache-zookeeper-3.9.3-bin/ /opt/zookeeper-i3/
Change the folders permissions (if needed):
$ chmod -R 755 /opt/zookeeper-i1/
$ chmod -R 755 /opt/zookeeper-i2/
$ chmod -R 755 /opt/zookeeper-i3/
$ sudo chown -R mtitek:mtitek /opt/zookeeper-i1/
$ sudo chown -R mtitek:mtitek /opt/zookeeper-i2/
$ sudo chown -R mtitek:mtitek /opt/zookeeper-i3/
You should replace
mtitek:mtitek with your actual user/group names.
First, for each ZooKeeper binary distribution ("
zookeeper-i1
", "
zookeeper-i2
", "
zookeeper-i3
"),
you need to do the following instructions:
-
Create the folder "
data
":
$ mkdir /opt/zookeeper-i1/data
$ mkdir /opt/zookeeper-i2/data
$ mkdir /opt/zookeeper-i3/data
-
Create the folder "
data-log
":
$ mkdir /opt/zookeeper-i1/data-log
$ mkdir /opt/zookeeper-i2/data-log
$ mkdir /opt/zookeeper-i3/data-log
-
Create the log folder "
logs
":
$ mkdir /opt/zookeeper-i1/logs
$ mkdir /opt/zookeeper-i2/logs
$ mkdir /opt/zookeeper-i3/logs
-
Copy the file "
conf/zoo_sample.cfg
" to "conf/zoo.cfg
":
$ cp /opt/zookeeper-i1/conf/zoo_sample.cfg /opt/zookeeper-i1/conf/zoo.cfg
$ cp /opt/zookeeper-i2/conf/zoo_sample.cfg /opt/zookeeper-i2/conf/zoo.cfg
$ cp /opt/zookeeper-i3/conf/zoo_sample.cfg /opt/zookeeper-i3/conf/zoo.cfg
-
Initialize the server id for each ZooKeeper instance:
$ echo "1" > /opt/zookeeper-i1/data/myid
$ echo "2" > /opt/zookeeper-i2/data/myid
$ echo "3" > /opt/zookeeper-i3/data/myid
For each ZooKeeper binary distribution you will need to modify the "
conf/zoo.cfg
" file:
Example: ZooKeeper configuration file "zoo.cfg
"
/opt/zookeeper-i1/conf/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 directory where the snapshot data is stored.
dataDir=/opt/zookeeper-i1/data
# The directory the transaction log of updates is stored.
dataLogDir=/opt/zookeeper-i1/data-log
# the port at which the clients will connect: 2181, 2182, 2183
# the port address at which the clients will connect: 0.0.0.0
server.1=localhost:2888:3888:participant;0.0.0.0:2181
server.2=localhost:2889:3889:participant;0.0.0.0:2182
server.3=localhost:2890:3890:participant;0.0.0.0:2183
# Jetty AdminServer http port
admin.serverPort=8081
/opt/zookeeper-i2/conf/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 directory where the snapshot data is stored.
dataDir=/opt/zookeeper-i2/data
# The directory the transaction log of updates is stored.
dataLogDir=/opt/zookeeper-i2/data-log
# the port at which the clients will connect: 2181, 2182, 2183
# the port address at which the clients will connect: 0.0.0.0
server.1=localhost:2888:3888:participant;0.0.0.0:2181
server.2=localhost:2889:3889:participant;0.0.0.0:2182
server.3=localhost:2890:3890:participant;0.0.0.0:2183
# Jetty AdminServer http port
admin.serverPort=8082
/opt/zookeeper-i3/conf/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 directory where the snapshot data is stored.
dataDir=/opt/zookeeper-i3/data
# The directory the transaction log of updates is stored.
dataLogDir=/opt/zookeeper-i3/data-log
# the port at which the clients will connect: 2181, 2182, 2183
# the port address at which the clients will connect: 0.0.0.0
server.1=localhost:2888:3888:participant;0.0.0.0:2181
server.2=localhost:2889:3889:participant;0.0.0.0:2182
server.3=localhost:2890:3890:participant;0.0.0.0:2183
# Jetty AdminServer http port
admin.serverPort=8083