Rman for Oracle Backup

Source: Internet
Author: User

1. Backup: Backup at file level during physical backup, backup at logical backup level, physical backup, logical backup as supplement.
Physical backups are divided into user-managed backups and Rman backups, which use the SQL command and the OS's CP command for file backups, which use the Rman tools.
Undo Segment: During the modification of a record, the state before the record modification is recorded in the Undo Segment, which is known as the pre-image (before images). When you need to undo a change such as executing a rollback, overwrite the existing record with the previous image. For insert operations, the front image is an empty record, and for update,delete operations, the pre-image is the state before the modification.
2. During the database recovery process, the log and undo segment work together, guaranteeing a consistent state of eventual recovery. Corresponds to two stages: roll Forward (Rollforward) and (rollback). In the roll forward phase, the log file is replayed on the file to restore the file to the state when the database is closed, but there may be many modifications that are not committed when the database is closed, and these operations need to be rolled back, which requires the use of Undo segment's content.
Rman is a client-side tool that does not itself perform real recovery work, and the real work is done by the server process on the servers, and when Rman connects to the database, it assigns a server process and it completes the backup recovery operation. The backup activity record can be placed in the control file of target database, or it can be stored in a separate catalog, which requires consideration of the catalog database backup strategy.
3.RMAN supports backup disks and tapes, and if you use a tape library, you need to do so through the vendor-provided media management library (media Management LIBRARY,MML).

Flash Recovery Area Space monitoring: When space usage reaches 90%, automatic deletion is triggered. The deletion process is recorded in alert, and if there is no space to release, and the space is used more than 85%, a warning log is logged, and if more than 97%, a critical warning log is logged, which can be from dba_outstanding_ See in the Alerts view. Image copy cannot be backed up to tape and can only be backed up to disk.
4. Backup and Recovery: The DBA makes a full backup of the database at the time of scn=100, and the subsequent database modifications are recorded in the log files (including archive logs and online log files). At scn=500 time, the database fails, such as the loss of data files due to storage media failure. At this point, you need to recover the scn=500 data file from the previous backup, then replay the log between 100--500 (these logs in the archive log and the online log file), and finally rollback the uncommitted changes with the undo content and eventually revert to scn= 500 of the consistent state continues to serve the outside. Specific processes such as:



5. Configure backup retention policies: Based on recovery windows and redundancy-based policies.
A. Policy based on recovery window: rman>configure Retention Policy to recovery window of 7 days;
The retained backup file must be guaranteed to revert to any point in time for nearly 7 days.
The recovery window is used to define the earliest point in time that the database can be recovered.
Assuming that the backup strategy is fully prepared once a week, 1th and 14th of the month are fully prepared, the Recovery window is defined as 7 days, and now the date is 23rd. For number 23rd, a recovery window of 7 days means that you can ensure that the database state is restored to 7 days ago (that is, number 16th). In order to achieve this goal
The full backup of number 14th and all archived logs after 14th must be retained, so Oracle evaluates the 1th backup, 1th to 14th archive log as expired (Obsolete) and can be deleted, while the 14th backup and archive log after 14th cannot be deleted.
B. Redundancy-based policy: Define a minimum of several backups per file
Rman>configure retention Policy to redundancy 2;
Keep at least 2 copies of each file, and if there are 3 backups, sort by time, and the oldest backup will be evaluated as expired (OBSOLETE) and can be deleted.
C. Other actions related to retention policies
(1) View backup strategy: rman>show retention policy;
(2) View expired obsolete file: Rman>report obsolete;
If the backup policy is not defined, report obsolete will report an error, rman>congfigure retention policy to none;
Rman>report obsolete;
rman-00571:===============================================
Rman-00569:===========error MESSAGE STACK follows=========
rman-00571:===============================================
(3) by specifying recovery Window:
Rman>report Obsolete Recovery window of 7 days;
(4) by specifying the redundancy policy:
Rman>report obsolete redundancy 2;
(5) Delete outdated files based on retention policy
Rman>delete obsolete;
(6) Specify the redundancy backup policy:
Rman>delete obsolete redundancy 2;
(7) Specify the deletion of the recovery window policy
Rman>delete Obsolete Recovery window of 4 days;
(8) Prohibit retention policy:
When the backup policy is disabled, all backups are not evaluated as expired (OBSOLETE)
Rman>configure retention policy to none;
6. Full Backup and incremental backup
In the case of backup set, the full backup is to back up all data blocks used in the data file, and if image copy is used, the full backup is a full copy of the data file. An incremental backup is a backup of a block of data that has changed since a particular point, which is generally referred to as the point in time of the last incremental backup. Incremental backups produce files that are backup Set,rman only for incremental backups of data files, control files, and daily log files that cannot be incrementally backed up. An incremental backup is a backup at the block level and is a backup of a block of data that has changed since the last incremental backup. This mechanism has two advantages. First, when the media is restored, it is possible to overwrite the contents of the data block directly with the contents of the data block in the backup set, and if the archive log is used to recover the required steps, it is better to use an incremental backup than
Recovery using archived logs is much faster; second, incremental backups can get data changes for nologging operations that are not logged, so incremental backups provide more data protection than just backing up the archive log.
7. Full Backup:
Rman>backup database;
Rman>backup as compressed backupset database;
Rman>backup as copy database;
Example: First configure the control file automatic backup, then configure the automatic backup control file location in/backup/test/autobackup/, file format%f, and finally the image copy of the database to do a full backup, backup files and data file name is the same.
run{
Configure Controlfile autobackup on;
Configure Controlfile autobackup format for device type disk to '/bakcup/test/autobackup/%f ';
Backup as Copy db_file_name_convert (' +data/wxxrzxm ', '/backup/test ') database;
}
After completing the database backup, automatically back up the control file, when using image copy mode backup, through the hope that the name of the backup file generated in the directory and the original file, this can be achieved through the Db_file_name_convert parameter. But note that the location of the keyword is before datafile or database.
Rman>backup as Copy db_file_name_convert= (' +data/wxxrzxm/datafile ', '/backup/test ') database;
If you want to back up the data files on ASM to ASM, this method may give an error. ORA-15046
Rman>backup as COPY db_file_name_convert (' +data/wxxrzxm/datafile ', ' +arch/wxxrzxm2/datafile ') database;
ASM is the use of OMF to manage data files, the data file name generated by the OMF method is tag_name.file_number.incarnation number format, where "incarnation number" is a number generated internally by Oracle to uniquely identify each file, and this value is not allowed to be specified manually. And the above command wants to be specified manually. This will result in an error.
You can use DBCA to create a database when you remove the OMF function, the way to remove OMF is to select the 2nd "Use Common location for all database Files".
8. Incremental backup
A. Incremental backup backs up only the changed content. Oracle is a block of data as the basic storage unit, each chunk of the block has an SCN, representing the latest version number. An incremental backup reads the SCN number for each data block and compares it to the checkpoint SCN at the time of the last backup, if the SCN of the data blocks is greater than or equal to the Checkponit SCN, this
The data block may have changed, and Rman will make a copy of the block and put it in the backup file. In previous releases, Oracle allowed to define multiple levels of incremental backups, only 0 and 12 levels were allowed in oracle10g, and level 0 was the equivalent of a full backup, but the full backup could not be used for the 0 level of incremental backups. Incremental backups can speed up recovery and reduce data loss, and you can enjoy the benefits of incremental backups regardless of the backup file format, or image copy, but only image copy will be able to use an incremental recovery backup. (Incrementally Updated Backup)
B. Incremental backup types
Incremental backup algorithms can be divided into two categories: differential incremental backup and cumulative incremental backup
C. Differential incremental backups (differential Incremental Backup)
The point of Backup is that the content of each backup is something that has changed since the last 0-or 1-level backup. For example, Sunday to do 0 levels of backup, Monday to Friday are 1 levels of backup, Monday back up is the day of the Monday changes, and so on.
Syntax for differential incremental backups: rman>backup incremental level=1 database;
D. Cumulative incremental backups (cumulative Incremental Backup)
The point is that each backup is a change that has occurred since the last level 0 or 1 backup. For example, Monday Backup is Monday changes, Tuesday Backup is Monday and Tuesday a total of 2 days of change, Wednesday backup is Monday, Tuesday, Wednesday a total of 3 days change. See figure below:



Cumulative incremental backup syntax: Rman>backup incremental level 1 cumulative database;
Level 0:
Rman>run {
Backup as Copy db_file_name_convert (' +data/wxxrzxm ', '/backup/test ') incremental level 0 database tag ' full_backup ';
}
Level 1:
Rman>run {
Backup incremental Level 1 cumulative for recover of copy with tag ' full_backup ' database;
Recover Coyp of database with tag ' full_backup ';
}
9.Block Change Tracing (block tracking)
A. Traditional incremental backup in order to obtain a block of data that needs to be backed up, all data blocks in the data file must be traversed, although incremental backups reduce the volume of the backup file, but the backup efficiency is not high.
Oracle provides a special file called the block change tracing file, which is logged whenever the data block changes, so that when Rman makes an incremental backup,
From this file, you can get a list of the blocks of data that need to be backed up without having to traverse all the blocks, thus increasing the efficiency of incremental backups.
B. Start block change tracing
The Block change tracing feature is turned off by default, enabling this feature
Sql>alter database enable block change tracing;
If you do not specify a file name, Oracle uses the default file location, which can be viewed from the view:
Sql>select * from v$block_change_tracking;
Manually specify the file location by command:
Sql>alter Database enable block change tracking using file '/U04/ORADATA/ORD/CHANGETRACKING/CHG01.DBF ';
After you start block change tracking, Oracle initiates a CTWR process that is responsible for tracking data changes.
Ps-ef|grep CTWR;
Close block Change Tracking
Sql>alter Database disable block change tracking;
(1) See if block change tracking is enabled
Sql>select * from v$block_change_tracking;
(2) 1 start function, specify file
Sql>alter Database enable block change tracking using file '/BACKUP/BCK ';
(3) Confirm the change to take effect
Sql>select * from v$block_change_tracking;
(4) Close function and confirm
Sql>alter Database disable block change tracking;
SELECT * from V$block_change_tracking;
10. Other Rman commands
Backing up the database: backup databases;
Backup archive log: Backup Archivelog all;
Back up the database, archive the log, and delete the archive log at the same time: Backup database plus archivelog delete input;
The Oracle 10g Backup command adds the duration clause to explicitly tell Oracle about the resource consumption allowed during the backup process, such as wanting to complete the backup within 2 hours:
Rman>backup duration the database;
If the backup task cannot be completed at a specified time, Rman runs out of error and ORA-19591 indicates that the reason for the error is due to exceeding the specified time range.
If you do not want this result, you can use the partial keyword, rman backs up as many files as possible, and files that are not backed up will be canceled. When using partial, Oracle recommends specifying the Fileperset 1 parameter at the same time, which guarantees that each backup file produced corresponds to a data file.
Rman>backup duration 0:05 Partial database Fileperset 1;
If the backup is not completed within the specified time, the incomplete backup task is canceled and the reservation has been completed.
When using the Duration statement, you can also specify the desired load state through the keyword minimize load/time. For example, minimize load is the minimum load that you want the backup to consume.
Rman>backup duration 0:01 Minimize load database;
Minimize time is expected to take a minimum of:
Rman>backup duration 0:01 Minimize time database;
11. Restore command
The recovery command for the database includes two stages of restore and recover, respectively, with the same name as the corresponding command.
In oracle10g, the Restore command adds a preview subcommand, which can be used to determine in advance which Rman will use those devices for recovery.
C:/>rman Target/
Rman>spool log to Abc.log;
Rman>restore datafile 1 Preview;
Rman>restore Database Preview Summary;
Rman>spool Log off;
rman>exit;
The output from the Restore DataFile 1 preview shows that Rman will select/BACKUP/TEST/SYSTEM01.DBF This backup file for recovery, but the required archive logs are missing.
12. View, check, and maintain backup records
Rman>list backup;
Rman>list copy;
If it is expired or x, the file is not available and may have been deleted from disk. However, Rman does not automatically check and must be checked using the Crosscheck command.
Rman>crosscheck copy; The output of the failed,succeeded indicates that the results are checked and then re-viewed with the list command, and this time the corresponding file status is x, which means that the disk files are no longer present.
Rman>delete expired copy;
13. View backup status from a view
2 new views in Oracle 10g: V$rman_output and V$rman_status, you can view the logs for each task from the first view, and a 2nd view can see the completion status of the backup task.
Sql>select output from V$rman_output;
To view the completion status of each backup task:
Select Command_id,row_type,operation,status from V$rman_status ORDER BY command_id Desc

Transferred from: http://blog.sina.com.cn/s/blog_a32eff2801011fhn.html

Rman for Oracle Backup

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.