[内容] Linux 处理器详细信息的显示 (显示 /proc/cpuinfo 文件里的信息)

内容一:显示处理器详细信息

1.1 显示处理器详细信息

# cat /proc/cpuinfo

或者:

# lscpu

1.2 /proc/cpuinfo 文件里或者 lscpu 命令里重要参数

1) processor,进程 (虚拟核心) ID
2) core ID,物理核心 ID
3) physical id,物理封装处理器 ID (CPU socket ID)
4) cpu cores, 每 1 个物理封装处理器 ID (CPU socket ID) 里的物理核心数量
5) siblings, 每 1 个物理封装处理器 ID (CPU socket ID) 里的进程 (虚拟核心) 数量

内容二:显示 Linux 处理器详细信息的案例

2.1 案例一:显示处理器所有信息

# cat /proc/cpuinfo
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 23
model		: 1
model name	: AMD Ryzen 7 1700 Eight-Core Processor
stepping	: 1
microcode	: 0x8001138
cpu MHz		: 1371.214
cache size	: 512 KB
physical id	: 0
siblings	: 16
core id		: 0
cpu cores	: 8
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate sme ssbd sev ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca
bugs		: sysret_ss_attrs null_seg spectre_v1 spectre_v2 spec_store_bypass
bogomips	: 5987.93
TLB size	: 2560 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 43 bits physical, 48 bits virtual
power management: ts ttp tm hwpstate eff_freq_ro [13] [14]

......

2.2 案例二:显示处理器进程 (虚拟核心) 数

# cat /proc/cpuinfo | egrep "core id|physical id|processor" | tr -d "\n" | sed s/processor/\\nprocessor/g | sed 's/physical/     physical/' | sed 's/core/     core/' | grep -v ^$ | wc -l

2.3 案例三:显示处理器物理核心数

# cat /proc/cpuinfo | egrep "core id|physical id" | tr -d "\n" | sed s/physical/\\nphysical/g | grep -v ^$ | sort | uniq | wc -l

2.4 案例四:显示物理封装处理器 (处理器 socket) 数

# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l

2.5 案例五:显示处理器所有进程 (虚拟核心) ID

# cat /proc/cpuinfo | grep processor
processor	: 0
processor	: 1
processor	: 2
processor	: 3
processor	: 4
processor	: 5
processor	: 6
processor	: 7
processor	: 8
processor	: 9
processor	: 10
processor	: 11
processor	: 12
processor	: 13
processor	: 14
processor	: 15

2.6 案例六:显示处理器所有物理核心 ID

# cat /proc/cpuinfo | grep 'core id'
core id		: 0
core id		: 1
core id		: 2
core id		: 3
core id		: 4
core id		: 5
core id		: 6
core id		: 7
core id		: 0
core id		: 1
core id		: 2
core id		: 3
core id		: 4
core id		: 5
core id		: 6
core id		: 7

2.7 案例七:显示处理器所有物理封装处理器 ID (处理器 socket ID)

# cat /proc/cpuinfo | grep 'physical id'
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0

2.8 案例八:显示处理器所有物理封装处理器 ID (处理器 socket ID) 和物理核心 ID 以及对应关系

# cat /proc/cpuinfo | egrep "core id|physical id" | tr -d "\n" | sed s/physical/\\nphysical/g | sed 's/core/ core/'g |  grep -v ^$ | sort | uniq
physical id	: 0 core id		: 0
physical id	: 0 core id		: 1
physical id	: 0 core id		: 2
physical id	: 0 core id		: 3
physical id	: 0 core id		: 4
physical id	: 0 core id		: 5
physical id	: 0 core id		: 6
physical id	: 0 core id		: 7

2.9 案例九:显示处理器所有进程 (虚拟核心) ID、物理封装处理器 ID (处理器 socket ID) 、物理核心 ID 以及对应关系

# cat /proc/cpuinfo | egrep "core id|physical id|processor" | tr -d "\n" | sed s/processor/\\nprocessor/g | sed 's/physical/     physical/' | sed 's/core/     core/' | grep -v ^$
processor	: 0     physical id	: 0     core id		: 0
processor	: 1     physical id	: 0     core id		: 1
processor	: 2     physical id	: 0     core id		: 2
processor	: 3     physical id	: 0     core id		: 3
processor	: 4     physical id	: 0     core id		: 4
processor	: 5     physical id	: 0     core id		: 5
processor	: 6     physical id	: 0     core id		: 6
processor	: 7     physical id	: 0     core id		: 7
processor	: 8     physical id	: 0     core id		: 0
processor	: 9     physical id	: 0     core id		: 1
processor	: 10     physical id	: 0     core id		: 2
processor	: 11     physical id	: 0     core id		: 3
processor	: 12     physical id	: 0     core id		: 4
processor	: 13     physical id	: 0     core id		: 5
processor	: 14     physical id	: 0     core id		: 6
processor	: 15     physical id	: 0     core id		: 7

2.10 案例十:显示每 1 个物理封装处理器 (处理器 socket) 里物理核心数

# cat /proc/cpuinfo | grep 'cpu cores'
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8

2.11 案例十一:显示每 1 个物理封装处理器 (处理器 socket) 里进程 (虚拟核心) 核心数

# cat /proc/cpuinfo | grep 'siblings'
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16

内容二:理解显示的处理器详细信息

1) processor 的数字从 0 到 15,代表有 16 个进程 (虚拟核心)
2) core id 的数字从 0 到 7,代表有 8 个物理核心
3) physical id 的数字都是 0,代表只有 1 个物理封装处理器 (处理器 socket)
4) cpu cores 的数字都是 8,代表每 1 个物理封装处理器 (处理器 socket) 里有 8 个物理核心
5) siblings 的数字都是 16,代表每 1 个物理封装处理器 (处理器 socket) 里有 16 个进程 (虚拟核心)
6) 总结:1 个处理器,8 个物理核心,16 个进程 (虚拟核心)

[步骤] Linux 软件指定版本的升级 (openSUSE & SLES 版)

步骤一:解锁软件

# zypper removelocks docker

(补充:这里以解锁 docker 软件包为例)

步骤二:显示所有可用的软件版本

# zypper se -s docker

(补充:这里以显示 docker 软件包的所有可用的版本为例)

步骤三:升级指定版本的软件

# zypper install --oldpackage docker-<version>.<architecture>

(补充:这里以升级 docker 软件包的指定版本为例)

步骤四:重新锁定软件

# zypper addlock docker

(补充:这里以重新锁定 docker 软件包为例)

步骤五:重启系统

# reboot

[排错] 解决 openSUSE & SLES 升级系统时报错 “Can’t get available migrations from server: SUSE::Connect::ApiError: Multiple base products found:……”

报错代码

Can't get available migrations from server: SUSE::Connect::ApiError: Multiple base products found: ......

分析

当上一次升级失败或者升级回滚了以后可能会报此类错误

解决方法

方法一:通过 SUSEConnect 命令回滚

1.1 通过 SUSEConnect 命令回滚

# SUSEConnect –rollback

1.2 重新升级

(步骤略)

步骤二:取消注册再重新注册

2.1 取消注册再重新注册

(步骤略)

2.2 重新升级

(步骤略)

参考文献:

https://www.suse.com/support/kb/doc/?id=000019523

[内容] Linux 生命周期

Red Hat:

RHEL

English:

https://access.redhat.com/product-life-cycles

Or:

https://access.redhat.com/support/policy/updates/errata/#Extended_Life_Cycle_Phase

Chinese:

https://access.redhat.com/product-life-cycles?product=Red%20Hat%20Enterprise%20Linux

Or:

https://access.redhat.com/zh_CN/support/policy/updates/errata#Extended_Life_Cycle_Phase

Red Hat all products

https://access.redhat.com/product-life-cycles/update_policies

Red Hat software packages

https://access.redhat.com/support/policy/updates/rhel-app-streams-life-cycle?extIdCarryOver=true&sc_cid=701f2000001OH6fAAG

SUSE:

openSUSE

English:

https://en.opensuse.org/Lifetime

Chinese:

https://zh.opensuse.org/%E4%BD%BF%E7%94%A8%E6%9C%9F%E9%99%90

SLES

https://www.suse.com/lifecycle

[步骤] Linux Kdump 内核奔溃信息的分析 (Rocky Linux & RHEL 版)

正文:

步骤一:开启 Kdump

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

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

1.2 给 Kdump 分配保留内存

1.2.1 通过在 /etc/default/grub 配置文件里修改 crashkernel 参数
# vim /etc/default/grub

在这一行里:

GRUB_CMDLINE_LINUX_DEFAULT="......"

添加:

GRUB_CMDLINE_LINUX_DEFAULT="...... crashkernel=auto"


补充:这里的 auto 代表系统会根据内存大小自动设置一个值,也可以指定一个值,例如:crashkernel=128M,high、crashkernel=256M,high 等等。如果设置成一个固定值,建议
1) 1 GB 到 4 GB 内存设置成 160 M
2) 4 GB 到 64 GB 内存设置成 192 M
3) 64 GB 到 1 TB 内存设置成 256 M
4) 大于 1 TB 内存设置成 512 M

1.2.2 让刚刚修改的内核参数生效
# grub2-mkconfig -o /boot/grub2/grub.cfg;reboot
1.2.3 显示给 Kdump 预留内存的大小
# makedumpfile --mem-usage /proc/kcore

步骤二:触发 Kdump 内核奔溃

# echo 1 > /proc/sys/kernel/sysrq
# echo c > /proc/sysrq-trigger

步骤三:分析 KDUMP 生成的内核奔溃信息

3.1 进入存放 KDUMP 内核奔溃信息的目录

# cd /var/crash/<date>/

3.2 解析 KDUMP 生成内核崩溃信息

# crash vmlinux-2.6.32.12-0.7-default vmcore

(补充:这里以使用 2.6.32.12-0.7-default 版本的 kernel-debuginfo 解析为例)

3.3 确认生成了 vmlinux-2.6.32.12-0.7-default.gz 压缩包

# ls vmlinux-2.6.32.12-0.7-default.gz

(注意:如果这里生成了 vmlinux-2.6.32.12-0.7-default.gz 压缩包的话,这里会有 vmlinux-2.6.32.12-0.7-default.gz 信息的显示)

(补充:这里以确认 2.6.32.12-0.7-default 版本的 kernel-debuginfo 生成的压缩包为例)

3.4 解压 vmlinux-2.6.32.12-0.7-default.gz 压缩包

# gzip -d vmlinux-2.6.32.12-0.7-default.gz

(补充:这里以解压 2.6.32.12-0.7-default 版本的 kernel-debuginfo 生成的压缩包为例)

3.5 分析 KDUMP 生成的内核奔溃信息

(步骤略)

参考文献:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/analyzing-a-core-dump_managing-monitoring-and-updating-the-kernel