我最近从我们的生产 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 管理员并且知道自己在做什么。
或者,更简单的是,将实例类型更改为与您创建快照相同的类型。这应该将设备名称恢复到以前的状态。
您可以更改大小,例如从large到medium,但保持类型 - 如果是 T2,请再次使用 T2。
另外我建议您将其从快照恢复到新实例 - 当前的实例可能已尝试容纳新设备名称并且可能处于不一致的状态。最好从 Prod 快照重新开始。
希望有帮助:)
您可以在您发布的 udev 规则中修改设备名称。编辑该行并重命名
ens5
为eth0