How to use Amazon RDS & S3 with AMIMOTO AMI WordPress

How to use Amazon RDS & S3 with AMIMOTO AMI WordPress

How to use Amazon RDS & S3 with AMIMOTO AMI WordPress

Bdaf0b291f02fe64a02cdf592a8a0c8f?s=128

AMIMOTO

April 02, 2016
Tweet

Transcript

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

  2. WHAT IS AMAZON RDS

  3. Scalable 6 database engines Relational Database Easy to set up

    and operate
  4. 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
  5. 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
  6. MOVING YOUR
 DATABASE TO RDS

  7. Architecture without RDS

  8. Architecture with RDS

  9. Login to your AWS Console

  10. Creating a MySQL server in Amazon RDS

  11. Database Engine

  12. Database Engine

  13. Specify database details

  14. Advanced Settings

  15. Creating DB

  16. DB created

  17. Login to your instance

  18. 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 

  19. {endpoint} can be found in the RDS information of AWS

    Management Console
 {mymasteruser} and password are specified when you want to create RDS
  20. 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} 

  21. 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
  22. 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', ); }
  23. 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.
  24. 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
  25. 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]" ]
 }
  26. 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]" ] }
  27. Stoping MySQL in the AMIMOTO AMI Finally run the following

    command:
 
 $ sudo /opt/local/proviosion 
 $ mysql stop service
  28. WHAT IS AMAZON S3

  29. AMAZON S3 • Scalable, high-speed, low-cost • Designed for online

    back and archiving
 of data • Static website hosting • Uploading, storage and downloading 
 of practically any file or object up to 5 GB • No limit on the number of items that 
 a subscriber can store • Data is stored on redundant servers 
 in multiple data centers
  30. Select S3 from the AWS Console

  31. Create a Bucket

  32. Create a Bucket

  33. Bucket summary

  34. Enable website hosting

  35. Go to Security Credentials

  36. Create New Access Key

  37. Copy/Download the Access Key details

  38. Enable the Nephila clavata plugin

  39. Configure the plugin

  40. WordPress Media Library on Amazon S3

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

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

    S3