99: Cannot assign requested addressnginx
#本地網卡上沒有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方法:app
出現上面的問題就是在物理網卡上沒有與配置文件例監聽的IP相對應的IP,解決方法是在/etc/sysctl.conf 中加入以下內核參數配置spa
echo 'net.ipv4.ip_nonlocal_bind = 1' >>/etc/sysctl.conf sysctl -p# 生效 #也能夠用如下方法讓Nginx啓動時忽略配置中監聽的VIP是否存在一樣適合haproxy echo "1" >/proc/sys/net/ipv4/ip_nonlocal_bind