zakihayaメモ

RubyとRailsのことが中心

AWS VPC内にRDSでDBを作成する

AWS VPCでセグメントを分けてサーバを管理する - zakihayaメモ
AWS VPC内にアプリケーションサーバを作成する - zakihayaメモ
の続きです。

DBを作成して、アプリケーションサーバから接続できることを確認します。

RDSからVPCを利用するための設定

1) AWSにログイン → RDSを選択

f:id:zakihaya:20140503184121p:plain

2) Subnet Groupsを選択 → Create DB Subnet Groupをクリック

f:id:zakihaya:20140503185606p:plain

3) Subnet Group名を入力し、private subnetを選択 → Addをクリックし、Yes, Createをクリック

f:id:zakihaya:20140503185958p:plain

RDSインスタンスの作成

1) AWSにログイン → RDSを選択

f:id:zakihaya:20140503184121p:plain

2) Launch a DB Instanceをクリック

f:id:zakihaya:20140503184218p:plain

3) MySQLを選択

f:id:zakihaya:20140503184320p:plain

4) Noを選択してNext Stepをクリック

f:id:zakihaya:20140503184450p:plain

Multi AZにする場合はここでYesを選択する

5) DBの情報、サイズ、ユーザー、パスワード等を入力する

f:id:zakihaya:20140503184837p:plain

6) VPC、DB Subnet Groupを選択してNext Stepを選択

f:id:zakihaya:20140504191313p:plain

7) バックアップの設定

f:id:zakihaya:20140504191409p:plain

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.