Slide 1

Slide 1 text

@Amimoto_Ami amimoto-ami.com AMIMOTO (HHVM) + AMAZON RDS

Slide 2

Slide 2 text

WHAT IS AMAZON RDS

Slide 3

Slide 3 text

Scalable 6 database engines Relational Database Easy to set up and operate

Slide 4

Slide 4 text

ADVANTAGES • Scale your CPU, IOPS, and storage space
 • Snapshot-based on demand 
 and automatic backups
 • Multi Availability Zones deployment
 • Secondery synchronous instance in 
 case the primary fails

Slide 5

Slide 5 text

DISADVANTAGES • No shell access to the DB instance
 • Restricted user privileges
 • Disabled replication in MySQL
 • Weekly 4-hour maintenance window
 • RDS Instance cannot be stopped

Slide 6

Slide 6 text

MOVING YOUR
 DATABASE TO RDS

Slide 7

Slide 7 text

Architecture without RDS

Slide 8

Slide 8 text

Architecture with RDS

Slide 9

Slide 9 text

Login to your AWS Console

Slide 10

Slide 10 text

Creating a MySQL server in Amazon RDS

Slide 11

Slide 11 text

Database Engine

Slide 12

Slide 12 text

Database Engine

Slide 13

Slide 13 text

Specify database details

Slide 14

Slide 14 text

Advanced Settings

Slide 15

Slide 15 text

Creating DB

Slide 16

Slide 16 text

DB created

Slide 17

Slide 17 text

Login to your instance

Slide 18

Slide 18 text

Connecting your EC2 to RDS 1. Log into the root of your server using SSH:
 
 $ ssh -i /Users/macpil/Desktop/example.pem ec2-user@instance_ip or domain
 2. Run the following command:
 
 $ mysql -h {endpoint} -P 3306 -u {mymasteruser} -p 


Slide 19

Slide 19 text

{endpoint} can be found in the RDS information of AWS Management Console
 {mymasteruser} and password are specified when you want to create RDS

Slide 20

Slide 20 text

Data migration Export data via wp-cli:
 
 $ wp --path=/path/to/wordpress db export
 
 
 /path/to/wordpress is the directory where WordPress is installed
 In AMIMOTO AMI it’s usually /var/www/vhosts/{instance_id} 


Slide 21

Slide 21 text

Data migration Import data to RDS:
 
 $ mysql -h {endpoint} -P 3306 -u {mymasteruser} -p {databasename} < dump.sql
 
 {endpoint} can be found in the RDS information of AWS Management Console
 {mymasteruser} and {databasename} are specified when you want to create RDS

Slide 22

Slide 22 text

Rewriting wp-config.php // ** MySQL settings - You can get this info from your web host ** // $db_data = false; if ( file_exists('/opt/aws/cloud_formation.json') ) { $db_data = json_decode(file_get_contents('/opt/aws/ cloud_formation.json'), true); if ( isset($db_data['rds']) ) { $db_data = $db_data['rds']; $db_data['host'] = $db_data['endpoint'] . ':' . $db_data['port']; } } if ( !$db_data ) { $db_data = array( 'database' => 'RDS_DATABASE_NAME_HERE', 'username' => 'RDS_USER_NAME_HERE', 'password' => 'RDS_PASSWORD_HERE', 'host' => 'RDS_ENDPOINT_HERE', ); }

Slide 23

Slide 23 text

Rewriting wp-config.php RDS_DATABASE_NAME_HERE Database Name which was set in Configure Advanced Settings RDS_USER_NAME_HERE Master Username which was set in Specify DB Details RDS_PASSWORD_HERE Master Password which was set in Specify DB Details RDS_ENDPOINT_HERE RDS endpoint When you set as above in wp-config.php, let’s check if you can connect to WordPress.

Slide 24

Slide 24 text

Stoping MySQL in the AMIMOTO AMI Since MySQL was moved to RDS, MySQL process in AMIMOTO AMI is no longer necessary. Rewrite the configuration file, in AMIMOTO AMI, the middleware settings use chef-solo, where they are described in /opt/local/amimoto.json

Slide 25

Slide 25 text

Stoping MySQL in the AMIMOTO AMI Since MySQL was moved to RDS, MySQL process in AMIMOTO AMI is no longer necessary. Rewrite the configuration file, in AMIMOTO AMI, the middleware settings use chef-solo, where they are described in /opt/local/amimoto.json 
 To stop starting MySQL, please rewrite the file:
 
 {
 "nginx" : { "config" : { "user" : "nginx", "group" : "nginx" } },
 "php" : { "config" : { "user" : "nginx", "group" : "nginx" } },
 "mysql" : { "enabled" : false },
 "phpfpm" : { "enabled" : true },
 "run_list" : [ "recipe[amimoto]" ]
 }

Slide 26

Slide 26 text

Stoping MySQL in the AMIMOTO AMI For AMIMOTO AMI HHVM version, rewrite as follows: { "nginx" : { "config" : { "user" : "nginx", "group" : "nginx" } }, "php" : { "config" : { "user" : "nginx", "group" : "nginx" } }, "mysql" : { "enabled" : false }, "hhvm" : { "enabled" : true }, "run_list" : [ "recipe[amimoto]" ] }

Slide 27

Slide 27 text

Stoping MySQL in the AMIMOTO AMI Finally run the following command:
 
 $ sudo /opt/local/proviosion 
 $ mysql stop service

Slide 28

Slide 28 text

http://amimoto-ami.com/slack/ Questions:

Slide 29

Slide 29 text

@Amimoto_Ami amimoto-ami.com THANK YOU! AMIMOTO (HHVM) + AMAZON RDS