各位朋友,
我完全是 Linux 新手。我正尝试在运行 PUIAS 6.4 (i86_64) 的计算节点之一上部署 mcelog
[root@lov3 edac]# uname -a
Linux lov3.mylab.org 2.6.32-358.18.1.el6.x86_64 #1 SMP Tue Aug 27 22:40:32 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
在 AMD 硬件上免费克隆 Red Hat 6.4
[root@lov3 mcelog]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 64
On-line CPU(s) list: 0-63
Thread(s) per core: 2
Core(s) per socket: 8
Socket(s): 4
NUMA node(s): 8
Vendor ID: AuthenticAMD
CPU family: 21
Model: 2
Stepping: 0
CPU MHz: 1400.000
BogoMIPS: 4999.30
Virtualization: AMD-V
L1d cache: 16K
L1i cache: 64K
L2 cache: 2048K
L3 cache: 6144K
NUMA node0 CPU(s): 0-7
NUMA node1 CPU(s): 8-15
NUMA node2 CPU(s): 16-23
NUMA node3 CPU(s): 24-31
NUMA node4 CPU(s): 32-39
NUMA node5 CPU(s): 40-47
NUMA node6 CPU(s): 48-55
NUMA node7 CPU(s): 56-63
除了我想将 mcelog 作为守护进程运行并记录错误之外,我的 mcelog.conf 文件或多或少是默认的。当我启动 mcelog 时
[root@lov3 mcelog]# mcelog --config-file mcelog.conf
AMD Processor family 21: Please load edac_mce_amd module.
但是模块存在
[root@lov3 mcelog]# locate edac_mce_amd.ko
/lib/modules/2.6.32-358.18.1.el6.x86_64/kernel/drivers/edac/edac_mce_amd.ko
/lib/modules/2.6.32-358.el6.x86_64/kernel/drivers/edac/edac_mce_amd.ko
并加载
[root@lov3 edac]# lsmod | grep mce
edac_mce_amd 14705 1 amd64_edac_mod
我能做些什么来让 mcelog 正常工作?我找到的唯一参考资料是这个帖子
http://lists.centos.org/pipermail/centos/2012-November/130226.html
答案1
mcelog 不适用于该 AMD CPU 或更新版本(如 所示mcelog.c
family >= 15
)。AMD EPYC 处理器也存在同样的问题。
不要使用 mcelog,而要使用内核模块edac_mce_amd
,它会将 MCE 日志放入内核日志中,该日志最终会通过 syslog 记录到磁盘上。这次 mcelog 可能会为您加载该模块,但我建议在启动时以其他方式加载它,例如/etc/initramfs-tools/modules
基于 Debian 的 Linux 上的文件和update-initramfs -u
。
但是我找不到任何说明这种日志格式的东西...所以这里是根据 Linux 源代码得出的一个猜测...
在中include/linux/printk.h
,我们看到:
#define HW_ERR "[Hardware Error]: "
在中drivers/edac/mce_amd.c
,我们会看到类似这样的输出pr_emerge(HW_ERR ...)
:
pr_emerg(HW_ERR "MC0 Error: ");
还有更多带有pr_cont(...)
但不带有 的线条HW_ERR
。
"[Hardware Error]:"
所以我想你可以在日志中查找。也许这些行也会说明edac_mce_amd
。
这里有一条规则,我认为它将记录第一个 pr_emerg,但不会记录 pr_cont 部分(请参阅这里)。我在这里设置了一条rsyslog.d
规则来查找"[Hardware Error]:"
。但这将匹配除 edac_mce_amd 模块之外的其他内容。
vim /etc/rsyslog.d/09-edac_mce_amd.conf
if ($syslogfacility-text == 'kern') and \
($msg contains '[Hardware Error]:') \
then -/var/log/edac_mce_amd.log
#uncomment this to also remove it from the other files
#& stop
仅第一行对我来说已经足够了,因为我将设置一个监控脚本,仅检查文件大小是否为 0。如果有人知道正确的方法,请发表评论。
答案2
由于您使用的是 CPU 系列 21,因此消息很明显:您可以看到以下代码:
mcelog.c of the mcelog-1.0pre3_20110718-0.14.el6 package show where the cpu family of greater than 15 returns 0 to is_cpu_supported():
416 int is_cpu_supported(void)
417 {
418 enum {
419 VENDOR = 1,
420 FAMILY = 2,
421 MODEL = 4,
422 MHZ = 8,
423 FLAGS = 16,
424 ALL = 0x1f
425 } seen = 0;
426 FILE *f;
427 static int checked;
428
429 if (checked)
430 return 1;
431 checked = 1;
432
433 f = fopen("/proc/cpuinfo","r");
434 if (f != NULL) {
435 int family = 0;
436 int model = 0;
437 char vendor[64] = { 0 };
438 char *line = NULL;
439 size_t linelen = 0;
440 double mhz;
441
442 while (getdelim(&line, &linelen, '\n', f) > 0 && seen != ALL) {
443 if (sscanf(line, "vendor_id : %63[^\n]", vendor) == 1)
444 seen |= VENDOR;
445 if (sscanf(line, "cpu family : %d", &family) == 1)
446 seen |= FAMILY;
447 if (sscanf(line, "model : %d", &model) == 1)
448 seen |= MODEL;
449 /* We use only Mhz of the first CPU, assuming they are the same
450 (there are more sanity checks later to make this not as wrong
451 as it sounds) */
452 if (sscanf(line, "cpu MHz : %lf", &mhz) == 1) {
453 if (!cpumhz_forced)
454 cpumhz = mhz;
455 seen |= MHZ;
456 }
457 if (!strncmp(line, "flags", 5) && isspace(line[6])) {
458 processor_flags = line;
459 line = NULL;
460 linelen = 0;
461 seen |= FLAGS;
462 }
463
464 }
465 if (seen == ALL) {
466 if (!strcmp(vendor,"AuthenticAMD")) {
467 if (family == 15)
468 cputype = CPU_K8;
469 if (family >= 15) <-----------
470 fprintf(stderr, "AMD Processor family %d: Please load edac_mce_amd module.\n", f amily);
471 return 0;
472 } else if (!strcmp(vendor,"GenuineIntel"))
473 cputype = select_intel_cputype(family, model);
474 /* Add checks for other CPUs here */
475 } else {
476 Eprintf("warning: Cannot parse /proc/cpuinfo\n");
477 }
478 fclose(f);
479 free(line);
480 } else
481 Eprintf("warning: Cannot open /proc/cpuinfo\n");
482
483 return 1;
484 }