Biểu hiện
Trường hợp Hardware Node bị treo, chuỗi SysRq rất hữu dụng để thu thập thông tin debug và restart HW bằng cách sử dụng ATL + Sysrq keys.
Giải pháp
1. Kiểm tra cấu hình hình hiện tại của kernell:
- Nhấn Alt+SysRq+H để hiện thị lệnh sẵn có:
SysRq HELP : loglevel0-8 vsced_stAte reBoot Crashdump tErm Full debuG kIll thaw-filesystems(J) saK showMem Nice powerOff showPc unRaw Sync showTasks Unmount shoWcpus
- Dưới đây là output:
- Alt+SysRq+0 – Alt+SysRq+8 – set kernel log level, where 0 is the lowest and 8 is the highest verbosity of logging. It is recommended to set log level to 8 before executing other commands.
- Alt+SysRq+A – Show Vsched.
- Alt+SysRq+B – Reboot immediately without syncing or unmounting your disks, it may lead to file system corruption.
- Alt+SysRq+C – Trigger a crash.
- Alt+SysRq+E – Send the TERM signal to all running processes except init, asking them to exit.
- Alt+SysRq+F – Manual OOM execution.
- Alt+SysRq+G – Debug mode.
- Alt+SysRq+H – Show help message.
- Alt+SysRq+I – Send KILL signal to all running processes except init, asking them to exit.
- Alt+SysRq+J – Emergency Thaw of all frozen filesystems.
- Alt+SysRq+K – Kill all processes (including X) which are running on the currently active virtual console. This key combination is know as “secure access key” (SAK).
- Alt+SysRq+M – Show Memory.
- Alt+SysRq+N – Nice All RT Tasks.
- Alt+SysRq+O – Shut the system off. Without preliminary operations it may lead to file system corruption.
- Alt+SysRq+P – Dump the current registers and flags.
- Alt+SysRq+Q – Quit from debugging mode.
- Alt+SysRq+R – Turn off keyboard raw mode.
- Alt+SysRq+S – Run an emergency sync (cache write) on all mounted filesystems. This can prevent data loss.
- Alt+SysRq+T – Dump a list of current tasks and their information.
- Alt+SysRq+U – Remount all mounted filesystems as read-only.
- Alt+SysRq+W – Show CPUs.
2. Thu thập dữ liệu debug:
- Dump thông tin CPU bằng cách nhấn Alt+SysRq+W, bạn sẽ thấy thông tin xuất hiện trên serial console:
Mar 8 10:07:57 pvcfl46 SysRq: Show CPUs
Mar 8 10:07:57 pvcfl46 requested on CPU0:
Mar 8 10:07:57 pvcfl46 CPU0:
Mar 8 10:07:57 pvcfl46 ffff810037d69dd0 0000000000000000 ffffffff80344648 0000000000000000
Mar 8 10:07:57 pvcfl46 ffffffff801aef3f 0000000000000000 ffffffff801aef2d ffffffff801aef97
Mar 8 10:07:57 pvcfl46 ffffffff801aef2d ffffffff8009463e ffffffff80344640 ffff81007ffabdc0
Mar 8 10:07:57 pvcfl46 Call Trace:
Mar 8 10:07:57 pvcfl46 [] showacpu+0x0/0x65
Mar 8 10:07:57 pvcfl46 [] sysrq_showregs_othercpus+0x0/0x12
Mar 8 10:07:57 pvcfl46 [] showacpu+0x58/0x65
Mar 8 10:07:57 pvcfl46 [] sysrq_showregs_othercpus+0x0/0x12
Mar 8 10:07:57 pvcfl46 [] on_each_cpu+0x19/0x22
Mar 8 10:07:57 pvcfl46 [] run_workqueue+0x94/0xe5
Mar 8 10:07:57 pvcfl46 [] worker_thread+0x0/0x122
Mar 8 10:07:57 pvcfl46 [] worker_thread+0xf0/0x122
Mar 8 10:07:57 pvcfl46 [] default_wake_function+0x0/0xe
Mar 8 10:07:57 pvcfl46 [] kthread+0xfe/0x132
Mar 8 10:07:57 pvcfl46 [] child_rip+0xa/0x11
Mar 8 10:07:57 pvcfl46 [] kthread+0x0/0x132
Mar 8 10:07:57 pvcfl46 [] child_rip+0x0/0x11
- Dump thông tin bộ nhớ nhấn Alt+SysRq+M (thực hiện 2-3 lần)
- Dump tất cả trạng thái registers bằng cách nhấn Alt+SysRq+P (thực hiện 2-3 lần)
- Dump tất cả thông tin tác vụ bằng cách nhấn Alt+SysRq+T (thực hiện 2-3 lần)
- Dump thông tin Vsched nhấn Alt+SysRq+A.
4. Thử reboot một cách an toàn:
-
Sync all filesystems nhấn Alt+SysRq+S. Output tương tự như:
Mar 8 10:31:58 pvcfl46 SysRq: Emergency Sync
Mar 8 10:31:58 pvcfl46 Emergency Sync complete
- Umount filesystem bằng cách nhấn Alt+SysRq+U:
Mar 8 10:33:30 pvcfl46 SysRq: Emergency Remount R/O
Mar 8 10:33:30 pvcfl46 Emergency Remount complete
- Kill tất cả tiến trình nhấn Alt+SysRq+I. Output tương tự như:
Mar 8 10:36:13 pvcfl46 SysRq: Kill All Tasks
Mar 8 10:36:13 pvcfl46 CT: 1: stopped
- Gửi lệnh reboot node nhấn Alt+SysRq+B.
Sẽ rất hữu ích khi debug trong các trường hợp node bị treo bằng cách nhấn Alt+SysRq+C, tuy nhiên bạn phải cấu hình kernel crash dump.
5. Thay vì gửi lệnh qua keyboard, bạn có thể ghi kí tự tương ứng vào /proc/sysrq-trigger
:
~# echo 1 > /proc/sys/kernel/sysrq
~# echo h > /proc/sysrq-trigger
Doanh nghiệp quan tâm về giải pháp Tổng đài ảo vui lòng liên hệ trực tiếp cho Mắt Bão One theo số hotline (028) 7777 7788 hoặc website: https://matbao.one để được tư vấn và hỗ trợ nhanh nhất.