CentOS 7.6
ZooKeeper 3.5.7
本文介绍了如何在CentOS 7系统中安装单机版的ZooKeeper。
# 解压
tar -xzvf apache-zookeeper-3.5.7-bin.tar.gz
sudo mv apache-zookeeper-3.5.7-bin /usr/local/zookeeper-3.5.7
# 打开/etc/profile
vi /etc/profile
# 添加如下内容,然后保存
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.5.7
export PATH=.:$ZOOKEEPER_HOME/bin:$JAVA_HOME/bin:$PATH
# 重新编译使环境变量生效
source /etc/profile
# 切换到conf目录下
cd /usr/local/zookeeper-3.5.7/conf
# 复制zoo_sample.cfg到zoo.cfg
cp zoo_sample.cfg zoo.cfg
# 打开zoo.cfg
vi zoo.cfg
# 修改配置如下,然后保存
# 存放数据
dataDir=/usr/local/zookeeper-3.5.7/dataDir
# 存放日志文件
dataLogDir=/usr/local/zookeeper-3.5.7/dataLogDir
# 端口默认为2181,单机版不需要配置
#clientPort=2181
# 创建文件夹
mkdir /usr/local/zookeeper-3.5.7/dataDir
mkdir /usr/local/zookeeper-3.5.7/dataLogDir
cd /usr/local/zookeeper-3.5.7/bin
# 启动命令
./zkServer.sh start
# 停止命令
./zkServer.sh stop
# 直接修改/etc/rc.local文件
sudo vi /etc/rc.local
# 添加启动命令
/usr/local/zookeeper-3.5.7/bin/zkServer.sh start
# 赋予其可执行权
chmod +x /etc/rc.d/rc.local
如果需要允许其他机器访问,需要开放2181
端口
firewall-cmd --add-port=2181/tcp --permanent
firewall-cmd --reload