本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
安装适用于亚马逊 Linux 或 RHEL 的 CodeDeploy 代理
登录到实例,并依次运行以下命令。首先运行命令 sudo yum update 被认为是使用 yum 安装软件包的最佳做法,但如果您不想更新所有软件包,也可以跳过它。
sudo yum update
对于 2.0.x 及更高版本:
sudo yum install wget
对于 1.8.x 及更早版本:
sudo yum install ruby wget
(可选)要清理 AMI 中以前的代理缓存信息,请运行以下脚本:
#!/bin/bash CODEDEPLOY_BIN="/opt/codedeploy-agent/bin/codedeploy-agent" $CODEDEPLOY_BIN stop yum erase codedeploy-agent -y
转到您的主目录:
cd /home/ec2-user
注意
在前面的命令中,/home/ec2-user 表示 Amazon Linux 或 RHEL Amazon EC2 实例的默认用户名。如果您的实例是使用某个自定义 AMI 创建的,该 AMI 所有者可能已指定不同的默认用户名。
下载 CodeDeploy 代理安装程序。前latestv2/缀为 2.0.x 版本的安装程序提供服务,latest/前缀为 1.8.x 版本的安装程序提供服务。
对于中国(北京)区域:
-
对于 2.0.x 及更高版本:
wget https://aws-codedeploy-cn-north-1.s3.cn-north-1.amazonaws.com/latestv2/install对于 1.8.x 及更早版本:
wget https://aws-codedeploy-cn-north-1.s3.cn-north-1.amazonaws.com/latest/install
对于中国(宁夏)区域:
-
对于 2.0.x 及更高版本:
wget https://aws-codedeploy-cn-northwest-1.s3.cn-northwest-1.amazonaws.com/latestv2/install对于 1.8.x 及更早版本:
wget https://aws-codedeploy-cn-northwest-1.s3.cn-northwest-1.amazonaws.com/latest/install
有关存储桶名称和区域标识符的列表,请参阅各区域的资源工具包存储桶名称。
为 install 文件设置执行权限:
chmod +x ./install
要安装最新版本的 CodeDeploy 代理,请执行以下操作:
-
sudo ./install auto
要安装特定版本的 CodeDeploy 代理,请执行以下操作:
-
列出您所在地区的可用版本:
aws s3 ls s3://aws-codedeploy-region-identifier/releases/ --regionregion-identifier| grep '\.rpm$' -
安装以下版本之一:
对于 2.0.x 及更高版本,软件包是特定于架构的:
sudo ./install auto -v releases/codedeploy-agent-version.arch.rpm在
arch哪里,x86_64或者aarch64取决于您的实例架构。对于 1.8.x 及更早版本,软件包使用:
noarchsudo ./install auto -v releases/codedeploy-agent-version.noarch.rpm有关最新发布的版本,请参阅CodeDeploy 代理的版本历史记录。
要检查服务是否正在运行,请运行以下命令:
systemctl status codedeploy-agent
对于 2.0.x 及更高版本,如果代理正在运行,您应该会看到一条消息,例如 The AWS CodeDeploy agent is running.
对于 1.8.x 及更早版本,如果代理正在运行,您应该会看到类似这样的消息 The AWS CodeDeploy agent is running.
如果代理未运行,请启动服务并检查状态:
systemctl start codedeploy-agent
systemctl status codedeploy-agent