使用命令行下载和配置 CloudWatch 代理
您可以使用以下步骤来下载 CloudWatch 代理软件包,创建 IAM 角色或用户,以及(可选)修改常见配置文件。
下载 CloudWatch 代理软件包
注意
要下载 CloudWatch 代理,您的连接必须使用 TLS 1.2 或更高版本。
CloudWatch 代理在 Amazon Linux 2023 和 Amazon Linux 2 中,可作为软件包使用。如果您使用此操作系统,则可以通过输入以下命令来安装该软件包。您还必须确保附加到实例的 IAM 角色附加了 CloudWatchAgentServerPolicy。有关更多信息,请参阅 创建 IAM 角色和用户以用于 CloudWatch 代理。
sudo yum install amazon-cloudwatch-agent
在所有支持的操作系统中,您可以使用命令行下载并安装 CloudWatch 代理。
对于每个下载链接,有一个常规链接以及每个区域的链接。例如,对于 Amazon Linux 2023 和 Amazon Linux 2 以及 x86-64 架构,三个有效的下载链接如下:
-
https://amazoncloudwatch-agent.s3.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
-
https://amazoncloudwatch-agent-us-east-1.s3.us-east-1.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
-
https://amazoncloudwatch-agent-eu-central-1.s3.eu-central-1.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
您也可以下载有关代理的最新更改的 README 文件,以及指示可供下载的版本号的文件。这些文件位于以下位置:
-
https://amazoncloudwatch-agent.s3.amazonaws.com/info/latest/RELEASE_NOTES
或https://amazoncloudwatch-agent-
region
.s3.region
.amazonaws.com/info/latest/RELEASE_NOTES -
https://amazoncloudwatch-agent.s3.amazonaws.com/info/latest/CWAGENT_VERSION
或https://amazoncloudwatch-agent-
region
.s3.region
.amazonaws.com/info/latest/CWAGENT_VERSION
架构 | 平台 | 下载链接 | 签名文件链接 |
---|---|---|---|
x86-64 |
Amazon Linux 2023 和 Amazon Linux 2 |
https://amazoncloudwatch-agent.s3.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm.sig https://amazoncloudwatch-agent- |
x86-64 |
Centos |
https://amazoncloudwatch-agent.s3.amazonaws.com/centos/amd64/latest/amazon-cloudwatch-agent.rpm https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/centos/amd64/latest/amazon-cloudwatch-agent.rpm.sig https://amazoncloudwatch-agent- |
x86-64 |
Redhat |
https://amazoncloudwatch-agent.s3.amazonaws.com/redhat/amd64/latest/amazon-cloudwatch-agent.rpm https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/redhat/amd64/latest/amazon-cloudwatch-agent.rpm.sig https://amazoncloudwatch-agent- |
x86-64 |
SUSE |
https://amazoncloudwatch-agent.s3.amazonaws.com/suse/amd64/latest/amazon-cloudwatch-agent.rpm https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/suse/amd64/latest/amazon-cloudwatch-agent.rpm.sig https://amazoncloudwatch-agent- |
x86-64 |
Debian |
https://amazoncloudwatch-agent.s3.amazonaws.com/debian/amd64/latest/amazon-cloudwatch-agent.deb https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/debian/amd64/latest/amazon-cloudwatch-agent.deb.sig https://amazoncloudwatch-agent- |
x86-64 |
Ubuntu |
https://amazoncloudwatch-agent.s3.amazonaws.com/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb.sig https://amazoncloudwatch-agent- |
x86-64 |
Oracle |
https://amazoncloudwatch-agent.s3.amazonaws.com/oracle_linux/amd64/latest/amazon-cloudwatch-agent.rpm https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/oracle_linux/amd64/latest/amazon-cloudwatch-agent.rpm.sig https://amazoncloudwatch-agent- |
x86-64 |
macOS |
https://amazoncloudwatch-agent.s3.amazonaws.com/darwin/amd64/latest/amazon-cloudwatch-agent.pkg https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/darwin/amd64/latest/amazon-cloudwatch-agent.pkg.sig https://amazoncloudwatch-agent- |
x86-64 |
Windows |
https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon-cloudwatch-agent.msi https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon-cloudwatch-agent.msi.sig https://amazoncloudwatch-agent- |
ARM64 |
Amazon Linux 2023 和 Amazon Linux 2 |
https://amazoncloudwatch-agent.s3.amazonaws.com/amazon_linux/arm64/latest/amazon-cloudwatch-agent.rpm https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/amazon_linux/arm64/latest/amazon-cloudwatch-agent.rpm.sig https://amazoncloudwatch-agent- |
ARM64 |
Redhat |
https://amazoncloudwatch-agent.s3.amazonaws.com/redhat/arm64/latest/amazon-cloudwatch-agent.rpm https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/redhat/arm64/latest/amazon-cloudwatch-agent.rpm.sig https://amazoncloudwatch-agent- |
ARM64 |
Ubuntu |
https://amazoncloudwatch-agent.s3.amazonaws.com/ubuntu/arm64/latest/amazon-cloudwatch-agent.deb https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/ubuntu/arm64/latest/amazon-cloudwatch-agent.deb.sig https://amazoncloudwatch-agent- |
ARM64 |
Debian |
https://amazoncloudwatch-agent.s3.amazonaws.com/debian/arm64/latest/amazon-cloudwatch-agent.deb https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/debian/arm64/latest/amazon-cloudwatch-agent.deb.sig https://amazoncloudwatch-agent- |
ARM64 |
SUSE |
https://amazoncloudwatch-agent.s3.amazonaws.com/suse/arm64/latest/amazon-cloudwatch-agent.rpm https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/suse/arm64/latest/amazon-cloudwatch-agent.rpm.sig https://amazoncloudwatch-agent- |
ARM64 |
MacOS |
https://amazoncloudwatch-agent.s3.amazonaws.com/darwin/arm64/latest/amazon-cloudwatch-agent.pkg https://amazoncloudwatch-agent- |
https://amazoncloudwatch-agent.s3.amazonaws.com/darwin/arm64/latest/amazon-cloudwatch-agent.pkg.sig https://amazoncloudwatch-agent- |
使用命令行下载和安装 CloudWatch 代理软件包
-
下载 CloudWatch 代理。
在 Linux 服务器上,输入以下命令。对于
download-link
,请使用上表中的相应下载链接。wget
download-link
在运行 Windows Server 的服务器上,下载以下文件:
https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon-cloudwatch-agent.msi
-
在下载该软件包后,您可以选择验证软件包签名。有关更多信息,请参阅 验证 CloudWatch 代理软件包的签名。
-
安装 软件包。如果已在 Linux 服务器上下载 RPM 程序包,请更改为包含程序包的目录,并输入以下内容:
sudo rpm -U ./amazon-cloudwatch-agent.rpm
如果已在 Linux 服务器上下载 DEB 程序包,请更改为包含程序包的目录,并输入以下内容:
sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
如果已运行在 Windows Server 的服务器上下载 MSI 程序包,请更改为包含程序包的目录,并输入以下内容:
msiexec /i amazon-cloudwatch-agent.msi
此命令还可在 PowerShell 中发挥作用。有关 MSI 命令选项的更多信息,请参阅 Microsoft Windows 文档中的命令行选项
。 如果已在 macOS 服务器上下载 PKG 程序包,请更改为包含程序包的目录,并输入以下内容:
sudo installer -pkg ./amazon-cloudwatch-agent.pkg -target /
创建和修改代理配置文件
在下载 CloudWatch 代理后,您必须先创建配置文件,然后再在任何服务器上启动该代理。有关更多信息,请参阅 创建 CloudWatch 代理配置文件。