Zookeeper的服务器的log4j升级为log4j2的升级方案(忽略配置化兼容问题) - 洛神灬殇
source link: https://www.cnblogs.com/liboware/p/16928708.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
参考在线markdown编辑器:
http://marxi.co/
Zookeeper的服务器的log4j升级为log4j2的升级方案(忽略配置化兼容问题)
目前希望可以升级将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服务,进行查看是否启动正常
可以通过:
ps -ef | grep zookeeper
来查看是否正常启动服务
查看是否已经存在加载的对应的jar包服务
如果没有输出目录文件属于正常情况
当然一般情况下也可以执行查看/bin/zookeeper.out文件信息,打印log。
参考配置(zoo.cfg)
# 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=/tmp/zookeeper # 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 ## Metrics Providers # # https://prometheus.io Metrics Exporter #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider #metricsProvider.httpPort=7000 #metricsProvider.exportJvmInfo=true
__EOF__
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK