mysql_first_performance_ tuning_y8

mysql_first_performance_ tuning_y8

初めてのMySQLパフォーマンスチューニング

3c9c5f9a91cac73073db8bb2903bd968?s=128

mamy1326

May 27, 2017
Tweet

Transcript

  1. ॳΊͯͷ .Z42-αʔόʔ ύϑΥʔϚϯε νϡʔχϯά ·Έ΍ͳ͓͖ !NBNZ  .BZ!Z4QSJOHJO4IJCVZB

  2. ࣗݾ঺հ Name ɹɹ ɿ·Έ΍ͳ͓͖ Twitterɹɹ ɿ@mamy1326 2016೥·ͰΞϓϦத৺ 2017೥͔Βຊ֨తʹ ɹɹɹɹɹɹɹDBɾΠϯϑϥ΁

  3. ϫλγ Πϯϑϥ νϣοτσΩϧ

  4. ɹ૝ఆΦʔσΟΤϯε ɾΞϓϦΤϯδχΞ ɾ%#͸ීஈ͸πʔϧͰࢀরɾૢ࡞ ɹˠίϚϯυϥΠϯͰ%#ૢ࡞͠ͳ͍ ɾίϯιʔϧ͸͋Μ·Γ࢖Θͳ͍

  5. ߏ੒ ⾣NZDOG ɹશ߲໨ͷௐࠪɾઃఆ ⾣ΫΤϦΩϟογϡͷଌఆ ⾣ϨϓϦέʔγϣϯ

  6. ϓϩϩʔά

  7. ɹͱ͋ΔαʔϏεͷӡ༻ঢ়گ िʹҰ౓ %#αʔόʔμ΢ϯ ೾͕ऩ·ΔͷΛ ͻͨ͢Β଴ͭ

  8. ɹͱ͋ΔαʔϏεͷӡ༻ঢ়گ %#ͷ -"͕௓Ͷ্͕ͬͯΔΜͰ ͱΓ͋͑ͣ 8FCͷ઀ଓ਺੍ݶͯ͠ Ͳ͏ʹ͔͍ͯͨ͠

  9. ɹͱ͋ΔαʔϏεͷӡ༻ঢ়گ %#ͷ -"͕௓Ͷ্͕ͬͯΔΜͰ ͱΓ͋͑ͣ 8&#ͷ઀ଓ਺੍ݶͯ͠ Ͳ͏ʹ͔͍ͯͨ͠ ౖ

  10. ঢ়گ̍ νϡʔχϯά͞Ε͍ͯͳ͍ .Z42- ઐ༻αʔόʔ

  11. ঢ়گ̎ ࢭ·Βͳ͍ )551ϦΫΤετ Ͱ΋ඵؒ̑

  12. ঢ়گ̏ ڊେͳϩάςʔϒϧ ϑϧεΩϟϯ º̎ ֤ສϨίʔυ

  13. ঢ়گ̐ ࿈ൃ͢ΔεϩʔΫΤϦ ϩά͸औ͍ͬͯͳ͍

  14. ঢ়گ̑ ࢮΜͩΒऴΘΔϚελʔ εϨʔϒ͕ͳ͍

  15. ঢ়گ̒ .Z42-ܥ ੓࣏తʹ όʔδϣϯΞοϓͰ͖ͳ͍

  16. ໨ࢦ͢ .Z42-ͷઃఆΛ ͪΌΜͱཧղͯ͠ ࠷దͳύϑΥʔϚϯεΛɻ

  17. NZDOG શ߲໨ͷ ௐࠪɾઃఆ

  18. ɹNZDOG֬ೝ [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock symbolic-lincs=0 expire_logs_days=3 sort_buffer=4M log-bin=mysql-bin server-id=1001 ΄΅σϑΥϧτ

    ɾТɾA
  19. ɹNZDOGઃఆํ਑ ɾڞ༗ྖҬ͔Β ɹɹɹςʔϒϧݸผྖҬ΁ ɾద੾ͳϝϞϦׂΓ౰ͯ

  20. ɹNZDOGઃఆํ਑ ɾڞ༗ྖҬ͔Β ɹɹɹςʔϒϧݸผྖҬ΁ ɾద੾ͳϝϞϦׂΓ౰ͯ

  21. ɹڞ༗ྖҬͱ͸ ɾ.Z42-ͷσϑΥϧτ͸ɺ͓͖͍ͬശͷத ɹͰશςʔϒϧΛऔΓѻ͍ͬͯΔ ɾେ͖ͳςʔϒϧ΋খ͞ͳςʔϒϧ΋ಉډ ɾϨίʔυͰ΋ߋ৽ʹ͕͔͔࣌ؒΔ

  22. ɹڞ༗ྖҬͷ࣮ྫ EBUBCBTF UBCMFSPXTTJ[F WBSMJCNZTRMJCEBUB

  23. ɹڞ༗ྖҬͷ࣮ྫ EBUBCBTF UBCMFSPXTTJ[F WBSMJCNZTRMJCEBUB ͜ͷϑΝΠϧʹ શͯͷςʔϒϧͷσʔλ͕ ه࿥͞Ε͍ͯΔ

  24. ɹςʔϒϧݸผྖҬͱ͸ ɾςʔϒϧΛ̍ͭͣͭ෼͚ͯऔΓѻ͏ ɾେ͖ͳςʔϒϧ΋খ͞ͳςʔϒϧ΋ݸผ ɾߋ৽ର৅ͷςʔϒϧͷྖҬʹͷΈߋ৽͕ ɹ͔͔ΔͨΊଞʹӨڹΛ༩͑ͳ͍

  25. ɹઃఆ಺༰ ͜Ε͚ͩʂ [mysqld] innodb_file_per_table=1

  26. ͨͩ͠ɾɾɾ ɾNZTRM࠶ىಈ͚ͩͰ͸ ɹطଘͷςʔϒϧʹରͯ͠͸ద༻͞Εͳ͍ ɾ࠶ىಈޙʹ$3&"5& ɹ͞ΕΔςʔϒϧʹͷΈ༗ޮ EVNQϦετΞ͕ඞཁ

  27. ɹ݁Ռ EBUBCBTF UBCMFSPXTTJ[F WBSMJCNZTRMJCEBUB WBSMJCNZTRMNBNZ

  28. ɹ݁Ռ EBUBCBTF UBCMFSPXTTJ[F WBSMJCNZTRMJCEBUB WBSMJCNZTRMNBNZ EBUBCBTF໊Ͱ σΟϨΫτϦ͕࡞੒͞Ε ςʔϒϧ͝ͱʹ ϑΝΠϧ͕࡞ΒΕ͍ͯΔ

  29. ɹ݁Ռ EBUBCBTF UBCMFSPXTTJ[F WBSMJCNZTRMJCEBUB WBSMJCNZTRMNBNZ EBUBCBTF໊Ͱ σΟϨΫτϦ͕࡞੒͞Ε ςʔϒϧ͝ͱʹ ϑΝΠϧ͕࡞ΒΕ͍ͯΔ Ώɹ͑ɹʹ

  30. ɹ݁Ռ EBUBCBTF UBCMFSPXTTJ[F WBSMJCNZTRMJCEBUB WBSMJCNZTRMNBNZ SFQPSUςʔϒϧɹ͕ ߋ৽͞Εͨ৔߹ ֘౰ͷϑΝΠϧͷΈߋ৽

  31. ɹNZDOGઃఆํ਑ ɾڞ༗ྖҬ͔Β ɹɹɹςʔϒϧݸผྖҬ΁ ɾద੾ͳϝϞϦׂΓ౰ͯ

  32. ɹϝϞϦׂΓ౰ͯͱ͸ ɾσʔλͱJOEFY͸ ɹɹɹɹϝϞϦʹΩϟογϡ ɾద੾ͳαΠζ͸ ɹɹɹɹ෺ཧϝϞϦͷׂ

  33. ɹઃఆ಺༰ ͜Ε͚ͩʂ [mysqld] # InnoDBͷσʔλͱindexΛΩϟογϡ͢ΔόοϑΝαΠζ # (ਪ঑͸෺ཧϝϞϦ8ׂ) innodb_buffer_pool_size=6G # InnoDBͷߋ৽ϩάΛه࿥͢ΔσΟεΫ্ͷϑΝΠϧαΠζ

    innodb_log_file_size=1G
  34. ղઆ ⾣JOOPEC@CV⒎FS@QPPM@TJ[F( ɾσʔλͱJOEFYΛΩϟογϡ͓ͯ͘͠αΠζ ɾ%#αʔόʔͷ෺ཧϝϞϦ(ʹର͢Δ͓Αׂͦ ɾNZTRM࠶ىಈ࣌ʹׂΓ౰ͯΒΕ·͢ ɾॻ͖ࠐΈ࣌ʹ΋ύϑΥʔϚϯε޲্͕ݟࠐ·ΕΔ ɹˏ.Z42-ެࣜ

  35. ղઆ ⾣JOOPEC@MPH@pMF@TJ[F( ɾ*OOP%#ͷߋ৽ϩάαΠζ ɾDPNNJUཤྺΛه࿥͢Δ ɹˠ.Z42-͸DPNNJU࣌ɺ͍ͬͨΜϩάʹه࿥͞ΕΔ ɾϑΝΠϧ͸γʔέϯγϟϧͳͷͰɺߋ৽͕଎͍ ɾੵΜͩDPNNJUΛॱ࣮࣍σʔλʹ൓ө͢Δ

  36. ͦͷଞͷઃఆ ⾣εϩʔΫΤϦϩάؔ࿈ [mysqld] # εϩʔΫΤϦͷग़ྗઃఆ slow_query_log=ON # εϩʔΫΤϦͱ൑ఆ͢Δඵ਺ long_query_time=3 #

    εϩʔΫΤϦͷ৔ॴ log-slow-queries=/var/log/slow.log
  37. ͦͷଞͷઃఆ ⾣ΫΤϦΩϟογϡؔ࿈ [mysqld] # ΫΤϦΩϟογϡ࠷େαΠζ query_cache_limit=16M # ΫΤϦΩϟογϡͰ࢖༻͢ΔϝϞϦαΠζ query_cache_size=512M #

    ΫΤϦΩϟογϡͷλΠϓ # 0:off, 1:ON SELECT SQL_NO_CACHE, 2:DEMAND SELECT SQL_CACHE query_cache_type=1⊠
  38. NZDOGઃఆ݁Ռ ⾣ඵؒϦΫΤετʂ ⾣ϝϞϦ͕ੵ·Εͨ෼͚ͩՔಇʂ ⾣ςʔϒϧݸผͰߋ৽ܥ͕ૣ͘ʂ ⾣ΫΤϦΩϟογϡώοτʂ ⾣JOEFYݟ௚͠ͰεϩʔΫΤϦղফʂ

  39. ɹNZDOGઃఆ·ͱΊ ⾣αʔϏεʹԠͯ͡ద੾ʹઃఆʂ ⾣σϑΥϧτμϝʂθολΠʂ ⾣ઃఆޙͷ਺஋͸ఆظతʹ؂ࢹʂ ɹˠνϡʔχϯά͸ܧଓ໋͕ʂ ⾣ςʔϒϧઃܭ͸ܭըతʹʂ

  40. ແࣄʹɾɾɾ αʔϏε͕ ӡ༻ʹ଱͑ΒΕΔΑ͏ʹ

  41. ΫΤϦΩϟογϡ ଌఆ

  42. ଌఆ NZDOGઃఆ͔ͯ͠Βिؒ ΫΤϦΩϟογϡ͕ Ͳ͏ͳͬͨͷ͔

  43. ΍Δ͜ͱ ΫΤϦΩϟογϡΛద੾ʹ࣋ͨͤ ݁ՌΛͳΔ΂͘Ωϟογϡ͔Βฦ͢Α͏ νϡʔχϯάΛߦͬͨ ݁ՌΛݕূ ਺஋Ͱݕূ

  44. ΫΤϦΩϟογϡͱ͸ %#Λ4&-&$5ͨ݁͠ՌΛ ϝϞϦʹΩϟογϡ͠ ࣍ʹಉҰͷΫΤϦͷ৔߹ Ωϟογϡ͔Β݁ՌΛฦ͢

  45. ɹઃఆ಺༰ [mysqld] # ΫΤϦΩϟογϡ࠷େαΠζ query_cache_limit=16M # ΫΤϦΩϟογϡͰ࢖༻͢ΔϝϞϦαΠζ query_cache_size=512M # ΫΤϦΩϟογϡͷλΠϓ

    # 0:off, 1:ON SELECT SQL_NO_CACHE, 2:DEMAND SELECT SQL_CACHE query_cache_type=1⊠
  46. ઃఆ஋ͷ֬ೝ NZTRM4)087"3*"#-&4-*,&bRVFSZ@DBDIF +------------------------------+-----------+ | Variable_name | Value | +------------------------------+-----------+ |

    have_query_cache | YES | | query_cache_limit | 16777216 | | query_cache_min_res_unit | 4096 | | query_cache_size | 536870912 | | query_cache_type | ON | | query_cache_wlock_invalidate | OFF | +------------------------------+-----------+
  47. ઃఆ஋ͷղઆ ⾣IBWF@RVFSZ@DBDIFɿ:&4 ɹΫΤϦΩϟογϡΛ ɹ࢖༻Մೳ͔Ͳ͏͔

  48. ઃఆ஋ͷղઆ ⾣RVFSZ@DBDIF@MJNJUɿ   ɹͭͷRVFSZͷ࣮ߦ݁Ռ ɹɹͱͯ͠ ɹDBDIF͢Δ࠷େͷαΠζ

  49. ઃఆ஋ͷղઆ ⾣RVFSZ@DBDIF@TJ[Fɿ   ɹΫΤϦΩϟογϡͷ ɹ૯ྖҬ

  50. ઃఆ஋ͷղઆ ⾣RVFSZ@DBDIF@UZQFɿ0/PS ɹ4&-&$542-@/0@$"$)& ɹͰ࢝·ΔΫΤϦҎ֎Ωϟογϡ Ωϟογϡ͔Β ໌ࣔతʹআ֎Ͱ͖Δ

  51. ɹ൓өঢ়ଶͷݕূ NZTRM4)084&44*0/45"564-*,&b2DBDIF +-------------------------+-----------+ | Variable_name | Value | +-------------------------+-----------+ |

    Qcache_free_blocks | 791 | | Qcache_free_memory | 533156064 | | Qcache_hits | 1442086 | | Qcache_inserts | 291072 | | Qcache_lowmem_prunes | 0 | | Qcache_not_cached | 3599 | | Qcache_queries_in_cache | 1760 | | Qcache_total_blocks | 4361 | +-------------------------+-----------+
  52. ൓ө஋ͷղઆ ⾣2DBDIF@IJUTɿ   ɹΫΤϦʔ݁Ռ͕ ɹΫΤϦʔΩϟογϡ͔Βฦ͞Εͨ਺ ɹͭ·ΓΩϟογϡώοτ਺ Ωϟογϡʹ͋ΔΫΤϦʔ͕ ࢖ΘΕΔͨͼʹΠϯΫϦϝϯτ

  53. ൓ө஋ͷղઆ ⾣2DBDIF@JOTFSUTɿ  ɹΫΤϦʔΩϟογϡʹ௥Ճ͞Εͨ ɹΫΤϦʔͷ਺

  54. ൓ө஋ͷղઆ ⾣2DBDIF@OPU@DBDIFEɿ  ɹΩϟογϡͰ͖ͳ͍͔ ɹRVFSZ@DBDIF@UZQFઃఆͷͨΊ ɹΩϟογϡ͞Εͳ͔ͬͨ਺ ϝϞϦෆ଍ͳͲͰΩϟογϡ͞Εͳ͍ ৔߹΋͋ΔͷͰ஫ҙ

  55. ɹ݁Ռ ΫΤϦΩϟογϡIJU཰ 

  56. ώοτ཰ͷܭࢉ શΫΤϦʔ ͷ਺Ͱ ΫΤϦΩϟογϡώοτ਺Λ আࢉ͢Δ

  57. ώοτ཰ͷܭࢉ શΫΤϦʔ Ωϟογϡ͔Βฦͨ͠਺ ʴ Ωϟογϡ͔Βฦͤͳ͔ͬͨ਺

  58. ώοτ཰ͷܭࢉ Ωϟογϡ͞ΕΔͱ 2DBDIF@JOTFSUT͕ Χ΢ϯτΞοϓ͞ΕΔ Ωϟογϡʹ ৽نొ࿥ͨ͠஋

  59. ώοτ཰ͷܭࢉ Ωϟογϡʹొ࿥Ͱ͖ͳ͍ͱ 2DBDIF@OPU@DBDIFE͕ Χ΢ϯτΞοϓ͞ΕΔ Ωϟογϡ͔Β ฦͤͳ͔ͬͨ஋

  60. ώοτ཰ͷܭࢉ ⾣2DBDIF@IJUTɿ   ⾣2DBDIF@JOTFSUTɿ  ⾣2DBDIF@OPU@DBDIFEɿ   

       ʜ
  61. ɹͨͩ͠ɾɾɾ Ұൠతʹ ΛԼճͬͨΒ ͍Ζ͍Ζݟ௚ͨ͠ํ͕͍͍

  62. ஫ҙ఺ ʲલఏʳ ΫΤϦΩϟογϡ͸ 4&-&$5ʢݕࡧʣ

  63. ஫ҙ఺ ॻ͖ࠐΈ͕ଟൃ͢Δ ςʔϒϧʹ͸޲͔ͳ͍ Ωϟογϡ͕ॻ͖׵ΘΔ

  64. ஫ҙ఺ ΫΤϦΩϟογϡΛ΍Ί ϓϩάϥϜଆͰΩϟογϡ NFNDBDIFEͳͲ

  65. ɹΫΤϦΩϟογϡ·ͱΊ ⾣ϝϞϦʹԠͯ͡ద੾ʹઃఆʂ ⾣IJU཰Λܧଓͯ͠ܭଌʂ ⾣αʔϏεͷੑ࣭ΛݟۃΊΔʂ ⾣ܿ͘ϓϩάϥϜʹ೚ͤΔʂ

  66. ϨϓϦέʔγϣϯ ࣮ࢪ

  67. ͜͜·ͰͰɾɾɾ ɾӡ༻͕҆ఆ ɾΫΤϦΩϟογϡ ɹɹɹώοτ཰΋҆ఆ

  68. ͔͠͠

  69. ՝୊ Ϛελʔ͕ࢮ͵ͱ σʔλ͕શ෦ࢮ͵

  70. ෳ੡ Ϛελʔ͔͠ͳ͍ ݱঢ়ʹ εϨʔϒΛ࡞Γ

  71. ෳ੡ ϨϓϦέʔγϣϯ Λ࣮ࢪ͠·͢

  72. ɹϨϓϦέʔγϣϯͱ͸ ⾣σʔλϕʔεશମͷෳ੡ ϨϓϦΧ  ⾣ผͷαʔόʔʹෳ੡ʢεϨʔϒʣ ⾣.Z42-ͷඪ४ػೳͰ͓खܰ ⾣΄΅࣌ؒࠩͳ͠ʹಉظ

  73. ߏ੒ Ϛελʔ ʢ୯Ұʣ εϨʔϒ ʢʣ εϨʔϒ ʢOʣ ɾɾɾ

  74. Ϛελʔ ⾣σʔλΛߋ৽͢Δଆ ⾣ߋ৽಺༰ΛεϨʔϒ͕औΓʹདྷΔ ɹˠεϨʔϒʹର͠ߋ৽ΠϕϯτΛ௨஌ ⾣ෳ਺ͷεϨʔϒΛ࣋ͯΔ

  75. εϨʔϒ ⾣ߋ৽༻Ͱ͸ͳ͘ࢀর༻ ⾣Ϛελʔͷߋ৽಺༰Λड͚औΔ ⾣ϚελʔͷόΠφϦϩάΛऔಘ ⾣ߋ৽಺༰Λ%#ʹ൓ө ⾣ͭͷϚελʔͷΈ࣋ͯΔ

  76. ϝϦοτ ⾣ࢀর 4&-&$5 ੑೳͷ޲্ ݕࡧॲཧ͕ॏ͍৔߹ εϨʔϒΛࢀরܥʹͯ͠ ෛՙ෼ࢄ

  77. ϝϦοτ ⾣Մ༻ੑͷߴ͍ߏ੒ͷ࣮ݱ Ϛελʔো֐ͷ৔߹ εϨʔϒΛϚελʔʹঢ֨ μ΢ϯλΠϜ୹ॖ

  78. ϝϦοτ ⾣όοΫΞοϓαʔόʔ εϨʔϒͰόοΫΞοϓ ϚελʔʹӨڹͳ͘ όοΫΞοϓऔಘ

  79. ࣄલ४උ ⾣ϨϓϦέʔγϣϯϢʔβʔ࡞੒ ⾣ϚελʔՔಇঢ়ଶͷ֬ೝ ⾣ϚελʔόΠφϦϩάͷ֬ೝ ⾣εϨʔϒͷઃఆ֬ೝ

  80. ࣄલ४උ ⾣ϨϓϦέʔγϣϯϢʔβʔ࡞੒ ⾣ϚελʔՔಇঢ়ଶͷ֬ೝ ⾣ϚελʔόΠφϦϩάͷ֬ೝ ⾣εϨʔϒͷઃఆ֬ೝ

  81. ɹɹϨϓϦέʔγϣϯϢʔβʔ࡞੒ ⾣ఆٛ ɹɾϚελʔଆʹ࡞੒ ɹɾεϨʔϒ͔Β઀ଓ͢Δ ɹɾϨϓϦέʔγϣϯઐ༻Ϣʔβʔ

  82. ɹɹϨϓϦέʔγϣϯϢʔβʔ࡞੒ ⾣࡞੒ίϚϯυ NZTRM NBTUFS $3&"5&64&3 NZTRM NBTUFS `SFQM`!`<εϨʔϒͷϗετ໊>` NZTRM NBTUFS

    *%&/5*'*&%#:1"44803%` `
  83. ɹɹϨϓϦέʔγϣϯϢʔβʔ࡞੒ ⾣ݖݶίϚϯυ NZTRM NBTUFS (3"/53&1-*$"5*0/4-"7& NZTRM NBTUFS 0/  50

    NZTRM NBTUFS `SFQM`!`<εϨʔϒͷϗετ໊>`
  84. ࣄલ४උ ⾣ϨϓϦέʔγϣϯϢʔβʔ࡞੒ ⾣ϚελʔՔಇঢ়ଶͷ֬ೝ ⾣ϚελʔόΠφϦϩάͷ֬ೝ ⾣εϨʔϒͷઃఆ֬ೝ

  85. ϚελʔͷNZDOG [mysqld] # εϨʔϒʹ௨஌͢ΔόΠφϦϩά(࣮ࡍ͸φόϦϯά͞ΕΔ) log-bin=mysql-bin # ϨϓϦέʔγϣϯ࣌ͷɺαʔόʔϢχʔΫID server-id=1001 # όΠφϦϩάϑΝΠϧͷϩʔςʔτ೔਺

    set-variable=expire_logs_days=3
  86. [mysqld] # εϨʔϒʹ௨஌͢ΔόΠφϦϩά(࣮ࡍ͸φόϦϯά͞ΕΔ) log-bin=mysql-bin # ϨϓϦέʔγϣϯ࣌ͷɺαʔόʔϢχʔΫID server-id=1001 # όΠφϦϩάϑΝΠϧͷϩʔςʔτ೔਺ set-variable=expire_logs_days=3

    ϚελʔͷNZDOG DPNNJUΛ௨஌ޙ εϨʔϒ͕઀ଓͯ͠औಘ WBSMJCNZTRM NZTRMCJO999999
  87. [mysqld] # εϨʔϒʹ௨஌͢ΔόΠφϦϩά(࣮ࡍ͸φόϦϯά͞ΕΔ) log-bin=mysql-bin # ϨϓϦέʔγϣϯ࣌ͷɺαʔόʔϢχʔΫID server-id=1001 # όΠφϦϩάϑΝΠϧͷϩʔςʔτ೔਺ set-variable=expire_logs_days=3

    ϚελʔͷNZDOG εϨʔϒ͔Βݟͨ Ϛελʔͷ*%
  88. [mysqld] # εϨʔϒʹ௨஌͢ΔόΠφϦϩά(࣮ࡍ͸φόϦϯά͞ΕΔ) log-bin=mysql-bin # ϨϓϦέʔγϣϯ࣌ͷɺαʔόʔϢχʔΫID server-id=1001 # όΠφϦϩάϑΝΠϧͷϩʔςʔτ೔਺ set-variable=expire_logs_days=3

    ϚελʔͷNZDOG ଟ͗͘͢͠Δͱ ετϨʔδѹഭ
  89. ࣄલ४උ ⾣ϨϓϦέʔγϣϯϢʔβʔ࡞੒ ⾣ϚελʔՔಇঢ়ଶͷ֬ೝ ⾣ϚελʔόΠφϦϩάͷ֬ೝ ⾣εϨʔϒͷઃఆ֬ೝ

  90. ɹɹϚελʔόΠφϦϩάͷ֬ೝ ⾣όΠφϦϩάͱҐஔ৘ใ ɹɾόΠφϦϩάϑΝΠϧͱ͸ ɹɹɹˠϚελʔ͕DPNNJUͨ͠ཤྺ ɹɾϩʔςʔτ͞ΕΔ ɹɹɹˠݱࡏͷϑΝΠϧ໊Λ֬ೝ ɹɾͲ͜·ͰDPNNJUͰ͖ͯΔ͔ ɹɹɹˠҐஔ৘ใΛ֬ೝ

  91. ɹɹϚελʔόΠφϦϩάͷ֬ೝ mysql> SHOW MASTER STATUS\G ********* 1. row ********* File:

    mysql-bin.000075 Position: 588201136 Binlog_Do_DB: Binlog_Ignore_DB: 1 row in set (0.01 sec)
  92. ɹɹϚελʔόΠφϦϩάͷ֬ೝ mysql> SHOW MASTER STATUS\G ********* 1. row ********* File:

    mysql-bin.000075 Position: 588201136 Binlog_Do_DB: Binlog_Ignore_DB: 1 row in set (0.01 sec) DPNNJUΛ௨஌ޙ εϨʔϒ͕઀ଓͯ͠औಘ WBSMJCNZTRM NZTRMCJO999999
  93. ɹɹϚελʔόΠφϦϩάͷ֬ೝ mysql> SHOW MASTER STATUS\G ********* 1. row ********* File:

    mysql-bin.000075 Position: 588201136 Binlog_Do_DB: Binlog_Ignore_DB: 1 row in set (0.01 sec) ϚελʔͰ DPNNJU͕࣮ߦ͞Εͨ ϙδγϣϯ
  94. ɹɹϚελʔόΠφϦϩάͷ֬ೝ mysql> SHOW MASTER STATUS\G ********* 1. row ********* File:

    mysql-bin.000075 Position: 588201136 Binlog_Do_DB: Binlog_Ignore_DB: 1 row in set (0.01 sec) εϨʔϒઃఆͰ࢖༻͢ΔͨΊ ϝϞ͓͖ͯ͠·͠ΐ͏
  95. ⾣εϨʔϒΛ࡞Δࡍͷݪଇ ɹϚελʔΛϩοΫͯ͠EVNQ͠ ɹಉҰͷঢ়ଶͰϦετΞͯ͠ ɹϑΝΠϧɾϙδγϣϯΛ߹ΘͤΔ ࠩ෼ɾൈ͚࿙Εͳ͘ ϨϓϦέʔγϣϯ։࢝ ɹɹϚελʔόΠφϦϩάͷ֬ೝ

  96. ࣄલ४උ ⾣ϨϓϦέʔγϣϯϢʔβʔ࡞੒ ⾣ϚελʔՔಇঢ়ଶͷ֬ೝ ⾣ϚελʔόΠφϦϩάͷ֬ೝ ⾣εϨʔϒͷઃఆ֬ೝ

  97. ɹɹεϨʔϒͷઃఆ֬ೝ mysql> SHOW SLAVE STATUS\G **************** 1. row **************** Slave_IO_State:

    Master_Host: [Ϛελʔͷϗετ໊] Master_User: repl Master_Log_File: mysql-bin.000009 Read_Master_Log_Pos: 303456264 Slave_IO_Running: No Slave_SQL_Running: No Seconds_Behind_Master: NULL Master_Server_Id: 0 1 row in set (0.01 sec)
  98. ɹɹεϨʔϒͷઃఆ֬ೝ ⾣4MBWF@*0@4UBUFɿۭจࣈ ɹεϨʔϒͷݱࡏͷεςʔλε ɹϨϓϦέʔγϣϯ్͕੾Ε͍ͯΔͨΊ ɹۭจࣈͱͳ͍ͬͯΔ ࣮ߦ͞Ε͍ͯΕ͹ 8BJUJOHGPSNBTUFSUPTFOEFWFOU

  99. ɹɹεϨʔϒͷઃఆ֬ೝ ⾣.BTUFS@6TFSɿSFQM εϨʔϒ͔ΒϚελʔʹ ઀ଓ͢ΔϢʔβʔ໊ ɹ ϚελʔͰ࡞੒ͨ͠ઐ༻Ϣʔβʔ

  100. ɹɹεϨʔϒͷઃఆ֬ೝ ⾣.BTUFS@-PH@'JMFɿNZTRMCJO εϨʔϒ͕Ϛελʔ͔Β औಘ͢ΔόΠφϦϩά ɹ Քಇ͍ͯ͠ͳ͔ͬͨͷͰ ζϨ͍ͯΔ

  101. ɹɹεϨʔϒͷઃఆ֬ೝ ⾣3FBE@.BTUFS@-PH@1PTɿ εϨʔϒͷ*0εϨου͕ ࠷ޙʹಡΈऔͬͨҐஔ ɹ ͔͜͜ΒϨϓϦέʔγϣϯ࠶։͕ͩ େ͖͘ζϨ͍ͯΔ

  102. ɹɹεϨʔϒͷઃఆ֬ೝ ⾣4MBWF@*0@3VOOJOHɿ/0 εϨʔϒͷ*0εϨου͕ ࣮ߦ͞Ε͍ͯͳ͍ ɹ ϚελʔͷόΠφϦϩά͕ҧ͏ͷͰ ઀ଓͰ͖͍ͯͳ͍

  103. ɹɹεϨʔϒͷઃఆ֬ೝ ⾣4MBWF@42-@3VOOJOHɿ/0 εϨʔϒͷ42-εϨου͕ ࣮ߦ͞Ε͍ͯͳ͍ ɹ εϨʔϒͷ%#͕ ߋ৽͞Ε͍ͯͳ͍

  104. ɹɹεϨʔϒͷઃఆ֬ೝ ⾣4FDPOET@#FIJOE@.BTUFSɿ/6-- Ϛελʔʹൺ΂ͯ ஗Ԇ͍ͯ͠Δඵ਺ ɹ ϨϓϦέʔγϣϯ࣮ߦ͞Ε͍ͯͳ͍

  105. ɹϨϓϦέʔγϣϯखॱ ⾣ϚελʔͷEVNQΛऔಘ ⾣εϨʔϒͷNZDOGઃఆ ⾣εϨʔϒʹϦετΞ ⾣εϨʔϒઃఆมߋ ⾣ϨϓϦέʔγϣϯ࣮ߦ ⾣࣮ߦঢ়گΛ؂ࢹ

  106. ɹϨϓϦέʔγϣϯखॱ ⾣ϚελʔͷEVNQΛऔಘ ⾣εϨʔϒͷNZDOGઃఆ ⾣εϨʔϒʹϦετΞ ⾣εϨʔϒઃఆมߋ ⾣ϨϓϦέʔγϣϯ࣮ߦ ⾣࣮ߦঢ়گΛ؂ࢹ

  107. ɹɹϚελʔͷEVNQΛऔಘ ⾣ϚελʔΛϩοΫ mysql(master)> FLUSH TABLES WITH READ LOCK; Query OK,

    0 rows affected (0.00 sec) ⾣όΠφϦϩάͱϙδγϣϯऔಘ mysql(master)> SHOW MASTER STATUS; File: mysql-bin.000075 Position: 588201136 Binlog_Do_DB: Binlog_Ignore_DB: 1 row in set (0.01 sec)
  108. ɹɹϚελʔͷEVNQΛऔಘ ⾣ϚελʔΛϩοΫ mysql(master)> FLUSH TABLES WITH READ LOCK; Query OK,

    0 rows affected (0.00 sec) ⾣όΠφϦϩάͱϙδγϣϯऔಘ mysql(master)> SHOW MASTER STATUS; File: mysql-bin.000075 Position: 588201136 Binlog_Do_DB: Binlog_Ignore_DB: 1 row in set (0.01 sec) εϨʔϒઃఆͰ࢖༻͢ΔͨΊ ϝϞ͓͖ͯ͠·͠ΐ͏
  109. ɹɹϚελʔͷEVNQΛऔಘ ⾣EVNQऔಘ $ mysqldump -u root -p mamy1326 > gzip

    mamy1326.dump.gz ɾผίϯιʔϧ͔Β࣮ࢪ ɹˠRVJU͢ΔͱϩοΫ͕֎Ε·͢ ɾετϨʔδ༰ྔΛߟྀͯ͠H[JQ ɾTDQίϚϯυ౳ͰεϨʔϒʹసૹ
  110. ɹɹϚελʔͷEVNQΛऔಘ ⾣ϚελʔͷϩοΫΛղআ mysql(master)> UNLOCK TABLES; Query OK, 0 rows affected

    (0.00 sec)
  111. ɹϨϓϦέʔγϣϯखॱ ⾣ϚελʔͷEVNQΛऔಘ ⾣εϨʔϒͷNZDOGઃఆ ⾣εϨʔϒʹϦετΞ ⾣εϨʔϒઃఆมߋ ⾣ϨϓϦέʔγϣϯ࣮ߦ ⾣࣮ߦঢ়گΛ؂ࢹ

  112. ɹɹεϨʔϒͷNZDOGઃఆ [mysqld] # εϨʔϒͷαʔόʔID server-id=1002 # Ϛελʔͷঢ֨Λߟྀ͠ɺϩΪϯάΛ༗ޮʹ͢Δ log-bin=mysql-bin # όΠφϦϩάϑΝΠϧͷϩʔςʔτ೔਺

    set-variable=expire_logs_days=3 # όΠφϦϩάͷग़ྗઃఆ log_slave_updates
  113. [mysqld] # εϨʔϒͷαʔόʔID server-id=1002 # Ϛελʔͷঢ֨Λߟྀ͠ɺϩΪϯάΛ༗ޮʹ͢Δ log-bin=mysql-bin # όΠφϦϩάϑΝΠϧͷϩʔςʔτ೔਺ set-variable=expire_logs_days=3

    # όΠφϦϩάͷग़ྗઃఆ log_slave_updates ɹɹεϨʔϒͷNZDOGઃఆ ϚελʔɺεϨʔϒ શͯ߹Θͤͯ Ұҙͷ*%
  114. [mysqld] # εϨʔϒͷαʔόʔID server-id=1002 # Ϛελʔͷঢ֨Λߟྀ͠ɺϩΪϯάΛ༗ޮʹ͢Δ log-bin=mysql-bin # όΠφϦϩάϑΝΠϧͷϩʔςʔτ೔਺ set-variable=expire_logs_days=3

    # όΠφϦϩάͷग़ྗઃఆ log_slave_updates ɹɹεϨʔϒͷNZDOGઃఆ όΠφϦϩάઃఆ Ϛελʔʹঢ֨ͨ͠৔߹ εϨʔϒʹ௨஌͢Δ
  115. [mysqld] # εϨʔϒͷαʔόʔID server-id=1002 # Ϛελʔͷঢ֨Λߟྀ͠ɺϩΪϯάΛ༗ޮʹ͢Δ log-bin=mysql-bin # όΠφϦϩάϑΝΠϧͷϩʔςʔτ೔਺ set-variable=expire_logs_days=3

    # όΠφϦϩάͷग़ྗઃఆ log_slave_updates ɹɹεϨʔϒͷNZDOGઃఆ ༰ྔѹഭ͠ͳ͍Α͏ʹ
  116. [mysqld] # εϨʔϒͷαʔόʔID server-id=1002 # Ϛελʔͷঢ֨Λߟྀ͠ɺϩΪϯάΛ༗ޮʹ͢Δ log-bin=mysql-bin # όΠφϦϩάϑΝΠϧͷϩʔςʔτ೔਺ set-variable=expire_logs_days=3

    # όΠφϦϩάͷग़ྗઃఆ log_slave_updates ɹɹεϨʔϒͷNZDOGઃఆ εϨʔϒͰ΋ όΠφϦϩάΛग़ྗ͠ Ϛελʔঢ֨Մೳʹ
  117. ɹɹεϨʔϒͷͦͷଞͷ࡞ۀ ⾣NZDOGΛຊ൪ʹ߹ΘͤΔ ⾣NZTRM࠶ىಈ ⾣ϦετΞର৅ͷ ɹɹɹσʔλϕʔε࡟আɾ࠶࡞੒

  118. ɹϨϓϦέʔγϣϯखॱ ⾣ϚελʔͷEVNQΛऔಘ ⾣εϨʔϒͷNZDOGઃఆ ⾣εϨʔϒʹϦετΞ ⾣εϨʔϒઃఆมߋ ⾣ϨϓϦέʔγϣϯ࣮ߦ ⾣࣮ߦঢ়گΛ؂ࢹ

  119. ɹɹεϨʔϒʹϦετΞ ⾣ϦετΞ࣮ߦ ɾετϨʔδ༰ྔʹ஫ҙʂ ɹɹˠαΠζେ͖ΊͷόΠφϦϩά͕ ɹɹɹɹͲΜͲΜͰ͖ͯ༰ྔΛѹഭ $ zcat mamy1326.dump.gz | mysql

    -u root -p mamy1326
  120. ɹɹεϨʔϒʹϦετΞ ⾣ϦετΞ࣮ߦ ɾετϨʔδ༰ྔʹ஫ҙʂ ɹɹˠαΠζେ͖ΊͷόΠφϦϩά͕ ɹɹɹɹͲΜͲΜͰ͖ͯ༰ྔΛѹഭ $ zcat mamy1326.dump.gz | mysql

    -u root -p mamy1326 163(&."45&3-0(450 bNZTRMCJOYYYYYY` ద੾ʹύʔδ͠·͠ΐ͏
  121. ɹϨϓϦέʔγϣϯखॱ ⾣ϚελʔͷEVNQΛऔಘ ⾣εϨʔϒͷNZDOGઃఆ ⾣εϨʔϒʹϦετΞ ⾣εϨʔϒઃఆมߋ ⾣ϨϓϦέʔγϣϯ࣮ߦ ⾣࣮ߦঢ়گΛ؂ࢹ

  122. ɹεϨʔϒઃఆมߋ ⾣ϚελʔͰϝϞͨ͠಺༰Λઃఆ mysql> STOP SLAVE; mysql> RESET SLAVE; mysql> CHANGE

    MASTER TO -> master_log_file = ’mysql-bin.000075’, -> master_log_pos = 588201136;
  123. mysql> STOP SLAVE; mysql> RESET SLAVE; mysql> CHANGE MASTER TO

    -> master_log_file = ’mysql-bin.000075’, -> master_log_pos = 588201136; ɹεϨʔϒઃఆมߋ ⾣ϚελʔͰϝϞͨ͠಺༰Λઃఆ εϨʔϒΛࢭΊ·͢
  124. mysql> STOP SLAVE; mysql> RESET SLAVE; mysql> CHANGE MASTER TO

    -> master_log_file = ’mysql-bin.000075’, -> master_log_pos = 588201136; ɹεϨʔϒઃఆมߋ ⾣ϚελʔͰϝϞͨ͠಺༰Λઃఆ εϨʔϒ͕อ͍࣋ͯͨ͠ ϨϓϦέʔγϣϯҐஔΛ Ϧηοτ͠·͢
  125. mysql> STOP SLAVE; mysql> RESET SLAVE; mysql> CHANGE MASTER TO

    -> master_log_file = ’mysql-bin.000075’, -> master_log_pos = 588201136; ɹεϨʔϒઃఆมߋ ⾣ϚελʔͰϝϞͨ͠಺༰Λઃఆ ϚελʔͷόΠφϦϩάɺ ϙδγϣϯΛઃఆ
  126. ɹϨϓϦέʔγϣϯखॱ ⾣ϚελʔͷEVNQΛऔಘ ⾣εϨʔϒͷNZDOGઃఆ ⾣εϨʔϒʹϦετΞ ⾣εϨʔϒઃఆมߋ ⾣ϨϓϦέʔγϣϯ࣮ߦ ⾣࣮ߦঢ়گΛ؂ࢹ

  127. ɹϨϓϦέʔγϣϯ࣮ߦ ⾣ϨϓϦέʔγϣϯͷ։࢝ mysql> START SLAVE; ઃఆͨ͠ϙδγϣϯ͔Β ಉظ͕࣮ߦ͞Ε·͢

  128. ɹϨϓϦέʔγϣϯ࣮ߦ ⾣ϨϓϦέʔγϣϯͷ֬ೝ mysql> SHOW SLAVE STATUS\G ***************** 1. row *****************

    Slave_IO_State: Waiting for master to send event Master_Log_File: mysql-bin.000075 Read_Master_Log_Pos: 878873047 Slave_IO_Running: Yes Slave_SQL_Running: Yes Exec_Master_Log_Pos: 605504154 Seconds_Behind_Master: 244615 Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Master_Server_Id: 1001
  129. ɹϨϓϦέʔγϣϯͷ֬ೝ ⾣4MBWF@*0@4UBUFɿ 8BJUJOHGPSNBTUFSUPTFOEFWFOU εϨʔϒͷݱࡏͷεςʔλε ϨϓϦέʔγϣϯ͕։࢝͞Ε Ϛελʔ͔ΒͷΠϕϯτ଴ͪ

  130. ɹϨϓϦέʔγϣϯͷ֬ೝ ⾣.BTUFS@-PH@'JMFɿ NZTRMCJO ϚελʔͷόΠφϦϩάϑΝΠϧ ݱࡏϚελͰߋ৽͞Ε͍ͯΔ ϑΝΠϧ໊ʹͳ͍ͬͯΔ

  131. ɹϨϓϦέʔγϣϯͷ֬ೝ ⾣3FBE@.BTUFS@-PH@1PTɿ  ϚελʔͷόΠφϦϩά͔Β *0εϨου͕ಡΈऔͬͨҐஔ ˞42-࣮ߦ͞Εͨͱ͸ݶΒͳ͍

  132. ɹϨϓϦέʔγϣϯͷ֬ೝ ⾣&YFD@.BTUFS@-PH@1PTɿ  *0εϨου͕ಡΈࠐΜͩϩά͔Β 42-εϨου͕ ࣮ߦͨ͠ΫΤϦͷҐஔ

  133. ɹϨϓϦέʔγϣϯͷ֬ೝ ⾣4FDPOET@#FIJOE@.BTUFSɿ  εϨʔϒ͕Ϛελʔʹൺ΂ ஗Ԇ͍ͯ͠Δඵ਺

  134. ɹϨϓϦέʔγϣϯͷ֬ೝ ⾣4MBWF@*0@3VOOJOHɿ:&4 ϚελʔͷόΠφϦϩάΛ औಘͰ͖͍ͯΔ

  135. ɹϨϓϦέʔγϣϯͷ֬ೝ ⾣4MBWF@42-@3VOOJOHɿ:&4 औಘͨ͠όΠφϦϩάͷ 42-࣮ߦͰ͖͍ͯΔ

  136. ɹϨϓϦέʔγϣϯखॱ ⾣ϚελʔͷEVNQΛऔಘ ⾣εϨʔϒͷNZDOGઃఆ ⾣εϨʔϒʹϦετΞ ⾣εϨʔϒઃఆมߋ ⾣ϨϓϦέʔγϣϯ࣮ߦ ⾣࣮ߦঢ়گΛ؂ࢹ

  137. ɹ࣮ߦঢ়گΛ؂ࢹ mysql> SHOW SLAVE STATUS\G **************** 1. row ************** Read_Master_Log_Pos:

    878873047 Exec_Master_Log_Pos: 605504154 Seconds_Behind_Master: 244615 ⾣࣮ߦ௚ޙ
  138. ɹ࣮ߦঢ়گΛ؂ࢹ mysql> SHOW SLAVE STATUS\G **************** 1. row ************** Read_Master_Log_Pos:

    878873047 Exec_Master_Log_Pos: 605504154 Seconds_Behind_Master: 244615 ⾣࣮ߦ௚ޙ mysql> SHOW SLAVE STATUS\G **************** 1. row ************** Read_Master_Log_Pos: 879066686 Exec_Master_Log_Pos: 879066686 Seconds_Behind_Master: 0 ⾣ಉظ׬ྃ
  139. ɹϨϓϦέʔγϣϯ·ͱΊ ⾣ෳ੡࡞੒ɾӡ༻׬ྃʂ ⾣ࢀরܥͷαʔόʔ४උ׬ྃʂ ⾣όοΫΞοϓαʔόʔ࡞੒׬ྃ

  140. ৼΓฦΓ

  141. શମͷৼΓฦΓ ⾣NZDOGઃఆ ຊདྷͷύϑΥʔϚϯεΛಘͨ ⾣ΫΤϦΩϟογϡଌఆ ܧଓ؂ࢹͷେࣄ͞Λ஌ͬͨ ⾣ϨϓϦέʔγϣϯ࣮ࢪ ৑௕Խͷ४උ͕Ͱ͖ͨ

  142. ՝୊

  143. ࠓޙͷ՝୊ ⾣ܧଓ؂ࢹͷ࢓૊Έ ֤छγΣϧͰରԠத ⾣ࢀরܥΛεϨʔϒʹ ϓϩάϥϜվमઃܭத ⾣ෆཁϨίʔυͷ࡟আ ϩάܥ  ஈ֊Λ౿ΜͰ࡟আܭըத

  144. Τϐϩʔά

  145. ઃఆ͔ͨ͠Β ऴΘΓͰ͸ͳ͍

  146. Πϯϑϥ͸ ϥΠϑαΠΫϧ͕௕͍

  147. ೔ʑͷ؂ࢹɾܭଌ͔Β ઌखΛଧͭʂ

  148. ܧଓ͸ྗͳΓ

  149. ࠓ೔Ұ൪ ఻͔͑ͨͬͨ͜ͱ

  150. Πϯϑϥʹಓʹೖͬͨ͹͔Γ ਖ਼௚ܟԕͯ͠·ͨ͠

  151. ͻΐΜͳ͜ͱ͔Βೖͬͨಓ͕ ࠓ͸ָͯ͘͠࢓ํ͕ͳ͍ʂ

  152. ΄ͱΜͲ1)1ॻ͍ͯͳ͍͠ ॻ͍ͯ΋γΣϧ

  153. WJN͔͠࢖Θͳ͍ͷͰ ຖ೔ࠇ͍ը໘

  154. ͔͠͠ʂ

  155. ਂ͘ߟ͑ ͭͣͭௐ΂ͯ ൓ө͢Δ

  156. ܭଌͯ݁͠ՌΛௐ΂ ࣍ͷखΛଧͭ

  157. ࡞ۀϩάΛ ϚʔΫμ΢ϯͰશͯه࿥

  158. ΤϯτϦʔʹ͢Δͱ͖ શ෦ௐ΂௚͢

  159. ϩʔΧϧʹ؀ڥߏஙΛ ΧδϡΞϧʹ͍ͯ͠Δ

  160. Ξ΢τϓοτ ָ͍͠ʂʂʂʂ

  161. ָ͍͠ʂʂʂʂ

  162. ΞϓϦΤϯδχΞ͔ͩΒͬͯ ΠϯϑϥΛ ଞਓ೚ͤʹ͠ͳ͍

  163. ΞϓϦΤϯδχΞ͔ͩΒͬͯ ϑϩϯτΤϯυΛ ଞਓ೚ͤʹ͠ͳ͍

  164. ੈքΛ޿͛Δ͜ͱ͸ ΤϯδχΞਓੜͷ޿͕Γ Λҙຯ͢Δ

  165. ஌Βͳ͍ΑΓ΋ ஌Δ΄͏ָ͕͍͠ʂ

  166. ੈքΛ޿͛ͯ ͜Ε͔Β΋ ָ͍͠ΤϯδχΞϥΠϑΛʂ

  167. ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ

  168. ͓·͚ ⾣ݩهࣄͷ͝঺հ ɾ.Z42-ύϑΥʔϚϯενϡʔχϯά ɹɹNZDOGͷݟ௚͠ ɹIUUQRJJUBDPNNBNZJUFNTDFBFFDD⒎B ɾ.Z42-ύϑΥʔϚϯενϡʔχϯά ɹɹΫΤϦΩϟογϡద༻ঢ়گͷ֬ೝ ɹIUUQRJJUBDPNNBNZJUFNTEEDGB ɾ.Z42-ϨϓϦέʔγϣϯઃఆ ɹɹखॱɾ֤छεςʔλεͷৄࡉͱτϥϒϧγϡʔςΟϯά

    ɹIUUQRJJUBDPNNBNZJUFNTBFEGBCGE