Beruflich Dokumente
Kultur Dokumente
Ravi Poruri
June 10, 2008
Yahoo! Confidential 1
Agenda
Types of failures and backups in Oracle RMAN Architecture Manual vs. RMAN backups On-tape backups with RMAN RMAN Configuration RMAN backup strategies RMAN backup examples Reporting from RMAN Validate Backups
2
Yahoo! Confidential
Types of failures
Types of failures
Instance Failure Usually connected with an Oracle process failure Media Failure Disk failure, storage array controller failure etc. Block Corruption Usually caused by bugs in Oracle software Human error In most cases accidentally deleted/updated data Database user or DBA Disaster Fire, flood, earthquake, plane crash etc.
Yahoo! Confidential
Yahoo! Confidential
SGA
Backup proc.
LGWR
RedoLog
Log archiver
Db file
RedoLog
Yahoo! Confidential
RMAN architecture
Target Database
Target Database
Auxiliary Database
Catalog Database
Yahoo! Confidential
Differential incremental
Yahoo! Confidential
Cumulative incremental
9
Yahoo! Confidential
11
Yahoo! Confidential
12
Yahoo! Confidential
13
Bitmap Extents
1 header + 63 bitmap blocks (32 KB) Every bitmap block provides 488 bytes or 3904 bits; i.e. 3904 chunks covered 1 bitmap block serves 122 MB of space in datafile 1 bitmap extent can track 7686 MB of data Extents allocated when file resized 7 versions kept Every version occupies separate extents
Yahoo! Confidential
14
Yahoo! Confidential
15
Yahoo! Confidential
16
Yahoo! Confidential
17
RMAN Configuration
RMAN can be preconfigured Configuration is stored in the control file and in the recovery catalog (if used) Can facilitate backup automation
to disk
off none unlimited
to sbt
off sbt parms=... depends on your database size
18
The SHOW ALL command lists all RMAN configuration settings To clear a given settings append CLEAR at the end of the CONFIGURE command
Yahoo! Confidential
19
Yahoo! Confidential
20
run { crosscheck archivelog all; backup force tag some_tag_0T' incremental level 0 check logical database force format '%d_%T_%U_lvl0T' plus archivelog format '%d_%T_%U_lvl0Tarch'; delete noprompt force archivelog all completed before sysdate - 2"; } run { crosscheck archivelog all; backup tag some_tag_1D' incremental level 1 database format '%d_%T_%U_lvl1D' plus archivelog format '%d_%T_%U_lvl1Darch'; delete noprompt force archivelog all completed before sysdate 2; }
Yahoo! Confidential
22
run { backup maxsetsize 2047G tag ' DB_Copy_tag' device type disk incremental level 1 for recover of copy with tag DB_Copy_tag database; recover device type disk copy of database with tag DB_Copy_tag until time sysdate -2 ; delete force noprompt backupset device type disk tag DB_Copy_tag completed before sysdate -2; }
Yahoo! Confidential
23
Yahoo! Confidential
24
The most typical recovery in case of systems implementing SAME approach If done after a disaster it has to be preceded by:
Hardware configuration OS and Oracle software installation Re-creation or restore from non-RMAN backup of listener.ora, tnsnames.ora and other important configuration files ASM instance and diskgroup configuration (if needed) MML installation and configuration ...
Requires
Spfile restore Controlfile restore Datafiles restore and recovery
Yahoo! Confidential
25
set dbid=xxxxxxx startup nomount; run { allocate channel c1 device type disk|sbt; restore spfile to some_location from autobackup; recover database; alter database open resetlogs; } shutdown immediate; startup nomount; run { allocate channel c1 device type disk|sbt; restore controlfile from autobackup; alter database mount; } run { set until time = "to_date(09-Jun-2008 00:00:00','dd-mon-yyyy hh24:mi:ss')"; allocate channel c1 device type disk|sbt; allocate channel c2 device type disk|sbt; restore database check readonly; recover database; alter database open resetlogs; }
Yahoo! Confidential 26
Yahoo! Confidential
27
ORA-01578: ORACLE data block corrupted (file # 19, block # 44) ORA-01110: data file 19: d:\oracle\oradata\data\mydb_maintbs_01.dbf run { allocate channel c1 device type disk|sbt; blockrecover datafile 19 block 44; }
Yahoo! Confidential
28
run { sql alter tablespace users offline; allocate channel c1 device type disk|sbt; restore tablespace users; recover tablespace users; sql alter tablespace users online; }
Yahoo! Confidential
29
Yahoo! Confidential
30
CATALOG command
Add backup pieces and image copies on disk to repository so they can be used in restores and recoveries Record backup images (i.e. COPY command in RMAN) as INCREMENTAL LEVEL = 0 backups
Yahoo! Confidential
31
CHANGE command
To change the status of backups, copies, and archived logs in the repository to AVAILABLE or UNAVAILABLE. This feature is useful when a previously unavailable file is made available again, or you do not want a specific backup or copy to be eligible to be restored but also do not want to delete it. To alter the repository status of usable backups and copies from prior incarnations (i.e. prior to RESETLOGS) To remove catalog records for backups and copies, and update the corresponding records in the target control file to status DELETED. This feature is useful when you remove a file by using an operating system command rather than the RMAN DELETE command, and want to remove its repository record as well.
Yahoo! Confidential
32
DELETE command
Delete backupsets and/or image-copies on disk or tape
DELETE [ OBSOLETE | EXPIRED ]
Update backupset piece records in the target control file to status DELETED, regardless of the state of the backupset piece
DELETE FORCE
Remove their repository records from the recovery catalog (if you use a catalog)
DELETE FORCE
Yahoo! Confidential
33
CROSSCHECK command
Verify the status of backups and copies recorded in the RMAN repository against media such as disk or tape 1. Read entries in the repositories
Connect NOCATALOG or CATALOG
Yahoo! Confidential
34
RESYNC command
Synchronize information between control files and recovery catalog Can also be used to completely repopulate the recovery catalog from a backup controlfile, if desired When you run RESYNC CATALOG, RMAN creates a snapshot control file in order to obtain a read-consistent view of the control file, then updates the recovery catalog with any new information from the snapshot.
Yahoo! Confidential
35
LIST command
To display information about backup sets, proxy copies, and image copies recorded in the repository Displays files against which you can run CROSSCHECK and DELETE
commands
Yahoo! Confidential
36
REPORT command
Use the REPORT command to answer questions such as the following: Which datafiles need a backup?
REPORT NEED BACKUP;
What was the physical schema (i.e. datafiles and tablespaces) of the database at a previous time?
REPORT SCHEMA AT [ SCN | SEQUENCE | TIME ]
Yahoo! Confidential 37
Examples
Back up the database, and then the control file: (which contains a record of the backup) RMAN> BACKUP DATABASE; RMAN> BACKUP CURRENT CONTROLFILE; Backup datafiles: RMAN> BACKUP AS BACKUPSET DATAFILE 'ORACLE_HOME/oradata/trgt/users01.dbf', 'ORACLE_HOME/oradata/trgt/tools01.dbf'; Backup all datafiles in the database: (bit-for-bit copies, created on disk) RMAN> BACKUP AS COPY DATABASE;
Yahoo! Confidential
38
Examples
Backup archive logs
RMAN> BACKUP ARCHIVELOG COMPLETION TIME BETWEEN 'SYSDATE-28' AND 'SYSDATE-7';
Backup tablespace
RMAN> BACKUP TABLESPACE system, users, tools;
Backup controlfile
RMAN> BACKUP CURRENT CONTROLFILE TO '/backup/cntrlfile.copy';
Backup everything:
RMAN> BACKUP BACKUPSET ALL;
Yahoo! Confidential
39
Validate Backups
Backup Validation confirms that a backup could be run, by confirming that all database files exist and are free of physical and logical corruption, this does not generate any output
RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;
Yahoo! Confidential
40
Restore Validate
RESTORE... VALIDATE causes RMAN to check whether the set of available backups is sufficient to restore the specified database objects.
Example: RESTORE TABLESPACE TBS_1 VALIDATE selects backups sufficient to restore the named tablespace, just as RMAN does in a real restore operation, and reads the backups to ensure that they are present and not corrupted.
Yahoo! Confidential
41
42
Yahoo! Confidential
43