[日本語] 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 07, 2016
Tweet

Transcript

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

  2. AMAZON RDS ͱ͸

  3. εέʔϥϒϧ 6ͭͷσʔλϕʔεΤϯδϯ ϦϨʔγϣφϧσʔλϕʔε ༰қͳηοτΞοϓͱӡ༻

  4. ϝϦοτ • εέʔϧՄೳͳCPUɼIOPSɼ
 ετϨʔδεϖʔε • εφοϓγϣοτϕʔεͷόοΫΞοϓ
 ࣗಈԽ΋Մೳ
 • Ϛϧν AZσϓϩΠϝϯτ


    • ϑΣΠϧΦʔόʔ͸ಉظࡁηΧϯμϦ͔Β
  5. σϝϦοτ • DB Πϯελϯε΁γΣϧΞΫηεෆՄ
 • Ϣʔβಛݖʹ੍ݶ͕͋Δ
 • MySQL ͷϨϓϦέʔγϣϯ͕ແޮ
 •

    ຖि4࣌ؒͷϝϯςφϯε΢Οϯυ΢
 • RDS Πϯελϯε͸ࢭΊΔࣄ͕Ͱ͖ͳ͍
  6. σʔλϕʔεΛ RDS ΁Ҡߦ

  7. RDS ͷͳ͍ΞʔΩςΫνϟ

  8. RDS ͷ͋ΔΞʔΩςΫνϟ

  9. AWS ίϯιʔϧ ΁ϩάΠϯ

  10. MySQL Λ Amazon RDS ಺ʹ࡞੒

  11. σʔλϕʔεΤϯδϯͷબ୒

  12. σʔλϕʔεΤϯδϯͷબ୒

  13. σʔλϕʔεͷ֤छઃఆ

  14. σʔλϕʔεͷৄࡉઃఆ

  15. σʔλϕʔεͷ࡞੒

  16. ࡞੒͞Εͨσʔλϕʔε

  17. Πϯελϯε΁ϩάΠϯ

  18. EC2 Λ RDS ΁઀ଓ͠·͢ 1. SSH Λ࢖͍Πϯελϯε΁ϩάΠϯ͠·͢
 
 $ ssh

    -i /Users/macpil/Desktop/example.pem ec2-user@instance_ip or domain
 2. ࣍ͷίϚϯυΛ࣮ߦ͍ͯͩ͘͠͞
 
 $ mysql -h {endpoint} -P 3306 -u {mymasteruser} -p 

  19. {endpoint} ͸ AWS ίϯιʔϧͷ RDS ৘ใηΫγϣϯʹ͋Γ·͢
 {mymasteruser} ͱύεϫʔυ͸ RDS ࡞੒࣌ʹܾΊͨ΋ͷͰ͢

  20. σʔλͷҠߦ wp-cli ͰσʔλϕʔεͷσʔλΛΤΫεϙʔτ:
 
 $ wp --path=/path/to/wordpress db export
 


    
 /path/to/wordpress ͸ WordPress ͷΠϯετʔϧσΟϨΫτϦͰ͢ɻ
 AMIMOTO AMIͷσϑΥϧτ͸ /var/www/vhosts/{instance_id} Ͱ͢ɻ

  21. Data migration RDS ΁σʔλΛΠϯϙʔτ: 
 
 $ mysql -h {endpoint}

    -P 3306 -u {mymasteruser} -p {databasename} < dump.sql
 
 {endpoint} ͸ AWS Ϛωʔδϝϯτίϯιʔϧʹදࣔ͞Ε͍ͯ·͢ɻ
 {mymasteruser} ͱ {databasename} ͸ RDS ࡞੒࣌ʹܾΊͨ΋ͷΛೖྗ͍ͯͩ͘͠͞ɻ
  22. 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. wp-config.php ͷมߋ RDS_DATABASE_NAME_HERE: DB ͷৄࡉઃఆͰࢦఆͨ͠σʔλϕʔε໊ RDS_USER_NAME_HERE: DB ͷৄࡉઃఆͰࢦఆͯͨ͠ϚελʔϢʔβ໊ RDS_PASSWORD_HERE: DB

    ͷৄࡉઃఆͰࢦఆͯͨ͠Ϛελʔύεϫʔυ RDS_ENDPOINT_HERE: RDS ͷΤϯυϙΠϯτ ͜ΕΒͷઃఆΛ wp-config.php ΁ઃఆޙ WordPress ͕ಈ࡞͢Δ͔֬ೝ͍ͯͩ͘͠͞ɻ
  24. AMIMOTO AMI ͷ MySQL Λఀࢭ͢Δ MySQL Λ RDS ΁Ҡಈͤ͞Δͱ AMIMOTO

    AMI ಺ͷ MySQL ϓϩηε͕ෆཁʹͳΓ·͢ɻ ઃఆϑΝΠϧΛฤूͯ͠ MySQL ϓϩηεΛऴ͍ྃͤͯͩ͘͞͞ɻ AMIMOTO AMI Ͱ͸ϛυϧ΢ΣΞͷઃఆ͸ /opt/local/amimoto.json ʹ͋Δ 
 chef-solo Λ࢖͍ͬͯ·͢ɻ
  25. Stoping MySQL in the AMIMOTO AMI MySQL Λ RDS ΁Ҡಈͤ͞Δͱ

    AMIMOTO AMI ಺ͷ MySQL ϓϩηε͕ෆཁʹͳΓ·͢ɻ ઃఆϑΝΠϧΛฤूͯ͠ MySQL ϓϩηεΛऴ͍ྃͤͯͩ͘͞͞ɻ AMIMOTO AMI Ͱ͸ϛυϧ΢ΣΞͷઃఆ͸ /opt/local/amimoto.json ʹ͋Δ 
 chef-solo Λ࢖͍ͬͯ·͢ɻ 
 MySQL Λఀࢭͤ͞Δʹ͸ϑΝΠϧΛ࣍ͷΑ͏ʹॻ͖׵͍͑ͯͩ͘͞:
 {
 "nginx" : { "config" : { "user" : "nginx", "group" : "nginx" } },
 "php" : { "config" : { "user" : "nginx", "group" : "nginx" } },
 "mysql" : { "enabled" : false },
 "phpfpm" : { "enabled" : true },
 "run_list" : [ "recipe[amimoto]" ]
 }
  26. AMIMOTO AMI ͷ MySQL ΛࢭΊΔ AMIMOTO AMI HHVM ൛ͷ৔߹͸ҎԼͷΑ͏ʹมߋ͍ͯͩ͘͠͞: {

    "nginx" : { "config" : { "user" : "nginx", "group" : "nginx" } }, "php" : { "config" : { "user" : "nginx", "group" : "nginx" } }, "mysql" : { "enabled" : false }, "hhvm" : { "enabled" : true }, "run_list" : [ "recipe[amimoto]" ] }
  27. AMIMOTO AMI ͷ MySQL ΛࢭΊΔ ࠷ޙʹ࣍ͷίϚϯυΛ࣮ߦ͍ͯͩ͘͠͞:
 
 $ sudo /opt/local/proviosion

    
 $ mysql stop service
  28. AMAZON S3
 ͱ͸

  29. AMAZON S3 • ΦϯϥΠϯόοΫΞοϓ͓Αͼ
 σʔλͷΞʔΧΠϒʹಛԽͨ͠ઃܭ • ੩తαΠτͷϗεςΟϯά΋Մೳ • 1ϑΝΠϧ͋ͨΓ 5GB

    ·ͰΞοϓϩʔυɼ
 ετϨʔδɼμ΢ϯϩʔυ͕Մೳ • ετϨʔδ͢ΔϑΝΠϧ਺ʹ্ݶͳ͠ • ෳ਺ͷσʔληϯλʹ৑௕Խ͞ΕετΞ
  30. AWS ίϯιʔϧ͔Β S3 Λબ୒͍ͯͩ͘͠͞

  31. όέοτΛ࡞੒͠·͢

  32. όέοτʹ໊લΛ෇͚ͯϦʔδϣϯΛબ୒ɼ࡞੒͍ͯͩ͘͠͞

  33. όέοτͷ֓ཁ

  34. ΢ΣϒαΠτϗεςΟϯάΛ༗ޮԽ͍ͯͩ͘͠͞

  35. ηΩϡϦςΟΫϨσϯγϟϧ΁Ҡಈͯ͠……

  36. ΞΫηεΩʔΛ࡞੒͍ͯͩ͘͠͞

  37. ΞΫηεΩʔΛίϐʔɾμ΢ϯϩʔυ͍ͯͩ͘͠͞

  38. WordPress ͷμογϡϘʔυͰ Nephila clavata ϓϥάΠϯΛ༗ޮԽ

  39. ϓϥάΠϯΛઃఆ͠·͢

  40. Amazon S3 ্΁Ҡಈͨ͠ WordPress ϝσΟΞϥΠϒϥϦ

  41. ja.amimoto-ami.com/support/ ࣭͝໰͸͓ؾܰʹ:

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

    S3