Elasticsearch 1.7.4日志轮换

时间:2016-07-04 08:52:08

标签: elasticsearch logrotate

我正在尝试使用logging.yml(Elasticsearch文件)+ logrotate配置进行弹性搜索日志轮换。

信息:

1。 Elasticsearch版本 - 1.7.4

  1. 我不想保留任何旋转的文件......
  2. 配置:

    logging.yml配置:

     file:
        type: org.apache.log4j.rolling.RollingFileAppender 
        file: ${path.logs}/${cluster.name}.log
        rollingPolicy: org.apache.log4j.rolling.TimeBasedRollingPolicy
        rollingPolicy.FileNamePattern: ${path.logs}/${cluster.name}.log.%d{yyyy-MM-dd}.gz
        layout:
          type: pattern
          conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
    

    Logrotate配置:

    /var/log/elasticsearch/*.log {
        daily
        rotate 0
        copytruncate
        compress
        delaycompress
        missingok
        notifempty
        maxage 0 
        create 644 elasticsearch elasticsearch
    }
    

    更多详情:

    在/ var / log / elasticsearch上运行ls:

    total 20K
    -rw-r--r-- 1 elasticsearch elasticsearch 18763 Jul  4 08:46 dba01es.d1.log
    -rw-r--r-- 1 elasticsearch elasticsearch     0 Jun 19 10:01 dba01es.d1_index_indexing_slowlog.log
    -rw-r--r-- 1 elasticsearch elasticsearch     0 Jun 19 10:01 dba01es.d1_index_search_slowlog.log
    

    手动运行logrotate:

    logrotate -fv /etc/logrotate.d/elasticsearch 
    

    logrotate输出:

     reading config file /etc/logrotate.d/elasticsearch
    reading config info for /var/log/elasticsearch/*.log 
    
    Handling 1 logs
    
    rotating pattern: /var/log/elasticsearch/*.log  forced from command line (no old logs will be kept)
    empty log files are not rotated, old logs are removed
    considering log /var/log/elasticsearch/dba01es.d1.log
      log needs rotating
    considering log /var/log/elasticsearch/dba01es.d1_index_indexing_slowlog.log
      log does not need rotating
    considering log /var/log/elasticsearch/dba01es.d1_index_search_slowlog.log
      log does not need rotating
    rotating log /var/log/elasticsearch/dba01es.d1.log, log->rotateCount is 0
    dateext suffix '-20160704'
    glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
    previous log /var/log/elasticsearch/dba01es.d1.log.1 does not exist
    renaming /var/log/elasticsearch/dba01es.d1.log.1.gz to /var/log/elasticsearch/dba01es.d1.log.2.gz (rotatecount 1, logstart 1, i 1), 
    old log /var/log/elasticsearch/dba01es.d1.log.1.gz does not exist
    renaming /var/log/elasticsearch/dba01es.d1.log.0.gz to /var/log/elasticsearch/dba01es.d1.log.1.gz (rotatecount 1, logstart 1, i 0), 
    old log /var/log/elasticsearch/dba01es.d1.log.0.gz does not exist
    log /var/log/elasticsearch/dba01es.d1.log.2.gz doesn't exist -- won't try to dispose of it
    copying /var/log/elasticsearch/dba01es.d1.log to /var/log/elasticsearch/dba01es.d1.log.1
    truncating /var/log/elasticsearch/dba01es.d1.log
    

    手动运行logrotate后运行ll:

    total 32K
    -rw-r--r-- 1 elasticsearch elasticsearch     0 Jul  4 08:48 dba01es.d1.log
    -rw-r--r-- 1 elasticsearch elasticsearch 28937 Jul  4 08:48 dba01es.d1.log.1
    -rw-r--r-- 1 elasticsearch elasticsearch     0 Jun 19 10:01 dba01es.d1_index_indexing_slowlog.log
    -rw-r--r-- 1 elasticsearch elasticsearch     0 Jun 19 10:01 dba01es.d1_index_search_slowlog.log
    

    我的问题是:

    1. 为什么不压缩dba01es.d1.log.1文件?
    2. 为什么旋转0在这里不起作用?和logrotate一直保存旋转文件....
    3. 非常感谢! 阿米特

0 个答案:

没有答案