==作者:YB-Chi==
[toc]
安装包
官网下载,git只有souce code版
https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz
部署
- 所有节点上传解压重命名安装包
- 修改所有节点zoo.cfg
1 2 3 4 5 6 7 8
| cp zookeeper/conf/zoo_sample.cfg zoo.cfg mkdir -p zookeeper/data
vim zookeeper/conf/zoo.cfg dataDir=/home/cyb/zookeeper/data/ server.1=192.168.33.128:2888:3888 server.2=192.168.33.129:2888:3888 server.3=192.168.33.130:2888:3888
|
- data目录下生成myid,每个节点不同,如1 2 3
- 修改所有节点环境变量
1 2 3 4 5 6 7
| vim /etc/profile
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64/jre ZK_HOME=/home/cyb/zookeeper PATH=$PATH:$JAVA_HOME/bin:$ZK_HOME/bin
source /etc/profile
|
- 写集群启动脚本
- 启动~
./start-cluster.sh
- 每个节点执行zkServer.sh status测试是否成功
加到systemctl的service中
vim /usr/lib/systemd/system/zookeeper.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| [Unit] # 服务描述 Description=cosmo-bdp zookeeper # 在网络服务启动后运行 After=network.target
[Service] Type=forking
# Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64/jre ZOO_LOG_DIR=/home/cyb/zookeeper/logs # 启动命令 ExecStart=/home/cyb/zookeeper/bin/zkServer.sh start # 停止命令 ExecStop=/home/cyb/zookeeper/bin/zkServer.sh stop # 重载命令 ExecReload=/home/cyb/zookeeper/bin/zkServer.sh restart
# [Install] WantedBy=multi-user.target
|
1 2 3 4 5
| systemctl reload zookeeper.service systemctl start zookeeper.service systemctl is-enabled zookeeper.service
zkCli.sh -server node1:2181,node2:2181,node3:2181
|