네트워크 만들기
이름: tokyo-vpc
서브넷: 커스텀
이름: tokyo-subnet01
리전: asia-northeast1
IPv4 범위: 10.127.0.0/22
완료
이름: tokyo-subnet02
리전: asia-northeast1
IPv4 범위: 10.127.4.0/22
완료
방화벽 규칙 전부 체크
만들기
결과
인스턴스 만들기
이름: gcp-tokyo-web01
리전: asia-northeast1 (도쿄)
영역: asia-northeast1-a
머신 유형: e2-micro
부팅 디스크 -> 변경
공개 이미지
운영체제: CentOS
버전: CentOS 7
크기: 20GB
선택
네트워크 인터페이스
네트워크 인터페이스 수정
네트워크: tokyo-vpc
서브 네트워크: tokyo-subnet01
외부 IPv4 주소: 없음
완료
시작 스크립트
#!/bin/bash
yum install -y httpd
systemctl enable --now httpd
echo "<h1>tokyo-web01</h1>" > /var/www/html/index.html
이름: gcp-tokyo-web02
리전: asia-northeast1 (도쿄)
영역: asia-northeast1-c
머신 유형: e2-micro
부팅 디스크 -> 변경
공개 이미지
운영체제: CentOS
버전: CentOS 7
크기: 20GB
선택
네트워크 인터페이스
네트워크 인터페이스 수정
네트워크: tokyo-vpc
서브 네트워크: tokyo-subnet02
외부 IPv4 주소: 없음
완료
시작 스크립트
#!/bin/bash
yum install -y httpd
systemctl enable --now httpd
echo "<h1>tokyo-web02</h1>" > /var/www/html/index.html
이름: gcp-vp
리전: asia-northeast1
예약
할당 받은 IP: 35.187.203.206
이름: aws-gcp-cgw
IP 주소: gcp-vp ip
(35.187.203.206)
기존에 OpenStack VPN 연결에 사용했던 프라이빗 게이트웨이 사용(center04-vgw)
공급업체: Generic
다운로드
vpn-04e4b1510414f79e3.txt
IKE version:
IKEv2
IPSec Tunnel #1
Pre-Shared Key:
AwrRicXOs8YiHKtKYr7oBtUT2BkfRxcS
Outside IP Addresses-Virtual Private Gateway:43.200.210.83
IPSec Tunnel #2
Pre-Shared Key:
pJLBhDTHrj959Oge7UAuE4tnQzK5bJ88
Outside IP Addresses-Virtual Private Gateway:52.78.67.73
이름: gcp-aws-vgw
네트워크: tokyo-vpc
리전: asia-northeast1(도쿄)
IP 주소: gcp-vp ip
(35.187.203.206)
이름: vpn-1-tunnel-1
원격 피어 IP 주소: 43.200.210.83
IKE 버전: IKEv2
IKE 사전 공유 키: AwrRicXOs8YiHKtKYr7oBtUT2BkfRxcS
라우팅 옵션: 라우팅 기반
원격 네트워크 IP 범위: AWS VPC 범위
(10.35.0.0/16)
완료
이름: vpn-1-tunnel-2
원격 피어 IP 주소: 52.78.67.73
IKE 버전: IKEv2
IKE 사전 공유 키: pJLBhDTHrj959Oge7UAuE4tnQzK5bJ88
라우팅 옵션: 라우팅 기반
원격 네트워크 IP 범위: AWS VPC 범위
(10.35.0.0/16)
완료
생성 결과
destination: 10.127.0.0/22
target: vpn gatway
destination: 10.127.0.0/22
target: vpn gatway
라우팅 추가
gcp-vpc 가용영역 ICMP 규칙 허용
sudo su
yum install –y wget unzip
wget https://s3.amazonaws.com/amazoncloudwatch-agent/centos/amd64/latest/amazon-cloudwatch-agent.rpm
sudo rpm -U ./amazon-cloudwatch-agent.rpm
mkdir ~/.aws
vi ~/.aws/credentials
[AmazonCloudWatchAgent]
aws_access_key_id = [Access_Key]
aws_secret_access_key = [Secret_Access_Key]
region = ap-northeast-2
vi /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml
[credentials]
shared_credential_profile = "AmazonCloudWatchAgent"
shared_credential_file = "/root/.aws/credentials"
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
#설정 시작
#linux -> On-Premises -> 쭉 디폴트로 진행
#-> Log file path 에 '/home/centos/logs/**.log' 입력
#더이상 추가할 파일 없고 SSM 파라미터 스토어에 저장하지 않는다로 마무리
#생성한 설정 파일 확인하려면
vi /opt/aws/amazon-cloudwatch-agent/bin/config.json
mkdir -p /usr/share/collectd/ && touch /usr/share/collectd/types.db
systemctl enable —now amazon-cloudwatch-agent
#실행 명령어
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m onPremise -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json
※ 처음은 system상 amazon-cloudwatch-agent.service가 실행되고 있지 않기 때문에 'stopped' 상태가 됐을시에 한번 더 실행시켜준다.
#중지 명령어
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
#CloudWatchAgent 로그 경로
/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log
경보 이름: gcp-web01-cpu-util-alarm
다음
경보 생성