Server是运行Ubuntu 12.04的Xen VPS,重启后nginx和NSD3都没有出现。 明显的原因是,它们无法在引导后立即绑定到分配的IP地址,
来自/var/log/boot.log
* Starting configure network device [ OK ] * Stopping save kernel messages [ OK ] * Starting MTA [ OK ] nginx: [emerg] bind() to [2a01:1b0:removed:1c9c]:80 failed (99: Cannot assign requested address) * Starting nsd3... [ OK ] [...] * Starting configure virtual network devices [ OK ] * Stopping configure virtual network devices [ OK ]
来自/var/log/nsd.log
[1351715473] nsd[956]: error: can't bind udp socket: Cannot assign requested address [1351715473] nsd[956]: error: server initialization failed, nsd could not be started
几秒钟后,一切正常,nginx和NSD3都可以启动。
在我看来,问题是在错误的启动顺序,nginx和NSD3是在networkingconfiguration完全发生之前启动的。 我通过放置它来解决这个问题
# nginx and nsd boot fix sleep 4 /etc/init.d/nsd3 start /etc/init.d/nginx start
在/etc/rc.local中,但这不是一个合适的解决scheme。 处理这个问题的正确方法是什么?
这是我的基本networkingconfiguration,从/ etc / network / interfaces auto eth0
iface eth0 inet static address 89.removed.121 gateway 89.removed.1 netmask 255.255.255.0 iface eth0 inet6 static up echo 0 > /proc/sys/net/ipv6/conf/all/autoconf up echo 0 > /proc/sys/net/ipv6/conf/default/autoconf netmask 64 gateway 2a01:removed:0001 address 2a01:removed:7c3b up ip addr add 2a01:removed:62bd dev eth0 preferred_lft 0 up ip addr add 2a01:removed:ce6d dev eth0 preferred_lft 0 up ip addr add 2a01:removed:3e13 dev eth0 preferred_lft 0 up ip addr add 2a01:removed:1c9c dev eth0 preferred_lft 0 auto lo iface lo inet loopback
那些尴尬的ID addr在那里,因为我想添加额外的IP,但仍然使用源于服务器的所有stream量的第一个。
看起来nsd3必须在networking之后启动。 在/etc/init.d/nsd3文件的Required-Start部分添加$ network应该可以解决这个问题。
最简单的解决方法是不要将nginx或nsd绑定到特定的IP地址,而是监听任何地址。 比如在nginx中:
listen [::]:80;
修复您的networking接口脚本不太容易。 现在你已经configuration了IP地址,你的IP地址被路由给你,但是它们并没有被实际绑定到接口上,程序可以明确地监听它们。 (如果他们绑定到任何地址,他们只接收stream量,如上所述)。为此,您需要额外的iface部分,而不是ip route命令。
iface eth0 inet6 static address 2001:db8::1234 netmask 64 iface eth0 inet6 static address 2001:db8::5678 netmask 64 iface eth0 inet6 static address 2001:db8::abcd netmask 64