这是我参与11月更文挑战的第21天,活动详情查看:2021最后一次更文挑战
问题
zookeeper4字运维指令:is not executed because it is not in the whitelist
如果需要直接看解决办法的可以直接路过分析过程,看最后面,其实原因分析也很简单。
问题描述
本来是想用wchc查看监听路径信息的,结果使用这个指令查询的时候,zookeeper服务器返回的响应信息是:
wchc is not executed because it is not in the whitelist.
分析原因
查了下日志,找到了这条信息是从这个类org.apache.zookeeper.server.NettyServerCnxn
里返回的,然后直接上github找到源码在这个类里,找到这条信息出现的方法体内,如下:
1 | java复制代码/** Return if four letter word found and responded to, otw false **/ |
看我中文注释的地方,就可以确定问题点在FourLetterCommands这个类里,然后进入这个类:org.apache.zookeeper.server.command.FourLetterCommands
,找到isEnabled这个方法,源码如下:
1 | java复制代码 /** |
下面是cmd2String初始化缓存的所有指令,结合上面的代码来看:
1 | java复制代码 // specify all of the commands that are available |
重点看我上面代码的中文说明,便明白,可以在启动脚本里添加VM环境变量-Dzookeeper.4lw.commands.whitelist=*
,便可以把所有指令添加到白名单,我是添加在脚本的这个位置:
1 | bash复制代码 ZOOMAIN="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=$JMXPORT -Dcom.sun.management.jmxremote.authenticate=$JMXAUTH -Dcom.sun.management.jmxremote.ssl=$JMXSSL -Dzookeeper.jmx.log4j.disable=$JMXLOG4J org.apache.zookeeper.server.quorum.QuorumPeerMain" |
然后重启,问题就解决了
本文转载自: 掘金