一: JDK1.8安装
参考: Centos7卸载|安装JDK1.8|Xshell7批量控制多个终端
二:Maven安装
2.1:下载maven安装包
maven 下载地址:https://mirror.bit.edu.cn/apache/maven/maven-3/
[root@www ~]# mkdir -p /usr/local/maven
[root@www ~]# cd /usr/local/tools
[root@www tools]# wget https://mirror.bit.edu.cn/apache/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
--2023-08-27 12:44:30-- https://mirror.bit.edu.cn/apache/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
正在解析主机 mirror.bit.edu.cn (mirror.bit.edu.cn)... 2001:da8:204:1205::22
正在连接 mirror.bit.edu.cn (mirror.bit.edu.cn)|2001:da8:204:1205::22|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:8296049 (7.9M) [application/octet-stream]
正在保存至: “apache-maven-3.8.8-bin.tar.gz”100%[===========================================================================================================================================================================================================>] 8,296,049 3.84MB/s 用时 2.1s
2023-08-27 12:44:32 (3.84 MB/s) - 已保存 “apache-maven-3.8.8-bin.tar.gz” [8296049/8296049])
2.2: 解压maven安装包到/usr/local/maven目录
[root@www tools]# ll
总用量 8972
-rw-r--r-- 1 root root 8296049 3月 8 22:09 apache-maven-3.8.8-bin.tar.gz
-rw-r--r--. 1 root root 887908 12月 9 2015 nginx-1.9.9.tar.gz
[root@www tools]# tar -zxvf apache-maven-3.8.8-bin.tar.gz -C /usr/local/maven/
[root@www maven]# ll
总用量 0
drwxr-xr-x 6 root root 99 8月 27 12:45 apache-maven-3.8.8
[root@www maven]# cd apache-maven-3.8.8/
[root@www apache-maven-3.8.8]# clear
[root@www apache-maven-3.8.8]# pwd
/usr/local/maven/apache-maven-3.8.8
[root@www apache-maven-3.8.8]# echo 'export PATH=/usr/local/maven/apache-maven-3.8.8/bin:$PATH' >>/etc/profile
[root@www apache-maven-3.8.8]# source /etc/profile
2.3: 配置阿里云仓库镜像
[root@www conf]# pwd
/usr/local/maven/apache-maven-3.8.8/conf[root@www conf]# mkdir -p /usr/local/maven/repository
[root@www conf]# vi settings.xml
<!--找到</mirrors>节点添加即可-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
三: 在线安装Git
[root@www conf]# yum install git -y
[root@www conf]# git --version
git version 1.8.3.1
四: 安装zookeeper服务
参考:使用Xshell7控制多台服务同时安装ZK最新版集群服务
五: 安装zkui
下载地址: mirrors / DeemOpen / zkui · GitCode
[root@www conf]# mkdir -p /usr/local/zkui
[root@www zkui]# git clone https://gitcode.net/mirrors/DeemOpen/zkui.git
[root@www zkui]# cd zkui/
[root@www zkui]# mvn clean install -DskipTests
看到如图所示,即打包成功了;
六: 准备配置文件并启动服务
[root@www zkui]# cat config.cfg
#Server Port
serverPort=9999
#Comma seperated list of all the zookeeper servers
zkServer=192.168.1.100:2181,192.168.1.101:2181,192.168.1.102:2181
[root@www zkui]# pwd
/usr/local/zkui/zkui
[root@www zkui]# ll
总用量 108
-rw-r--r-- 1 root root 2385 8月 27 13:46 config.cfg
drwxr-xr-x 2 root root 61 8月 27 13:46 docker
drwxr-xr-x 2 root root 114 8月 27 13:46 images
-rw-r--r-- 1 root root 11358 8月 27 13:46 LICENSE-2.0.txt
-rw-r--r-- 1 root root 416 8月 27 13:46 Makefile
-rw-r--r-- 1 root root 1746 8月 27 13:46 nbactions.xml
-rw-r--r-- 1 root root 5374 8月 27 13:46 pom.xml
-rw-r--r-- 1 root root 6216 8月 27 13:46 README.md
-rwxr-xr-x 1 root root 43 8月 27 13:46 run.sh
drwxr-xr-x 4 root root 30 8月 27 13:46 src
drwxr-xr-x 7 root root 205 8月 27 14:07 target
-rw-r--r-- 1 root root 43008 8月 27 14:09 zkui.h2.db
-rw-r--r-- 1 root root 848 8月 27 14:07 zkui.out
-rw-r--r-- 1 root root 11065 8月 27 14:09 zkui-out.log
-rwxr-xr-x 1 root root 1252 8月 27 13:51 zkui.sh
七: 脚本启动:
[root@www zkui]# cat zkui.sh
#!/usr/bin/env bashPIDFILE=~/zkui.pid
ZKUIBINDIR=$(cd `dirname $0`; pwd)
ZKUICLASSNAME="target/zkui-2.0-SNAPSHOT-jar-with-dependencies.jar"
ZKUI_DAEMON_OUT=$ZKUIBINDIR/zkui.outstart(){
echo "Starting zkui ... $ZKUIBINDIR"
if [ -f "$PIDFILE" ]; then
if kill -0 `cat "$PIDFILE"` > /dev/null 2>&1; then
echo zkui already running as process `cat "$PIDFILE"`.
exit 0
fi
fi
cp config.cfg target
nohup java -jar "$ZKUIBINDIR/$ZKUICLASSNAME" > "$ZKUI_DAEMON_OUT" 2>&1 < /dev/null &
if [ $? -eq 0 ];
then
echo $!>$PIDFILE
if [ $? -eq 0 ];
then
sleep 1
echo STARTED
else
echo FAILED TO WRITE PID
exit 1
fi
else
echo SERVER DID NOT START
exit 1
fi
}stop(){
echo -n "Stopping zkui ... "
if [ ! -f "$PIDFILE" ]
then
echo "no zkui to stop (could not find file $PIDFILE)"
else
kill -9 $(cat "$PIDFILE")
rm "$PIDFILE"
echo STOPPED
fi
exit 0
}case "$1" in
start)
start
;;
stop)
stop
;;
restart)
shift
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
esac
执行命令启动服务
[root@www zkui]# ll
总用量 108
-rw-r--r-- 1 root root 2385 8月 27 13:46 config.cfg
drwxr-xr-x 2 root root 61 8月 27 13:46 docker
drwxr-xr-x 2 root root 114 8月 27 13:46 images
-rw-r--r-- 1 root root 11358 8月 27 13:46 LICENSE-2.0.txt
-rw-r--r-- 1 root root 416 8月 27 13:46 Makefile
-rw-r--r-- 1 root root 1746 8月 27 13:46 nbactions.xml
-rw-r--r-- 1 root root 5374 8月 27 13:46 pom.xml
-rw-r--r-- 1 root root 6216 8月 27 13:46 README.md
-rwxr-xr-x 1 root root 43 8月 27 13:46 run.sh
drwxr-xr-x 4 root root 30 8月 27 13:46 src
drwxr-xr-x 7 root root 205 8月 27 14:07 target
-rw-r--r-- 1 root root 43008 8月 27 14:09 zkui.h2.db
-rw-r--r-- 1 root root 848 8月 27 14:07 zkui.out
-rw-r--r-- 1 root root 11065 8月 27 14:09 zkui-out.log
-rwxr-xr-x 1 root root 1252 8月 27 13:51 zkui.sh
[root@www zkui]# ./zkui.sh stop
Stopping zkui ... STOPPED
[root@www zkui]# ./zkui.sh start
Starting zkui ... /usr/local/zkui/zkui
STARTED
查看启动端口:
[root@www zkui]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8877 0.0.0.0:* LISTEN 1174/nginx: master
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 654/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1136/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1411/master
tcp6 0 0 :::9999 :::* LISTEN 3642/java
tcp6 0 0 :::111 :::* LISTEN 654/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1136/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1411/master
[root@www zkui]# cd target/
[root@www target]# ll
总用量 13556
drwxr-xr-x 2 root root 6 8月 27 13:47 archive-tmp
drwxr-xr-x 5 root root 101 8月 27 13:47 classes
-rw-r--r-- 1 root root 2385 8月 27 14:13 config.cfg
drwxr-xr-x 4 root root 49 8月 27 13:47 generated-sources
drwxr-xr-x 2 root root 28 8月 27 13:47 maven-archiver
drwxr-xr-x 3 root root 17 8月 27 13:47 test-classes
-rw-r--r-- 1 root root 277078 8月 27 13:47 zkui-2.0-SNAPSHOT.jar
-rw-r--r-- 1 root root 13595676 8月 27 13:47 zkui-2.0-SNAPSHOT-jar-with-dependencies.jar
[root@www target]# ps -ef |grep zkui
root 5176 1 1 14:13 pts/0 00:00:24 java -jar /usr/local/zkui/zkui/target/zkui-2.0-SNAPSHOT-jar-with-dependencies.jar
root 5448 1737 0 14:36 pts/0 00:00:00 grep --color=auto zkui
八:浏览器访问:
http://192.168.1.111:9999/login
输入: admin/manager 登录
九: “stat is not executed because it is not in the whitelist.” 异常解决
原因
zookeeper.4lw.commands.whitelist:3.4.10中的新增功能:此属性包含以逗号分隔的四个字母单词命令的列表。引入它是为了对ZooKeeper可执行的命令集提供精细的控制,因此用户可以在必要时关闭某些命令。默认情况下,如果未指定该属性,则它包含所有受支持的四个字母单词命令,但“ wchp”和“ wchc”除外。如果指定了属性,则仅启用白名单中列出的命令。
解决方案: 在zoo.cfg文件中添加
在
zookeeper
配置中新增
4lw.commands.whitelist=*
点击Monitor:
十: 修改后重启,再次查看
Server: 192.168.1.100:2181
Zookeeper version: 3.9.0-1674a5e97f43bc38e9bf56b04f83a7ae34d68249, built on 2023-07-19 09:09 UTC
Clients:
/192.168.1.111:50992[1](queued=0,recved=9,sent=9)
/192.168.1.111:50994[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/2.8889/10
Received: 11
Sent: 10
Connections: 2
Outstanding: 0
Zxid: 0x400000002
Mode: follower
Node count: 7
Environment:
zookeeper.version=3.9.0-1674a5e97f43bc38e9bf56b04f83a7ae34d68249, built on 2023-07-19 09:09 UTC
host.name=docker0
java.version=1.8.0_371
Server: 192.168.1.101:2181
Zookeeper version: 3.9.0-1674a5e97f43bc38e9bf56b04f83a7ae34d68249, built on 2023-07-19 09:09 UTC
Clients:
/192.168.1.111:54260[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0.0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x400000002
Mode: follower
Node count: 7
Environment:
zookeeper.version=3.9.0-1674a5e97f43bc38e9bf56b04f83a7ae34d68249, built on 2023-07-19 09:09 UTC
host.name=docker1
java.version=1.8.0_371
Server: 192.168.1.102:2181
Zookeeper version: 3.9.0-1674a5e97f43bc38e9bf56b04f83a7ae34d68249, built on 2023-07-19 09:09 UTC
Clients:
/192.168.1.111:40514[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0.0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x400000002
Mode: leader
Node count: 7
Proposal sizes last/min/max: 48/48/48
Environment:
zookeeper.version=3.9.0-1674a5e97f43bc38e9bf56b04f83a7ae34d68249, built on 2023-07-19 09:09 UTC
host.name=docker2
java.version=1.8.0_371
可以看到Zookeeper集群已经纳入监控
[root@www ~]# echo stat |nc localhost 2181
Zookeeper version: 3.9.0-1674a5e97f43bc38e9bf56b04f83a7ae34d68249, built on 2023-07-19 09:09 UTC
Clients:
/0:0:0:0:0:0:0:1:49704[0](queued=0,recved=1,sent=0)Latency min/avg/max: 0/0.0/0
Received: 3
Sent: 2
Connections: 1
Outstanding: 0
Zxid: 0x400000002
Mode: leader
Node count: 7
Proposal sizes last/min/max: 48/48/48
[root@www conf]# echo stat |nc localhost 2181
Zookeeper version: 3.9.0-1674a5e97f43bc38e9bf56b04f83a7ae34d68249, built on 2023-07-19 09:09 UTC
Clients:
/0:0:0:0:0:0:0:1:33244[0](queued=0,recved=1,sent=0)
/192.168.1.111:50992[1](queued=0,recved=58,sent=58)Latency min/avg/max: 0/1.1207/10
Received: 62
Sent: 61
Connections: 2
Outstanding: 0
Zxid: 0x400000002
Mode: follower
Node count: 7
[root@www ~]# echo stat |nc localhost 2181
Zookeeper version: 3.9.0-1674a5e97f43bc38e9bf56b04f83a7ae34d68249, built on 2023-07-19 09:09 UTC
Clients:
/0:0:0:0:0:0:0:1:33320[0](queued=0,recved=1,sent=0)Latency min/avg/max: 0/0.0/0
Received: 3
Sent: 2
Connections: 1
Outstanding: 0
Zxid: 0x400000002
Mode: follower
Node count: 7