在一台CentOS 8的Linux服務器上使用下面腳本判斷BIOS層是否開啟了numa時。尷尬的事情的發生了,這台CentOS 8上沒有dmesg這個日志,但是可以通過命令dmesg查看相關日志。那么到底是什么情況呢?
[root@Zabbix log]# more /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
[root@Zabbix log]#grep -i numa /var/log/dmesg
搜索資料時,在官方文檔終於找到答案,因為這個資料需要賬號才能訪問,特將這個資料摘抄在此,方便查看!
The /var/log/dmesg file is not created during boot for Red Hat Enterprise Linux 8
環境
· Red Hat Enterprise Linux 8
問題
· On boot, there is no /var/log/dmesg file after install RHEL8.
· I can get dmesg file via command dmesg, is this new design for RHEL 8, or do I need to modify some configuration to generate it automatically?
決議
Re-enabling the /var/log/dmesg log file
1) Create a /etc/systemd/system/dmesg.service configuration file with the following contents
[Unit]
Description=Create /var/log/dmesg on boot
ConditionPathExists=/var/log/dmesg
[Service]
ExecStart=/usr/bin/dmesg
StandardOutput=file:/var/log/dmesg
[Install]
WantedBy=multi-user.target
2) Create the /var/log/dmesg file and verify SELinux contexts
# touch /var/log/dmesg
# restorecon -v /var/log/dmesg
3) Enable the service to start on boot
# systemctl enable dmesg
根源
By design, the /var/log/dmesg file is not generated during boot. The kernel ring buffer is captured within the systemd-journal as well as /var/log/messages, via the imjournal rsyslog plugin.
簡單來說,CentOS 8在設計之初,在啟動過程中不會生成/var/log/dmesg日志文件。 內核環形緩沖區在systemd-journal和日志/var/log/messages中捕獲內核啟動信息,通過imjournal rsyslog 插件捕獲。當然你也可以通過上面設置生成/var/log/dmesg日志文件。
參考資料:
https://access.redhat.com/solutions/3748981