Prerequisites: Before setting up the Zookeeper cluster, ensure that the Hadoop cluster is set up. Refer to the white bearA0-02.Hadoop cluster construction
1. Set up the Zookeeper cluster
- MyNode01 machine (iceBear user)
- Downloading the Installation package
- Zookeeper.apache.org/releases.ht…
- Upload and decompress the ZooKeeper installation package
cd /home/bgd/soft
Tar -zxvf zookeeper-3.4.5-cdh5.14.2.tar.gz -c /home/bg/install /
- Modifying a Configuration File
CD/home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / conf
cp zoo_sample.cfg zoo.cfg
The mkdir -p/home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / zkdatas
vim zoo.cfg
# to add the following configuration dataDir = / home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / zkdatas autopurge. SnapRetainCount = 3 autopurge.purgeInterval=1 server.1=MyNode01:2888:3888 server.2=MyNode02:2888:3888 server.3=MyNode03:2888:3888Copy the code
- Distribute the configured ZooKeeper to other machines
cd /home/bgd/install
Sudo SCP -r zookeeper-3.4.5-cdh5.14.2/ MyNode02:$PWD
Sudo SCP -r zookeeper-3.4.5-cdh5.14.2/ MyNode03:$PWD
- Configuring environment Variables
sudo vim /etc/profile
JAVA_HOME = / home/BGD/install/jdk1.8.0 _141 HADOOP_HOME = / home/BGD/install/hadoop - server - cdh5.14.2 # the add ZK_HOME = / home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$ZK_HOME/bin export JAVA_HOME export HADOOP_HOME Export ZK_HOME export PATHCopy the code
- Distribute the configured environment variables to other machines
sudo scp /etc/profile MyNode02:/etc/
sudo scp /etc/profile MyNode03:/etc/
- Downloading the Installation package
- Add myID and put the environment variable into effect
- MyNode01 (iceBear user)
Echo 1 > / home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / zkdatas/myid
source /etc/profile
- MyNode02 (iceBear user)
Echo 2 > / home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / zkdatas/myid
source /etc/profile
- MyNode03 (iceBear user)
Echo 3 > / home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / zkdatas/myid
source /etc/profile
- MyNode01 (iceBear user)
2. Enable or disable the ZooKeeper cluster
- All machines executed separately (IceBear users)
- open
Sudo/home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh start
- To view
Sudo/home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh status
- stop
Sudo/home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh stop
- restart
Sudo/home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh restart
- View error logs
Sudo/home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh start - foreground
- open
- MyNode01 machine (iceBear user)
- A key to open
sudo bash zk_start.sh
#! / bin/sh for host in MyNode01 MyNode02 MyNode03 do SSH $host "/ home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh start" echo "$host ZK is running" doneCopy the code
- A key to see
sudo bash zk_status.sh
#! / bin/sh for host in MyNode01 MyNode02 MyNode03 do SSH $host "/ home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh status" echo "$host" doneCopy the code
- A button to turn off the
sudo bash zk_stop.sh
#! / bin/sh for host in MyNode01 MyNode02 MyNode03 do SSH $host "/ home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh stop" echo "$host ZK is stoped" doneCopy the code
- A key to open
3. View the cluster
Four, error detection
- See the log
Sudo/home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh start - foreground
- If the Zookeeper cluster fails to start
- Modify zkServer. Sh
Sudo vim/home/BGD/install/zookeeper - 3.4.5 - cdh5.14.2 / bin/zkServer. Sh
Add source /etc/profileCopy the code
- Restart the cluster again
- Modify zkServer. Sh