Nginx无法监听虚拟VIP的问题报:99: Cannot assign requested address

99: Cannot assign requested address

#本地网卡上没有10.0.0.3这个IPNginx就会报错:

[root@lb01 conf]# /application/nginx/sbin/nginx -t

nginx: the configuration file /application/nginx-1.10.2/conf/nginx.conf syntax is ok

nginx: [emerg] bind() to 10.0.0.3:80 failed (99: Cannot assign requested address)

nginx: configuration file /application/nginx-1.10.2/conf/nginx.conf test failed

[root@lb01 conf]# ip a s eth0

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 00:0c:29:27:4e:e9 brd ff:ff:ff:ff:ff:ff

    inet 10.0.0.5/24 brd 10.0.0.255 scope global eth0

    inet6 fe80::20c:29ff:fe27:4ee9/64 scope link

       valid_lft forever preferred_lft forever

#注意:nginx 没有办法 监听 本地不存在的ip地址 

解决Nginx监听虚拟VIP方法:

出现上面的问题就是在物理网卡上没有与配置文件例监听的IP相对应的IP,解决方法是在/etc/sysctl.conf 中加入如下内核参数配置

echo 'net.ipv4.ip_nonlocal_bind = 1' >>/etc/sysctl.conf

sysctl -p# 生效 

#也可以用以下方法让Nginx启动时忽略配置中监听的VIP是否存在同样适合haproxy

echo "1" >/proc/sys/net/ipv4/ip_nonlocal_bind

 

转载于:https://www.cnblogs.com/HByang/p/9280853.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值