0 课程地址
https://coding.imooc.com/lesson/201.html#mid=12713
1 重点关注
1.1 [mntr] 监控zk健康信息
进入shell命令页而不是zookeeper命令页
echo mntr | nc localhost 2181
echo mntr | nc localhost 2181 输出: zk_version 3.4.11-37e277162d567b55a07d1755f0b31c32e93c01a0, built on 11/01/2017 18:06 GMT zk_avg_latency 1 zk_max_latency 18 zk_min_latency 0 zk_packets_received 14 zk_packets_sent 13 zk_num_alive_connections 2 zk_outstanding_requests 0 zk_server_state standalone zk_znode_count 13 --节点数(包含永久节点和临时节点) zk_watch_count 0 --watch数量 zk_ephemerals_count 0 --临时节点 zk_approximate_data_size 130 zk_open_file_descriptor_count 30 zk_max_file_descriptor_count 4096
1.2 [wchs] 展示watch的信息
echo wchs | nc localhost 2181
echo wchs | nc localhost 2181 输出: 0 connections watching 0 paths Total watches:0
开启客户端和服务端 见2.2 get /names watch --添加watch信息 输出: names cZxid = 0x49 ctime = Tue Feb 20 07:06:56 CST 2024 mZxid = 0x49 mtime = Tue Feb 20 07:06:56 CST 2024 pZxid = 0x63 cversion = 6 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 5 numChildren = 2 echo wchs | nc localhost 2181 输出: 1 connections watching 1 paths Total watches:1
1.3 [wchc] 与 [wchp] session与watch 及 path与watch信息
- 配置文件开启相关命令:
cd /usr/local/zookeeper/conf/
vim zoo.cfg
最后一行加入 4lw.commands.whitelist=*
保存后重启 --参照2.2
- 执行相关命令
echo wchc | nc localhost 2181
echo wchp | nc localhost 2181
注意:需要新建个watch事件,否则没有session无法验证
get /names watch --添加watch信息 输出: names cZxid = 0x49 ctime = Tue Feb 20 07:06:56 CST 2024 mZxid = 0x49 mtime = Tue Feb 20 07:06:56 CST 2024 pZxid = 0x63 cversion = 6 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 5 numChildren = 2 echo wchc | nc localhost 2181 输出: 0x10000513f000000 /names echo wchp | nc localhost 2181 输出: /names 0x10000513f000000
2 课程内容
2.1 课程内容
2.2 启动项目
进入zk目录 cd /usr/local/zookeeper/bin/ 启动服务端 ./zkServer.sh restart 启动客户端 ./zkCli.sh
3 Coding
诸葛