47. RMAN in Details: - Agnivo102/Database_Architect GitHub Wiki
┌──────────────────────────────────────────────────────────────┐
│ RMAN CLIENT (connect to Traget DataBase │ //The RMAN client we connect
│ or optionaly a recover catalog │ to backup or restore database
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ RMAN CHANNEL (The channel which reads │ //The server session to read or backup data
│ or writes data │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Connects to database files │ //The source files, whose backup is taken
│ (Data files, Control files, Archived log files, SPfile) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐ //Backup destination where backup is kept
│ Writes the backup in backup destination │ (like /u01/backup/)
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐ //Metadata like the timestamp of the backup taken,
│ Repository update (Control file or recovery catalog) │ location of the backup, is avalable or expired etc
└──────────────────────────────────────────────────────────────┘ is written in control file or recovery catalog
│
▼
┌──────────────────────────────────────────────────────────────┐ //RMAN detarmines which backup is obsolete
│ Retention Evaluation │ according to recovery window and redundancy policy
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐ //Validation by crosscheck backup and v$rman_status
│ Monitor and Crosscheck │ dynamic view and list backup to see is they are
└──────────────────────────────────────────────────────────────┘ physically available or not.
│
▼
┌──────────────────────────────────────────────────────────────┐ //Restore Validate and validate database
│ Test Restore Readiness │ to check (?)
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐ //restore database, recover database
│ Recovery Use │ restore data from backup
└──────────────────────────────────────────────────────────────┘
RMAN repository or the repository of physical backup holds the metadata (data about data) information about the backup like when the backup was taken the exact time, the location of the backup etc.
This repository can be 2 things:
We know control file is the repository of the physical backup and holds all metadata information about backup.
This is another place which can be used as a repository for backup. This recovery catalog is a separate database schema, entirety dedicated for metadata about backup. This requires an extra database schema, their separate maintenance and backup. In return it keeps longer historical information about backups, centralized reporting, can be used to store scripts for backup, and will hold historical metadata even if the control file is lost.
The database that is being backed up or recovered.
Example Command: rman target /
External database schema for metedata regarding backup. This is optional.
Example Command: rman catalog rman@RCAT
The server session which does the backup and read and write operation on the storage.
Example Command: device type disk (?)
Physical file produced by backup
Example Command: backup datafile 1; Sample file: db_1.bkp
Logical RMAN backup containing one or more backup piece.
Example Command: backup database;
Copy of a datafile, control file or archived log (?)
Example Command: backup as copy database;
A level assigned to the backup file.
Example Command: backup datafile 1 tag 'Name'; OR backup incremental level 1 database tag 'Level_1_differential';
System change number, a number generated every nano second the database is active, used in many things, like to put the SCN of the commited DML sentence in control file and the header of data file to know which statements are commited. Here RMAN uses this for incomplete recovery and complete recovery (?) .
No longer required by configured retention policy.
Recorded in repository but the physical file got lost. Need crosscheck backup; to find them.
Physcal backup file exist now and its record exist in repository.
Storage Format: RMAN propritory backup pieces.
Compression: Supports RMAN compression.
Unused Block Skipping: (?) Supported
Restore required: Yes.
Typical Use: Standard Backup Strategy.
Storage Format: Exact copy of source file.
Compression: Normally same size as source.
Unused Block Skipping: (?) Not applicable in the same way.
Restore required: Can switch directly to copies.
Typical Use: Incrementally updated copy or fast switch over recovery ?.
Command: Backup as copy database.
backup as compressed backupset database;
backup archivelog all;
The session through whch backup input and output operations are done.
configure device type disk parallelism 3 backup type backupset;
run
{
allocate channel c1 device type disk;
backup database;
release channel c1;
}
run
{
allocate channel c1 device type disk;
allocate channel c3 device type disk;
allocate channel c3 device type disk;
backup database;
release channel c1;
release channel c2;
release channel c3;
}
configure channel device type disk format '/u05/rman/%d_%T_%U_%s_%p_%t_%c.bkp';
These are format variables. Their use is optional and can be used as you want. %d : Variable for Database Name. &T : Variable for date in YYYYMMDD Format %U : Garunteed unique backup piece name %s : Backup set number %p : Backup piece number within set %t : Backup set timestamp %c : Copy number
The location of the backup changed.
Retention policy is the settings RMAN keeps backup files of the database. It (?)
configure retention policy to recovery window of 10 days;
RMAN retains enough backups to recover the database to any point within the last 10 days (?)
configure retention policy to redundancy 2;
RMAN retains 2 complete backup generation. (?)
configure retention policy to none;
which one to report obsolete? (?)
report obsolete;
configure archivelog deletion policy to backed up 1 times to disk;
This means that after that arhive log is backed up 1 time in a backup file, the archive log will be deleted.(?)
RMAN Operation status and timing
Recent RMAN output in memory.
Backup job duration, size, throughput, status.
Backup set metadata.
Backup piece metadata.
Datafile backup records.
Archive log backup records.
Control file record usage and capacity.
Fast Recovery Area (FRA) Size and usage
FRA usage by file type.
rman target /
rman target sys@PROD
How to create a catalog database?
rman target / catalog rman_catalog@RCAT
Connect target /
sql 'select name, open_mode, log_mode from v$database';
(?)
A configuration is the set of setting for all the features of a tool.
This is what I set.
Requirement: Comfigure a 14 day recovery window, disk backup destination, 2 channels, compressed backup set, control file autobackup, archive log deletion after one successfull disk backup.
Step 1: To see the current configuration: show all
Step 2: For 14 days recovery window: configure retention policy to recovery window of 14 days;
Step 3: 2 channels, disk backup destination, and compressed backup set: configure device type disk parallelism 2 backup type to compressed backupset;
Step 4: Control file autobackup: configure controlfile autobackup on;
Step 5: Archive log deletion policy to delete after one succesful disk backup: configure archivelog deletion policy to backed up 1 times to disk;
Step 6: Validate: show all;
Previously the backup optimization (?) was turned off so i turned it on. And see the highlighted ones, it matches with the requirement.
sysdate - 1 (?)
Backup with tag and specific format and location: backup database tag 'tags' format = '/home/oracle/%d_%T_%U.bkp';
select session_key, input_type, status, start_time, end_time, elapsed_seconds, input_bytes_display, output_bytes_display, output_device_type, compression_ratio from v$rman_backup_job_details order by start_time desc fetch first 30 rows only;
select session_recid, session_stamp, operation, status, start_time, end_time, object_type, output_bytes from v$rman_status where start_time > sysdate - 7 order by start_time desc;
select recid, stamp, output from v$rman_output order by recid;
select sid, serial#, opname, sofar, totalwork, units, round(sofar * 100/nullif(totalwork,0),2) as pct_done, elapsed_seconds, time_remaining from v$session_longops where opname like 'RMAN%' and totalwork > 0 and sofar = totalwork order by start_time;
select handle, status, device_type, bytes/1024/1024 as size_mb, start_time, completion_time, compressed from v$backup_piece order by completion_time desc fetch first 50 rows only;
List backup;
List backup summary;
list backup of database;
list backup of archivelog all;
list copy;
list expired backup;
crosscheck archivelog all;
crosscheck copy;
crosscheck backup;
Catalog backuppiece 'name and location to the backup file';
This is similar to create directory for expdp and impdp.
Catalog start with '/u05/rman/';
Or
Catalog start with '/u05/rman/' noprompt;
No prompt is for not prompt the user to enter yes or no.
Delete expired backup;
Delete expired archivelog all;
Change backuppiece 'the name and path of the catalogged file' uncatalog;
Validate database;
Backup validate check logical database;
Restore database validate;
Restore controlfile validate;
Restore spfile validate:
Restore database preview;
Restore database preview summary;
Select file#, block#, blocks, corruption_change#, corruption_type from v$database_block_corruption order by file#, block#;
Configure controlfile autobackup on;
Backup current controlfile;
Backup spfile;
List backup of controlfile:
List backup of spfile;
Select type, record_size, records_total, records_used, first_index, last_index, last_recid from v$controlfile_record_section where type like 'BACKUP%' or type like 'ARCHIVED%' ordered by type;
Show parameter control_file_record_keep_time;
select input_type, status, elapsed_seconds, input_bytes_per_sec_display, output_bytes_per_sec_display, compression_ratio from v$rman_backup_job_details order by start_time desc fetch first 20 rows only;
1. Capture show all output.
2. Confirm database role, archivelog mode, fast recovery area, data gaurd status.
3. Review RPO, RTO, retention, archive deletion and offsite requirement. ?
4. Validate backup destintion capacity and throughput. ?
5. Confirm control file autobackup and SPFILE protection.
6. Plan rollback commands for every configure statement. ?
7. Test restore and recovery regularly. ?
select name, open_mode, log_mode, database_role, force_logging from v$database;
select name, space_limit/1024/1024/1024 as limit_gb, space_used/1024/1024/1024 as used_gb, space_reclaimable/1024/1024/1024 as reclaimable_gb from v$recovery_file_dest;
select file_type, percent_space_used, percent_space_reclaimable, number_of_files from v$recovery_area_usage order by file_type;
show all; crosscheck backup; crosscheck archivelog all; list backup summary, report obsolete;
list backup summary; list backup of database; list backup of archivelog all; restore database preview summary; report need backup recovery window of 14 days;