linux centos7 安装zookeeper
Posted 七脉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux centos7 安装zookeeper相关的知识,希望对你有一定的参考价值。
linux 系统下 zookeeper 安装教程
1.下载安装包
1)进入安装目录
cd /home/install/
2)下载
wget http://mirror.bit.edu.cn/apache/zookeeper/stable/zookeeper-3.4.12.tar.gz
2.安装
1)创建和解压至安装目录
mkdir /usr/local/zookeeper
tar -zxcf /home/install/zookeeper-3.4.12.tar.gz -C /usr/local/zookeeper/
2)拷贝样本配置为主配置
进入配置目录,赋值拷贝样本文件
cd /usr/local/zookeeper/zookeeper-3.4.12/conf/
cp zoo_sample.cfg zoo.cfg
3)简单修改配置
创建数据存储目录与日志目录
mkdir /usr/local/zookeeper/zookeeper-3.4.12/dataDir
mkdir /usr/local/zookeeper/zookeeper-3.4.12/dataLogDir
修改数据存储和日志目录
vim /usr/local/zookeeper/zookeeper-3.4.12/conf/zoo.cfg
3.配置zookeeper环境变量
1)依赖JVM环境,所以JVM与zookeeper环境变量都要配置
vim /etc/profile
在尾部加入或修改以下
JAVA_HOME=/usr/local/java/jdk1.8.0_181
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME PATH
ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.12
PATH=$PATH:$ZOOKEEPER_HOME/bin
export PATH ZOOKEEPER_HOME PATH
2)生效
source /etc/profile
3.测试
1)启动
/usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh start
2)连接
/usr/local/zookeeper/zookeeper-3.4.12/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/zookeeper-3.4.12/bin/zkServer.sh start
ExecReload=/usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh restart
ExecStop=/usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh stop
[Install]
WantedBy=multi-user.target
(2)生效
systemctl daemon-reload
(3)改变文件权限
chmod 777 /usr/lib/systemd/system/zookeeper.service
(4)systemctl开机启动zookeeper
systemctl enable /usr/lib/systemd/system/zookeeper.service
或
systemctl enable /usr/lib/systemd/system/zookeeper
(5)查看是否开机启动
systemctl is-enabled zookeeper.service
(6)systemctl取消开机启动redis
systemctl disable zookeeper.service
本章只讲安装,关于配置属性与操作指令,先参考度娘
以上是关于linux centos7 安装zookeeper的主要内容,如果未能解决你的问题,请参考以下文章
Zookeeper3.5.7版本——单机部署(linux环境-centos7)
精简总结redis/rabbitmq/zookeeper在linux centos7上的安装