Apache und logrotate Konfiguration
Letzte Woche habe ich ein Problem auf meinem Server gefunden, da die Festplattenauslastung 100% betrug und ich herausgefunden habe, dass Apache eine riesige error.log-Datei mit 60 GB erstellt hat. Ich habe dann den LogLevel auf emerg geändert, aber nach einer Woche sind es wieder 1.3GB, was definitiv zu viel ist. Außerdem habe ich ein access.log von 6MB und ein other_vhosts_access.log von 167MB. So fand ich heraus, dass das Problem logrotate nicht arbeiten könnte. Tatsächlich haben die gezippten Dateien der Protokolle ein sehr altes Datum (23. Februar). Also habe ich zuerst versucht, die Konfiguration der Logrotate-Datei für Apache2 zu ändern, indem ich eine maximale Größe für die Datei hinzufügte, die jetzt so aussah:
/var/log/apache2/*.log {
weekly
size 500M
missingok
rotate 20
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
}
anach habe ich manuell versucht, logrotate zu zwingen, eine bestimmte Konfiguration für Apache mit @ auszuführe
logrotate -f /etc/logrotate.d/apache2
und ich habe diesen Fehler:
error: skipping "/var/log/apache2/access.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.
error: skipping "/var/log/apache2/error.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.
error: skipping "/var/log/apache2/other_vhosts_access.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.
Das Seltsame ist, dass auf irgendeine Weise die Rotation ausgeführt wird und eine leere error.log-Datei erstellt wird, die jedoch andere Berechtigungen als die alte hat. Dabei wird die vorhandene error.log-Datei nicht komprimiert. Wenn Sie sich das Apache-Protokollverzeichnis ansehen, sieht es jetzt so aus:
-rwxrwxrwx 1 root adm 6.3M Oct 21 10:54 access.log
-rwxrwxrwx 1 root adm 22K Feb 18 2014 access.log.1
-rwxrwxrwx 1 root adm 7.0K Feb 16 2014 access.log.2.gz
-rwxrwxrwx 1 root adm 4.0K Feb 9 2014 access.log.3.gz
-rw------- 1 amministratore amministratore 0 Oct 21 10:32 error.log
-rw-r--r-- 1 root root 1.3G Oct 21 10:57 error.log.1
-rwxrwxrwx 1 root adm 167M Oct 21 10:57 other_vhosts_access.log
-rwxrwxrwx 1 root adm 225K Feb 23 2014 other_vhosts_access.log.1
-rwxrwxrwx 1 root adm 16K Feb 15 2014 other_vhosts_access.log.2.gz
-rwxrwxrwx 1 root adm 3.2K Feb 8 2014 other_vhosts_access.log.3.gz
Also, was ist der richtige Weg, um fortzufahren? soll ich die Berechtigungen des Verzeichnisses / var / log / apache2 ändern? (das ist jetzt 777) Ich habe diese Berechtigungen nicht festgelegt und ich weiß nicht, ob es richtig ist. oder soll ich logrotate mitteilen, welcher benutzer für die drehung verwendet werden soll? und wie