环境
系统:CentOS 7
软件:apache-zookeeper-3.6.3-bin.tar.gz
准备
安装
-
下载二进制包
- 浏览器下载:https://zookeeper.apache.org/releases.html
- wget下载:
wget --no-check-certificat https://dlcdn.apache.org/zookeeper/zookeeper-3.6.3/apache-zookeeper-3.6.3-bin.tar.gz
-
安装
tar -xzvf apache-zookeeper-3.6.3-bin.tar.gz mv apache-zookeeper-3.6.3-bin /usr/local/zookeeper
-
配置环境变量
cat << EOF >> /etc/profile # zookeeper export PATH=/usr/local/zookeeper/bin:\$PATH EOF source /etc/profile
配置
-
创建数据目录
mkdir -p /data/zookeeper
-
配置
cp /usr/local/zookeeper/conf/zoo_sample.cfg /usr/local/zookeeper/conf/zoo.cfg vim /usr/local/zookeeper/conf/zoo.cfg dataDir=/data/zookeeper
启动
-
添加启动服务
cat << EOF > /usr/lib/systemd/system/zookeeper.service [Unit] Description=Zookeeper After=network.target [Service] Type=forking Environment=JAVA_HOME=/usr/local/jdk ExecStart=/usr/local/zookeeper/bin/zkServer.sh start ExecStop=/usr/local/zookeeper/bin/zkServer.sh stop [Install] WantedBy=multi-user.target EOF
-
启动
systemctl enable zookeeper systemctl start zookeeper