The first step, download, unzip Zookeeper
download URL: https://www.apache.org/dyn/closer.cgi/zookeeper/
readers can find their own favorite version download
note that this permission setting is very important! !
$ sudo wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
$ tar -xvf zookeeper-3.4.13.tar.gz
$ sudo mv zookeeper-3.4.13.tar.gz /srv/
$ sudo chown -R hadoop:hadoop /srv/zookeeper-3.4.13
$ sudo chmod g+w /srv/zookeeper-3.4.13
$ sudo ln -s /srv/zookeeper-3.4.13 /srv/zookeeper
The second step, configure the environment variables
$ sudo su hadoop
$ vim ~/.bashrc
Add the following configuration:
export ZOOKEEPER_HOME=/srv/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
After saving the configuration to take effect
$ source ~/.bashrc
The third step is to configure zookeeper
$ cd $ZOOKEEPER_HOME
$ cd conf
$ cp zoo_sample.cfg zoo.cfg
$ vim zoo.cfg
Add the following configuration:
dataDir=/srv/zookeeper/Data/data
dataLogDir=/srv/zookeeper/Data/datalog
Save and exit
and then create two directories just configured
$ sudo mkdir /srv/zookeeper/Data
$ sudo mkdir /srv/zookeeper/Data/data
$ sudo mkdir /srv/zookeeper/Data/datalog
The fourth step, start zookeeper
$ cd $ZOOKEEPER_HOME
$ cd bin
$ ./zkServer.sh start
$ ./zkCli.sh
No error will be no problem