Failed to save registry cache file, will retry, cause: Can not lock the registry cache

问题描述:

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

Failed to save registry cache file, will retry, cause: Can not lock the registry cache file /root/.dubbo/dubbo-registry-finance-service-xxx.xx.xxx.xxx-2181.cache, ignore and retry later, maybe multi java process use the file, please config: dubbo.registry.file=xxx.properties, dubbo version: 2.7.6, current host: xxx.xx.x.x
java.io.IOException: Can not lock the registry cache file /root/.dubbo/dubbo-registry-finance-service-xxx.xx.xxx.xxx-2181.cache, ignore and retry later, maybe multi java process use the file, please config: dubbo.registry.file=xxx.properties

从异常看,是多个线程都要写信息,导致不能获取锁,同时也不尝试再次获取


原因分析:

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


解决方案:

服务模块各自缓存自己的cache文件,在<dubbo:registry />中加入 file=“dubboregistry/dubbo-registry.properties” ,这样就会在bin目录下生成dubboregistry这个目录,cache文件就缓存在这个里边了。

参考:

链接: https://github.com/alibaba/dubbo/issues/81

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值