如何在ubuntu启动过程中提前启动eth0 / eth1

让我们看看我能否解释这个权利:

  1. 我有两个以太网接口的服务器 – 一个外部和一个内部面对。
  2. 我在一台服务器上有一个DB(pg),可以从内部networking上的其他机器访问。
  3. 我有其他服务器上的RoR应用程序,并configuration为使用所述数据库服务器上的数据库。
  4. Mongrel Clustersconfiguration正确 – 我可以启动集群并通过控制台访问Rails应用程序。
  5. 我在Ubuntu 9.10服务器版。
  6. IP在机器上静态分配 – 没有DHCP工作。

好了,所以问题是init脚本启动Mongrel火灾之前,以太网适配器似乎出现。 当然,问题在于数据库对于Rails应用程序来说是不可见的,因为networking还没有激活。

系统日志引导事件的相关部分在下面发布。

我通过使用/usr/sbin/update-rc.d mongrel_cluster默认值,将“通常”的mongrel脚本添加到init中。 我已将“启动顺序”移至99z_mongrel_cluster。 请注意,在下面的系统日志中,杂项群集在CRON之后立即执行,所以似乎我已经尽可能晚地把它写到init.d.

看起来像是在初始化周期结束时,以太网接口尝试激活,然后花一些时间来激活。 我对这一些有点无知,但它看起来像我们从7.537 …在tcpdump到eth0网卡在9.266 …超过1.5秒加载?

这在我使用DHCP分配静态IP地址的其他环境中是“应该的”。

所以,问题是:

  1. 有没有办法让网卡更快或更快地加载(基于高清出现我猜“快”问题)?

  2. 有没有办法确保在进入其他初始化任务之前,网卡是活动的? 根据我所读到的LSB规范,我已经把$ network放在了用于杂种群集的Required-Start的初始化脚本中(再次,在其他testing环境中不必这样做)。

  3. 有什么我必须做的configurationnetworking加载更快? 我的/ etc / hosts和/etc/resolv.conf 看起来是正确的。

  4. 司机问题?

非常感谢。 我一直在为此挠了挠脑筋。

Jul 26 15:08:03 web-01 kernel: [ 4.166954] usbhid: v2.6:USB HID core driver Jul 26 15:08:03 web-01 kernel: [ 4.321657] 0000:03:00.0: eth0: (PCI Express:2.5GB/s:Width x1) 00:30:48:9f:08:cc Jul 26 15:08:03 web-01 kernel: [ 4.321659] 0000:03:00.0: eth0: Intel(R) PRO/1000 Network Connection Jul 26 15:08:03 web-01 kernel: [ 4.321743] 0000:03:00.0: eth0: MAC: 3, PHY: 8, PBA No: 0101ff-0ff Jul 26 15:08:03 web-01 kernel: [ 4.321974] e1000e 0000:04:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17 Jul 26 15:08:03 web-01 kernel: [ 4.322008] e1000e 0000:04:00.0: setting latency timer to 64 Jul 26 15:08:03 web-01 kernel: [ 4.322264] alloc irq_desc for 37 on node 0 Jul 26 15:08:03 web-01 kernel: [ 4.322265] alloc kstat_irqs on node 0 Jul 26 15:08:03 web-01 kernel: [ 4.322270] e1000e 0000:04:00.0: irq 37 for MSI/MSI-X Jul 26 15:08:03 web-01 kernel: [ 4.322271] alloc irq_desc for 38 on node 0 Jul 26 15:08:03 web-01 kernel: [ 4.322272] alloc kstat_irqs on node 0 Jul 26 15:08:03 web-01 kernel: [ 4.322274] e1000e 0000:04:00.0: irq 38 for MSI/MSI-X Jul 26 15:08:03 web-01 kernel: [ 4.322275] alloc irq_desc for 39 on node 0 Jul 26 15:08:03 web-01 kernel: [ 4.322276] alloc kstat_irqs on node 0 Jul 26 15:08:03 web-01 kernel: [ 4.322278] e1000e 0000:04:00.0: irq 39 for MSI/MSI-X Jul 26 15:08:03 web-01 kernel: [ 4.397418] scsi6 : 3ware 9000 Storage Controller Jul 26 15:08:03 web-01 kernel: [ 4.397484] 3w-9xxx: scsi6: Found a 3ware 9000 Storage Controller at 0xfadff000, IRQ: 16. Jul 26 15:08:03 web-01 kernel: [ 4.481131] 0000:04:00.0: eth1: (PCI Express:2.5GB/s:Width x1) 00:30:48:9f:08:cd Jul 26 15:08:03 web-01 kernel: [ 4.481133] 0000:04:00.0: eth1: Intel(R) PRO/1000 Network Connection Jul 26 15:08:03 web-01 kernel: [ 4.481218] 0000:04:00.0: eth1: MAC: 3, PHY: 8, PBA No: 0101ff-0ff Jul 26 15:08:03 web-01 kernel: [ 4.757252] 3w-9xxx: scsi6: Firmware FE9X 4.10.00.007, BIOS BE9X 4.08.00.002, Ports: 2. Jul 26 15:08:03 web-01 kernel: [ 4.757743] scsi 6:0:0:0: Direct-Access AMCC 9650SE-2LP DISK 4.10 PQ: 0 ANSI: 5 Jul 26 15:08:03 web-01 kernel: [ 4.768713] sd 6:0:0:0: Attached scsi generic sg0 type 0 Jul 26 15:08:03 web-01 kernel: [ 4.769035] sd 6:0:0:0: [sda] 585916416 512-byte logical blocks: (299 GB/279 GiB) Jul 26 15:08:03 web-01 kernel: [ 4.769880] sd 6:0:0:0: [sda] Write Protect is off Jul 26 15:08:03 web-01 kernel: [ 4.769885] sd 6:0:0:0: [sda] Mode Sense: 23 00 10 00 Jul 26 15:08:03 web-01 kernel: [ 4.770609] sd 6:0:0:0: [sda] Write cache: disabled, read cache: enabled, supports DPO and FUA Jul 26 15:08:03 web-01 kernel: [ 4.772342] sda: sda1 sda2 < sda5 > Jul 26 15:08:03 web-01 kernel: [ 4.775558] sd 6:0:0:0: [sda] Attached SCSI disk Jul 26 15:08:03 web-01 kernel: [ 5.278745] PM: Starting manual resume from disk Jul 26 15:08:03 web-01 kernel: [ 5.278747] PM: Resume from partition 252:1 Jul 26 15:08:03 web-01 kernel: [ 5.278748] PM: Checking hibernation image. Jul 26 15:08:03 web-01 kernel: [ 5.278922] PM: Resume from disk failed. Jul 26 15:08:03 web-01 kernel: [ 5.301586] kjournald starting. Commit interval 5 seconds Jul 26 15:08:03 web-01 kernel: [ 5.301606] EXT3-fs: mounted filesystem with ordered data mode. Jul 26 15:08:03 web-01 kernel: [ 5.689456] type=1505 audit(1280182081.322:2): operation="profile_load" pid=480 name=/sbin/dhclient3 Jul 26 15:08:03 web-01 kernel: [ 5.689838] type=1505 audit(1280182081.322:3): operation="profile_load" pid=480 name=/usr/lib/NetworkManager/nm-dhcp-client.action Jul 26 15:08:03 web-01 kernel: [ 5.690045] type=1505 audit(1280182081.322:4): operation="profile_load" pid=480 name=/usr/lib/connman/scripts/dhclient-script Jul 26 15:08:03 web-01 kernel: [ 5.703353] type=1505 audit(1280182081.332:5): operation="profile_load" pid=481 name=/usr/sbin/tcpdump Jul 26 15:08:03 web-01 kernel: [ 6.118815] Adding 1949688k swap on /dev/mapper/web--01-swap. Priority:-1 extents:1 across:1949688k Jul 26 15:08:03 web-01 kernel: [ 6.262044] EXT3 FS on dm-0, internal journal Jul 26 15:08:03 web-01 kernel: [ 6.298767] udev: starting version 147 Jul 26 15:08:03 web-01 kernel: [ 6.798595] ADDRCONF(NETDEV_UP): eth1: link is not ready Jul 26 15:08:03 web-01 kernel: [ 6.803872] ip_tables: (C) 2000-2006 Netfilter Core Team Jul 26 15:08:03 web-01 kernel: [ 6.830538] ADDRCONF(NETDEV_UP): eth0: link is not ready Jul 26 15:08:03 web-01 kernel: [ 6.834499] lp: driver loaded but no devices found Jul 26 15:08:03 web-01 kernel: [ 7.285196] kjournald starting. Commit interval 5 seconds Jul 26 15:08:03 web-01 kernel: [ 7.321785] EXT3 FS on dm-2, internal journal Jul 26 15:08:03 web-01 kernel: [ 7.321792] EXT3-fs: mounted filesystem with ordered data mode. Jul 26 15:08:03 web-01 kernel: [ 7.535727] type=1505 audit(1280182083.165:6): operation="profile_replace" pid=868 name=/sbin/dhclient3 Jul 26 15:08:03 web-01 kernel: [ 7.536095] type=1505 audit(1280182083.165:7): operation="profile_replace" pid=868 name=/usr/lib/NetworkManager/nm-dhcp-client.action Jul 26 15:08:03 web-01 kernel: [ 7.536298] type=1505 audit(1280182083.165:8): operation="profile_replace" pid=868 name=/usr/lib/connman/scripts/dhclient-script Jul 26 15:08:03 web-01 kernel: [ 7.537283] type=1505 audit(1280182083.165:9): operation="profile_replace" pid=869 name=/usr/sbin/tcpdump Jul 26 15:08:03 web-01 cron[950]: (CRON) INFO (pidfile fd = 3) Jul 26 15:08:03 web-01 init: apport pre-start process (943) terminated with status 1 Jul 26 15:08:03 web-01 init: apport post-stop process (958) terminated with status 1 Jul 26 15:08:03 web-01 cron[961]: (CRON) STARTUP (fork ok) Jul 26 15:08:03 web-01 cron[961]: (CRON) INFO (Running @reboot jobs) Jul 26 15:08:03 web-01 logger: mongrel: starting mongrel cluster Jul 26 15:08:04 web-01 kernel: [ 9.266524] e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None Jul 26 15:08:04 web-01 kernel: [ 9.266892] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready Jul 26 15:08:05 web-01 kernel: [ 9.430149] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None Jul 26 15:08:05 web-01 kernel: [ 9.430505] ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready Jul 26 15:08:05 web-01 kernel: [ 9.777969] e1000e: eth0 NIC Link is Down Jul 26 15:08:07 web-01 kernel: [ 12.056047] e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None Jul 26 15:08:15 web-01 kernel: [ 19.831671] eth0: no IPv6 routers present Jul 26 15:08:16 web-01 kernel: [ 20.401469] eth1: no IPv6 routers present Jul 26 15:08:38 web-01 ntpdate[783]: can't find host ntp.ubuntu.com Jul 26 15:08:38 web-01 ntpdate[783]: no servers can be used, exiting Jul 26 15:08:53 web-01 ntpdate[1130]: step time server 91.189.94.4 offset -0.293984 sec Jul 26 15:17:01 web-01 CRON[1294]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) 

除非你已经做了一些奇怪的事情,在任何服务开始之前就已经开始了networking连接,所以我有点惊讶,事情并不奏效。

我不确定你在/ etc / network / interfaces文件中有什么,但是你可能想用auto eth0来代替allow-hotplug eth0这样的行。 hotplug选项意味着在有完全协商的networking链接之前,接口不会被启动。

我也会检查你的交换机configuration。 您可能需要启用portfast或您的交换机上的任何等效项。 Portfast允许计算机跳过与生成树,vlans和etherchannel相关的一些协商,并且更快地调出链接。 但是,您不应该在任何用于连接到其他交换机的交换机端口上使用此function。

你需要让Mongrel的启动依赖于networking的build立。 添加如下内容:

 start on started networking 

到你的/etc/init/mongrel.conf (或类似的)。 查看该目录中的其他文件以获取指导或参阅man 5 init

更新 – 丹尼斯的build议指出我在正确的方向,虽然Ubuntu / Debian不使用默认的Upstart,这是“开始”似乎是一个命令。 在安装之前,我想看看我是否可以使用SysVInit工作。

LSB用Required-Start指定这种types的操作。 我原来使用的是$networking,只有在网卡上网时才激活,不一定当IP地址被获取或其他networking服务激活时。 然后,我已经转移到$ all,而不是查询服务,这似乎只是将脚本执行移动到所有其他init脚本的末尾,但不等待服务。

所以,为了解决,我添加了$ named和$ time到Required-Start。 $ named引用名称parsing,$ time要求查询时间服务器后设置系统时间。 我从syslog知道这发生在eth0之后,所以应该是安全的。

谢谢你的帮助 – 这肯定帮了我。