2. Backup with RMAN

Source: Internet
Author: User

Iv. Backup with RMAN
RMAN can be used to back up primary or backup databases, such as tablespaces, data files, archived logs, control files, and services.
File and backup set.
9
4.1 copy a file
The copy of the original file is a bit similar to OS hot backup. You can copy the entire data file to another location,
The results are only written to the hard disk, and separate files are separated.
Example of copying a file
Run {
Allocate channel D1 type disk;
Allocate channel D2 type disk;
Allocate channel D3 type disk;
Copy # first
Datafile 1 to '$ home/prd1.dbf ',
Datafile 2 to '$ home/prd2.dbf ';
Copy # Second
Datafile 3 to '$ home/prd3.dbf ';
SQL 'alter system archive log current ';
}
4.2 backup and backup set
Common backups of RMAN generate backup sets that can only be identified by RMAN. Therefore, apart from the Copy command
All other backups are backup sets generated by RMAN and corresponding backup slices.
An example of backing up a database, enabling two channels to back up a database to tape
Run {
Allocate channel T1 type 'sbt _ tape ';
Allocate channel T2 type 'sbt _ tape ';
Backup
Filesperset 2
Format 'df _ % T _ % S _ % P'
Database;
}
RMAN supports backup of multiple mirror phases.
Run {
Allocate channel D1 type disk;
Allocate channel D2 type disk;
Allocate channel D3 type disk;
Set backup copies 3;
Backup datafile 7 format'/tmp/% U ','? /Oradata/% U ','? /% U ';
};
The following is a common example of backup Archiving:
RMAN> SQL 'alter system archive log current ';
RMAN> Backup archivelog all Delete input;
RMAN> Backup archivelog from time '01-Jan-00 'until time '30-jun-00 ';
RMAN> Backup archivelog like 'oracle/ARC/DEST/log % ';
10
RMAN> Backup archivelog all;
RMAN> Backup archivelog from logseq 20 until logseq 50 thread 1;
RMAN> Backup archivelog from SCN 1 until SCN 9999;
In the RAC environment, because the database is shared, you can connect to an instance to back up the entire database,
However, because archive logs can be backed up locally, the backup of RAC archive logs becomes more complex.
Back up the archived logs of the two instances by connecting to the channels of the two instances.
Run {
Allocate channel node_c1 device type disk connect 'sys/pass @ dbin1 ';
Allocate channel node_c2 device type disk connect 'sys/pass @ dbin2 ';
SQL 'alter system archive log current ';
Backup archivelog all Delete input format'/u01/dbbak/% u _ % S. Bak 'filesperset = 5;
}
4.3 common backup Parameters
1. The keep parameter can maintain special backups or copies for a long time so that they are not affected by the default backup retention policy,
For example
RMAN> backup database keep until time
2> "to_date ('31-Mar-2002 ', 'dd _ mm_yyyy)" nologs;
RMAN> Backup tablespace sample keep forever nologs;
Nologs indicates that the archived logs since the backup can be retained. The default value is logs, indicating that the backup is retained
To make the backup permanently valid, you can use the forever parameter.
2. The tag parameter specifies the flag of the Backup set, which can be up to 30 characters in length, as shown in figure

RMAN> Backup Device Type disk datafile 1 tag
2> "wkly_bkup ";

Later than Oracle 92, RMAN automatically provides a tag in the format of tagyyyymmddthhmmss.
For example, tag20020208t133437 can be easily restored from the backup set by using the backup tag, as shown in figure
Restore database from tag = 'tagname'
4.4 Incremental Backup
Before describing Incremental backup, you must first understand the incremental and cumulative incremental backup differences, as well as the backup and recovery principles of Incremental backup.
Incremental differential backup is the default Incremental backup method.

Accumulative incremental backup
We can see that the incremental difference is the block changed since the backup of the upper level or the backup of the same level, and the cumulative increment is the block changed since the backup of the upper level. The cumulative incremental increase increases the backup time, but because data needs to be restored from fewer backup sets during recovery, in order to reduce the recovery time, cumulative Incremental backup is more effective than differential incremental backup.
No matter how Incremental backup is performed, in Oracle version 9, we still need to compare all the data blocks in the database. This process is actually a long process, in addition, because Incremental Backup forms multiple different backup sets, the recovery becomes more unreliable and slow, so Incremental Backup remains a weakness in version 9, unless it is a large data warehouse system, there is no need to select Incremental backup.

Oracle version 10 has made great improvements in Incremental backup, which can make Incremental Backup an incremental one. Because of the unique incremental log, so that RMAN does not need to compare every data block in the database. Of course, the cost is the IO and disk space of logs, which is completely not suitable for OLTP systems. In addition, version 10 combines the Incremental Backup results by combining backups, which completely reduces the recovery time.
Incremental Backup requires a foundation. For example, level 0 backup is the basic backup of all incremental backups, the difference between level 0 backup and full backup is that level 0 backup can be used as the basic backup for other Incremental backup, but full backup is not allowed. Do you want to choose Incremental backup as your backup policy, you need to have a clear understanding of yourself.

The following is an example of zero-level backup.
Backup incremental level 0 database;
Example of incremental Level 1 difference
Backup incremental Level 1 database;
Example of a cumulative Increment
Backup incremental Level 1 Cumulative database;
12
4.5 backup check
We can use the validate command to check whether the backup can be performed, such as whether the data file exists and whether there are bad blocks or not.
Can be backed up, such:
Backup validate database;
Backup validate database archivelog all;
4.6 restart backup
For backups with an exception ended, many people may not want to re-start the backup, especially back up to 90%
The backup is terminated due to an exception. What should I do? RMAN provides a method to start backup again.
After a simple command, you can back up less than 10% of the data.
RMAN> Backup not backed up since time 'sysdate-14'
2> Database Plus archivelog;
4.7 RMAN dynamic performance View
The following are some dynamic performance views related to RMAN backup. The information is obtained from the control file.
V $ archived_log
V $ backup_upload uption
V $ copy_uption
V $ backup_datafile
V $ backup_redolog
V $ backup_set
V $ backup_piece
V $ backup_device
V $ controlfile_record_section
There is also a view that can roughly monitor the degree of RMAN backup. Use the following SQL script,
The backup progress will be obtained.
SQL> select Sid, serial #, context, SOFAR, totalwork,
2 round (SOFAR/totalwork * 100,2) "% _ complete"
3 from V $ session_longops
4 where opname like 'rman %'
5 and opname not like '% aggregate %'
6 and totalwork! = 0
7. And SOFAR <> totalwork;
Sid serial # context SOFAR total work % _ complete
-------------------------------------------
13 75 1 9470 15360 61.65
12 81 1 15871 28160 56.36
13

Article Source: http://www.diybl.com/course/7_databases/oracle/Oracleshl/2008926/145855.html

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.