Centos7: Stoppen Sie die aufgeblähte Protokollierung

Centos7: Stoppen Sie die aufgeblähte Protokollierung

Ich habe einen Server mit dem Betriebssystem Centos 7 und schaue mir Protokolldateien an, wie zum Beispiel die Nachrichtenprotokolldatei("/var/log/Nachrichten")Ich sehe, dass es hauptsächlich Einträge wie die folgenden enthält:

Aug 29 12:46:01 localhost systemd: Created slice user-48.slice.
Aug 29 12:46:01 localhost systemd: Starting user-48.slice.
Aug 29 12:46:01 localhost systemd: Started Session 984866 of user apache.
Aug 29 12:46:01 localhost systemd: Starting Session 984866 of user apache.
Aug 29 12:46:01 localhost systemd: Started Session 984868 of user apache.
Aug 29 12:46:01 localhost systemd: Starting Session 984868 of user apache.
Aug 29 12:46:01 localhost systemd: Started Session 984867 of user apache.
Aug 29 12:46:01 localhost systemd: Starting Session 984867 of user apache.
Aug 29 12:46:01 localhost systemd: Started Session 984869 of user apache.
Aug 29 12:46:01 localhost systemd: Starting Session 984869 of user apache.
Aug 29 12:46:02 localhost systemd: Removed slice user-48.slice.
Aug 29 12:46:02 localhost systemd: Stopping user-48.slice.
Aug 29 12:47:01 localhost kernel: audit_printk_skb: 51 callbacks suppressed
Aug 29 12:47:01 localhost kernel: type=1101 audit(1535543221.712:13161497): pid=45989 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:crond_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_access,pam_unix,pam_localuser acct="apache" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
Aug 29 12:47:01 localhost kernel: type=1101 audit(1535543221.712:13161499): pid=45992 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:crond_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_access,pam_unix,pam_localuser acct="apache" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
Aug 29 12:47:01 localhost kernel: type=1101 audit(1535543221.743:13161500): pid=45991 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:crond_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_access,pam_unix,pam_localuser acct="apache" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
Aug 29 12:47:01 localhost kernel: type=1103 audit(1535543221.749:13161502): pid=45989 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:crond_t:s0-s0:c0.c1023 msg='op=PAM:setcred grantors=pam_env,pam_unix acct="apache" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
Aug 29 12:47:01 localhost kernel: audit: audit_lost=6572998 audit_rate_limit=0 audit_backlog_limit=320
Aug 29 12:47:01 localhost kernel: audit: printk limit exceeded

Mir scheinen diese Nachrichten nicht besonders nützlich zu sein und daher würde ich, wenn ich richtig liege, gerne mit der Protokollierung aufhören.

Ich möchte wissen, ob meine Annahmen hinsichtlich der Nutzlosigkeit dieser Nachrichten richtig sind und wenn ja, wie ich verhindern kann, dass diese protokolliert werden?

Mein/etc/rsyslog.confInhalt:

# rsyslog configuration file

# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html

#### MODULES ####

# The imjournal module bellow is now used as a message source instead of imuxsock.
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imjournal # provides access to the systemd journal
#$ModLoad imklog # reads kernel messages (the same are read from journald)
#$ModLoad immark  # provides --MARK-- message capability

# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

# Provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514


#### GLOBAL DIRECTIVES ####

# Where to place auxiliary files
$WorkDirectory /var/lib/rsyslog

# Use default timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# File syncing capability is disabled by default. This feature is usually not required,
# not useful and an extreme performance hit
#$ActionFileEnableSync on

# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf

# Turn off message reception via local log socket;
# local messages are retrieved through imjournal now.
$OmitLocalLogging on

# File to store the position in the journal
$IMJournalStateFile imjournal.state


#### RULES ####

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                                                 /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none                /var/log/messages

# The authpriv file has restricted access.
authpriv.*                                              /var/log/secure

# Log all the mail messages in one place.
mail.*                                                  -/var/log/maillog


# Log cron stuff
cron.*                                                  /var/log/cron

# Everybody gets emergency messages
*.emerg                                                 :omusrmsg:*

# Save news errors of level crit and higher in a special file.
uucp,news.crit                                          /var/log/spooler

# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log

Mein Syslog:

/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
    missingok
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

Antwort1

Ich verwende CentOS nicht, aber es läuft wahrscheinlich systemdmit journaldund rsyslog. Jedes davon kann für die Protokollierung konfiguriert werden, aber das der endgültigen Datei am nächsten kommende /var/log/messagesist vermutlich /etc/rsyslog.conf. Dies könnte eine Zeile wie die folgende enthalten:

*.info;mail.none;authpriv.none;cron.none   /var/log/messages

Sie können *.infodurch eine andere Ebene ersetzen, z. B. *.warning. (Die Ebenen sind: emerg alert crit err warning notice info debug). Sie müssen den Daemon mit neu starten.

sudo systemctl status rsyslogd

Dies ist alles, was Sie ändern müssen. Der Vollständigkeit halber sind hier jedoch die beiden anderen Konfigurationen aufgeführt, die normalerweise nicht geändert werden.

Mit systemd werden Sie wahrscheinlich auch komprimierte Binärdateien in protokollieren . Dies wird durch die Datei (und andere, siehe ) /var/log/journal/konfiguriert , die Sie bearbeiten können, um beispielsweise die Zeile hinzuzufügen:/etc/systemd/journald.confman journald.conf

MaxLevelSyslog=warning

um den Pegel vom Standardwert zu reduzieren debug, der es erlaubt, alle Nachrichten an Syslog zu senden, wo sie wie oben beschrieben gefiltert werden. Sie benötigen wahrscheinlich einen , sudo systemctl restart systemd-journaldwenn Sie Änderungen an dieser Datei vornehmen.

Die Datei /etc/systemd/system.conf(siehe man systemd-system.conf) enthält auch eine Zeile für die von systemd protokollierten Meldungen, und zwar standardmäßig

LogLevel=info

was auch geändert werden kann. Möglicherweise müssen Sie einen Neustart durchführen, damit diese Datei erneut gelesen wird.

verwandte Informationen