Networking

從快照 AMI 創建 AWS EC2 實例,啟動後缺少 eth0

  • October 16, 2018

我最近從我們的生產 EC2 的快照創建了一個新的 EC2。

機器啟動良好,但是我可以通過 ssh 進入 - 無法通過其他任何方式訪問。沒有全球資訊網,什麼都沒有。

在進一步檢查設備後,主要是網路堆棧 - 我看到了:

/etc/udev/rules.d/70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="06:68:f3:22:91:f2", NAME="ens5"

如果配置

ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
       inet 172.31.12.146  netmask 255.255.240.0  broadcast 172.31.15.255
       inet6 fe80::468:f3ff:fe22:91f2  prefixlen 64  scopeid 0x20<link>
       ether 06:68:f3:22:91:f2  txqueuelen 1000  (Ethernet)
       RX packets 492  bytes 81928 (80.0 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 474  bytes 76982 (75.1 KiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
       inet 127.0.0.1  netmask 255.0.0.0
       inet6 ::1  prefixlen 128  scopeid 0x10<host>
       loop  txqueuelen 1000  (Local Loopback)
       RX packets 6  bytes 416 (416.0 B)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 6  bytes 416 (416.0 B)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

注意第一行的ens5ifconfig

$$ /etc $$#服務網路重啟

Restarting network (via systemctl):  Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
                                                      [FAILED]

$$ /etc $$# systemctl status network.service

● network.service - LSB: Bring up/down networking
  Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
  Active: failed (Result: exit-code) since Tue 2018-10-16 11:13:34 EDT; 1min 4s ago
    Docs: man:systemd-sysv-generator(8)
 Process: 2223 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
  CGroup: /system.slice/network.service
          └─857 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--ens5.lease -pf /var/run/dhclient-ens5.pid -H ip-172-31-12-146 ens5

Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal network[2223]: RTNETLINK answers: File exists
Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal network[2223]: RTNETLINK answers: File exists
Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal network[2223]: RTNETLINK answers: File exists
Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal network[2223]: RTNETLINK answers: File exists
Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal network[2223]: RTNETLINK answers: File exists
Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal network[2223]: RTNETLINK answers: File exists
Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal systemd[1]: network.service: control process exited, code=exited status=1
Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal systemd[1]: Failed to start LSB: Bring up/down networking.
Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal systemd[1]: Unit network.service entered failed state.
Oct 16 11:13:34 ip-172-31-12-146.us-west-1.compute.internal systemd[1]: network.service failed.

它找不到 eth0,也無法重新啟動網路堆棧。我嘗試重新啟動機器,關閉並啟動,但沒有成功。我錯過了什麼?

您是否從舊實例類型更改為 T3 / M5 / C5?它們具有不同的硬體並使用不同的設備名稱。

一種選擇是重新配置網路堆棧以反映新的設備名稱——這可能是一項艱鉅的任務,除非您是熟練的 Linux 管理員並且知道自己在做什麼。

或者,更簡單的是,將實例類型更改為與您創建快照相同的類型。這應該將設備名稱恢復到以前的狀態。

您可以更改大小,例如從largemedium,但保持類型 - 如果是 T2,請再次使用 T2。

另外我建議您將其從快照恢復到新實例 - 目前的實例可能已嘗試容納新設備名稱並且可能處於不一致的狀態。最好從 Prod 快照重新開始。

希望有幫助:)

引用自:https://serverfault.com/questions/935770