[步骤] Linux Kdump 的开启 (用于收集内核崩溃时的信息) (CentOS 7 & Rocky Linux 8 & RHEL 7 & RHEL 8 版)

步骤一:开启 Kdump

1.1 确保 crash 和 kernel-debuginfo 两个软件包已安装

# rpm -qa | grep crash || yum install crash ; rpm -qa | grep kernel-debug || yum install kernel-debug

1.2 设置内核崩溃信息的存放位置

# vim /etc/kdump.conf

修改以下内容:

......
path /var/crash
......


补充:
1) 默认的存放位置是 /var/crash
2) 把这里修改成想要存放内核崩溃信息的目录
3) 为了保险起见存放内核崩溃信息的位置最好有大于内存大小的剩余空间

1.3 重新启动 kdump 服务并设置为开机自启

# systemctl restart kdump ; systemctl enable kdump

1.4 确保 kdump 服务已经开启

# systemctl status kdump

(补充:当显示输出结果里包含 operational 或者 Active: active (exited) 时,则说明 Kdump 已经启用)

步骤二:设置收集内核崩溃信息的触发条件

2.1 当内核崩溃时自动收集内核崩溃信息

2.1.1 修改 /etc/sysctl.conf 文件
# vim /etc/sysctl.conf

添加以下内容:

......
kernel.hung_task_panic=1
2.1.2 让修改的 /etc/sysctl.conf 文件生效
# sysctl -p /etc/sysctl.conf
2.1.3 当内核崩溃时,系统会自动收集内核崩溃信息并重启

(步骤略)


注意:
1) 只有 task hang 住,或者处理器线程 soft lock 时才会自动产生 dump
2) 此过程系统会自动重启

2.2 当内核崩溃时使用魔术键收集内核崩溃信息

2.2.1 修改 /etc/sysctl.conf 文件
# vim /etc/sysctl.conf

添加以下内容:

......
kernel.sysrq = 1
2.2.2 让修改的 /etc/sysctl.conf 文件生效
# sysctl -p /etc/sysctl.conf
2.2.3 当内核崩溃时,使用魔术键收集内核崩溃信息并让系统自动重启

同时先后按下以下三个按键:

ALT + PRINTSCREEN + C


注意:
1) 此过程会让系统自动重启
2) 只是系统死机并不代表有 kernel panic

2.3 当内核崩溃时使用硬件发送 NMI 收集内核崩溃信息

2.3.1 修改 /etc/sysctl.conf 文件
# vim /etc/sysctl.conf

添加以下内容:

......
kernel.unknown_nmi_panic = 1
kernel.panic_on_unrecovered_nmi = 1
kernel.panic_on_io_nmi = 1
2.3.2 让修改的 /etc/sysctl.conf 文件生效
# sysctl -p /etc/sysctl.conf
2.3.3 当内核崩溃时,联系硬件技术支持使用硬件发送 NMI 收集内核崩溃信息

(步骤略)

步骤三:手动触发内核崩溃测试 Kdmup

# echo c > /proc/sysrq-trigger

(注意:此操作会造成系统重启)

参考文献:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/system_design_guide/installing-and-configuring-kdump_system-design-guide
https://access.redhat.com/solutions/916043
https://access.redhat.com/solutions/3698411
https://access.redhat.com/solutions/6038
https://access.redhat.com/solutions/23069

[内容] iptables 防火墙数据接收情况和发出情况的查看

# iptables -nvL

Chain INPUT (policy ACCEPT 5 packets, 500 bytes)
......
Chain FORWARD (policy DROP 0 packets, 0 bytes)
......
Chain OUTPUT (policy DROP 1000 packets, 200K bytes)
......


补充:
1) 这里的 policy ACCEPT 5 packets, 500 bytes 是指接收了 5 个数据包和 500 bytes 流量,ACCEPT 是指接收的状态
2) 这里的 policy DROP 1000 packets, 200K bytes 是指发出了 1000 数据包和 200K bytes 流量。DROP 是拒绝的状态

[STEP] Shortcut Script Creation (Windows 10 Edition)

Text:

Step One: Open a PowerShell terminal

(Steps omitted)

Step Two: Execute follow script

$installedapps = get-AppxPackage

$aumidList = @()
foreach ($app in $installedapps)
{
    foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id)
    {
        $aumidList += $app.packagefamilyname + "!" + $id
    }
}

$aumidList
Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy!App
Microsoft.BioEnrollment_cw5n1h2txyewy!App
1527c705-839a-4832-9118-54d4Bd6a0c89_cw5n1h2txyewy!Microsoft.Windows.FilePicker
c5e2524a-ea46-4f67-841f-6a9465d9d515_cw5n1h2txyewy!App
E2A4F912-2574-4A75-9BB0-0D023378592B_cw5n1h2txyewy!Microsoft.Windows.AppResolverUX
Microsoft.LockApp_cw5n1h2txyewy!WindowsDefaultLockScreen
Microsoft.Win32WebViewHost_cw5n1h2txyewy!DPI.PerMonitorAware
Microsoft.Win32WebViewHost_cw5n1h2txyewy!DPI.SystemAware
Microsoft.Win32WebViewHost_cw5n1h2txyewy!DPI.Unaware
Microsoft.MicrosoftEdgeDevToolsClient_8wekyb3d8bbwe!App
Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy!App
Microsoft.Windows.OOBENetworkCaptivePortal_cw5n1h2txyewy!App
Microsoft.Windows.NarratorQuickStart_8wekyb3d8bbwe!App
Microsoft.Windows.ParentalControls_cw5n1h2txyewy!App
Microsoft.Windows.PeopleExperienceHost_cw5n1h2txyewy!App
Microsoft.Windows.CallingShellApp_cw5n1h2txyewy!Microsoft.Windows.CallingShellApp
Microsoft.Windows.CapturePicker_cw5n1h2txyewy!App
NcsiUwpApp_8wekyb3d8bbwe!App
MicrosoftWindows.UndockedDevKit_cw5n1h2txyewy!App
Windows.CBSPreview_cw5n1h2txyewy!Microsoft.Windows.CBSPreview
Microsoft.Windows.XGpuEjectDialog_cw5n1h2txyewy!Microsoft.Windows.XGpuEjectDialog
Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy!App
Microsoft.Windows.SecHealthUI_cw5n1h2txyewy!SecHealthUI
Microsoft.AccountsControl_cw5n1h2txyewy!App
Microsoft.CredDialogHost_cw5n1h2txyewy!App
Microsoft.Windows.ShellExperienceHost_cw5n1h2txyewy!App
Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy!App
Microsoft.Windows.OOBENetworkConnectionFlow_cw5n1h2txyewy!App
F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE_cw5n1h2txyewy!App
Microsoft.XboxGameCallableUI_cw5n1h2txyewy!Microsoft.XboxGameCallableUI
Microsoft.AsyncTextService_8wekyb3d8bbwe!App
Microsoft.Windows.PinningConfirmationDialog_cw5n1h2txyewy!App
Windows.PrintDialog_cw5n1h2txyewy!Microsoft.Windows.PrintDialog
Microsoft.Windows.Apprep.ChxApp_cw5n1h2txyewy!App
windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel
Microsoft.WindowsCamera_8wekyb3d8bbwe!App
Microsoft.Wallet_8wekyb3d8bbwe!App
RealtekSemiconductorCorp.RealtekAudioControl_dt26b99r8h8gj!App
Microsoft.GetHelp_8wekyb3d8bbwe!App
Microsoft.ECApp_8wekyb3d8bbwe!App
Microsoft.MicrosoftEdge.Stable_8wekyb3d8bbwe!App
Microsoft.MicrosoftPCManager_8wekyb3d8bbwe!App
Microsoft.MicrosoftPCManager_8wekyb3d8bbwe!PCWndManager
Microsoft.MicrosoftPCManager_8wekyb3d8bbwe!PCManagerService
Microsoft.ScreenSketch_8wekyb3d8bbwe!App
Microsoft.LanguageExperiencePackzh-CN_8wekyb3d8bbwe!App
Microsoft.LanguageExperiencePackzh-TW_8wekyb3d8bbwe!App
Microsoft.LanguageExperiencePacken-GB_8wekyb3d8bbwe!App
Clipchamp.Clipchamp_yxz26nhyzhsrt!App
Clipchamp.Clipchamp_yxz26nhyzhsrt!CLI
AppleInc.iTunes_nzyj5cx40ttqa!iTunes
AppleInc.iTunes_nzyj5cx40ttqa!AppleInc.Defaults
AppleInc.iTunes_nzyj5cx40ttqa!AppleInc.MDCrashReporter
Microsoft.HEIFImageExtension_8wekyb3d8bbwe!App
Microsoft.XboxGameOverlay_8wekyb3d8bbwe!App
Microsoft.XboxSpeechToTextOverlay_8wekyb3d8bbwe!App
Microsoft.Xbox.TCUI_8wekyb3d8bbwe!Microsoft.Xbox.TCUI
Microsoft.WebMediaExtensions_8wekyb3d8bbwe!Microsoft.WebMediaExtensions
Microsoft.XboxIdentityProvider_8wekyb3d8bbwe!Microsoft.XboxIdentityProvider
Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe!App
Microsoft.Getstarted_8wekyb3d8bbwe!App
Microsoft.ZuneVideo_8wekyb3d8bbwe!Microsoft.ZuneVideo
Microsoft.WindowsStore_8wekyb3d8bbwe!App
Microsoft.StorePurchaseApp_8wekyb3d8bbwe!App
Microsoft.VP9VideoExtensions_8wekyb3d8bbwe!App
Microsoft.Whiteboard_8wekyb3d8bbwe!Whiteboard
Microsoft.WebpImageExtension_8wekyb3d8bbwe!App
Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe!App
Microsoft.XboxGamingOverlay_8wekyb3d8bbwe!App
Microsoft.Windows.Photos_8wekyb3d8bbwe!App
Microsoft.YourPhone_8wekyb3d8bbwe!App
Microsoft.DesktopAppInstaller_8wekyb3d8bbwe!App
Microsoft.DesktopAppInstaller_8wekyb3d8bbwe!PythonRedirector
Microsoft.DesktopAppInstaller_8wekyb3d8bbwe!winget
Microsoft.DesktopAppInstaller_8wekyb3d8bbwe!WinGetComServer
Microsoft.Windows.Search_cw5n1h2txyewy!CortanaUI
Microsoft.Windows.Search_cw5n1h2txyewy!ShellFeedsUI
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!PackageMetadata
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!Global.Accounts
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!Global.AppListBackup
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!Global.BackupBanner
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!Global.DesktopSpotlight
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!InputApp
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!Global.IrisService
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!Global.RulesEngine
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!ScreenClipping
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!WebExperienceHost
MicrosoftWindows.Client.CBS_cw5n1h2txyewy!WindowsBackup
AppleInc.iCloud_nzyj5cx40ttqa!iCloud
AppleInc.iCloud_nzyj5cx40ttqa!iCloudPhotoViewer
AppleInc.iCloud_nzyj5cx40ttqa!iCloudPasswords
AppleInc.iCloud_nzyj5cx40ttqa!iCloudChrome
AppleInc.iCloud_nzyj5cx40ttqa!iCloudPasswordsExtensionHelper
AppleInc.iCloud_nzyj5cx40ttqa!iCloudFirefox
AppleInc.iCloud_nzyj5cx40ttqa!eReporter
AppleInc.iCloud_nzyj5cx40ttqa!iCloudDrive
AppleInc.iCloud_nzyj5cx40ttqa!iCloudPhotos
AppleInc.iCloud_nzyj5cx40ttqa!ApplePhotoStreams
AppleInc.iCloud_nzyj5cx40ttqa!iCloudCKKS
AppleInc.iCloud_nzyj5cx40ttqa!APSDaemon
Microsoft.WindowsTerminal_8wekyb3d8bbwe!App

Step three: Create local boot script

Create a new bat file and create follow content:

start shell:Appsfolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App

(Add: taking starting the Terminal application as an example here)

Step Four: Double click this boot script

(Steps omitted)

Reference:

https://forum.rainmeter.net/viewtopic.php?t=22716

[步骤] Linux 虚拟内存 (交换分区) swap 的设置

步骤一:理解 Linux 虚拟内存 (交换分区) swap 使用优先级的设置机制

Linux 的 swappiness 参数用于控制虚拟内存 (交换分区) swap 的使用。
swappiness 参数的默认值是 60,也就是说当物理内存使用率达到 40 时,开始使用虚拟内存 (交换分区) swap。
当 swappiness 参数的值是 0 时,则只有当物理机内存耗尽了以后才会使用虚拟内存 (交换分区) swap。
当 swappiness 参数的值是 100 时,则立刻使用虚拟内存 (交换分区) swap。

步骤二:Linux 虚拟内存 (交换分区) swap 开关的设置

2.1 查看虚拟内存 (交换分区) swap

# swapon -s

2.2 开启虚拟内存 (交换分区) swap

# swapon -a

2.3 关闭虚拟内存 (交换分区) swap

# swapoff -a

2.4 重启虚拟内存 (交换分区) swap

# swapoff -a && swapon -a

步骤三:Linux 虚拟内存 (交换分区) swap 使用优先级的设置

3.1 临时设置虚拟内存 (交换分区) swap 使用优先级的设置

# sysctl -p swappiness=60

或者:

# sysctl vm.swappiness=60

或者:

# echo 60 > /proc/sys/vm/swappiness

(补充:这里以把 swappiness 的值设置成 60 为例)


注意:
1) 临时设置重启后失效
2) 临时设置了以后不会马上生效,只有当系统重新调用内存以后才会生效

3.2 永久设置虚拟内存 (交换分区) swap 使用优先级的设置

3.2.1 修改 /etc/sysctl.conf 文件
# vim /etc/sysctl.conf

添加以下内容:

......
vm.swappiness=60

(补充:这里以把 swappiness 的值设置成 60 为例)

3.2.2 让刚刚修改的 /etc/sysctl.conf 文件生效
# sysctl -p

3.3 查看虚拟内存 (交换分区) swap 使用优先级的设置

3.3.1 通过 /proc/sys/vm/swappiness 文件查看
# cat /proc/sys/vm/swappiness
3.3.2 通过 sysctl vm.swappiness 命令查看
# sysctl vm.swappiness