dubbo 启动Failed to save registry store file报错

2020-09-27 10:37:40 浏览数 (1)

代码语言:javascript复制
com.alibaba.dubbo.common.logger.log4j.Log4jLogger:Log4jLogger.java(78) |  [DUBBO] Failed to save registry store file, cause: Can not lock the registry cache file /root/.dubbo/dubbo-registry-10.141.4.168.cache, ignore and retry later, maybe multi java process use the file, please config: dubbo.registry.file=xxx.properties, dubbo version: 2.8.3, current host: 127.0.0.1
java.io.IOException: Can not lock the registry cache file /root/.dubbo/dubbo-registry-10.141.4.168.cache, ignore and retry later, maybe multi java process use the file, please config: dubbo.registry.file=xxx.properties
        at com.alibaba.dubbo.registry.support.AbstractRegistry.doSaveProperties(AbstractRegistry.java:193) ~[dubbo-2.8.3.jar:2.8.3]
        at com.alibaba.dubbo.registry.support.AbstractRegistry$SaveProperties.run(AbstractRegistry.java:150) [dubbo-2.8.3.jar:2.8.3]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_60]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_60]
        at java.lang.Thread.run(Thread.java:745) [na:1.7.0_60]
原因

Can not lock the registry cache file /root/.dubbo/dubbo-registry-10.141.4.168.cache,拿不到文件锁,无法保存服务列表。

解决办法

既然是由于竞争文件锁导致的,那么让服务模块各自缓存自己的cache文件就可以避免这样的问题了。

具体做法是:在provider的xml配置文件中加入 file=”${catalina.home}/dubbo-registry/dubbo-registry.properties” ,如下:

代码语言:javascript复制
<dubbo:registry id="zkcenter" protocol="zookeeper" address="${dubbo.zk_address}" file="${catalina.home}/dubbo-registry/dubbo-registry.properties"/>

这样就会在catalina.home目录下生成dubbo-registry这个目录,cache文件就缓存在这个里边了。

0 人点赞