安裝 Ubuntu 伺服器的 CodeDeploy 代理程式 - AWS CodeDeploy

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

安裝 Ubuntu 伺服器的 CodeDeploy 代理程式

注意

建議您使用安裝 CodeDeploy 代理程式,以 AWS Systems Manager 便能夠設定代理程式的預約更新。如需詳細資訊,請參閱 使用安裝 CodeDeploy 代理程式 AWS Systems Manager

若要在 Ubuntu 伺服器上安裝 CodeDeploy 代理程式
  1. 登入執行個體。

  2. 一個接一個地輸入以下命令:

    sudo apt update
    sudo apt install ruby-full
    sudo apt install wget
  3. 輸入以下命令:

    cd /home/ubuntu

    /家庭/ubuntu 代表一個 Ubuntu 服務器實例的默認用戶名。如果您的執行個體是使用自訂的 AMI 建立的,AMI 擁有者可能已指定不同的預設使用者名稱。

  4. 輸入以下命令:

    wget https://bucket-name.s3.region-identifier.amazonaws.com/latest/install

    值區名稱是 Amazon S3 儲存貯體的名稱,該儲存貯體包含您區域的 CodeDeploy 資源套件檔案,而區域識別碼是您區域的識別碼

    例如:

    https://aws-codedeploy-us-east-2.s3.us-east-2.amazonaws.com/latest/install

    如需值區名稱和地區識別碼的清單,請參閱依區域的資源套件時段名稱

  5. 輸入以下命令:

    chmod +x ./install
  6. 執行以下任意一項:

    • 若要在任何受支援的 Ubuntu 伺服器版本 (20.04 除外) 上安裝最新版本的 CodeDeploy 代理程式:

      sudo ./install auto
    • 若要在 Ubuntu 伺服器 20.04 上安裝最新版本的 CodeDeploy 代理程式:

      注意

      將輸出寫入臨時日誌文件是一種解決方法,當我們使用 Ubuntu Server 20.04 上的install腳本解決已知錯誤時,應該使用該解決方法。

      sudo ./install auto > /tmp/logfile
    • 若要在任何受支援的 Ubuntu 伺服器版本 (20.04 除外) 上安裝特定版本的 CodeDeploy 代理程式:

      • 列出您所在地區的可用版本:

        aws s3 ls s3://aws-codedeploy-region-identifier/releases/ --region region-identifier | grep '\.deb$'
      • 安裝下列其中一個版本:

        sudo ./install auto -v releases/codedeploy-agent-###.deb
        注意

        AWS 支援 CodeDeploy 代理程式的最新次要版本。目前最新的次要版本是 1.7.x。

    • 若要在 Ubuntu 伺服器 20.04 上安裝特定版本的 CodeDeploy 代理程式:

      • 列出您所在地區的可用版本:

        aws s3 ls s3://aws-codedeploy-region-identifier/releases/ --region region-identifier | grep '\.deb$'
      • 安裝下列其中一個版本:

        sudo ./install auto -v releases/codedeploy-agent-###.deb > /tmp/logfile
        注意

        將輸出寫入臨時日誌文件是一種解決方法,當我們使用 Ubuntu Server 20.04 上的install腳本解決已知錯誤時,應該使用該解決方法。

        注意

        AWS 支援 CodeDeploy 代理程式的最新次要版本。目前最新的次要版本是 1.7.x。

檢查服務是否正在執行
  1. 輸入以下命令:

    systemctl status codedeploy-agent

    如果已安裝並執行 CodeDeploy 代理程式,您應該會看到類似的訊息The AWS CodeDeploy agent is running

  2. 如果您看到類似 error: No AWS CodeDeploy agent running 的訊息,請啟動服務並執行以下兩個命令,一次一個:

    systemctl start codedeploy-agent
    systemctl status codedeploy-agent