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

プログラマのためのOracle DBA入門

プログラマのためのOracle DBA入門

第57回 CRL/Hで発表したスライドです。

Takuya Shibata

April 16, 2011
Tweet

More Decks by Takuya Shibata

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ •  H/N : γόλ(ૉఢͳ͓ͻ͛) •  Twitter : @stknohg • 

    Blog : http://d.hatena.ne.jp/stknohg/ •  ࡳຈͰಇ͘SIerͰ͢ɻ Πϯϑϥߏங͔Βɺઃܭɺ੡଄ɺอक·Ͱ͍Ζ͍Ζத్൒୺ʹ ΍͍ͬͯ·͢ɻ ̎̌̍̌೥ΑΓCLR/Hελοϑͱͯ͠׆ಈதɻ •  อ༗ࢿ֨ •  ORACLE MASTER Gold Oracle Database 10g •  σʔλϕʔεεϖγϟϦετ •  ଞ…
  2. DBAͷλεΫʢOracle Database؅ཧऀΨΠυΑΓҾ༻ʣ •  Oracle DatabaseαʔόʔͱΞϓϦέʔγϣϯɾπʔϧΛΠϯετʔϧ͓ΑͼΞοϓάϨʔυ ͠·͢ɻ •  σʔλϕʔεɾγεςϜʹγεςϜهԱҬΛׂΓ౰ͯɺকདྷͷهԱҬཁ݅Λܭը͠·͢ɻ •  ΞϓϦέʔγϣϯ։ൃऀ͕ΞϓϦέʔγϣϯΛઃܭͨ͠ޙɺϓϥΠϚϦɾσʔλϕʔεͷهԱ

    Ҭߏ଄ʢදྖҬʣΛ࡞੒͠·͢ɻ •  ΞϓϦέʔγϣϯ։ൃऀ͕ΞϓϦέʔγϣϯΛઃܭͨ͠ޙɺϓϥΠϚϦɾΦϒδΣΫτʢදɺ ϏϡʔɺࡧҾʣΛ࡞੒͠·͢ɻ •  ΞϓϦέʔγϣϯ։ൃऀ͔Βಘͨ৘ใʹج͖ͮɺඞཁʹԠͯ͡σʔλϕʔεߏ଄Λमਖ਼͠ ·͢ɻ •  ϢʔβʔΛొ࿥͠ɺγεςϜɾηΩϡϦςΟΛϝϯςφϯε͠·͢ɻ •  OracleͷϥΠηϯεܖ໿ʹै͍ͬͯΔ͜ͱΛ֬ೝ͠·͢ɻ •  σʔλϕʔεʹର͢ΔϢʔβʔɾΞΫηεΛ੍ޚ͠ɺ؂ࢹ͠·͢ɻ •  σʔλϕʔεͷύϑΥʔϚϯεΛ؂ࢹ͠ɺ࠷దԽ͠·͢ɻ •  σʔλϕʔε৘ใͷόοΫΞοϓ͓ΑͼϦΧόϦͷܭըΛཱͯ·͢ɻ •  ςʔϓ্ͷΞʔΧΠϒࡁσʔλΛϝϯςφϯε͠·͢ɻ •  σʔλϕʔεΛόοΫΞοϓ͓ΑͼϦετΞ͠·͢ɻ •  ٕज़αϙʔτʹ͍ͭͯOracleαϙʔτɾαʔϏεʹ࿈བྷ͠·͢ɻ
  3. ؀ڥ • ୯ҰͷαʔόɺΫϥΠΞϯτແ͠ • OS • Windows 2008 Server R2 SP1(64bit) • Standard Edition

    • σʔλϕʔε • Oracle Database 11g R2(11.2.0.1.0) • Standard Edition
  4. Oracleͷྺ࢙ ϦϦʔε όʔδϣϯ ಛهࣄ߲ 1978೥ Oracle version 1 ౰࣌ͷ໊ࣾ͸RSIࣾɻΞηϯϒϦͰ࣮૷ɻະϦϦʔεɻ 1979೥

    Oracle version 2 ࠷ॳͷ঎༻ϦϦʔεɻ 1983೥ Oracle version 3 ໊͕ࣾOracleʹมߋɻCͰ࠶࣮૷ɻ 1984೥ Oracle version 4 ಡΈऔΓҰ؏ੑͷαϙʔτɻ 1985೥ Oracle version 5 C/SରԠɻ 1988೥ Oracle version 6 PL/SQLɺߦϨϕϧϩοΫͷαϙʔτɻ 1992೥ Oracle 7 ετΞυϓϩγʔδϟɺτϦΨʔͷαϙʔτɻ 1997೥ Oracle 8 ΦϒδΣΫτࢦ޲ɺେ༰ྔσʔλʹରԠɻJava΁ͷίϛοτɻ 1998೥ Oracle 8i i͸ʮinternetʯͷུɻ 2001೥ Oracle 9i RAC(Real Application Cluster)ɻ 2002೥ Oracle 9i Release 2 ։ൃ؀ڥͷػೳڧԽͳͲɻ 2003೥ Oracle 10g g͸ʮgridʯͷུɻRACͷ֦ுɻASMɻϑϥογϡόοΫػೳɻ 2005೥ Oracle 10g Release 2 ֤छػೳڧԽͳͲɻ 2007೥ Oracle 11g Real Application Testingɻ 2009೥ Oracle 11g Release 2 Oracle Grid Infrastructureɻ
  5. ΫϥΠΞϯτϓϩηε هԱྖҬ Oracleͷ࢓૊Έ Πϯελϯε Ϧεφʔ αʔόʔϓϩηε όοΫ άϥ΢ϯυ ϓϩηε System

    Global Area (SGA) Program Global Area (PGA) ੍ޚϑΝΠϧ Redoϩά σʔλ ϑΝΠϧ ΞʔΧΠϒ ϩά ύϥϝʔλ ϑΝΠϧ
  6. System Global Area (SGA) •  Πϯελϯεʹର͢Δ੍ޚ৘ใ΍Ωϟογϡ౳ͷڞ༗ϝϞϦ ྖҬ •  ओͳྖҬ ྖҬ໊

    ಺༰ Shared Pool ղੳࡁΈSQL΍σʔλσΟΫγϣφϦͷ಺ ༰ΛΩϟογϡ Database Buffer Cache σʔλϒϩοΫͷΩϟογϡ Java Pool Javaίʔυ͓Αͼσʔλ༻ Large Pool େ༰ྔϝϞϦׂΓ౰ͯ༻ Redo Log Buffer Redoϩάॻ͖ࠐΈ༻ͷόοϑΝ
  7. ུশ ໊শ ಺༰ PMON ϓϩηεϞχλʔ ଞͷϓϩηεΛ؂ࢹ ϓϩηεϦΧόϦͷ࣮ࢪ SMON γεςϜϞχλʔ ΠϯελϯεϦΧόϦͷ࣮ࢪ

    ະ࢖༻ηάϝϯτͷΫϦʔϯΞοϓ DBWn σʔλϕʔεϥΠλʔ όοϑΝͷ಺༰ΛσΟεΫʹॻ͖ࠐΉ LGWR ϩάϥΠλʔ REDOϩάϑΝΠϧͷॻ͖ࠐΈ CKPT νΣοΫϙΠϯτϓϩηε νΣοΫϙΠϯτͰͷDBWnॻ͖ࠐΈࢦࣔ MMON ؅ཧੑϞχλʔϓϩηε ࣗಈϫʔΫϩʔυϦϙδτϦʢAWRʣʹؔ࿈ ͢ΔλεΫͷ࣮ࢪ ARCn ΞʔΧΠό ΞʔΧΠϒϩάͷॻ͖ࠐΈ JCQ0 δϣϒΩϡʔϓϩηε εέδϡʔϧδϣϒͷ࣮ߦ؅ཧ όοΫάϥ΢ϯυϓϩηε •  ओͳόοΫάϥ΢ϯυϓϩηε
  8. •  σʔλϕʔεΛߏ੒͢ΔϑΝΠϧ͸ҎԼͷ̏छྨ •  ͦͷଞϑΝΠϧ هԱྖҬ छྨ ಺༰ ಛهࣄ߲ ੍ޚϑΝΠϧ σʔλϕʔεͷ෺ཧߏ੒΍

    ϩάॱং൪߸౳Λอଘ͢ΔϑΝΠϧ ଟॏԽՄ RedoϩάϑΝΠϧ σʔλϕʔε΁ͷมߋΛه࿥ ॥؀ར༻ ଟॏԽՄ σʔλϑΝΠϧ σʔλΛอଘ͢Δ (Undoηάϝϯτʣ τϥϯβΫγϣϯதͷมߋΛه࿥͢Δ ϑΝΠϧ ॥؀ར༻ (Ұ࣌ηάϝϯτ) SQL࣮ߦ࣌ͷιʔτॲཧͳͲʹ࢖༻ छྨ ಺༰ ಛهࣄ߲ ΞʔΧΠϒϩά ݹ͍RedoϩάϑΝΠϧͷίϐʔ ύϥϝʔλϑΝΠϧ Πϯελϯεͷઃఆ৘ใΛอ࣋
  9. Program Global Area (PGA) •  αʔόʔϓϩηε͕࢖༻͢ΔϝϞϦྖҬ •  ओͳྖҬ ྖҬ໊ ಺༰

    SQL Work Area SQLͷιʔτ༻ϝϞϦྖҬ౳ Session Memory ηογϣϯ৘ใͷϝϞϦྖҬ Private SQL Area ղੳࡁΈSQL৘ใɺόΠϯυม਺౳ͷϝ ϞϦྖҬ
  10. oradim.exe • Πϯελϯεͷ࡞੒ɺमਖ਼ɺ࡟আΛߦ͏ •  ࡞੒ •  oradim.exe -new –sid {SID໊} …

    •  मਖ਼ •  Oradim.exe –edit –sid {SID໊} … •  ࡟আ •  Oradim.exe –delete –sid {SID໊} … • Πϯελϯεͷ࣮ମ͸WindowsαʔϏε (Oracle.exe)
  11. ϑΝΠϧγεςϜ • OracleͰ࢖༻Ͱ͖ΔϑΝΠϧγεςϜ 1.  OSͷϑΝΠϧγεςϜ •  NTFS౳ͷ͍ΘΏΔී௨ͷϑΝΠϧγεςϜ 2.  Automatic Storage ManagementʢASMʣ

    •  Oracleઐ༻ͷϑΝΠϧγεςϜ •  ઐ༻ͷϘϦϡʔϜ͕ඞཁ •  ؅ཧ༻ͷΠϯελϯε(ASMΠϯελϯε)͕ඞཁ
  12. ॳظԽύϥϝʔλ • σʔλϕʔεશମʹؔΘΔઃఆϑΝΠϧ •  PFILE •  ςΩετܗࣜͷઃఆϑΝΠϧ •  σʔλϕʔεىಈதʹϑΝΠϧͷมߋ͸Ͱ͖ͳ͍ •  SPFILE

    •  Oracle 9i͔Βొ৔ •  όΠφϦܗࣜͷઃఆϑΝΠϧ •  σʔλϕʔεىಈதʹϑΝΠϧͷมߋ͕Մೳ • جຊSPFILEΛѻ͏
  13. SGA/PGAʹؔΘΔύϥϝʔλ •  ৄࡉ͸ϚχϡΞϧ(Oracle Database ϦϑΝϨϯε)Λࢀর SGA/PGA ύϥϝʔλ ಺༰ SGA SGA_MAX_SIZE

    SGAͷ࠷େαΠζ SGA_TARGET ࣗಈ؅ཧ͢ΔSGAͷαΠζ DB_CACHE_SIZE σʔλϒϩοΫΩϟογϡͷαΠζ SHARED_POOL_SIZE ڞ༗ϓʔϧͷαΠζ LARGE_POOL_SIZE ϥʔδϓʔϧͷαΠζ JAVA_POOL_SIZE JAVAϓʔϧͷαΠζ STREAM_POOL_SIZE Stream PoolͷαΠζ LOG_BUFFER REDOϩάόοϑΝͷαΠζ PGA PGA_AGGREGATE_TARGET PGAͷूܭαΠζ PGA/SGA MEMORY_TARGET σʔλϕʔεશମͷϝϞϦαΠζ MEMORY_MAX_TARGET MEMORY_TARGETͷ࠷େ஋
  14. ෺ཧϑΝΠϧ/දྖҬ/ΦϒδΣΫτ දྖҬA DBF01 DBF02 DBF03 දྖҬB DBF04 DBF05 ςʔϒϧ A

    ςʔϒϧ B Πϯσο ΫεA Πϯσο ΫεB Πϯσο ΫεC Πϯσο ΫεD ςʔϒϧ C ςʔϒϧ D
  15. σʔλϕʔεͷىಈͱऴྃ • σʔλϕʔεͷىಈͱఀࢭʹ͸؅ཧऀݖݶ͕ඞཁ • ىಈ͸ STARTUP ίϚϯυ •  STARTUP NOMOUNT •  STARTUP

    MOUNT •  STARTUP (OPEN) • ఀࢭ͸ SHUTDOWN ίϚϯυ •  SHUTDOWN NORMAL •  SHUTDOWN TRANSACTIONAL •  SHUTDOWN IMMEDIATE •  SHUTDOWN ABORT
  16. هԱྖҬ σʔλϕʔεͷىಈ(NOMOUNT) Πϯελϯε όοΫ άϥ΢ϯυ ϓϩηε System Global Area (SGA)

    ύϥϝʔλ ϑΝΠϧ •  ύϥϝʔλϑΝΠϧ͕ಡΈࠐ·Εɺ SGA͕֬อ͞Εͨঢ়ଶ •  ੍ޚϑΝΠϧͷߏ੒ΛมߋՄೳ
  17. هԱྖҬ σʔλϕʔεͷىಈ(MOUNT) Πϯελϯε όοΫ άϥ΢ϯυ ϓϩηε System Global Area (SGA)

    ੍ޚϑΝΠϧ ύϥϝʔλ ϑΝΠϧ •  ੍ޚϑΝΠϧ͕ಡΈࠐ·Εͨঢ়ଶ •  REDOϩάϑΝΠϧɺσʔλϑΝΠϧ ͷߏ੒ΛมߋՄೳ
  18. ΫϥΠΞϯτϓϩηε هԱྖҬ σʔλϕʔεͷىಈ(OPEN) Πϯελϯε Ϧεφʔ αʔόʔϓϩηε όοΫ άϥ΢ϯυ ϓϩηε System

    Global Area (SGA) Program Global Area (PGA) ੍ޚϑΝΠϧ Redoϩά σʔλ ϑΝΠϧ ύϥϝʔλ ϑΝΠϧ •  σʔλϑΝΠϧɺREDOϩάϑΝΠϧ͕Φʔϓ ϯ͞Εɺσʔλϕʔε͕׬શʹىಈͨ͠ঢ়ଶ
  19. σʔλϕʔεͷऴྃ NORMAL TRANSACTIONAL IMMEDIATE ABORT ઀ଓηογϣϯͷ ऴྃ଴ͪ ͢Δ ͠ͳ͍ (ڧ੍੾அ)

    ͠ͳ͍ (ڧ੍੾அ) ͠ͳ͍ (ڧ੍ऴྃ) τϥϯβΫγϣϯͷ ऴྃ଴ͪ ͢Δ ͢Δ ͠ͳ͍ (ROLLBACK) ͠ͳ͍ (ڧ੍ऴྃ) νΣοΫϙΠϯτͷ ࣮ߦ ͢Δ ͢Δ ͢Δ ͠ͳ͍ (ڧ੍ऴྃ) σʔλϑΝΠϧͷ Ϋϩʔζ ͢Δ ͢Δ ͢Δ ͠ͳ͍ (ڧ੍ऴྃ)