- 2つのAZに分けてサブネット4つを作成し、その2つをPublic、2つをPrivateとする
- RDSでMySQLをMultiAZで起動
- ELB配下に2台置きWebサーバはApacheを置く
- セキュリティグループは80番と22番のみ公開
- vpc
- CIDR 10.0.0.0/16
- subnet ( t2.* 建てられる、ap-northeast-1c, ap-northeast-1d を選択)
- pub_c: 10.0.1.0/24
- pub_d: 10.0.2.0/24
- pte_c: 10.0.3.0/24
- pte_d: 10.0.4.0/24
- pub subnet allow set global ip
- internet-gw
- create
- vpc に attach
- rouging
-
main
- add routing: 0.0.0.0 igw-XXXX
- associations: pub_c,pub_d
-
create private routing table
- associations: pte_c,pte_d
-
- web
- 0.0.0.0/0 80
- 0.0.0.0/0 22
- rds
- web 3306
- DB サブネットグループの作成
- Privateのセグメントを選択
- インスタンス作成
- MySQL(本番稼動用 - MySQL)
- MultiAZ
- subnet: pte
- t2.smallぐらいで
- db config
- 識別子: dev
- user: masteruser
- pass:
mkpasswd -l 24
- db名:dev
-
[client]ssh-keygen
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa
-
add key pair
-
create instance x2(AZ それぞれで2回実行)
-
Amazon Linux 2
-
t2.small
-
userdata
- 以下のスクリプト
-
sg
web: 80,22
#!/bin/bash -x yum install -y git cd ~root git clone https://gist.github.com/0f4c5fcdc4569e52efce559be17f5037.git bootstrap chmod 700 bootstrap/bootstrap.sh bootstrap/bootstrap.sh cat << EOT >> /etc/php-fpm.d/www.conf env[DB_HOST] = RDSエンドポイント.ap-northeast-1.rds.amazonaws.com env[DB_USER] = masteruser env[DB_PASS] = パスワード env[DB_NAME] = dev EOT systemctl restart php-fpm
-
- listen port 80:80
- az: pte_c,pte_d
- sg: web
- pingパス:/
mysql -hRDSエンドポイント.ap-northeast-1.rds.amazonaws.com -umasteruser -p dev
CREATE TABLE dev(name varchar(20));
INSERT INTO dev(`name`) VALUES ("tanaka");