Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[日本語] 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

More Decks by Amimoto - Flexible Cloud WordPress Hosting

Other Decks in How-to & DIY

Transcript

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

    View full-size slide

  2. AMAZON RDS
    ͱ͸

    View full-size slide

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

    View full-size slide

  4. ϝϦοτ
    • εέʔϧՄೳͳCPUɼIOPSɼ

    ετϨʔδεϖʔε
    • εφοϓγϣοτϕʔεͷόοΫΞοϓ

    ࣗಈԽ΋Մೳ

    • Ϛϧν AZσϓϩΠϝϯτ

    • ϑΣΠϧΦʔόʔ͸ಉظࡁηΧϯμϦ͔Β

    View full-size slide

  5. σϝϦοτ
    • DB Πϯελϯε΁γΣϧΞΫηεෆՄ

    • Ϣʔβಛݖʹ੍ݶ͕͋Δ

    • MySQL ͷϨϓϦέʔγϣϯ͕ແޮ

    • ຖि4࣌ؒͷϝϯςφϯε΢Οϯυ΢

    • RDS Πϯελϯε͸ࢭΊΔࣄ͕Ͱ͖ͳ͍

    View full-size slide

  6. σʔλϕʔεΛ
    RDS ΁Ҡߦ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  10. MySQL Λ Amazon RDS ಺ʹ࡞੒

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. σʔλϕʔεͷ࡞੒

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  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 


    View full-size slide

  19. {endpoint} ͸ AWS ίϯιʔϧͷ RDS ৘ใηΫγϣϯʹ͋Γ·͢

    {mymasteruser} ͱύεϫʔυ͸ RDS ࡞੒࣌ʹܾΊͨ΋ͷͰ͢

    View full-size slide

  20. σʔλͷҠߦ
    wp-cli ͰσʔλϕʔεͷσʔλΛΤΫεϙʔτ:


    $ wp --path=/path/to/wordpress db export



    /path/to/wordpress ͸ WordPress ͷΠϯετʔϧσΟϨΫτϦͰ͢ɻ

    AMIMOTO AMIͷσϑΥϧτ͸ /var/www/vhosts/{instance_id} Ͱ͢ɻ


    View full-size slide

  21. Data migration
    RDS ΁σʔλΛΠϯϙʔτ: 


    $ mysql -h {endpoint} -P 3306 -u {mymasteruser} -p {databasename} <
    dump.sql


    {endpoint} ͸ AWS Ϛωʔδϝϯτίϯιʔϧʹදࣔ͞Ε͍ͯ·͢ɻ

    {mymasteruser} ͱ {databasename} ͸ RDS ࡞੒࣌ʹܾΊͨ΋ͷΛೖྗ͍ͯͩ͘͠͞ɻ

    View full-size slide

  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',
    );
    }

    View full-size slide

  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 ͕ಈ࡞͢Δ͔֬ೝ͍ͯͩ͘͠͞ɻ

    View full-size slide

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

    chef-solo Λ࢖͍ͬͯ·͢ɻ

    View full-size slide

  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]" ]

    }

    View full-size slide

  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]" ]
    }

    View full-size slide

  27. AMIMOTO AMI ͷ MySQL ΛࢭΊΔ
    ࠷ޙʹ࣍ͷίϚϯυΛ࣮ߦ͍ͯͩ͘͠͞:


    $ sudo /opt/local/proviosion 

    $ mysql stop service

    View full-size slide

  28. AMAZON S3

    ͱ͸

    View full-size slide

  29. AMAZON S3
    • ΦϯϥΠϯόοΫΞοϓ͓Αͼ

    σʔλͷΞʔΧΠϒʹಛԽͨ͠ઃܭ
    • ੩తαΠτͷϗεςΟϯά΋Մೳ
    • 1ϑΝΠϧ͋ͨΓ 5GB ·ͰΞοϓϩʔυɼ

    ετϨʔδɼμ΢ϯϩʔυ͕Մೳ
    • ετϨʔδ͢ΔϑΝΠϧ਺ʹ্ݶͳ͠
    • ෳ਺ͷσʔληϯλʹ৑௕Խ͞ΕετΞ

    View full-size slide

  30. AWS ίϯιʔϧ͔Β S3 Λબ୒͍ͯͩ͘͠͞

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  33. όέοτͷ֓ཁ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide