brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Aug 08. 2020

441.Elastic Beanstalk,배포 ,cli

이론

<1> EC2 서버 접속

<2>  Elastic Beanstalk  cli 사용하기

<3> 어플리케이션 배포하기

<4>  EB 운영

<5>  어플리케이션 업데이트

<6> 어플리케이션 배포 업데이트 하기



<1> EC2 서버 접속


<2>  Elastic Beanstalk  cli 사용하기


1

git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git 


./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer --location /home/ec2-user 


echo 'export PATH="/home/ec2-user/.ebcli-virtual-env/executables:$PATH"' >> ~/.bash_profile && source ~/.bash_profile


3분걸림



2

mkdir  ~/eb-lab

cd ~/eb-lab


eb init


ㅊ8 php

2  php 7.4

ssh for your instances ?

n



<3> 어플리케이션 배포하기


1

소스 다운로드

cd /tmp

wget https://us-west-2-aws-training.s3.us-west-2.amazonaws.com/awsu-spl/spl-47/1.4.7.prod/scripts/ec2-info.zip


unzip ec2-info.zip


cp -r ec2-info/* ~/eb-lab/


cd ~/eb-lab/


eb create --vpc --service-role aws-elasticbeanstalk-service-role



2

환경설정하기

default <엔터>

cname

myeb199


application lbn

spot  n

vpcid : 확인 

public   y

ec2 subnet ?

subnet-053969e1a69d2da50,subnet-0cfa37bf820d5de63

lb public

Y

// 



3

eb status


4

sudo yum -y install lynx


eb open


// eb 사이트 복사하기 , 접속해보기  , 메타 데이터를 확인할수 있다.

myeb199.us-west-2.elasticbeanstalk.com


5

// 콘솔에서 확인하기 , us-west-2  오래곤으로 변경

서비스 > elastic beanstalk  >  

환경이름은 eb-lab-dev  

애플리케이션 이름은 eb-lab

URL 복사

http://myeb199.us-west-2.elasticbeanstalk.com/




<4>  EB 운영


1

pwd

/home/ec2-user/eb-lab

2

// 이벤트 확인 , ERROR 가 없는지 확인

eb events


3

환경 정보 확인하기

LC_TIME="en_US.UTF-8" eb health --refresh


4

// 로그 확인하기

eb logs


5

환경 확장하기

eb scale 2


eb status

// 상태 확인.  Health: Green


6

eb config

// contrrol +x  


7

//현재 설정 저장

eb config save --cfg eb-lab-config


// 저장 경로


[ec2-user@ip-10-1-11-245 eb-lab]$ cd .elasticbeanstalk/saved_configs/
[ec2-user@ip-10-1-11-245 saved_configs]$
[ec2-user@ip-10-1-11-245 saved_configs]$ pwd
/home/ec2-user/eb-lab/.elasticbeanstalk/saved_configs
[ec2-user@ip-10-1-11-245 saved_configs]$
[ec2-user@ip-10-1-11-245 saved_configs]$ ls
eb-lab-config.cfg.yml
[ec2-user@ip-10-1-11-245 saved_configs]$

8

// vm 으로 볼수 있도로 확인

export EDITOR=vim


9

// 설정 확인

eb config


아래 경로 확인 

변경전

Application Healthcheck URL:


변경후

Application Healthcheck URL: /index.phpwq



10

eb status


// 아래 상태인지 확인
Status: Ready
Health: Green


 

<5>  어플리케이션 업데이트


1

 cd /home/ec2-user/eb-lab

 vi index.php


2

변경 하기

<h2>Instance Metadata v1.0</h2> 를

<h2>Instance Metadata v1.1 with eb deployment</h2>


3

배포하기

eb deploy


4

eb status


5

eb open



<6> 어플리케이션  블루 그린 배포하기


1

cd ~/eb-lab

vi  index.php


2

<h2>Instance Metadata v1.1 with eb deployment</h2>

<h2>Instance Metadata v2.0 with eb swap</h2> 

로 변경하기



3

새 환경 설정 하기

eb create --vpc --service-role aws-elasticbeanstalk-service-role New-EB -c New-EB


public

y

subnet-053969e1a69d2da50,subnet-0cfa37bf820d5de63

elb 서브넷 <공란엔터>

public

y

보안그룹  <공란엔터>



4

eb status New-EB


5

eb open New-EB


완료 확인 

// 5분 소요


6

// 콘솔 화면 

서비스  > elastic beanstalk 에서 확인

//  66


7

eb swap New-EB --destination_name eb-lab-dev


8

확인

eb status New-EB


9

eb terminate eb-lab-dev --force

eb status eb-lab-dev



권한

https://docs.aws.amazon.com/ko_kr/elasticbeanstalk/latest/dg/AWSHowTo.iam.managed-policies.html


감사합니다.

매거진의 이전글 440 MediaTailor
작품 선택
키워드 선택 0 / 3 0
댓글여부
afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari