AWS VPC内にRDSでDBを作成する
AWS VPCでセグメントを分けてサーバを管理する - zakihayaメモ
AWS VPC内にアプリケーションサーバを作成する - zakihayaメモ
の続きです。
DBを作成して、アプリケーションサーバから接続できることを確認します。
RDSからVPCを利用するための設定
1) AWSにログイン → RDSを選択
2) Subnet Groupsを選択 → Create DB Subnet Groupをクリック
3) Subnet Group名を入力し、private subnetを選択 → Addをクリックし、Yes, Createをクリック
RDSインスタンスの作成
1) AWSにログイン → RDSを選択
2) Launch a DB Instanceをクリック
3) MySQLを選択
4) Noを選択してNext Stepをクリック
Multi AZにする場合はここでYesを選択する
5) DBの情報、サイズ、ユーザー、パスワード等を入力する
6) VPC、DB Subnet Groupを選択してNext Stepを選択
7) バックアップの設定
8) 最後の確認ページでLaunch DB Instanceをクリック
接続確認
アプリケーションサーバから下のコマンドを実行
$ mysql -h testdb.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com -u awsuser -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 5.6.13 MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.