You need to enable JavaScript to run this app.
导航
升级 LogCollector(宿主机)
最近更新时间:2024.05.13 16:04:11首次发布时间:2022.08.16 11:17:17

LogCollector 支持自动升级和手动升级,本文档介绍升级 LogCollector 的操作步骤。

背景信息

LogCollector 是日志服务提供的日志采集工具,为保证日志采集的稳定性与效率,日志服务建议您始终选用最新版本的 LogCollector 采集服务器日志。为便于版本更新与迭代,日志服务提供自动升级和手动升级两种升级方式。

升级方式

说明

自动升级

创建机器组时,如果开启了LogCollector 自动升级,表示启用自动升级功能。
日志服务会在每天的指定时间段对指定机器组进行升级前检查,如果满足升级条件,则自动更新 LogCollector。建议将自动升级时间设置为业务低峰期。自动升级过程中可能会重启 LogCollector,但不会丢失日志。

说明

弹性容器实例 VCI场景下,暂不支持 LogCollector 自动升级,需手动替换镜像。

启用自动升级,请参考自动升级

手动升级

关闭了LogCollector 自动升级功能的机器组,或不满足 LogCollector 版本要求的机器组,只能手动升级 LogCollector。
您需要卸载历史版本 LogCollector,并下载安装最新版本 LogCollector,升级过程中还需要手动迁移断点文件目录和采集配置文件目录。
手动升级 LogCollector,请参考手动升级

自动升级 LogCollector

自动升级条件

开启自动升级之后,日志服务会在每天的指定时间段对指定机器组进行以下升级前检查,仅在满足所有升级条件的情况下才会执行自动升级操作。

检查项

说明

当前的 LogCollector 版本是否为 V1.0.8 及后续版本。

仅 V1.0.8 及后续版本的 LogCollector 支持自动升级。
如果版本不满足,请参考手动升级 LogCollector,手动升级到最新版本后,再使用自动升级功能。

当前的 LogCollector 版本是否为最新版本。

日志服务会定期检查 LogCollector 的版本更新情况,若有版本更新,才会进行下一步升级前检查。

LogCollector 的心跳状态是否为正常

心跳状态失败的 LogCollector 无法自动升级,请参考机器组心跳问题排查进行心跳排查。

说明

弹性容器实例 VCI场景下,暂不支持 LogCollector 自动升级,需手动替换镜像。

操作步骤

  1. 登录日志服务控制台
  2. 在左侧目录中选择日志服务 > 机器组管理
  3. 机器组管理页面找到需要开启自动升级功能的机器组,并在其对应的操作列单击编辑
  4. 打开LogCollector自动升级开关,并设置自动升级时间
  5. 单击确定
    成功开启自动升级功能之后,在机器组列表中,此机器组在LogCollector自动升级一列中会显示开启

说明

  • 建议设置自动升级时间为业务低峰期。自动升级过程中可能会重启 LogCollector,但不会丢失日志。
  • 如需为多个机器组开启自动升级功能,可以在机器组列表中选择多个机器组,并单击批量 LogCollector 自动升级进行设置。
    图片

手动升级 LogCollector

手动升级 LogCollector 时,需要备份旧版本的断点文件目录及采集配置文件目录,并在卸载、重装 LogCollector 后拷贝回原目录。
手动升级步骤如下:

  1. 执行以下命令停止运行旧版本 LogCollector。

    systemctl stop filebeatd.service  
    
  2. 备份旧版本中的断点文件目录(/usr/local/filebeat-7.12.0/data)和采集配置文件目录(/usr/local/filebeat-7.12.0/etc)到其他目录,例如备份至 /tmp/LogCollector-backup 目录。

    mkdir -p /tmp/LogCollector-backup
    cp -r /usr/local/filebeat-7.12.0/data  /tmp/LogCollector-backup
    cp -r /usr/local/filebeat-7.12.0/etc  /tmp/LogCollector-backup
    
  3. 卸载旧版本 LogCollector。
    您可以选择如下一种方式进行卸载。

    cd /usr/local/filebeat-7.12.0/tools/ && ./filebeat.sh uninstall
    
    cd /usr/local/filebeat-7.12.0/tools/ && ./logcollector.sh uninstall
    
  4. 下载并安装最新版本的 LogCollector。

    1. 下载 LogCollector。
      此处以华北2(北京)私网下载地址为例,详细地址说明请参考1 下载 LogCollector

      wget https://logcollector-cn-beijing.tos-cn-beijing.ivolces.com/logcollector.sh -O logcollector.sh; chmod 755 logcollector.sh
      
    2. 安装 LogCollector。
      命令中的endpointsecret_idsecret_keyregion 参数配置请参考2 安装并启动 LogCollector

      说明

      安装后提示是否运行 LogCollector 时,请选择不运行。

      sudo ./logcollector.sh install --endpoint {endpoint} --secret_id {AccessKeyID} --secret_key {AccessKeySecret} --region {region}
      
  5. 复制步骤 2 中所备份的断点文件目录和采集配置文件目录到新版本 LogCollector 目录下。

    注意

    如果未备份并覆盖相关目录和配置,或者安装后直接启动 LogCollector,可能会造成日志采集异常,例如重复采集日志或 LogCollector 采集配置丢失。

    cp -r /tmp/LogCollector-backup/data  /usr/local/filebeat-7.12.0/
    cp -r /tmp/LogCollector-backup/etc /usr/local/filebeat-7.12.0/ 
    
  6. 启动 LogCollector。

    systemctl start filebeatd.service