概述
zookeeper官网:https://zookeeper.apache.org/
安装环境
部署ip | 部署软件 | 开放端口 |
---|---|---|
192.168.199.10 | jdk1.8/zookeeper-3.5.8 | 2181 |
安装部署
依赖环境安装
tar -zxvf jdk-8u211-linux-x64.tar.gz
mv jdk1.8.0_211 /opt/
vi /etc/profile
#根据实际情况修改JAVA_HOME
export JAVA_HOME=/opt/jdk1.8.0_211
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
#测试
java -version
zookeeper安装
mkdir -p /data/zookeeper
tar zxzf apache-zookeeper-3.5.8-bin.tar.gz
mv apache-zookeeper-3.5.8-bin /data/zookeeper/zookeeper-3.5.8
mkdir -p /data/zookeeper/zookeeper-3.5.8/{data,logs}
基础配置
vim /data/zookeeper/zookeeper-3.5.8/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper/zookeeper-3.5.8/data
dataLogDir=/data/zookeeper/zookeeper-3.5.8/logs
clientPort=2181
配置启动脚本
vim /usr/lib/systemd/system/zookeeper.service
[Unit]
Description=zookeeper
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/data/zookeeper/zookeeper-3.5.8/bin/zkServer.sh start
ExecReload=/data/zookeeper/zookeeper-3.5.8/bin/zkServer.sh restart
ExecStop=/data/zookeeper/zookeeper-3.5.8/bin/zkServer.sh stop
[Install]
WantedBy=multi-user.target
开机自启动设置
# 加入开机启动
systemctl daemon-reload
systemctl enable zookeeper
# 查看开机是否启动成功
systemctl is-enabled zookeeper
# 启动服务
systemctl start zookeeper
# 停止服务
systemctl stop zookeeper
防火墙开放端口
firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --reload
setenforce 0