Ubuntu 22.04环境下AWS CodeDeploy Agent安装失败求助
解决Ubuntu 22.04安装AWS CodeDeploy Agent失败的问题
问题分析
手动安装deb包时,预安装脚本尝试停止未加载的codedeploy-agent.service,导致安装中断;同时install --sanity-check提示版本匹配跳过安装,说明系统存在残留的版本记录或服务配置。
解决方案
方案一:修复服务配置后重新安装
清理残留的服务文件
# 检查并删除残留的服务文件 sudo rm -f /etc/systemd/system/codedeploy-agent.service # 重新加载systemd配置 sudo systemctl daemon-reload创建临时服务占位(让预安装脚本能正常执行停止操作)
sudo tee /etc/systemd/system/codedeploy-agent.service <<EOF [Unit] Description=AWS CodeDeploy Agent (Temporary) [Service] Type=forking ExecStart=/bin/true ExecStop=/bin/true [Install] WantedBy=multi-user.target EOF sudo systemctl daemon-reload sudo systemctl stop codedeploy-agent.service重新安装deb包
sudo dpkg -i codedeploy-agent_1.3.2-1902_all.deb启用并验证官方服务
sudo systemctl daemon-reload sudo systemctl start codedeploy-agent.service sudo systemctl enable codedeploy-agent.service # 检查服务状态 sudo systemctl status codedeploy-agent.service
方案二:使用官方安装脚本指定Ruby路径
如果rbenv安装的Ruby未加入系统全局PATH,可通过官方脚本指定Ruby路径安装:
清理残留安装文件
sudo dpkg -r codedeploy-agent 2>/dev/null sudo apt-get autoremove -y && sudo apt-get clean下载并执行官方安装脚本(替换为你的AWS区域对应的脚本地址)
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install chmod +x install # 指定rbenv的Ruby路径,替换为你的实际用户目录 sudo ./install --ruby /home/your-username/.rbenv/shims/ruby执行 sanity check 验证
sudo ./install --sanity-check deb
额外检查:确保Ruby版本正确
确认系统使用的是Ruby 2.6.0:
# 设置rbenv全局版本 rbenv global 2.6.0 # 刷新环境变量 source ~/.bashrc # 若使用zsh则替换为 source ~/.zshrc # 验证版本 ruby -v
内容的提问来源于stack exchange,提问作者Mahim Safa
相关产品推荐
相关产品推荐

