Amazon Linux 2를 사용하여 Lightsail 인스턴스에 CodeDeploy를 설치할 수 없음
Amazon Linux (Amazon Linux 2도 사용하고 싶음) 만 사용할 수 있다는 점에 특별히 만족하지 않았기 때문에 두 OS 버전을 사용하고 동일한 스크립트를 추가하여 두 개의 인스턴스를 생성했습니다.
mkdir /etc/codedeploy-agent/
mkdir /etc/codedeploy-agent/conf
cat <<EOT >> /etc/codedeploy-agent/conf/codedeploy.onpremises.yml
---
aws_access_key_id: ACCESS
aws_secret_access_key: SECRET
iam_user_arn: arn:aws:iam::525221857828:user/GeneralUser
region: eu-west-2
EOT
wget https://aws-codedeploy-us-west-2.s3.us-west-2.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
내가 둘 사이에 언급 한 차이점은 Linux 2가있는 인스턴스에서는 폴더에 /etc/codedeploy-agent/conf/파일이 하나만 있다는 것입니다.
Linux에는 두 개의 파일이 있습니다.
이것을 알고 같은 이름으로 Linux 2 인스턴스에 새 파일을 만들었습니다.
touch codedeployagent.yml
, 권한이 다음에서 변경되었습니다.
-rw-r--r-- 1 root root 261 Oct 2 10:43 codedeployagent.yml
...에
-rwxr-xr-x 1 root root 261 Oct 2 10:43 codedeployagent.yml
, 동일한 콘텐츠를 추가했습니다.
:log_aws_wire: false
:log_dir: '/var/log/aws/codedeploy-agent/'
:pid_dir: '/opt/codedeploy-agent/state/.pid/'
:program_name: codedeploy-agent
:root_dir: '/opt/codedeploy-agent/deployment-root'
:verbose: false
:wait_between_runs: 1
:proxy_uri:
:max_revisions: 5
그런 다음 컴퓨터를 재부팅했습니다. 그래도 내가 실행할 때와 같이 문제가 해결되지 않았습니다.
sudo service codedeploy-agent status
여전히 얻을 것이다
/ bin / systemctl 상태로 리디렉션 중 codedeploy-agent.service 유닛 codedeploy-agent.service를 찾을 수 없습니다.
또한 모든 업데이트가 제자리에 있는지 확인하고 컴퓨터를 재부팅했지만 작동하지 않았습니다.
답변
CodeDeployGitHubDemo 를 배포하기위한 Amazon Linux 2 인스턴스 설정에 대한 세부 정보를 제공 할 수 있습니다 (과거 질문 기준 ).
1. CodeDeploy 에이전트
다음과 같이 사용했습니다 UserData(그렇지 않은 경우 영역을 조정해야 할 수 있음 us-east-1).
#!/bin/bash
yum update -y
yum install -y ruby wget
cd /home/ec2-user
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
chmod +x ./install
./install auto
하드 코딩 자격 증명이 필요하지 않았습니다. 다음은 Amazon Linux 2내가 사용한 인스턴스에서 완벽하게 작동합니다 .
2. 인스턴스 역할
인스턴스에는 CodeDeploy에 적합한 역할이 필요합니다. 여기에 나열된 정책과 함께 EC2 인스턴스 역할을 사용했습니다 .
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:Get*",
"s3:List*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
3. 배포 그룹
AutoScaling 그룹에는 다음과 같은 세 개의 테스트 인스턴스가 있습니다 myasg.
4. 배포
Load Balancer없이 S3에서 배포했습니다.
5. 결과
문제가 발견되지 않았고 성공적으로 배포되었습니다.
웹 사이트 실행 (보안 그룹에서 포트 80을 열어야 함) :
최신 정보
Amazon Linux 2에서 수동 설치의 sudo su -경우. 로그인 후 루트가 될 수 있습니다 .
mkdir -p /etc/codedeploy-agent/conf
cat <<EOT >> /etc/codedeploy-agent/conf/codedeploy.onpremises.yml
---
aws_access_key_id: ACCESS
aws_secret_access_key: SECRET
iam_user_arn: arn:aws:iam::525221857828:user/GeneralUser
region: eu-west-2
EOT
yum install -y wget ruby
wget https://aws-codedeploy-us-west-2.s3.us-west-2.amazonaws.com/latest/install
chmod +x ./install
env AWS_REGION=eu-west-2 ./install rpm
상태를 확인하려면 :
systemctl status codedeploy-agent
이것으로 다음과 같은 것을 얻어야합니다
● codedeploy-agent.service - AWS CodeDeploy Host Agent
Loaded: loaded (/usr/lib/systemd/system/codedeploy-agent.service; enabled; vendor prese
t: disabled)
Active: active (running) since Sat 2020-10-03 07:18:57 UTC; 3s ago
Process: 3609 ExecStart=/bin/bash -a -c [ -f /etc/profile ] && source /etc/profile; /opt
/codedeploy-agent/bin/codedeploy-agent start (code=exited, status=0/SUCCESS)
Main PID: 3623 (ruby)
CGroup: /system.slice/codedeploy-agent.service
├─3623 codedeploy-agent: master 3623
└─3627 codedeploy-agent: InstanceAgent::Plugins::CodeDeployPlugin::CommandPo...
Oct 03 07:18:57 ip-172-26-8-137.eu-west-2.compute.internal systemd[1]: Starting AWS Cod...
Oct 03 07:18:57 ip-172-26-8-137.eu-west-2.compute.internal systemd[1]: Started AWS Code...
Hint: Some lines were ellipsized, use -l to show in full.
실행하면
sudo service codedeploy-agent status
당신은 얻을 것입니다 (예상대로 작동한다는 의미)
The AWS CodeDeploy agent is running as PID 3623
실행 중이 아닌 경우 시작하려면 :
systemctl start codedeploy-agent