dubbo获取本机IP
发布Java应用到阿里云,启动失败,部分堆栈如下:
at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:502) at java.net.InetAddress.checkLookupTable(InetAddress.java:1393) ... at com.alibaba.dubbo.common.utils.NetUtils.getLocalAddress0(NetUtils.java:188) at com.alibaba.dubbo.common.utils.NetUtils.getLocalAddress(NetUtils.java:180) at com.alibaba.dubbo.common.utils.NetUtils.getLocalHost(NetUtils.java:146) at com.alibaba.dubbo.common.logger.support.FailsafeLogger.appendContextMessage(FailsafeLogger.java:40) at com.alibaba.dubbo.common.logger.support.FailsafeLogger.warn(FailsafeLogger.java:110) at com.alibaba.dubbo.common.utils.NetUtils.getLocalAddress0(NetUtils.java:220) at com.alibaba.dubbo.common.utils.NetUtils.getLocalAddress(NetUtils.java:180) at com.alibaba.dubbo.common.utils.NetUtils.getLocalHost(NetUtils.java:146) at com.alibaba.dubbo.common.logger.support.FailsafeLogger.appendContextMessage(FailsafeLogger.java:40)
看了代码,发现是dubbo的小bug:getLocalHost失败会调用日志打印,日志打印的时候会自动带上本机域名(调用getLocalHost),造成循环调用。
2种解决方法:
- 在 /etc/hosts 指定域名解析(自定义了hostname,但是没设定对应IP)
- 升级到dubbo 2.6.3或后续版本
指定域名解析的方式还有其它用途:daily环境从内网迁移到阿里云,指定解析为外网IP,方便在内网调用。
相关推荐
aNian 2020-06-16
香帅 2020-05-09
ATenhong 2020-10-15
supperme 2020-09-08
doctorvian 2020-08-02
aNian 2020-08-01
kongjunlongaa 2020-06-29
Fightingxr 2020-06-26
whileinsist 2020-06-24
doctorvian 2020-06-16
XuNeely 2020-06-16
wangyangsoftware 2020-06-16
大步流星 2020-06-16
gaoyongstone 2020-06-16
MartellJenkins 2020-06-11
范群松 2020-06-11
Fightingxr 2020-06-08
XuNeely 2020-06-07