IT-Symposium 2005 www.decus.de 1
Page 1
Mike Dietrich
BU Database Technologies
ORACLE Deutschland GmbH
Mike Dietrich BU Database Technologies ORACLE Deutschland GmbH - - PDF document
IT-Symposium 2005 Mike Dietrich BU Database Technologies ORACLE Deutschland GmbH Page 1 www.decus.de 1 IT-Symposium 2005 Total synchron Daten retten ohne Downtime ?! Oracle DataGuard und Flashback Agenda Oracle Oracle DataGuard
IT-Symposium 2005 www.decus.de 1
Page 1
Mike Dietrich
BU Database Technologies
ORACLE Deutschland GmbH
IT-Symposium 2005 www.decus.de 2
Page 2
IT-Symposium 2005 www.decus.de 3
Page 3
–
Was kostet ein Ausfall pro Minute/Stunde/Tag ?
–
Was kostet Datenverlust ?
–
Wie sichtbar ist ein Ausfall ?
–
Wieviel Downtime ist gestattet ?
–
Wie stark sind die Nerven der DBA's ?
IT-Symposium 2005 www.decus.de 4
Page 4
Desaster Recovery Lösung für Oracle DB's Kostenfreies Feature der Oracle Enterprise Edition Automatisiert das Anlegen und den Betrieb einer
Ausfall der Produktionsdatenbank Standby-Datenbank übernimmt x1000km Entfernung möglich
IT-Symposium 2005 www.decus.de 5
Page 5
Datenbank-Releases
–
gleicher Release-Stand
–
gleiche Bit-ness
Betriebssystem-Releases
–
gleiches OS
–
unterschiedliche Bit-ness möglich, aber nicht empfohlen
–
unterschiedliche Release-Stände möglich, aber nicht empf.
Empfehlung:
–
identische Hardware, identische Betriebssysteme, identische Patchlevel, identische Oracle-Patches Primary Primary Site Site
Clients
Standby Standby Site Site Log Informationen Log Informationen
Broker Agent Broker Agent
Data Guard Broker
Clients
Backup
DIGITAL DATA STORAGEFailover/Switchover Failover/Switchover Gap Detection Gap Detection No Data Loss No Data Loss Protection Modes Protection Modes
IT-Symposium 2005 www.decus.de 6
Page 6
2 Typen von Standby-Datenbanken
– Physical Standby
Redolog-Dateien werden recovert Entweder Recovery Modus oder Read-Only Blockidentische Kopie der Produktionsdatenbank Desaster Recovery (Failover)
– Logical Standby
Redolog-Dateien werden extrahiert SQL-Statements werden auf die Standby angewendet Logische Kopie der Produktionsdatenbank Online Reporting, Rolling Upgrades
? 3 Möglichkeiten zur Administration
– Pures SQL – DataGuard Broker und DGMGRL – DataGuard Broker und EM GridControl
IT-Symposium 2005 www.decus.de 7
Page 7
init-Parameter LOG_ARCHIVE_DEST_n: VALID_FOR-Attribute
– erlaubt eine init.ora für alle Rollen – kein Tauschen der Init-Dateinen mehr nach Failover
– Beispiel:
*.log_archive_dest_2= 'SERVICE=phys LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES, ALL_ROLES) DB_UNIQUE_NAME=PHYS' Primary Primary Site Site
Clients
Standby Standby Site Site
Broker Agent Broker Agent
Data Guard Broker
REAL TIME APPLY REAL TIME APPLY
sofort angewendet
IT-Symposium 2005 www.decus.de 8
Page 8
RFS
Standby Redo Logs
ARCH
Archivierte Redo Logs Online Redo Logs
Oracle Net
Archivierte Redo Logs
Primär Datenbank
Transaktionen
LGWR ARCH Up-to-date Standby DB MRP/ LSP Real Time Apply
Engere Synchronisation der Standby mit der Poduktivdatenbank
– Up-to-Date Echt-Zeit-Reporting – Schnelles Switchover und Failover
Verringert geplante und ungeplante Ausfallzeiten Bessere Recovery Time Objective (RTO) beim Desaster Recovery Kein Delay !!!
USING CURRENT LOGFILE; Physical Standby
IMMEDIATE; Logical Standby
IT-Symposium 2005 www.decus.de 9
Page 9
Logische Korruptionen, die durch Benutzerfehler entstehen, sind für
verantwortlich !!!
Benutzer- Fehler Andere Ursachen für Ausfälle
IT-Symposium 2005 www.decus.de 10
Page 10
Traditioneller Ansatz:
Backup vom Tape einspielen Recovery mit archivierten Logfiles + Online Redologs
Fehler F e h l e r b e h e b u n g
t
Fehler Fehler- behebung
t
Mit Flashback:
Einfach die Daten zum Zeitpunkt X aus dem Flashback-Log wiederherstellen - ein Kommando !!!
3 Ausprägungen von FLASHBACK
– Flashback Query
Versions Query Transaction Query
– Flashback Table / Drop – Flashback Database
Point-In-Time-Recovery Kein Restore des Backups Nahtlose Integration in den RMAN
Undo Segmente Recycle Bin Flashback Logs
IT-Symposium 2005 www.decus.de 11
Page 11
Rückspulknopf
in der Datenbank
Enthält vorherige Blockinhalte
Flashback Log
Blockinhalt - vorherige Versionen geänderter Block Disk Write
Flashback Konfiguration:
Initialisierungsparameter (init.ora / spfile)
db_recovery_file_dest db_recovery_file_dest_size db_flashback_retention_target
[Default: 1440]
Flash Recovery Area SQL> ALTER DATABASE FLASHBACK ON; Festlegen der Vorhaltezeit
Flashback Log
IT-Symposium 2005 www.decus.de 12
Page 12
Real Time Apply
FLASHBACK ON FLASHBACK ON
IT-Symposium 2005 www.decus.de 13
Page 13
I. Flashback auf PHYS Standby
Ziel: Wiederherstellen von Daten
Ziel: PITR auf Produktion ohne Verlust der Standby
Ziel: kein Neuaufbau der Standby nach Failover
TRUNCATE TABLE
Daten wiederherstellen, keine Downtime auf PROD
1) PHYS mit FLASHBACK STANDBY DATABASE zurückfahren 2) PHYS read-only öffnen 3) Benötigte Daten exportieren 4) Automatische Resynchronisation der Standby 5) Daten auf PROD wieder einspielen
TRUNCATE TABLE
IT-Symposium 2005 www.decus.de 14
Page 14
PROD: PROD:
SQL> SQL> select select current_scn current_scn from from v$database v$database; ; SQL> SQL> truncate truncate table table scott.emp scott.emp; ; SQL> SQL> select select oldest_flashback_scn
from from v$flashback_database_log v$flashback_database_log; ; $> $> imp imp scott scott/ /tiger tiger file=exp.dmp file=exp.dmp
** Daten stehen wieder zur Verfügung ** ** Keine Downtime auf der PROD-DB **
PHYS: PHYS:
SQL> SQL> shutdown shutdown immediate; immediate; SQL> SQL> startup startup mount mount; ; SQL> SQL> flashback flashback standby standby database database to to scn scn <CURRENT_SCN von PROD>; <CURRENT_SCN von PROD>; SQL> alter SQL> alter database database open
read only
; $> $> exp exp scott scott/ /tiger tiger tables=emp tables=emp SQL> SQL> shutdown shutdown immediate; immediate; SQL> SQL> startup startup mount mount; ; SQL> alter SQL> alter database database recover recover managed managed standby standby database database using using current current logfile logfile disconnect disconnect; ; ** automatische Synchronisation **
SQL> SQL> select select current_scn current_scn from from v$database v$database; ; SQL> SQL> truncate truncate table table scott.emp scott.emp; ; SQL> SQL> select select oldest_flashback_scn
from from v$flashback_database_log v$flashback_database_log; ; SQL> SQL> shutdown shutdown immediate; immediate; SQL> SQL> startup startup mount mount; ; SQL> SQL> flashback flashback standby standby database database to to scn scn <CURRENT_SCN von PROD>; <CURRENT_SCN von PROD>; SQL> alter SQL> alter database database open
read only
; $> $> exp exp scott scott/ /tiger tiger tables=emp tables=emp SQL> SQL> shutdown shutdown immediate; immediate; SQL> SQL> startup startup mount mount; ; SQL> alter SQL> alter database database recover recover managed managed standby standby database database using using current current logfile logfile disconnect disconnect; ; ** automatische Synchronisation ** $> $> imp imp scott scott/ /tiger tiger file=exp.dmp file=exp.dmp
** Daten stehen wieder zur Verfügung ** ** Keine Downtime auf der PROD-DB **
IT-Symposium 2005 www.decus.de 15
Page 15
PITR
Point-In-Time-Recovery der PROD-Datenbank notwendig
Erhalt der Standby trotz RESETLOGS auf PROD
1) Flashback Database auf PROD als PITR 2) Öffnen der PROD mit OPEN RESETLOGS 3) RESETLOGS_CHANGE#-2 auslesen 4) FLASHBACK STANDBY DATABASE auf PHYS durchführen 5) Automatische Resynchronisation von PHYS
PROD: PROD:
SQL> select current_scn from SQL> select current_scn from v$database; v$database; SQL> update emp set sal=1; SQL> update emp set sal=1; SQL> commit; SQL> commit; SQL> shutdown abort; SQL> shutdown abort; SQL> startup mount; SQL> startup mount; SQL> flashback database to scn SQL> flashback database to scn <CURRENT_SCN von oben>; <CURRENT_SCN von oben>; SQL> alter database open SQL> alter database open resetlogs resetlogs; ; SQL> select SQL> select resetlogs_change# resetlogs_change#-
2 from v$database; from v$database; SQL> select sal from scott.emp; SQL> select sal from scott.emp;
** Daten stehen wieder zur Verfügung **
PHYS: PHYS:
SQL> shutdown immediate; SQL> shutdown immediate; SQL> startup mount; SQL> startup mount; SQL> flashback standby database SQL> flashback standby database to scn < to scn <RESETLOGS_CHANGE# RESETLOGS_CHANGE#-
2 P>; P>; SQL> shutdown immediate; SQL> shutdown immediate; SQL> startup mount; SQL> startup mount; SQL> alter database recover managed SQL> alter database recover managed standby database using current standby database using current logfile disconnect; logfile disconnect;
** automatische Synchronisation **
SQL> select current_scn from SQL> select current_scn from v$database; v$database; SQL> update emp set sal=1; SQL> update emp set sal=1; SQL> commit; SQL> commit; SQL> shutdown abort; SQL> shutdown abort; SQL> startup mount; SQL> startup mount; SQL> flashback database to scn SQL> flashback database to scn <CURRENT_SCN von oben>; <CURRENT_SCN von oben>; SQL> alter database open SQL> alter database open resetlogs resetlogs; ; SQL> select SQL> select resetlogs_change# resetlogs_change#-
2 from v$database; from v$database; SQL> select sal from scott.emp; SQL> select sal from scott.emp; ** Daten stehen wieder zur Verfügung ** SQL> shutdown immediate; SQL> shutdown immediate; SQL> startup mount; SQL> startup mount; SQL> flashback standby database SQL> flashback standby database to scn < to scn <RESETLOGS_CHANGE# RESETLOGS_CHANGE#-
2
Prod Prod>;
>; SQL> shutdown immediate; SQL> shutdown immediate; SQL> startup mount; SQL> startup mount; SQL> alter database recover managed SQL> alter database recover managed standby database using current standby database using current logfile disconnect; logfile disconnect; ** automatische Synchronisation **
IT-Symposium 2005 www.decus.de 16
Page 16
Failover von PROD nach PHYS ist erfolgt
Neuaufbau der Standby-Datenbank umgehen
1) Failover von PROD nach PHYS ist erfolgt - PHYSalt ist PRODneu 2) Flashback der PRODproblem bis STANDBY_BECAME_PRIMARY_SCN 3) Flashback Logs bereinigen 4) Standby-Controlfile anlegen 5) Log-Transport wiedereinschalten und ggf. Switchover
ex ex-
PROD/new-
PHYS:
SQL> shutdown immediate; SQL> shutdown immediate; SQL> startup mount; SQL> startup mount; SQL> flashback database to scn SQL> flashback database to scn < <STANDBY_BECAME_PRIMARY_SCN STANDBY_BECAME_PRIMARY_SCN>; >; SQL> alter database flashback off; SQL> alter database flashback off; SQL> alter database create standby SQL> alter database create standby controlfile as <file controlfile as <filename> name>; ; SQL> shutdown immediate; SQL> shutdown immediate; SQL> startup mount SQL> startup mount SQL> alter database flashback on; SQL> alter database flashback on; SQL> alter database recover managed SQL> alter database recover managed standby database using current standby database using current logfile disconnect; logfile disconnect;
** Jetzt kontrollierter Rollentausch ** ** (Switchover) möglich, um zur ** ** Ausgangssituation zurückzukehren **
ex ex-
PHYS/new-
Prod:
SQL> select SQL> select standby_became_primary_scn standby_became_primary_scn from v$database; from v$database; SQL> alter system set SQL> alter system set log_archive_dest_state_2=enable; log_archive_dest_state_2=enable;
SQL> select SQL> select standby_became_primary_scn standby_became_primary_scn from v$database; from v$database; SQL> shutdown immediate; SQL> shutdown immediate; SQL> startup mount; SQL> startup mount; SQL> flashback database to scn SQL> flashback database to scn < <STANDBY_BECAME_PRIMARY_SCN STANDBY_BECAME_PRIMARY_SCN>; >; SQL> alter database flashback off; SQL> alter database flashback off; SQL> alter database create standby SQL> alter database create standby controlfile as <file controlfile as <filename> name>; ; SQL> shutdown immediate; SQL> shutdown immediate; SQL> startup mount SQL> startup mount SQL> alter database flashback on; SQL> alter database flashback on; SQL> alter system set SQL> alter system set log_archive_dest_state_2=enable; log_archive_dest_state_2=enable; SQL> alter database recover managed SQL> alter database recover managed standby database using current standby database using current logfile disconnect; logfile disconnect;
** Jetzt kontrollierter Rollentausch ** ** (Switchover) möglich, um zur ** ** Ausgangssituation zurückzukehren **
IT-Symposium 2005 www.decus.de 17
Page 17
IT-Symposium 2005 www.decus.de 18
Page 18