3 to build a cluster of machines that zookeeper to be installed in three hosts, each host is to be installed jdk.
1. Upload the file and extract the zookeeper
2. modify environment variables
vi / etc / profile
Add Content:
export ZOOKEEPER_HOME=/home/hadoop/zookeeper-3.4.5 export PATH=$PATH:$ZOOKEEPER_HOME/bin |
Recompile the file:
source /etc/profile
Note: 3 sets zookeeper will need to be modified
3. Modify the zookeeper's profile
cd zookeeper-3.4.5/conf
cp zoo_sample.cfg zoo.cfg # copy zoo_sample.cfg , named zoo.cfg
we zoo.cfg
Zoo.cfg file contents are as follows:
tickTime: heartbeat cycle initLimit: How many heartbeats time it takes to initialize
syncLimit: a request to obtain the maximum time difference between the response, if the difference exceeds the request is not considered the other's response, the other party may hang up
dataDir: data directory, save the data clientPort: zookeeper client access port
Add Content:
dataDir=/home/hadoop/zookeeper-3.4.5/data dataLogDir=/home/hadoop/zookeeper-3.4.5/log server.1 = slave1: 2888: 3888 ( server. Server id = hostname / host ip address : heartbeat port: data port ) server.2=slave2:2888:3888 server.3=slave3:2888:3888 Port communication between the leader and follower: # 2888 # 3888: communication port when the vote for leader |
4. Create a data directory and log directory
cd /home/hadoop/zookeeper-3.4.5/
mkdir -m 755 data
mkdir -m 755 log
5. The id data recorded to the directory
3 machines in the data directory under the new myid file, myid the machine as the present content file node id zookeeper
For the first:
cd data
vi myid
Add Content
1 |
Or directly echo 1> myid
The other two similar
6. Cluster issued to the other machine
scp -r /home/hadoop/zookeeper-3.4.5 hadoop@slave2:/home/hadoop/
# The /home/hadoop/zookeeper-3.4.5 directory hadoop nominal copied to the slave host / home / hadoop directory
scp -r /home/hadoop/zookeeper-3.4.5 hadoop@slave3:/home/hadoop/
7. Turn off the firewall
Clusters are generally not exposed to the outside world, so the three machines are closed all ports firewall
service iptables stop
8. Start on all machines zookeeper
Enter zookeeper-3.4.5 / bin
zkServer.sh start
9. Check the cluster status
(1) JPS (see the process)
(2) zkServer.sh Status (see cluster status information from the master , the first to enter the ZooKeeper-3.4.5 / bin , if the cluster is not functioning properly, there will be error in this order )