1. Create the /usr/local/zookeeper folder: mkdir -p /usr/local/zookeeper
2. Go to the /usr/local/zookeeper directory: cd /usr/local/zookeeper
3. Download zookeeper-3.5.3-beta.tar.gz wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.5.3-beta/zookeeper-3.5.3-beta.tar .gz
4. Decompress zookeeper-3.5.3-beta.tar.gz: tar -zxvf zookeeper-3.5.3-beta.tar.gz Problems encountered during decompression, and solutions:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Now I provide the solution I have summarized:
method one:
#tar -xvf zookeeper-3.5.3-beta.tar.gz
Use the cvf parameter when compressing the tar package, use the xvf parameter when decompressing, or use the czvf parameter when compressing, and use the xzvf parameter when decompressing
5. Go to the /usr/local/zookeeper/zookeeper-3.5.3-beta/conf directory: cd zookeeper-3.5.3-beta/conf/
6. Copy the zoo_sample.cfg file and name it zoo.cfg: cp zoo_sample.cfg zoo.cfg
7. Open the zoo.cfg file with vim and modify its content as follows:
# The number of milliseconds of each tick
# zookeeper 定义的基准时间间隔,单位:毫秒
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 is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# dataDir=/tmp/zookeeper
# 数据文件夹
dataDir=/usr/local/zookeeper/zookeeper-3.5.3-beta/data
# 日志文件夹
dataLogDir=/usr/local/zookeeper/zookeeper-3.5.3-beta/logs
# the port at which the clients will connect
# 客户端访问 zookeeper 的端口号
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
8. Save and close the zoo.cfg file:
9. Use vim to open the configuration file profile in the /etc/ directory: vim /etc/profile and append the following content at the end:
export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.5.3-beta
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
10. Make the profile file in the /etc/ directory take effect: source /etc/profile
11. Start the zookeeper service: zkServer.sh start If the following information is printed, the startup is successful:
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.5.3-beta/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
12. Query the zookeeper status: zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.5.3-beta/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone
13. Shut down the zookeeper service: zkServer.sh stop If the following information is printed, the shutdown is successful:
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.5.3-beta/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
14. Restart the zookeeper service: zkServer.sh restart If the following information is printed, the restart is successful:
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.5.3-beta/bin/../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.5.3-beta/bin/../conf/zoo.cfg
Stopping zookeeper ... no zookeeper to stop (could not find file /usr/local/zookeeper/zookeeper-3.5.3-beta/data/zookeeper_server.pid)
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.5.3-beta/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED