参考在线 markdown 编辑器:http://marxi.co/
目前希望可以升级将 Zookeeper 中 log4j 的版本升级到 log4j2 版本,并且要避开相关的 log4j2 的安全隐患问题,此时需要考虑的就是针对于如何将无缝衔接 log4j2 的版本 jar 包的安装呢?我们接下来观察一下看看问题所在。目前我采用的环境是 windows 环境,不过也同样对其他操作系统有效,毕竟万变不离其宗嘛。
Zookeeper 的服务的基础目录
windows 目录
Linux 目录
寻找对应的目录
首先我们需要进行替换相关的 lib 包信息,我们需要将相关的 zookeeper 中所相关的 log4j 相关的 jar 先迁移走,如下图所示:
windows 目录
Linux 目录
下图为 Linux 版本的相关的 jar 包展示
替换的 Jar 包目录为:
log4j-1.2.17.jar log4j 的本身的 jar 包服务
slf4j-api-1.7.30.jar slf4j 的 api 官方抽象接口包
slf4j-log4j12-1.7.30.jar 主要用于桥接处理包(slf4j 与 log4j 的桥接之用的包)
以上案例主要采用的是针对于 log4j 和 slf4j 的 jar 包进行相关的处理控制。版本制作参考之用。
参考相关的清理相关的 jar 包指令,可以采用 rm / mv 指令进行操作处理。
rm -rf slf4j-api-1.7.x.jar log4j-1.2.x.jar slf4j-log4j12-1.7.X.jar
复制代码
mv slf4j-api-1.7.X.jar log4j-1.2.X.jar slf4j-log4j12-1.7.x.jar /backup 路径也可
复制代码
注意具体的版本需要,可动态灵活进行调整对应的接口参数。
下载对应的 Log4j2 的资源包
下载对应 slf4j 包
wget --no-check-certificate https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar
复制代码
版本暂时统一为 1.7.36,测试了一下目前属于最稳定版本
下载对应 log4j2 包
wget --no-check-certificate https://dlcdn.apache.org/logging/log4j/2.19.0/apache-log4j-2.19.0-bin.tar.gz
复制代码
解压对应 log4j2 包 zookeeper 的 lib 包目录下
tar -zxvf apache-log4j-2.19.0-bin.tar.gz
复制代码
转移 jar 包到对应的 lib 下之后。
转移指定的 log4j2 包到 Zookeeper 的 lib 包目录下
mv log4j-core-2.19.0.jar log4j-1.2-api-2.19.0.jar log4j-slf4j-impl-2.19.0.jar log4j-api-2.19.0.jar /{ZK_HOME}/lib
复制代码
转移指定的 slf4j 包到 Zookeeper 的 lib 包目录下
mv slf4j-api-1.7.36.jar /{ZK_HOME}/lib
复制代码
展示效果
开始重启 Zookeeper 服务,进行查看是否启动正常
可以通过:
来查看是否正常启动服务
查看是否已经存在加载的对应的 jar 包服务
如果没有输出目录文件属于正常情况
当然一般情况下也可以执行查看/bin/zookeeper.out 文件信息,打印 log。
参考案例
参考配置(zoo.cfg)
# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=/tmp/zookeeper# the port at which the clients will connectclientPort=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
## Metrics Providers## https://prometheus.io Metrics Exporter#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider#metricsProvider.httpPort=7000#metricsProvider.exportJvmInfo=true
复制代码
评论