步骤一:进入/usr/local/software目录,通过wget命令下载zookeeper的压缩包。
cd /usr/local/software
sudo wget https://downloads.apache.org/zookeeper/zookeeper-3.6.0/apache-zookeeper-3.6.0-bin.tar.gz
步骤二:下载完成之后进行解压缩
sudo tar -zxvf apache-zookeeper-3.6.0-bin.tar.gz
步骤三: 删除压缩包,重命名为 zookeeper 目录
sudo rm -rf apache-zookeeper-3.6.0-bin.tar.gz
sudo mv apache-zookeeper-3.6.0-bin/ zookeeper
步骤四:在 /usr/local/software/zookeeper 目录下新建两个文件夹 data 和 log,用于存储zookeeper的数据和日志。
sudo mkdir data
sudo mkdir log
步骤五:将conf目录下的zoo_sample.cfg文件更名为zoo.cfg,简单修改配置文件,自定义设置数据文件目录和日志文件目录 步骤六:启动zookeeper服务,还是在/usr/local/software/zookeeper/bin目录下启动
注意:如果报以下错误
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /Users/malong63/opt/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
ZOO_DATADIR:/Users/malong63/opt/apache-zookeeper-3.5.8-bin/data/zookeeper
ZOO_DATADIR:-e /Users/malong63/opt/apache-zookeeper-3.5.8-bin/data/zookeeper
ZOO_DATALOGDIR:
mkdir: illegal option -- e
usage: mkdir [-pv] [-m mode] directory ...
-n Starting zookeeper ...
zkServer.sh: line 172: -e /Users/malong63/opt/apache-zookeeper-3.5.8-bin/data/zookeeper/zookeeper_server.pid: No such file or directory
FAILED TO WRITE PID
打开zkServer.sh文件,可见 ZOO_DATADIR 第二次过滤出错了多了个 -e , zkServer.sh 里面有两行 ZOO_DATADIR= 把第二行的ZOO_DATADIR
注释掉: 然后,打开 sudo ./zkServer.sh start
|