انتقل إلى المحتوى
أمين أبوزيد
MID-018

عمليات قواعد البيانات

  • 6 درس
  • 3 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • النسخ الاحتياطي
  • الاستعادة
  • أساسيات النسخ المتماثل (Replication)
  • المراقبة
  • الصيانة

تعلّم أولًا

3 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Take logical (pg_dump) and physical backups and restore them.
  2. Explain point-in-time recovery with WAL archiving.
  3. Explain streaming replication and read replicas, including replication lag.
  4. Monitor key database health indicators (connections, locks, cache hit ratio, replication lag, disk).

الدروس

  1. 01النسخ الاحتياطي: المنطقي مقابل الفيزيائي
  2. 02تمارين الاستعادة
  3. 03WAL والاستعادة إلى نقطة زمنية
  4. 04النسخ المتماثل ونسخ القراءة
  5. 05ماذا نراقب
  6. 06عرض عملي: الاستعادة إلى ما قبل DELETE خاطئ بخمس دقائق

المختبر والتمارين

Lab

MID-018-LAB1 · Restore drill

Outcomes: 1–4 · Time: ~3 h Back up Shop's database (logical and physical with WAL archiving), simulate data loss with a bad DELETE, restore with PITR to before the loss, and time every step. Set up a standby or read replica if your environment allows, and observe replication lag. Acceptance: a runbook plus a measured recovery time.

Exercises (assessment: runbook review)

IDOutcomeTask
MID-018-EX011Take a pg_dump in custom format and restore it into a new database with parallel jobs.
MID-018-EX021Compare logical and physical backups for a 2 TB database: size, restore time, portability.
MID-018-EX032List the settings and files needed to enable WAL archiving and recover to a point in time.
MID-018-EX042Given a base backup at 02:00 and a bad change at 14:05, give the recovery target and expected steps.
MID-018-EX053Explain why a read replica can return stale data after a write and propose two handling options.
MID-018-EX064Write a monitoring checklist of six indicators with a warning threshold for each.
MID-018-EX074Review a short runbook with three flaws (never tested, no timing, backups on the same disk) and correct it.
أظهر الحلول
  • EX01 pg_dump -Fc -f shop.dump shop; createdb shop2; pg_restore -d shop2 -j 4 shop.dump.
  • EX02 Logical: smaller to store maybe, slow restore (rebuilds indexes), portable across versions. Physical: fast, same major version, enables PITR.
  • EX03 wal_level suitable for archiving, archive_mode = on, archive_command (or library), a base backup; on restore restore_command, recovery_target_time, and recovery.signal (verify version).
  • EX04 Restore the 02:00 base backup, replay WAL to a target a little before 14:05 (for example 14:04), then promote.
  • EX05 Replication is asynchronous so the replica has not yet replayed the write. Options: read your own writes from the primary, or route by session or wait until the replica reaches the write's LSN.
  • EX06 For example: connections over 80%, replication lag over 30 s, disk over 80%, cache hit ratio under 99% for OLTP, idle-in-transaction over 1 minute, failed archive command. Thresholds are examples.
  • EX07 Add a scheduled restore test, record the measured time, copy backups to separate storage, and name an owner.
  • "Backups never restored" is addressed by EX01, EX07, and the lab.

الاختبار

Outcomes: O1 backups and restore · O2 WAL and PITR · O3 replication and lag · O4 monitoring.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1pg_dump produces a:O1
  2. 2The best proof that a backup works is:O1
  3. 3A physical backup can usually be restored to:O1
  4. 4PITR needs:O2
  5. 5WAL is:O2
  6. 6To undo a bad DELETE at 14:05 you set the recovery target to:O2
  7. 7Asynchronous replication means the replica:O3
  8. 8A replica protects against an accidental DROP TABLE:O3
  9. 9Reading your own write from a lagging replica may return:O3
  10. 10Which is a key health indicator?O4

الجزء العملي

Runbook review: find the gaps in a restore runbook (untested, untimed, same-host backups, missing WAL archive check). Pass: quiz 8/10, all gaps named with fixes, and the lab runbook with a measured recovery time.

أخطاء شائعة

Backups never restored; reading your own writes from a lagging replica.

التقييم

Runbook review.

الصلة بالمسار الوظيفي

Disaster recovery (SRC-013).

اكتب للبحث في المستويات والمراحل والوحدات والدروس.