Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> ฐานข้อมูล

เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

Part หนึ่งของซีรีส์ให้บทนำเกี่ยวกับ Oracle® Refreshable Clones รวมถึงเมื่อและทำไมถึงใช้ ในโพสต์นี้ ผมสาธิตวิธีตั้งค่า กำหนดค่า บำรุงรักษา และ Drop Refreshable Clone Pluggable Database (PDB) ใน Oracle 18c

Prerequisites สำหรับ Refreshable Clone PDB

เพื่อติดตามการสาธิตนี้ ให้ทำ Prerequisites ต่อไปนี้:

  1. มี Database Link สำหรับ Refreshable Clone ที่สร้างใหม่ ชี้ไปยัง Local หรือ Remote Container
  2. ตั้งค่า archive_log_mode เป็น enabled
  3. ใช้ Engineered System หรือ Enterprise Edition (EE) Oracle Cloud หากไม่มีใน Platform หรือ Version เดียวกัน ให้ตั้งค่า Hidden Parameter _exadata_feature_on เป็น True สำหรับการสาธิตนี้
  4. ตั้งค่า local_undo_mode เป็น enabled

คุณสามารถตั้งค่า Refreshable PDB ในโหมด CLOSED หรือ OPEN READ ONLY และในโหมด OPEN READ ONLY สำหรับ Queries หลัง Refresh

Environment

สำหรับการสาธิตนี้ ตรวจสอบให้แน่ใจว่าสภาพแวดล้อมของคุณสอดคล้องกับ Specifications ต่อไปนี้:

  • ติดตั้ง Oracle 18c และทำ Prerequisites บน Machine และ Database
  • สำหรับบทบาท Production Database:
    • ตั้งค่า Container Database (CDB) Name: YCDB1
    • ตั้งค่า PDB Name: PURCH_PDB
  • สำหรับบทบาท Refreshable Clone PDB:
    • ตั้งค่า CDB Name: XCDB1
    • ตั้งค่า PDB Name: PDB2_REFRO
    • ตั้งค่า PDB ให้ Refresh อัตโนมัติทุก 30 นาที
  • สร้าง Public Database Link โดยใช้ create_pdb บน XCDB Link ควรชี้ไป PURCH_PDB บน YCDB

- Execute TNS Commands ต่อไปนี้:

purch_pdb=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = tejashost2.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = purch_pdb))) XCDB1=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = tejashost2.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XCDB1))) YCDB1=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = tejashost2.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = YCDB1))) 

Demonstration

การสาธิตนี้ดำเนินกิจกรรมต่อไปนี้:

  • ตั้งค่าสภาพแวดล้อม
  • หา Refresh Mode ของ Production Database
  • แสดงวิธี Refresh Mode ของ Refreshable Clone รวมถึง Disable Refresh บน Refreshable Clone
  • Switch ระหว่าง Production และ Refreshable Clone

ตั้งค่าสภาพแวดล้อม Refreshable Clone:

สำหรับสภาพแวดล้อม Refreshable Clone ให้ดำเนินการต่อไปนี้

Actions บน YCDB1:

  1. สร้าง Production Database และเปิดมัน
เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs
  1. Import ข้อมูลจาก EXPDP Dumps ที่คุณสร้างโดยใช้ impdp Utility หรือ Import HR Schema เข้า PURCH_PDB สำหรับตัวอย่างนี้ Import HR Schema โดยรัน Script ต่อไปนี้บน Database:
 @?/demo/schema/human_resources/hr_main.sql 

หลังจากเสร็จสิ้น ให้ Validate HR Schema Details ตามรูปต่อไปนี้:

เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

Actions บน XCDB1:

  1. สร้าง Database Link ชี้ไปยัง Production Database PURCH_PDB
  2. สร้าง Refreshable PDB ตั้งค่า Refresh Period ทุก 30 นาที และ Validate ว่าข้อมูล Refresh แล้ว

คุณสามารถใช้ Attributes ทั้งหมดเมื่อคุณสร้าง PDB ที่คุณวางแผนจะใช้สร้าง Database ในตำแหน่งอื่น ตัวอย่างเช่น เพื่อแก้ไขตำแหน่ง PDB Datafile ใช้ CREATE_FILE_DEST หรือ FILE_NAME_CONVERT

การเพิ่มเติมเดียวคือ Attribute REFRESH MODE เพื่อทำให้การสาธิตนี้ง่ายขึ้น ผมไม่ได้เพิ่ม Optional Attributes ใดๆ

เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

หา Refresh Mode และรายละเอียด Production Database

คุณสามารถ Query ตาราง DBA_PDBS เพื่อตรวจสอบรายละเอียดของ Refreshable PDB Mode, Status, Last Refresh SCN และรายละเอียด Production Database ต้นทาง สำหรับ PDB PDB2_REFRO ตรวจสอบ Output ตามตัวอย่างต่อไปนี้:

เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

หลังจากคุณทำ Task เสร็จ คุณควรแปลง Refreshable PDB กลับเป็นโหมด MOUNTED เพื่อ Refresh ต่อเนื่องตามตารางเวลา ใช้คำสั่งต่อไปนี้เพื่อทำกิจกรรมนี้ open_mode.sql ที่ใช้ที่นี่คือ Query เพื่อตรวจสอบ Open Mode ปัจจุบันของ Database

คุณอาจเห็น Error ต่อไปนี้หากคุณไม่ปิด Database Instance สำหรับ Refresh:

ORA-65025: Pluggable database is not closed on all instances 
เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

เปลี่ยน Refresh Mode ของ Refreshable Clone

คุณสามารถเปลี่ยน Mode ของ Refreshable Clone ได้ดังนี้:

  • เปลี่ยน Manual Refresh เป็น Automatic Refresh
  • เปลี่ยน Automatic Refresh เป็น Manual Refresh
  • Disable Refresh จาก Automatic หรือ Manual Refresh Mode

แปลง Manual Refresh เป็น Automatic Refresh และในทางกลับกัน

หมายเหตุ: คุณไม่สามารถเปลี่ยน PDB Refresh Mode เมื่อ Logged Into PDB อื่น ตัวอย่างเช่น คุณไม่สามารถเปลี่ยน Mode ของ XPDB ขณะ Logged Into YPDB หากคุณลอง Error ต่อไปนี้จะเกิดขึ้น:

ORA-65118: operation affecting a pluggable database cannot be performed from another pluggable database. 
เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

ใน Manual Refresh Mode คุณสามารถ Refresh Cloned PDB ของคุณได้ตามต้องการโดยใช้คำสั่งต่อไปนี้:

เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

Disable PDB Refresh และแปลง Read-Only Clone เป็น Read-Write Database

คุณสามารถ Disable Refresh Mode ของ PDB เพื่อแปลง Refreshable Clone ของคุณเป็น Read-Write Mode

หมายเหตุ: หลังจากคุณ Disable Refresh สำหรับ Pluggable Database คุณไม่สามารถ Enable มันได้อีก คุณต้อง Re-create PDB เพื่อให้มันเป็น Refreshable PDB หากคุณลองแปลงจาก Refresh Mode NONE เป็น Refresh Mode คุณจะได้ Error ต่อไปนี้:

ORA-65261: pluggable database PDB2_REFRO3 not enabled for refresh. 
เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

หลังจาก Disable Refresh แล้ว PDB มี Read-Write Access

เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

Switch จาก Production ไป Refreshable Clone และในทางกลับกัน

ก่อน Oracle 18c คุณต้องทำทุกขั้นตอนสำหรับ Switchover Role รวมถึง Shut Primary และเปิดเป็น Read-Only

ในการสาธิตนี้ ผมทำดังนี้:

  1. สร้าง User C##SWITCHUSER บน Container Databases XCDB1 และ YCDB1 โดยใช้ Grant Connect, sysoper
  2. สร้าง Database Link dblink ชี้ไป Container Database อื่น ใน YCDB1 สร้าง dblink XCDB1SYSOPER เพื่อเชื่อมต่อ XCDB1 ใช้ Database Views DBA_DB_LINKS and V$DATABASE เพื่อรวบรวมรายละเอียด Database หลังสร้าง Database Link
  3. เปิด Refreshable Clone Database เป็น Read-Only
  4. รันคำสั่ง Switchover
  5. Validate Database Status และ Open Mode หลัง Switch Production และ Refreshable Clone Databases

Actions บน YCDB1 (ต่อ):

Complete Prerequisites 1 ถึง 3 ก่อน Execute คำสั่ง Switchover

Database Link Details:

เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

Actions บน XCDB1 (ต่อ)

ตรวจสอบ Database Link Details และหา Database Open Mode โดยใช้ DBA_DB_LINKS และ V$DATABASE

เชี่ยวชาญ Oracle Refreshable Clones: Demo ขั้นตอนสำหรับ 18c PDBs

หลังจาก Switchover เสร็จสิ้น Original Source PDB PURCH_PDB กลายเป็น Refreshable Clone PDB PDB นี้อยู่ใน Status MOUNT ปัจจุบัน และจากนี้คุณสามารถเปิดมันได้เฉพาะโหมด READ ONLY เท่านั้น ในทางกลับกัน Original Refreshable Clone PDB PDB2_REFRO ตอนนี้เปิดในโหมด READ หรือ WRITE และทำหน้าที่เป็น Source PDB

สรุป

คุณไม่ควรพิจารณาคุณลักษณะ Refreshable Clone PDB เป็นการแทนที่ Data Guard จากมุมมอง High Availability อย่างไรก็ตาม คุณสามารถใช้ Refreshable Clone เพื่อ Maintain Replica Database บน Server อื่น

โพสต์นี้อธิบายวิธีใช้ Refreshable PDBs เป็น Replicas เพื่อให้คุณสามารถ Resume การดำเนินงาน Low-Load, Non-Critical Applications ได้ ไม่ว่าจะเป็น Planned หรือ Unplanned Event โปรดทราบ คุณควรพิจารณา Switchovers จากมุมมอง Recovery Time Objectives (RTOs, เวลาในการ Resume Operations) และ Recovery Point Objectives (RPOs, เช่น การบรรลุ Minimal Data Loss)

ใช้แท็บ Feedback เพื่อแสดงความคิดเห็นหรือถามคำถาม คุณยังสามารถแชทได้ทันทีเพื่อเริ่มการสนทนา

เรียนรู้เพิ่มเติมเกี่ยวกับ Databases