2022年7月27日水曜日

AWS ロードバランサ EC2

 1) VPC 作成

・Name: test
・CLDR: 192.168.0.0/16
・IPv6ブロック無し

2) サブネット作成
サブネット名 アベイラビリティーゾーン IPv4 CIDR Block
subnet-public-1a ap-northeast-1a 192.168.10.0/24
subnet-public-1c ap-northeast-1c 192.168.20.0/24
subnet-public-1d ap-northeast-1d 192.168.30.0/24
subnet-private-api-1a ap-northeast-1a 192.168.11.0/24
subnet-private-api-1c ap-northeast-1c 192.168.21.0/24
subnet-private-api-1d ap-northeast-1d 192.168.31.0/24
subnet-private-web-1a ap-northeast-1a 192.168.12.0/24
subnet-private-web-1c ap-northeast-1c 192.168.22.0/24
subnet-private-web-1d ap-northeast-1d 192.168.32.0/24
subnet-private-nat-1a ap-northeast-1a 192.168.13.0/24
subnet-private-nat-1c ap-northeast-1c 192.168.23.0/24
subnet-private-nat-1d ap-northeast-1d 192.168.33.0/24
subnet-private-db-1a ap-northeast-1a 192.168.200.0/24
subnet-private-storage-1c ap-northeast-1c 192.168.210.0/24

3) インターネットゲートウェイの作成&VPCへのアタッチ
Name: test-igw
Action→VPCにアタッチ

4) ルートテーブル設定
Test-public-rtb (ルートテーブル作成)
subnet-public-1a/1c/1dを関連付け
ルート編集(0.0.0.0 igw-xxxxx )

5) パブリック内に踏み台インスタンス作成
AMI 選択 (amazon Linux)
ネットワーク: test (PVC選択)
サブネット: subnet-pubic-1a 選択
自動割り当てパブリックIP: 有効
Instance に名前を付ける
ネットワークインターフェース→プライマリIPに固定IPを設定

6) セキュリティグループの設定
Name : test-public-ec2-sg
ssh マイIP 150.246.20.210
Http カスタム 0.0.0.0 (フルオープン) ※ LB下のprivate時は、public のCLDRを指定( 192.168.10.0/24)

7) NAT ゲートウェイ 
   NATゲートウェイをパブリックサブネットに作成
     vpc->ナットゲートウェイ
  test-pablic-1a-ngw
  NAT下に置きたいプライベートサブネットのルートテーブルにデフォルトGWを設定

8) ssh鍵ペアの作成
test-key.pem download
$ cp test-key.pem ~/.ssh/
$ chmod 600 ~/.ssh/test-key.pem
$ scp -i test-key.pem ~/.ssh/test-key.pem  ec2-user@xx.xx.xx.xx:~/.ssh/
$ ssh ec2-user@xx.xx.xx.xx -i test-key.pem
$ chmod 600 ~/.ssh/test-key.pem

9) インスタンスからAMIを作る
Image-name: linux-base
EC2 auto scaling

10) セキュリティグループ作成
Scurity group name: test-oracle19c-1a
vpc
InBound Oracle-RDS  カスタム 192.168.0.0/24 Oracle-RDS
InBound ssh                   カスタム 192.168.10.0/24   from Step Server
InBound 10050             カスタム  192.168.23.0/24 from Zabbix Server
OutBoud  すべて          カスタム  192.168.0.0/16    to This VPC
Tag              Name           test-oracle19c-1a


11) EC2起動(oracleサーバ)
Name: test-oracle19c
OS image:Amazon Linux 2  64ビット
Instance type: t3.small
Key Pair:test-step-key
vpc:test-vpc
subnet:test-subnet-private-db-1a
Pabulic IP 自動割当: 無効
Security-group: test-oracle19c-1a
高度なネトワーク-プライマリIP:192.168.200.201
ストレージ設定:100G
EFS:test-common /u01

その他環境設定
vi /etc/yum.conf   proxy=http://192.168.13.101:3128
rpm -Uvh https://repo.zabbix.com/zabbix/6.2/rhel/7/x86_64/zabbix-agent2-6.2.6-release1.el7.x86_64.rpm  [ --httpproxy http://192.168.13.101:3128 ]
[ yum install zabbix-agent2.x86_64 ]

11-1) EC2起動テンプレートの作成
Template name: linux-base
Machine-image: linux-base?
Instance type : t2.micro
Key pair: hoge
Network : Virtual Private Cloud(VPC)
Security group: test-ec2-sg

12) autoScaling
Auto Scaling group Name : test-asg
起動テンプレート: linux-base
Vpc: test vpc選択
Subnet:subnet-private-api-1a subnet-private-api-1c subnet-private-api-1d

13) ロードバランサの設定
ALB選択
test-public-alb
Internet-facing
VPC: test
Subnet:
Listener: 80/443
AZ 選択 ( AZを跨って作成 1a/1c)
SG設定(NEW SG: test-alb-sg 80/443 0.0.0.0)
Target grop: test-alb-tg ( 新しいターゲットグループ作成 test-alb-tg/instance/http(80)/http1/helthcheck: /test/health )
ルールの設定で転送先を変更。DNS名で分離?
ルーティング設定

14) グループサイズとスケーリングポリシー設定
希望する容量:2
希望する最小キャパ:2
希望する最大キャパ:2

スケーリングポリシー:無し


【参考】 

https://dev.classmethod.jp/articles/introduction-to-aws-networking-and-autoscaling-web-server/

0 件のコメント:

コメントを投稿

シャットダウン時の後処理 (shutdown)

# vi /etc/systemd/system/drop.service [Unit] Description= stop httpgwd DefaultDependencies=no Before=shutdown.target RefuseManualStart=true ...