加载中

安装独立 Elastic Agents

要在独立模式下运行 Elastic Agent,请安装 Agent 并在安装它的系统上本地手动配置 Agent。您负责管理和升级 Agent。此方法仅建议高级用户使用。

如果可能,我们建议使用Fleet 托管的 Elastic Agents,因为这会大大简化 Agent 的管理和升级。

重要

独立 Agent 无法自动升级到新的集成包版本。当您在 Kibana 中升级集成时,您需要手动更新独立策略。

注意

每台主机只能安装一个 Elastic Agent。

Elastic Agent 可以监控部署它的主机,并且可以从无法直接部署的远程服务和硬件收集和转发数据。

安装和运行独立 Elastic Agent

  1. 在您的主机上,下载并提取安装包。

    curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz
    tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz
    
    curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz
    tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz
    
    # PowerShell 5.0+
    wget https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-windows-x86_64.zip -OutFile elastic-agent-9.0.0-windows-x86_64.zip
    Expand-Archive .\elastic-agent-9.0.0-windows-x86_64.zip
    

    或者手动

    1. 下载页面下载 Elastic Agent Windows zip 文件。

    2. 提取 zip 文件的内容。

    重要
    • 为了简化升级到未来版本的 Elastic Agent,我们建议您使用 tarball 分发版而不是 DEB 分发版。
    • 您可以在不需要 root 权限的 unprivileged 模式下安装 Elastic Agent。有关详细信息,请参阅以无管理权限运行 Elastic Agent
    curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb
    sudo dpkg -i elastic-agent-9.0.0-amd64.deb
    

    默认安装 Elastic Agent basic 版本。要安装 servers 版本,请添加 ELASTIC_AGENT_FLAVOR=servers 参数。有关不同版本的详细信息,请参阅Elastic Agent 安装版本

    您可以使用以下两种命令格式中的任何一种来设置 ELASTIC_AGENT_FLAVOR 环境变量

    curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb
    sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-amd64.deb
    
    curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb
    ELASTIC_AGENT_FLAVOR=servers sudo -E dpkg -i elastic-agent-9.0.0-amd64.deb
    
    注意

    如果您需要在 Debian Linux 上卸载 Elastic Agent 软件包,请注意,用于删除软件包的 dpkg -r 命令会保留 flavor 文件。相反,必须使用 dpkg -P 来清除所有软件包内容并重置 flavor。

    重要
    • 为了简化升级到未来版本的 Elastic Agent,我们建议您使用 tarball 分发版而不是 RPM 分发版。
    • 您可以在不需要 root 权限的 unprivileged 模式下安装 Elastic Agent。有关详细信息,请参阅以无管理权限运行 Elastic Agent
    curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm
    sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm
    

    默认安装 Elastic Agent basic 版本。要安装 servers 版本,请添加 ELASTIC_AGENT_FLAVOR=servers 参数。有关不同版本的详细信息,请参阅Elastic Agent 安装版本

    您可以使用以下两种命令格式中的任何一种来设置 ELASTIC_AGENT_FLAVOR 环境变量

    curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb
    sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-x86_64.rpm
    
    curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb
    ELASTIC_AGENT_FLAVOR=servers sudo -E rpm -vi elastic-agent-9.0.0-x86_64.rpm
    

    显示的命令适用于 AMD 平台,但也提供 ARM 软件包。有关可用软件包的完整列表,请参阅 Elastic Agent 下载页面

  2. 根据需要修改 elastic-agent.yml 中的设置。

    为了快速入门并避免错误,请使用 Kibana 创建和下载独立配置文件,而不是尝试手动构建。有关更多信息,请参阅创建独立 Elastic Agent 策略

    有关更多配置选项,请参阅配置独立 Elastic Agents

  3. elastic-agent.yml 策略文件中,在 outputs 下,指定 Elastic Agent 访问 Elasticsearch 的 API 密钥或用户凭据。例如

    [...]
    outputs:
      default:
        type: elasticsearch
        hosts:
          - 'https://da4e3a6298c14a6683e6064ebfve9ace.us-central1.gcp.cloud.es.io:443'
        api_key: _Nj4oH0aWZVGqM7MGop8:349p_U1ERHyIc4Nm8_AYkw
    [...]
    
    1. 有关所需的权限和创建 API 密钥的更多信息,请参阅授予独立 Elastic Agents 访问 Elasticsearch 的权限
  4. 确保您需要的资产(例如仪表板和摄入管道)已在 Kibana 和 Elasticsearch 中设置。如果您使用 Kibana 生成独立配置,资产将自动设置。否则,您需要手动安装它们。有关更多信息,请参阅查看集成资产安装集成资产

  5. 从 Agent 目录运行以下命令以安装 Elastic Agent 并将其作为服务启动。

    注意

    在 macOS、Linux (tar 包) 和 Windows 上,运行 install 命令将 Elastic Agent 安装为托管服务并启动该服务。DEB 和 RPM 包包含适用于使用 systemd 的 Linux 系统的服务单元,因此只需启用然后启动服务即可。

    提示

    您必须以 root 用户身份运行此命令,因为某些集成需要 root 权限才能收集敏感数据。

    sudo ./elastic-agent install
    

    默认安装 Elastic Agent basic 版本。要安装 servers 版本,请添加 --install-servers 参数。有关详细信息,请参阅Elastic Agent 安装版本

    提示

    您必须以 root 用户身份运行此命令,因为某些集成需要 root 权限才能收集敏感数据。

    sudo ./elastic-agent install
    

    默认安装 Elastic Agent basic 版本。要安装 servers 版本,请添加 --install-servers 参数。有关详细信息,请参阅Elastic Agent 安装版本

    以管理员身份打开 PowerShell 提示符(右键单击 PowerShell 图标并选择以管理员身份运行)。

    在 PowerShell 提示符下,切换到安装 Elastic Agent 的目录,然后运行

    .\elastic-agent.exe install
    

    默认安装 Elastic Agent basic 版本。要安装 servers 版本,请添加 --install-servers 参数。有关详细信息,请参阅Elastic Agent 安装版本

    sudo systemctl enable elastic-agent
    sudo systemctl start elastic-agent
    
    1. DEB 包包含适用于使用 systemd 的 Linux 系统的服务单元。在这些系统上,您可以使用常用的 systemd 命令来管理 Elastic Agent。如果您没有 systemd,请运行 sudo service elastic-agent start
    sudo systemctl enable elastic-agent
    sudo systemctl start elastic-agent
    
    1. RPM 包包含适用于使用 systemd 的 Linux 系统的服务单元。在这些系统上,您可以使用常用的 systemd 命令来管理 Elastic Agent。如果您没有 systemd,请运行 sudo service elastic-agent start

有关已安装 Elastic Agent 文件的位置,请参阅安装布局

由于 Elastic Agent 安装为自动启动服务,因此系统重启后它将自动重启。

如果遇到问题,请参阅排查常见问题

© . All rights reserved.