zookeeper集群搭建与监控工具ZK UI安装
zookeeper相关安装
记录下安装zookeeper集群的过程
zookeeper集群搭建
本次安装集群需要3个节点,下面是我的节点信息:
- node1 192.168.75.200
- node2 192.168.75.201
- node3 193.168.75.202
安装包下载
链接:https://pan.baidu.com/s/1pmDKErhMLfx0pcMMoZHPaQ
提取码:wghz
信息配置
- 下载安装后,解压到某个目录下面,复制一个zoo_sample.cfg文件并改名为zoo.cfg
- 下面是我的配置信息
配置dataDir,dataLogDir的属性值;clientPort端口号;相关集群节点信息
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/root/packages/zookeeper3.5.6/data
dataLogDir=/root/packages/zookeeper3.5.6/log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=1
#此处是重点关注的地方,其中0,1,2是myid里面的编号
server.0=192.168.75.200:2888:3888
server.1=192.168.75.201:2888:3888
server.2=192.168.75.202:2888:3888
- 在dataDir配置的目录下创建myid文件,写入节点对应的编号
- 开放2181,2888,3888端口(重点)
监控工具ZK UI安装
Shell一键启动脚本编写
这个启动脚本仅供参考:
start-zookeeper.sh
#!/bin/bash
echo "启动zookeeper中........"
#节点列表
nodes=("node1" "node2" "node3")
for node in ${nodes[@]}
do
echo "$node:启动开始"
ssh root@$node "zkServer.sh start"
echo "$node:启动成功"
done
echo "启动zookeeper成功"
echo "开启zookeeper客户端监控....."
cd /root/packages/zookeeper3.5.6/zkui/target
nohup java -jar zkui-2.0-SNAPSHOT-jar-with-dependencies.jar &
echo $! > tpid
exit0
stop-zookeeper.sh
#!/bin/bash
echo "关闭zookeeper中........"
nodes=("node1" "node2" "node3")
for node in ${nodes[@]}
do
echo "$node:关闭开始"
ssh root@$node "zkServer.sh stop"
echo "$node:关闭成功"
done
echo "关闭zookeeper成功"
echo "关闭zookeeper监控平台....."
cd /root/packages/zookeeper3.5.6/zkui/target
PID=$(cat tpid)
kill -9 $PID && echo "监控服务停止成功...."
name=$(lsof -i:9090|tail -1|awk '"$1"!=""{print $2}')
if [ -z $name ]
then
echo "No process can be used to killed!"
else
id=$(lsof -i:9090|tail -1|awk '"$1"!=""{print $2}')
kill -9 $id
echo "Process name=$name($id) kill!"
fi
来源:CSDN
作者:IUNIQUE
链接:https://blog.csdn.net/IUNIQUE/article/details/103850365