[步骤] SLE supportconfig 命令收集选项的设置

步骤一:supportconfig 的作用理解

supportconfig 是一个 SLE 系统搜集系统整体情况的命令,我们可以选择搜集哪些信息

步骤二:supportconfig 命令收集选项的设置

2.1 创建 /etc/supportconfig.conf 文件

# supportconfig -C

2.2 让 supportconfig 命令不搜集某些信息

# sed -i 's\OPTION_AUDIT=1\OPTION_AUDIT=0\g' /etc/supportconfig.conf

(补充:这里使 supportconfig 命令不搜集 audit 日志为例)

Several situations of Linux automatically reboot without reboot logs in the /var/log/messages

Situation One

This Linux server is a virtual server. If we reboot it though its virtual software, there is no relevant logs in the /var/log/messages.

Situation Two

This Linux server is a member of a pacemaker cluster. If the pacemaker cluster software fences this server for protecting the whole cluster, there is no relate logs in the /var/log/messages.

Situation Three

This Linux server has critical problems in its system or hardware. Core panic of Linux and hardware problem both can reboot the system automatically without any reboot logs in the /var/log/messages.

[排错] Linux 解决出现 “Read-only file system” 的目录

报错代码

Read-only file system

可尝试的解决方法一:重新挂载此目录

# mount -o remount rw /run

(补充:这里以重新挂载 /run 目录并给此目录添加读和写权限为例)

可尝试的解决方法二:修复出现此问题的分区

可尝试的解决方法二:分析

非正常关机可能造成文件系统受损,系统重启后,受损的分区自动挂载后就会变成只读。此时修复这个分区则可能修复这个问题

可尝试的解决方法二:解决方法

# fsck.ext4 -y /dev/sda1

(补充:这里以修复分区格式为 ext4 的分区 /dev/sda1 为例)

[步骤] Linux 关机前执行脚本

步骤一:创建要被管理的脚本

# vim /root/12456.sh

创建以下内容:

#!/bin/bash
for i in {1..5}
do
echo $i
done

(补充:这里以创建 /etc/root/for.sh 脚本为例)

步骤二:创建 systemctl 的管理文件

# vim /etc/systemd/system/12456.service

创建以下内容:

[Unit]
Description=12345
After=getty@tty1.service display-manager.service plymouth-start.service
Before=systemd-poweroff.service systemd-halt.service
DefaultDependencies=no

[Service]
ExecStart=/root/12456.sh
Type=forking

[Install]
WantedBy=poweroff.target
WantedBy=reboot.target
WantedBy=halt.target

(补充:这里以创建 /etc/systemd/system/12456.service 来管理 ExecStart=/root/12456.sh 为例)

步骤三:加载刚刚创建的 systemctl 管理文件

# systemctl daemon-reload

步骤四:给 systemctl 的管理文件添加执行权限

# chmod u+x /etc/systemd/system/12456.service

步骤五:设置关机前执行脚本

5.1 设置关闭系统前执行此脚本

# ln -s /usr/lib/systemd/system/12456.service /usr/lib/systemd/system/halt.target.wants/

5.2 设置关闭电源前执行此脚本

# ln -s /usr/lib/systemd/system/12456.service /usr/lib/systemd/system/poweroff.target.wants/

5.3 设置重启先执行此脚本

# ln -s /usr/lib/systemd/system/12456.service /usr/lib/systemd/system/reboot.target.wants/