本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
狀態檢查失敗的疑難排解 Amazon EC2 Linux 執行個體
如果您的 Linux 執行個體無法通過狀態檢查,則以下資訊有助於針對問題進行疑難排解。首先判斷應用程式是否出現任何問題。如果確認執行個體並未如預期執行應用程式,請檢閱狀態檢查資訊和系統日誌。
關於導致狀態檢查失敗的問題範例,請參閱 Amazon EC2 執行個體的狀態檢查 。
檢閱狀態檢查資訊
使用 Amazon EC2 主控台來調查狀態不健全的執行個體
-
在 https://console.aws.amazon.com/ec2/
-
在導覽窗格中,選取 Instances (執行個體),然後選取您的執行個體。
選取 狀態和警示 索引標籤,以查看所有 系統狀態檢查 、 執行個體狀態檢查 和 連接 EBS 狀態檢查 的個別結果。
如果未通過狀態檢查,您可以嘗試下列其中一個選項:
建立警示以復原執行個體,以回應失敗的狀態檢查。如需詳細資訊,請參閱 建立警示以停止、終止、重新啟動或復原執行個體 。
(執行個體狀態檢查) 如果您已將執行個體類型變更為 Nitro 型執行個體 ,則從沒有必要 ENA 和 NVMe 驅動程式的執行個體移轉時,狀態檢查會失敗。如需詳細資訊,請參閱 變更執行個體類型的相容性 。
如果是使用 EBS 支援的執行個體,請停止並重新啟動執行個體。如需詳細資訊,請參閱 停止和啟動 Amazon EC2 執行個體 。
如果是執行個體儲存體支援的執行個體,請終止執行個體,並啟動替代的執行個體。如需詳細資訊,請參閱 終止 Amazon EC2 執行個體 。
請等候 Amazon EC2 解決問題。
聯絡 支援 或發佈您的問題以 AWS re:Post
如果您的執行個體位於 Auto Scaling 群組:
(系統狀態檢查和執行個體狀態檢查) 預設情況下,Amazon EC2 Auto Scaling 會自動啟動替代執行個體。如需詳細資訊,請參閱「Amazon EC2 Auto Scaling 使用者指南」 中的 針對 Auto Scaling 群組中的執行個體進行運作狀態檢查 。
(連接的 EBS 狀態檢查) 您必須設定 Amazon EC2 Auto Scaling 以自動啟動替代執行個體。如需詳細資訊,請參閱「Amazon EC2 Auto Scaling 使用者指南」 中的 使用受損的 Amazon EBS 磁碟區監控和取代自動擴展執行個體 。
擷取系統日誌並尋找錯誤。如需詳細資訊,請參閱 擷取系統日誌 。
擷取系統日誌
如果執行個體狀態檢查未通過,您可以重新啟動執行個體和擷取系統日誌。日誌可能會顯示錯誤,有助於對發生的問題進行故障診斷。重新啟動作業會清除日誌中不必要的資訊。
重新啟動執行個體和擷取系統日誌
-
在 https://console.aws.amazon.com/ec2/
-
在導覽窗格中,選擇 Instances (執行個體) ,然後選取您的執行個體。
選擇 Instance state (執行個體狀態) 、 Reboot intance (重新啟動執行個體) 。執行個體重新啟動可能需要幾分鐘的時間。
確認問題是否仍持續存在;在某些情況中,重新啟動也許可以解決問題。
當執行個體處於
running
狀態時,選擇 Actions (動作) 、 Monitor and troubleshoot (監視和疑難排解) 、 Get system log (取得系統日誌檔) 。檢閱畫面上所顯示的日誌,然後使用下列的已知系統日誌錯誤陳述清單,來進行問題的故障診斷。
如果問題無法解決,您可以在 AWS re:Post
針對 Linux 執行個體,進行系統日誌錯誤的疑難排解
如果 Linux 執行個體未通過執行個體的狀態檢查 (例如執行個體可達性檢查),請確認是否已按照上述的步驟來擷取系統日誌。下列清單包含了一些常見的系統日誌錯誤和建議的動作,您可以針對每項錯誤採取這些動作,來解決問題。
Memory Errors (記憶體錯誤)
request_module:失控迴圈 modprobe (在舊版 Linux 上建立舊核心 modprobe 的迴圈)
「嚴重:核心版本太舊」和「fsck:嘗試開啟 /dev 時,找不到此等檔案或目錄」(核心與 AMI 不符)
「嚴重:無法載入 /lib/modules」或「BusyBox」(缺少核心模組)
File System Errors (檔案系統錯誤)
帶出界面 eth0:裝置 eth0 的 MAC 地址和預期的不同,略過。(將 MAC 地址直接寫入程式)
無法載入 SELinux 政策。機器正處於強制執行模式。現在停止中。(SELinux 組態設定不當)
記憶體不足:終止程序
系統日誌記錄項目會顯示記憶體不足的錯誤,類似於下列所示記錄。
[115879.769795]
Out of memory: kill process
20273 (httpd) score 1285879 or a child [115879.769795] Killed process 1917 (php-cgi) vsz:467184kB, anon- rss:101196kB, file-rss:204kB可能的原因
記憶體用盡
如果是此種執行個體類型 執行此作業系統日誌記錄項目會顯示記憶體管理更新作業的失敗,類似於下列所示記錄:
Press `ESC' to enter the menu... 0 [H[J Booting 'Amazon Linux 2011.09 (2.6.35.14-95.38.amzn1.i686)' root (hd0) Filesystem type is ext2fs, using whole disk kernel /boot/vmlinuz-2.6.35.14-95.38.amzn1.i686 root=LABEL=/ console=hvc0 LANG= en_US.UTF-8 KEYTABLE=us initrd /boot/initramfs-2.6.35.14-95.38.amzn1.i686.imgERROR: mmu_update failed with rc=-22
可能的原因
Amazon Linux 的問題
將您的問題發佈至 AWS re:Post
I/O 錯誤 (區塊型儲存設備故障)
系統日誌記錄項目會顯示輸入/輸出錯誤,類似於下列的範例:
[9943662.053217] end_request:
I/O error
, dev sde,sector 52428288
[9943664.191262] end_request: I/O error, dev sde, sector 52428168 [9943664.191285] Buffer I/O error on device md0, logical block 209713024 [9943664.191297] Buffer I/O error on device md0, logical block 209713025 [9943664.191304] Buffer I/O error on device md0, logical block 209713026 [9943664.191310] Buffer I/O error on device md0, logical block 209713027 [9943664.191317] Buffer I/O error on device md0, logical block 209713028 [9943664.191324] Buffer I/O error on device md0, logical block 209713029 [9943664.191332] Buffer I/O error on device md0, logical block 209713030 [9943664.191339] Buffer I/O error on device md0, logical block 209713031 [9943664.191581] end_request: I/O error, dev sde, sector 52428280 [9943664.191590] Buffer I/O error on device md0, logical block 209713136 [9943664.191597] Buffer I/O error on device md0, logical block 209713137 [9943664.191767] end_request: I/O error, dev sde, sector 52428288 [9943664.191970] end_request: I/O error, dev sde, sector 52428288 [9943664.192143] end_request: I/O error, dev sde, sector 52428288 [9943664.192949] end_request: I/O error, dev sde, sector 52428288 [9943664.193112] end_request: I/O error, dev sde, sector 52428288 [9943664.193266] end_request: I/O error, dev sde, sector 52428288可能的原因
執行個體類型 可能的原因系統日誌記錄項目會顯示裝置上的輸入/輸出錯誤,類似於下列的範例:
block drbd1: Local IO failed in request_timer_fn. Detaching... Aborting journal on device drbd1-8. block drbd1:IO ERROR: neither local nor remote disk
Buffer I/O error on device drbd1, logical block 557056 lost page write due to I/O error on drbd1 JBD2: I/O error detected when updating journal superblock for drbd1-8.可能的原因
執行個體類型 可能的原因request_module:失控迴圈 modprobe (在舊版 Linux 上建立舊核心 modprobe 的迴圈)
系統日誌記錄項目會顯示此狀況,類似於下列所示。使用不穩定的或舊版的 Linux 核心 (例如 2.6.16-xenU),可能會在啟動時造成無止盡的循環狀況。
如果是此種執行個體類型 執行此作業Linux version
2.6.16-xenU
([email protected]) (gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)) #1 SMP Mon May 28 03:41:49 SAST 2007 BIOS-provided physical RAM map: Xen: 0000000000000000 - 0000000026700000 (usable) 0MB HIGHMEM available.request_module: runaway loop modprobe binfmt-464c
request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c系統日誌記錄項目會顯示此狀況,類似於下列所示。
Linux version 2.6.16.33-xenU ([email protected]) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #2 SMP Wed Aug 15 17:27:36 SAST 2007
FATAL: kernel too old
Kernel panic - not syncing: Attempted to kill init!可能的原因
不相容的核心和使用者空間
如果是此種執行個體類型 執行此作業系統日誌記錄項目會顯示此狀況,類似於下列所示。
[ 0.370415] Freeing unused kernel memory: 1716k freed Loading, please wait... WARNING: Couldn't open directory /lib/modules/2.6.34-4-virtual: No such file or directory FATAL: Could not open /lib/modules/2.6.34-4-virtual/modules.dep.temp for writing: No such file or directory FATAL: Could not load /lib/modules/2.6.34-4-virtual/modules.dep: No such file or directory Couldn't get a file descriptor referring to the console Begin: Loading essential drivers... ... FATAL: Could not load /lib/modules/2.6.34-4-virtual/modules.dep: No such file or directory FATAL: Could not load /lib/modules/2.6.34-4-virtual/modules.dep: No such file or directory Done. Begin: Running /scripts/init-premount ... Done. Begin: Mounting root file system... ... Begin: Running /scripts/local-top ... Done. Begin: Waiting for root file system... ... Done. Gave up waiting for root device. Common problems: - Boot args (cat /proc/cmdline) - Check rootdelay= (did the system wait long enough?) - Check root= (did the system wait for the right device?) - Missing modules (cat /proc/modules; ls /dev) FATAL: Could not load /lib/modules/2.6.34-4-virtual/modules.dep: No such file or directory
FATAL: Could not load /lib/modules/
2.6.34-4-virtual/modules.dep: No such file or directory ALERT! /dev/sda1 does not exist. Dropping to a shell!BusyBox
v1.13.3 (Ubuntu 1:1.13.3-1ubuntu5) built-in shell (ash) Enter 'help' for a list of built-in commands. (initramfs)可能的原因
這項問題可能是下列一種或多種狀況所造成:
ERROR Invalid kernel: elf_xen_note_check: ERROR: Will only load images built for the generic loader or Linux images xc_dom_parse_image returned -1
Error 9: Unknown boot failure Booting 'Fallback' root (hd0) Filesystem type is ext2fs, using whole disk kernel /vmlinuz.old root=/dev/sda1 ro Error 15: File not found可能的原因
這項問題可能是下列狀況中的其中一種或兩種同時造成:
Welcome to Fedora Press 'I' to enter interactive startup. Setting clock : Wed Oct 26 05:52:05 EDT 2011 [ OK ] Starting udev: [ OK ] Setting hostname localhost: [ OK ] No devices found Setting up Logical Volume Management: File descriptor 7 left open No volume groups found [ OK ] Checking filesystems Checking all file systems. [/sbin/fsck.ext3 (1) -- /] fsck.ext3 -a /dev/sda1 /dev/sda1: clean, 82081/1310720 files, 2141116/2621440 blocks [/sbin/fsck.ext3 (1) -- /mnt/dbbackups] fsck.ext3 -a /dev/sdh
fsck
.ext3:No such file or directory
while trying to open /dev/sdh /dev/sdh: The superblock could not be read or does not describe a correct ext2 filesystem. If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> [FAILED] *** An error occurred during the file system check. *** Dropping you to a shell; the system will reboot *** when you leave the shell. Give root password for maintenance (or type Control-D to continue):可能的原因
停止執行個體、分離根磁碟區、修復/修改 /etc/fstab 磁碟區、將磁碟區連結到執行個體,以及啟動執行個體。
修正 ramdisk,以納入修改過的 /etc/fstab (如有適用)。
修改 AMI,以使用較新版的 ramdisk。
fstab 中的第 6 個欄位定義了掛載的可用性要求 – 非 0 值暗示 fsck 將在該磁碟區上完成,而且 必須 成功。在 Amazon EC2 中使用此欄位可能會出現問題,因為故障通常會產生互動式主控台提示,而 Amazon EC2 中目前並未提供此提示功能。使用此功能時請特別注意,並閱讀 fstab 的 Linux 手冊頁。
Loading ohci-hcd.ko module Loading uhci-hcd.ko module USB Universal Host Controller Interface driver v3.0 Loading mbcache.ko module Loading jbd.ko module Loading ext3.ko module Creating root device. Mounting root filesystem. kjournald starting. Commit interval 5 seconds EXT3-fs: mounted filesystem with ordered data mode. Setting up other filesystems. Setting up new root fs no fstab.sys, mounting internal defaults Switching to new root and running init. unmounting old /dev unmounting old /proc unmounting old /sys mountall:/proc: unable to mount: Device or resource busy mountall:/proc/self/mountinfo: No such file or directory mountall: root filesystem isn't mounted init: mountall main process (221) terminated with status 1General error mounting filesystems
. A maintenance shell will now be started. CONTROL-D will terminate this shell and re-try. Press enter for maintenance (or type Control-D to continue):可能的原因
執行個體類型 可能的原因系統日誌記錄項目會顯示此狀況,類似於下列所示。
Linux version 2.6.16-xenU ([email protected]) (gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)) #1 SMP Mon May 28 03:41:49 SAST 2007 Kernel command line: root=/dev/sda1 ro 4 Registering block device major 8
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,1)
可能的原因
執行個體類型 可能的原因 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/vbd/2048 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initializing network drop monitor service Freeing unused kernel memory: 508k freed :: Starting udevd... done. :: Running Hook [udev] :: Triggering uevents...<30>udevd[65]: starting version 173 done. Waiting 10 seconds for device /dev/xvda1 ... Root device '/dev/xvda1' doesn't exist. Attempting to create it.ERROR: Unable to determine major/minor number of root device '/dev/xvda1'
. You are being dropped to a recovery shell Type 'exit' to try and continue booting sh: can't access tty; job control turned off[ramfs /]#
可能的原因
系統日誌記錄項目會顯示此狀況,類似於下列所示。
XENBUS: Device with no driver: device/vbd/2048 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initializing network drop monitor service Freeing unused kernel memory: 508k freed :: Starting udevd... done. :: Running Hook [udev] :: Triggering uevents...<30>udevd[65]: starting version 173 done. Waiting 10 seconds for device /dev/xvda1 ... Root device '/dev/xvda1' doesn't exist. Attempting to create it.
ERROR: Unable to determine major/minor number of root device '/dev/xvda1'.
You are being dropped to a recovery shell Type 'exit' to try and continue booting sh: can't access tty; job control turned off[ramfs /]#
可能的原因
Checking filesystems Checking all file systems. [/sbin/fsck.ext3 (1) -- /] fsck.ext3 -a /dev/sda1 /dev/sda1 has gone 361days without being checked, check forced
可能的原因
已超過檔案系統檢查時間;強制進行檔案系統檢查。
Activating lvm and md swap...done. Checking file systems...fsck from util-linux-ng 2.16.2 /sbin/fsck.xfs: /dev/sdh does not existfsck died with exit status
8 [31mfailed (code 8).[39;49m可能的原因
GNU GRUB version 0.97 (629760K lower / 0K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ]
grubdom>
可能的原因
執行個體類型 可能的原因確認您的 GRUB 版本支援底層檔案系統的類型,必要時請更新 GRUB。
選擇適合的 GRUB 映像 (hd0-第 1 個磁碟機或 hd00 – 第 1 個磁碟機,第 1 個分割區)。
終止執行個體,並使用您所建立的 AMI 來啟動新的執行個體。
選項 2:修改現有的執行個體:
使用儲存於標準位置的 GRUB 組態檔案 (/boot/grub/menu.lst),來建立新的 AMI。
選擇適合的 GRUB 映像 (hd0-第 1 個磁碟機或 hd00 – 第 1 個磁碟機,第 1 個分割區)。
確認您的 GRUB 版本支援底層檔案系統的類型,必要時請更新 GRUB。
終止執行個體,並使用您所建立的 AMI 來啟動新的執行個體。
選項 2:終止執行個體,並啟動新的執行個體 (指定正確的核心)。
注意
若要從現有的執行個體復原資料,請聯絡 支援
Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring. [FAILED]
Starting auditd: [ OK ]可能的原因
在 AMI 組態中有直接寫入程式的界面 MAC
如果是此種執行個體類型 執行此作業系統日誌記錄項目會顯示此狀況,類似於下列所示。
audit(1313445102.626:2): enforcing=1 old_enforcing=0 auid=4294967295
Unable to load SELinux Policy. Machine is in enforcing mode. Halting now. Kernel panic - not syncing: Attempted to kill init!
可能的原因
SELinux 已在啟用時發生錯誤:
連線到復原執行個體,並掛載已故障執行個體的根磁碟區。
將已掛載根磁碟區上的 SELinux 停用。不同 Linux 版本的此項程序也會有所差異,如需詳細資訊,請參閱特定作業系統的文件。
注意
在某些系統上,您可以透過設定
SELINUX=disabled
檔案中的/
,來停用 SELinux,其中mount_point
/etc/sysconfig/selinuxmount_point
取消掛載根磁碟區、將該磁碟區從復原執行個體分離,然後再重新連結到原始執行個體。
啟動實例。
系統日誌記錄項目會顯示此狀況,類似於下列所示。
Linux version 2.6.16-xenU ([email protected]) (gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)) #1 SMP Mon May 28 03:41:49 SAST 2007
XENBUS: Timeout connecting to devices!
Kernel panic - not syncing: No init found. Try passing init= option to kernel.可能的原因
-