我最近从我们的生产 EC2 的快照创建了一个新的 EC2。
机器启动正常,我可以通过 ssh 进入,但是无法通过其他方式访问。没有 WWW,什么都没有。
经过对设备进行进一步检查,主要是网络堆栈 - 我看到了这个:
/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
注意ens5在 的第一行ifconfig
。
[/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 状态网络.服务
● 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,也无法重新启动网络堆栈。我尝试过重新启动机器、关闭并启动,但都没有成功。我遗漏了什么?
答案1
您是否从旧实例类型更改为 T3/M5/C5?这些实例类型具有不同的硬件并使用不同的设备名称。
一个选择是重新配置网络堆栈来反映新的设备名称 - 这可能是一项相当艰巨的任务,除非您是一位熟练的 Linux 管理员并且知道自己在做什么。
或者更简单一点,更改实例类型与您制作快照时所用的设备名称相同。这样应该可以将设备名称恢复到原来的状态。
您可以更改大小,例如从大的到中等的,但保留类型 - 如果是 T2,则再次使用 T2。
另外,我建议您将其从快照恢复到新实例 - 当前实例可能已尝试适应新设备名称,并且可能处于不一致状态。最好从 Prod 快照重新开始。
希望有帮助:)
答案2
您可以在发布的 udev 规则中修改设备名称。编辑该行并重命名ens5
为eth0
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="06:68:f3:22:91:f2", NAME="eth0"