Dubbo Failed to save registry store file, cause: Can not lock the registry cache file

1 篇文章 0 订阅

转载自:http://blog.csdn.net/top_code/article/details/52279072

 

启动的Dubbo 服务的时候报错,异常信息如下:

2016-08-22 16:44:40.588 | DubboSaveRegistryCache-thread-1 | WARN  | 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]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

报错的大概意思是 Dubbo在保存服务列表时失败,Can not lock the registry cache file /root/.dubbo/dubbo-registry-10.141.4.168.cache,拿不到文件锁,无法保存服务列表。

错误原因

出现这个的原因是服务向ZK注册的同时,会缓存Consumer的列表,写入user.home/.dubbo/dubbo-registry-” + url.getHost() + “.cache 这个文件,当在同一个机器上启动多个Provider的时候,就会出现文件锁争用的问题,报上面这个错误。

解决办法

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

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

<dubbo:registry id="zkcenter" protocol="zookeeper" address="${dubbo.zk_address}" file="${catalina.home}/dubbo-registry/dubbo-registry.properties"/>
  • 1
  • 1

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

参考资料

AbstractRegistry lock problem:https://github.com/alibaba/dubbo/issues/81

 

provider:服务提供者

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值