centos 多网卡 dubbo 启动异常【已解决】
dubbo应用启动报错:
[DUBBO] Destroy unsubscribe url consumer://192.168.0.240
原来是机器上多网卡导致。
目前我的解决方案是:删除那个无用的网卡配置
补充:如果两块网卡都需要用起来,可以尝试换下配置顺序,dubbo会去找第一个合理的网卡IP
dubbo获取本机ip地址的方法封装在com.alibaba.dubbo.common.utils.NetUtils类里面(dubbo-2.6.2.jar)。
其中有一个方法 getLocalAddress() 遍历本地网卡,返回第一个合理的IP
/** * Find first valid IP from local network card * * @return first valid local IP */ public static InetAddress getLocalAddress() { if (LOCAL_ADDRESS != null) return LOCAL_ADDRESS; InetAddress localAddress = getLocalAddress0(); LOCAL_ADDRESS = localAddress; return localAddress; }
centos 查看IP地址
ip -4 addr
[root@prod-39 outfit-order]# ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
inet 10.0.0.39/8 brd 10.255.255.255 scope global em1
valid_lft forever preferred_lft forever
3: em2: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen 1000
inet 192.168.0.240/24 brd 192.168.0.255 scope global em2
valid_lft forever preferred_lft forever
nmcli connection show
[root@prod-39 outfit-order]# nmcli connection show
名称 UUID 类型 设备
em1 ************************************************ 802-3-ethernet em1
em2 3997fdd6-****-****-****-********3154c6ab87 802-3-ethernet em2
em3 ************************************************ 802-3-ethernet --
em4 ************************************************ 802-3-ethernet --
cd /etc/sysconfig/network-scripts;ls
...
ifcfg-em2
...
备份
cp ifcfg-em2 ifcfg-em2.back
删除
nmcli connection delete em2
再看
nmcli connection show
[root@prod-39 outfit-order]# nmcli connection show
名称 UUID 类型 设备
em1 ************************************************ 802-3-ethernet em1
em3 ************************************************ 802-3-ethernet --
em4 ************************************************ 802-3-ethernet --
ip -4 addr
[root@prod-39 network-scripts]# ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
inet 10.0.0.39/8 brd 10.255.255.255 scope global em1
valid_lft forever preferred_lft forever
OK , 问题解决
上一篇: Java 计算党费