linux 系统下 zookeeper 安装教程
linux 系统下 zookeeper 安装教程
1.下载安装包
(说明:截图来自之前的博客文档,与现在安装不是完全一样请按照文字步骤操作,截图仅供参考)
1)进入安装目录
cd /home/install/
2)下载
wget http://mirror.bit.edu.cn/apache/zookeeper/stable/apache-zookeeper-3.5.8-bin.tar.gz
2.安装
1)解压至安装目录
tar -zxcf /home/install/apache-zookeeper-3.5.8-bin.tar.gz -C /usr/local/
mv /usr/local/apache-zookeeper-3.5.8-bin /usr/local/zookeeper
2)拷贝样本配置为主配置
进入配置目录,赋值拷贝样本文件
cd /usr/local/zookeeper/conf/
cp zoo_sample.cfg zoo.cfg
3)简单修改配置
创建数据存储目录与日志目录
mkdir /usr/local/zookeeper/dataDir
mkdir /usr/local/zookeeper/dataLogDir
修改数据存储和日志目录
vim /usr/local/zookeeper/conf/zoo.cfg
3.配置zookeeper环境变量
1)依赖JVM环境,所以JVM与zookeeper环境变量都要配置
vim /etc/profile
在尾部加入或修改以下
JAVA_HOME=/usr/local/java/jdk1.8.0_231
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME PATH
ZOOKEEPER_HOME=/usr/local/zookeeper
PATH=$PATH:$ZOOKEEPER_HOME/bin
export PATH ZOOKEEPER_HOME PATH
2)生效
source /etc/profile
3.测试
1)启动
/usr/local/zookeeper/bin/zkServer.sh start
2)连接
/usr/local/zookeeper/bin/zkCli.sh
3)增删改查
4)其他
help查看指令帮助
4.开机启动
(1)编辑zookeeper.service文件
vim /usr/lib/systemd/system/zookeeper.service
加入如下内容
[Unit]
Description=zookeeper
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/zookeeper/bin/zkServer.sh start
ExecReload=/usr/local/zookeeper/bin/zkServer.sh restart
ExecStop=/usr/local/zookeeper/bin/zkServer.sh stop
[Install]
WantedBy=multi-user.target
(2)zookeeper.service文件生效
systemctl daemon-reload
(3)设置开机启动
systemctl enabled zookeeper.service
(4)启动
systemctl start zookeeper.service
(5)关闭
systemctl stop zookeeper.service
(6)重启
systemctl restart zookeeper.service
(7)查看是否开机启动
systemctl is-enabled zookeeper.service
(8)systemctl取消开机启动redis
systemctl disable zookeeper.service
本章只讲安装,关于配置属性与操作指令,先参考度娘