Docker install zookeeper3.4
1. Configure the mapping of hostname to ip
Vi etc/hosts
2. Modify ZooKeeper configuration file
Modify the ZooKeeper configuration file. On the master machine, use the tar-zxvf command to extract the zookeeper-3.4.10.tar.gz.
Tar-zxvf / zookeeper-3.4.10.tar.gz-C / usr/local/
Cd / usr/local
Mv zookeeper-3.4.10 zookeeper
3. Configuration file conf/zoo.cfg
Profile conf/zoo.cfg
Use the cd command to enter the zookeeper-3.4.10/conf directory and copy the zoo_sample.cfg file
Beiyi, named "zoo.cfg".
Cp zoo_sample.cfg zoo.cfg
Zoo.cfg file configuration
TickTime=2000
InitLimit=10
SyncLimit=5
DataDir=/usr/local/zookeeper/zookeeper/zkdata
ClientPort=2181
DataLogDir=/usr/local/zookeeper/zookeeper/zkdatalog
Server.1=master:2888:3888
Server.2=slave1:2888:3888
Server.3=slave2:2888:3888
4. Create two folders, zkdata and zkdatalog
In the directory of zookeeper, create two folders, zkdata and zkdatalog.
The zkdatalog folder is to specify the corresponding path for zookeeper to generate logs.
Mkdir zkdata
Mkdir zkdatalog
5. Modify myid
Go to the zkdata folder, create the file myid, and write 1
6. Copy and distribute installation files remotely
Copy and distribute installation files remotely
The ZooKeeper has been configured on a machine master above, and you can now configure the
The installation files are remotely copied to the corresponding directory of each node in the cluster:
Scp-r / usr/local/zookeeper root@slave1:/usr/local
Scp-r / usr/loca/zookeeper root@slave2:/usr/local
7. Set myid from the node
Set up the myid. Create a myid under the directory specified by the dataDir that we configured
File, which contains a number that identifies the current host, which is configured in the conf/zoo.cfg file
Why is the number X in server.X, then this number is entered in the myid file.
Myid in Slave1 is 2
Myid in Slave2 is 3
8. Configure environment variables and start ZooKeeper
Configure environment variables and start ZooKeeper. On each machine, do the following:
Vi / etc/profile
# set zookeeper environment
Export ZOOKEEPER_HOME=/usr/local/zookeeper/
PATH=$PATH:$ZOOKEEPER_HOME/bin
Take effect
Source / etc/profile
9. Start the ZooKeeper cluster
Start the ZooKeeper cluster
On each node of the ZooKeeper cluster, execute the script to start the ZooKeeper service, as follows
Show:
Bin/zkServer.sh start
Bin/zkServer.sh status