Analysis and storage log (ii)
1. Find Events by Journalctl
The SYSTEMD log stores the log data in a structured binary file with indexes. This data contains additional information related to log events. In Red Hat 7, the SYSTEMD log is stored by default in/run/log, and its contents are cleared after a reboot.
Command: Journalctl
Journalctl-n 5 Default-n Displays the last 10 bars
Journalctl-f trace output last 10 records
Journalctl-p can accept the name or number of a known priority as a parameter for filtering
Example: Journalctl-p error Output filter priority is error or above log
Highlight notice or warning messages in bold, highlight error and higher messages in red
The JOURNALCTL command has two options to limit the output to the feature's time range, which is the--since and--until options respectively. All two options accept the time parameter in the format Yyyy-mm-dd Hh:mm:ss, which also accepts yesterday, today, and tomorrow as valid arguments
Journalctl--since today output Day record
Journalctl--since "2015-11-01 20:00:30"--until "2015-11-03 20:00:00"
2. Save SYSTEMD Log
By default, the Systemd log is saved in/run/log/journal, and it is purged after the system restarts.
If there is a/var/log/journal directory, the log will be recorded in this directory instead.
Configuration file/etc/systemd/journald.conf
Create directory as root user/var/log/journal
Modify the owning user and the owning group, and have permission 2755
Chown root:systemd-journal/var/log/journal
chmod 2755/var/log/journal
Restart the system or send a special signal as root USR1 to the Systemd-journald process
KILLALL-USR1 Systemd-journald
Because the SYSTEMD log is a permanent log, the log messages since the system's last boot can be displayed through Journalctl-b to check the output
3, to maintain accurate time
Network Event Protocol NTP is a standard method used by computers to provide and obtain correct time information over the Internet. The computer can obtain the correct time information through the public NTP service on the Internet. Another option is to provide accurate time for local clients with a high-quality hardware clock.
The Timedatectl command briefly displays the current time-relationship system settings, such as the system's current time, time zone, and NTP synchronization settings
Timedatectl current time-related system settings
Timedatectl list-timezones list Time zone database information
Timedatectl Set-timezone Setting the time zone
Timedatectl set-time yyyy-mm-dd hh:mm:ss Set Date Time
Timedatectl set-ntp true/false Enable or disable NTP synchronization
Configuring and Monitoring Chronyd
The Chronyd service synchronizes with the computed RTC clock drift value by synchronizing with the configured NTP server or without a network, which is recorded in the driftfile specified in the/etc/chrony.conf configuration file
You can configure two types of time sources in the/etc/chrony.conf configuration file, namely server and peer
Server is one level higher than the local NTP server, while peer is at the same level, you can specify multiple servers and multiple peer
Example: Server 0.rhel.pool.ntp.org iburst
Chronyc Sources view Time source
Chronyc sources-v contains additional verbose output
Linux Learning notes----5