2015-09-09 79 views
2

我們已經設置了syslogd,可以將來自幾個不同服務器的所有日誌合併到一個名爲/ var/log/centrallogs的文件夾中。 (使用logrotate的-d centrallogs)LR不Logrotate不壓縮

/var/log/centrallogs/*log { 
     rotate 5 
     compress 
     missingok 
     notifempty 
     sharedscripts 
     postrotate 
     /etc/init.d/httpd restart > /dev/null 2>/dev/null || true 
     endscript 
} 

在測試:

我們使用以下日誌此目錄旋轉配置:

/etc/logrotate.d/centrallogs似乎試圖做任何旋轉。

下面是輸出(注意,我已經改名的網站,但是這就是我所做的唯一變化):我已經使用過delaycompress而是因爲有些人已經成功與嘗試

rotating pattern: /var/log/centrallogs/*log 1048576 bytes (5 rotations) 
empty log files are not rotated, old logs are removed 
considering log /var/log/centrallogs/site1_access.log 
    log needs rotating 
considering log /var/log/centrallogs/site1_error.log 
    log does not need rotating 
considering log /var/log/centrallogs/site2_access.log 
    log needs rotating 
considering log /var/log/centrallogs/site2_error.log 
    log needs rotating 
considering log /var/log/centrallogs/site3_access.log 
    log needs rotating 
considering log /var/log/centrallogs/site3_error.log 
    log needs rotating 
rotating log /var/log/centrallogs/site1_access.log, log->rotateCount is 5 
dateext suffix '-20150908' 
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' 
renaming /var/log/centrallogs/site1_access.log.5.gz to /var/log/centrallogs/site1_access.log.6.gz (rotatecount 5, logstart 1, i 5), 
renaming /var/log/centrallogs/site1_access.log.4.gz to /var/log/centrallogs/site1_access.log.5.gz (rotatecount 5, logstart 1, i 4), 
renaming /var/log/centrallogs/site1_access.log.3.gz to /var/log/centrallogs/site1_access.log.4.gz (rotatecount 5, logstart 1, i 3), 
renaming /var/log/centrallogs/site1_access.log.2.gz to /var/log/centrallogs/site1_access.log.3.gz (rotatecount 5, logstart 1, i 2), 
renaming /var/log/centrallogs/site1_access.log.1.gz to /var/log/centrallogs/site1_access.log.2.gz (rotatecount 5, logstart 1, i 1), 
renaming /var/log/centrallogs/site1_access.log.0.gz to /var/log/centrallogs/site1_access.log.1.gz (rotatecount 5, logstart 1, i 0), 
rotating log /var/log/centrallogs/site2_access.log, log->rotateCount is 5 
dateext suffix '-20150908' 
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' 
renaming /var/log/centrallogs/site2_access.log.5.gz to /var/log/centrallogs/site2_access.log.6.gz (rotatecount 5, logstart 1, i 5), 
renaming /var/log/centrallogs/site2_access.log.4.gz to /var/log/centrallogs/site2_access.log.5.gz (rotatecount 5, logstart 1, i 4), 
renaming /var/log/centrallogs/site2_access.log.3.gz to /var/log/centrallogs/site2_access.log.4.gz (rotatecount 5, logstart 1, i 3), 
renaming /var/log/centrallogs/site2_access.log.2.gz to /var/log/centrallogs/site2_access.log.3.gz (rotatecount 5, logstart 1, i 2), 
renaming /var/log/centrallogs/site2_access.log.1.gz to /var/log/centrallogs/site2_access.log.2.gz (rotatecount 5, logstart 1, i 1), 
renaming /var/log/centrallogs/site2_access.log.0.gz to /var/log/centrallogs/site2_access.log.1.gz (rotatecount 5, logstart 1, i 0), 
rotating log /var/log/centrallogs/site2_error.log, log->rotateCount is 5 
dateext suffix '-20150908' 
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' 
renaming /var/log/centrallogs/site2_error.log.5.gz to /var/log/centrallogs/site2_error.log.6.gz (rotatecount 5, logstart 1, i 5), 
renaming /var/log/centrallogs/site2_error.log.4.gz to /var/log/centrallogs/site2_error.log.5.gz (rotatecount 5, logstart 1, i 4), 
renaming /var/log/centrallogs/site2_error.log.3.gz to /var/log/centrallogs/site2_error.log.4.gz (rotatecount 5, logstart 1, i 3), 
renaming /var/log/centrallogs/site2_error.log.2.gz to /var/log/centrallogs/site2_error.log.3.gz (rotatecount 5, logstart 1, i 2), 
renaming /var/log/centrallogs/site2_error.log.1.gz to /var/log/centrallogs/site2_error.log.2.gz (rotatecount 5, logstart 1, i 1), 
renaming /var/log/centrallogs/site2_error.log.0.gz to /var/log/centrallogs/site2_error.log.1.gz (rotatecount 5, logstart 1, i 0), 
rotating log /var/log/centrallogs/site3_access.log, log->rotateCount is 5 
dateext suffix '-20150908' 
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' 
renaming /var/log/centrallogs/site3_access.log.5.gz to /var/log/centrallogs/site3_access.log.6.gz (rotatecount 5, logstart 1, i 5), 
renaming /var/log/centrallogs/site3_access.log.4.gz to /var/log/centrallogs/site3_access.log.5.gz (rotatecount 5, logstart 1, i 4), 
renaming /var/log/centrallogs/site3_access.log.3.gz to /var/log/centrallogs/site3_access.log.4.gz (rotatecount 5, logstart 1, i 3), 
renaming /var/log/centrallogs/site3_access.log.2.gz to /var/log/centrallogs/site3_access.log.3.gz (rotatecount 5, logstart 1, i 2), 
renaming /var/log/centrallogs/site3_access.log.1.gz to /var/log/centrallogs/site3_access.log.2.gz (rotatecount 5, logstart 1, i 1), 
renaming /var/log/centrallogs/site3_access.log.0.gz to /var/log/centrallogs/site3_access.log.1.gz (rotatecount 5, logstart 1, i 0), 
rotating log /var/log/centrallogs/site3_error.log, log->rotateCount is 5 
dateext suffix '-20150908' 
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' 
renaming /var/log/centrallogs/site3_error.log.5.gz to /var/log/centrallogs/site3_error.log.6.gz (rotatecount 5, logstart 1, i 5), 
renaming /var/log/centrallogs/site3_error.log.4.gz to /var/log/centrallogs/site3_error.log.5.gz (rotatecount 5, logstart 1, i 4), 
renaming /var/log/centrallogs/site3_error.log.3.gz to /var/log/centrallogs/site3_error.log.4.gz (rotatecount 5, logstart 1, i 3), 
renaming /var/log/centrallogs/site3_error.log.2.gz to /var/log/centrallogs/site3_error.log.3.gz (rotatecount 5, logstart 1, i 2), 
renaming /var/log/centrallogs/site3_error.log.1.gz to /var/log/centrallogs/site3_error.log.2.gz (rotatecount 5, logstart 1, i 1), 
renaming /var/log/centrallogs/site3_error.log.0.gz to /var/log/centrallogs/site3_error.log.1.gz (rotatecount 5, logstart 1, i 0), 
renaming /var/log/centrallogs/site1_access.log to /var/log/centrallogs/site1_access.log.1 
renaming /var/log/centrallogs/site2_access.log to /var/log/centrallogs/site2_access.log.1 
renaming /var/log/centrallogs/site2_error.log to /var/log/centrallogs/site2_error.log.1 
renaming /var/log/centrallogs/site3_access.log to /var/log/centrallogs/site3_access.log.1 
renaming /var/log/centrallogs/site3_error.log to /var/log/centrallogs/site3_error.log.1 
running postrotate script 
running script with arg /var/log/centrallogs/*log : " 
    /etc/init.d/httpd restart > /dev/null 2>/dev/null || true 
" 
compressing log with: /bin/gzip 
removing old log /var/log/centrallogs/site1_access.log.6.gz 
error: error opening /var/log/centrallogs/site1_access.log.6.gz: No such file or directory 

那。

LR旋轉日誌就好了,它根本不會對它們執行壓縮。

望着那輸出的唯一錯誤的冠冕堂皇的部分:

error: error opening /var/log/centrallogs/site1_access.log.6.gz: No such file or directory 

我想通LR可能被嚇壞了,因爲它沒有使用.gz文件刪除,所以我創建日誌的每一個變化文件需要,它運行了一整晚,清除了gz,旋轉了,但仍然沒有壓縮。

這讓我有點生氣,任何幫助都會感激不盡。

+1

也許'delaycompress'會幫助:http://serverfault.com/a/117009/253150 – Samuel

+0

@Samuel我試過了,沒有快樂:( –

+1

嗯,應該用'gzip'默認壓縮。你能檢查一下嗎?如果你的''gzip'在'/ bin/gzip'? – Samuel

回答

0

基於日誌,它看起來像是在運行/ bin/gzip,通常gzip會壓縮所有列出的文件 - 跳過所有丟失的文件 - 沒有問題。請注意,如果結果較大,gzip將不會強制壓縮文件,這很容易發生在非常小的文件上。 「錯誤:錯誤[..]」消息可能不是來自gzip,它傾向於用「gzip ::」前綴錯誤。

檢查文件大小以查看它們是否很小(或者更具體地說,如果gzip認爲壓縮它們會使它們變大)。

notifempty的相似評論

delaycompress只是意味着你可以有.1.2.3.4gz .5.gz之類的東西。它是而不是使壓縮工作,並實際上使其跳過壓縮最近幾個文件。你可以使用兩者,或者只是使用壓縮,而不是延遲壓縮。

這很奇怪,你沒有頻率/大小{每天|每週|大小___}在您的文件中。我從來沒有嘗試過沒有使用它們。