部署cat版本为V3.1.0。docker安装。
docker启动错误信息如下:
log4j:WARN No appenders could be found for logger (io.netty.util.internal.logging.InternalLoggerFactory).
log4j:WARN Please initialize the log4j system properly.
[05-18 13:28:11.011] [INFO] [cat] Cat is lazy initialized!
java.lang.RuntimeException: Error when initializing modules! Exception: java.lang.RuntimeException: Unable to get component: class com.dianping.cat.analysis.TcpSocketReceiver.
看日志是cat已经加载,但是报错了。造成这个原因是:
主要就是数据库的连接问题。
排查方向:
- 数据库用mysql5.7试试
- 确保/data/appdatas/cat/datasources.xml的数据库配置是否正确
我的这个错误是,通过官网的docker进行安装,用的环境变量通过datasources.sh脚本写到datasources.xml文件里的。但是写入的时候报错了。(官方提供的脚本是用sed -i进行替换)
替换时报错信息为:
{"log":"sed: can't move '/data/appdatas/cat/datasources.xmlOlohei' to '/data/appdatas/cat/datasources.xml': Resource busy\n","stream":"stderr","time":"2023-07-19T13:06:40.419148982Z"}
{"log":"sed: can't move '/data/appdatas/cat/datasources.xmlAFLabB' to '/data/appdatas/cat/datasources.xml': Resource busy\n","stream":"stderr","time":"2023-07-19T13:06:40.419821155Z"}
{"log":"sed: can't move '/data/appdatas/cat/datasources.xmlKhLLPb' to '/data/appdatas/cat/datasources.xml': Resource busy\n","stream":"stderr","time":"2023-07-19T13:06:40.420463023Z"}
{"log":"sed: can't move '/data/appdatas/cat/datasources.xmlDDgmFa' to '/data/appdatas/cat/datasources.xml': Resource busy\n","stream":"stderr","time":"2023-07-19T13:06:40.421803972Z"}
{"log":"sed: can't move '/data/appdatas/cat/datasources.xmlMAmfAj' to '/data/appdatas/cat/datasources.xml': Resource busy\n","stream":"stderr","time":"2023-07-19T13:06:40.422388276Z"}
所以写入失败,导致数据库连接不上。
尝试了各种写入方式,都写不进去。最后用的最粗暴的方式,不用环境变量了。直接修改datasources.xml的环境变量参数,替换成真实的值。
再次启动就成功了。