1. 安装

1.1. Mcelog 安装

快速开始

一般选择适合自己的Mcelog发行版本,但如果你的Mcelog很旧的或错误配置了,您可以安装一个新的。

如果您安装的新版本是基于旧的crontab方式的Mcelog,你需要避免冲突。最简单的方法是删除mcelog在/etc/cron.* 中的计划任务文件。

编译git版本或一个tarball 。git版本是目前推荐的并且更有特色的。

获取 git 版本 :

git clone git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git

(或者,如果你已经拥有一个分支,你可以cd mcelog ; git pull -u)

编译和安装

cd mcelog
make
... become root ...
make install

基于Linux中init脚本安装

设置mcelog.init脚本,确保能够开机启动执行。例如可以这样(在opensuse系统):

cp mcelog.init /etc/init.d/mcelog
chkconfig mcelog on

其他发行版上可能需要找到相当于chkconfig的管理方式。Mcelog.init 也有一些配置可以设置,尽管默认值是合理的。

如果你不重新启动系统, 也可以是使用/etc/init.d/mcelog start方式启动mcelog。这样你不需要每次修改完配置文件后重启系统了。

基于systemd系统安装

mcelog包含一个标准的systemd文件:mcelog.service。安装服务文件 :

cp mcelog.service /usr/lib/systemd/system
systemctl enable mcelog.service

基于upstart系统安装

这里需要使用init脚本

其他的安装方式注意问题

如果你没有在syslog或journald日志系统中配置mcelog,那么你需要添加/var/log/mcelog日志轮询设置(如:logrotate)。这通常可以在/etc/logrotate .d目录中通过创建一个文件来实现(或重用已存在的版本)。

您可以验证mcelog的守护进程是否正在运行

mcelog --client

这是查询运行的守护进程中的信息。如果没有任何输出那么系统是健康的(没有错误记录)。

依赖关系

确认你的系统中存在/dev/mcelog设备文件。 如果没有请创建一个: mknod /dev/mcelog c 10 227 ,基于udev的系统还可以在/usr/lib/udev/rules.d udev规则文件 中添加信息:

ACTION=="add", KERNEL=="mcelog", SUBSYSTEM=="misc", TAG+="systemd", ENV{SYSTEMD_WANTS}+="mcelog.service"

如果/dev不是持久的,在许多新版本上udev还是需要的。特殊发布的版本会在意这些。

对于bad page offlining你需要一个2.6.33+内核或2.6.32内核与有该功能的补丁 (比如RHEL6或SLES11-SP1)

内核必须启用CONFIG_X86_MCE。对于32位内核需要2.6.30+内核。

Mcelog 运行模式

Mcelog有三种运行模式: cronjob(计划任务) , trigger(触发器) , daemon(守护进程)

推荐的方式是daemon方式,因为一些新的功能(如page error predictive错误预测分析)需要一个持续运行的守护进程。如果你只是想运行在守护进程模式,后面的内容你就不用看了。

在daemon模式mcelog持续的作为一个守护进程在后台运行来等待错误。可以从一个 init脚本运行mcelog --daemon &,这是最快和最feature-ful的方式。

cronjob方式是旧的方法。 mcelog每5分钟从cron运行时检查错误。缺点是它明显的延迟错误报告(高达10分钟),同时也不允许mcelog保持扩展状态 。

trigger方式是一种较新的方法,当内核有错误时运行mcelog。开启方式:

echo /usr/sbin/mcelog   >/sys/devices/system/machinecheck/machinecheck0/trigger 

这响应更快 , 但仍然不允许 mcelog 保持状态 , 并且当错误产生时会有较高系统资源开销, 因为mcelog必须从头开始初始化。


2. mcelog installation

2.1. Quickstart

The standard way should be to use the mcelog that comes with your distribution, but if your mcelog is very old or not correctly configured you can set up a newer one like this.

If your distribution has a old crontab based mcelog disable it to avoid conflicts. The easiest way is to delete the mcelog cronjob file in /etc/cron.*

Compile the git version or a tarball. The git version is currently recommended and more featureful.

Get the git version:

git clone git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git

(or cd mcelog ; git pull -u if you already have an earlier checkout)

Compile and install

cd mcelog

make

... become root ...
make install

2.2. Installation on Linux systems based on init scripts

Set up the init script mcelog.init and make sure it is executed at boot. For example this can be done (on a opensuse system) with:

cp mcelog.init /etc/init.d/mcelog

chkconfig mcelog on

On other distributions you may need to find the distribution equivalent of chkconfig. mcelog.init also has some configuration settings that you could change, although the defaults are reasonable.

If you don't reboot start mcelog explicitely with /etc/init.d/mcelog start. Not needed after each reboot if the init script is set up correctly.

2.3. Installation on systems based on systemd

mcelog includes a standard systemd unit file: mcelog.service. To install the service file:

cp mcelog.service /usr/lib/systemd/system
systemctl enable mcelog.service

2.4. Installation on systems based on upstart

Use the init script for now.

2.5. Other installation notes

You may need to add /var/log/mcelog to your log rotating setup (like logrotate) if you didn't configure mcelog to log to syslog or to journald. This can be often done by creating a file in /etc/logrotate.d (or reusing the one that is already there from the distribution)

You can verify the daemon is running completely by running

mcelog --client

This should query the information in the running daemon. If it prints nothing that is fine (no errors logged yet)

2.6. Dependencies

Verify you got a /dev/mcelog. If not create one with mknod /dev/mcelog c 10 227 On udev based systems you can also add a udev rule file in /usr/lib/udev/rules.d like

ACTION=="add", KERNEL=="mcelog", SUBSYSTEM=="misc", TAG+="systemd", ENV{SYSTEMD_WANTS}+="mcelog.service"

This is needed if the /dev is not persistent, as in many newer distributions. Typically the distribution package for mcelog takes care of that.

For bad page offlining you will need a 2.6.33+ kernel or a 2.6.32 kernel with the soft offlining capability backported (like RHEL6 or SLES11-SP1)

The kernel has to have CONFIG_X86_MCE enabled. For 32bit kernels you need at least a 2.6,30 kernel.

2.7. mcelog modi

mcelog can run in several modi: cronjob, trigger, daemon

The recommended mode is daemon, because several new functions (like page error predictive failure analysis) require a continuously running daemon. If you just want daemon mode you can stop reading here.

In daemon mode mcelog runs continuously as a daemon in the background and wait for errors. It is enabled by running mcelog --daemon & from a init script. This is the fastest and most feature-ful.

cronjob is the old method. mcelog runs every 5 minutes from cron and checks for errors. Disadvantage of this is that it can delay error reporting significantly (upto 10 minutes) and does not allow mcelog to keep extended state.

trigger is a newer method where the kernel runs mcelog on a error. This is configured with echo /usr/sbin/mcelog > /sys/devices/system/machinecheck/machinecheck0/trigger This is faster, but still doesn't allow mcelog to keep state, and has relatively high overhead for each error because a program has to be initialized from scratch.

Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2022-01-02 08:22:10

results matching ""

    No results matching ""