RMAN beginner's Guide

Source: Internet
Author: User
RMAN (recovery manager) is an important DBA tool used to back up, restore, and restore Oracle databases. Some time ago, some netizens asked me for it. Unfortunately, there was no time, I wrote it for the reference of beginners when I was on a business trip in the past two days. This article describes the basic operations of RMAN. For more information, see Oracle8i backup & Recovery guide and RMAN manual, or OCP student guide m09096 backup and recovery workshop volume 2, you can also contact me via gototop@ncn.cn. For the example provided by Oracle, see *. RCV script in the $ ORACLE_HOME/rdbms/demo directory.



I. Introduction to RMAN



RMAN can be used to back up and restore database files, archive logs and control files, or perform full or incomplete database recovery. RMAN has three different user interfaces: command line, Gui (Backup manager integrated in OEM), and API (used for integration into third-party backup software ). It has the following features:

1) functions are similar to physical backup, but they are n times more powerful than physical backup. We can see from the following features;

2) Empty blocks can be compressed;

3) increment can be achieved at the block level;

4) The backup output can be packaged into a backup set, or the backup set can be split by fixed size;

5) the backup and recovery process can be automatically managed;

6) scripts can be used (in recovery Catalog)

7) Monitoring of Bad blocks



Ii. Glossary

1) backup sets backup set

A backup set, as its name implies, is a set of backups. It contains all the copies of this backup and is saved in Oracle proprietary format. A backup set may constitute a full backup or Incremental Backup Based on Different backup types.

2) backup pieces

A backup set consists of several backup slices. Each backup file is a separate output file. The size of a backup slice is limited. If there is no size limit, the backup set is composed of only one backup slice. The size of the backup file cannot exceed the maximum file length supported by your file system.

3) image copies image backup

Image backup does not compress, pack, or directly copy independent files (data files, archived logs, and control files), similar to file backup at the operating system level. You can only copy data to disks, but not to tapes. It can be used as level 0 of Incremental backup and is generally used to back up control files.

4) Full backup

Full backup refers to the backup of data blocks used in data files. Unused data blocks are not backed up, that is, RMAN is compressed for backup.

5) Incremental Backup

Incremental Backup refers to the data block that has been modified since the last or lower-level backup in the backup data file. Same as full backup, Incremental backup is also compressed. Although the concept of Incremental backup is good and the backup is simple, it is another thing to restore, which is not only troublesome but error-prone, so it is rarely used in practice. We recommend that you stop using it when it comes to Oracle 9i, later versions will gradually remove support for Incremental backup.

6) Recovery catalog Restore directory

The recovery directory is used to record the control information during RMAN usage. The recovery directory should be synchronized frequently (This will be discussed later ). Although we can use RMAN in nocatalog mode, the control information is recorded in the control file of the target database, but this is not safe after all, if the control file of the target database is corrupted, all RMAN backups become invalid. In the same way, the recovery directory should be created in another database. In the following example, we call it "directory database ".



3. Create a recovery directory

1. Create and restore the tablespace used by the directory database

SQL> Create tablespace rmants datafile 'C: \ oracle \ oradata \ CC \ rmants. ora 'size 20 m;

The tablespace has been created.

2. Create and authorize the RMAN user in the directory database

SQL> create user RMAN identified by RMAN default tablespace rmants temporary tablespace temp quota

Unlimited On rmants;

User Created

SQL> grant recovery_catalog_owner to RMAN;

Authorization successful.

3. Create a recovery directory in the directory database

C: \> RMAN catalog RMAN/RMAN

Recovery MANAGER: Version 8.1.7.0.0-Production

RMAN-06008: connecting to recovery Catalog Database

RMAN-06428: Recovery directory Not Installed

RMAN> Create catalog tablespace rmants;

RMAN-06431: Recovery directory created

4. register the target database to the recovery directory

Note: here, the service name of my target database is rman, which means the database to be backed up using rman, And the Directory

The service name used by the database is CC.

C: \> RMAN target sys/sys @ RMAN

Recovery MANAGER: Version 8.1.7.0.0-Production

RMAN-06005: connect to target database: RMAN (dbid = 1303772234)

RMAN> connect catalog RMAN/RMAN @ CC

RMAN-06008: connecting to recovery Catalog Database

RMAN> Register database;

RMAN-03022: compiling command: Register

RMAN-03023: Executing command: Register

RMAN-08006: a database registered in the recovery directory

RMAN-03023: Executing command: Full Resync

RMAN-08002: Starting Resync for all recovery Directories

RMAN-08004: Finished all Resync

Now we have prepared all the preparations. Now we can use RMAN for backup and recovery.



Iv. Use RMAN

The following is an example to illustrate how to use RMAN. All RMAN operations except restoration will be involved here. For details about how to use RMAN for restoration, refer to another article I wrote earlier. Article : RMAN recovery practices.

1. Back up the entire database

RMAN> run {

2> allocate channel C1 type disk;

3> backup database format 'e: \ dbbackup \ 2db. dmp ';

4>}

2. Copy data files

RMAN> run {

2> allocate channel C1 type disk;

3> copy datafile 'C: \ oracle \ oradata \ RMAN \ users01.dbf' to 'e: \ dbbackup \ U. dbf' tag

= U1215;

4>}

3. View backup and copy information

RMAN> List backup;

RMAN-03022: compiling command: List

Backup set list

Keyword recid mark LV set mark set count completion time

-----------------------------------------------------------------------

216 1 417347013 0 417346992 1 26-December-00

Backup segment list

Keyword PC # cp # status completion time period name

----------------------------------------------------------------------

217 1 1 available 26-December-00 E: \ dbbackup \ 2db. dmp

Data File List

File Name LV checkpoint SCN checkpoint time

----------------------------------------------------------------------

1 c: \ oracle \ oradata \ RMAN \ system01.dbf 0 full 33224 26-January 1, December-00

2 c: \ oracle \ oradata \ RMAN \ rbs01.dbf 0 full 33224 26-January 1, December-00

3 c: \ oracle \ oradata \ RMAN \ users01.dbf 0 full 33224 26-January 1, December-00

4 c: \ oracle \ oradata \ RMAN \ temp01.dbf 0 full 33224 26-May 26-00

5 c: \ oracle \ oradata \ RMAN \ tools01.dbf 0 full 33224 26-August 1, December-00

6 c: \ oracle \ oradata \ RMAN \ indx01.dbf 0 full 33224 26-January 1, December-00

RMAN> List copy of datafile 'C: \ oracle \ oradata \ RMAN \ users01.dbf ';

RMAN-03022: compiling command: List

Data file backup list

Keyword File status completion time checkpoint SCN checkpoint time name

----------------------------------------------------------

226 3 A 26-December-00 33226 26-December-00 E: \ dbbackup \ U. DBF

4. Set related parameters during Backup

Format -- file output format,

% D -- Database Name,

% S -- backup sets sequence number,

% P -- backup pieces sequence number

Filesperset -- number of files included in each backup set

For more parameters, refer to the books listed at the beginning of this article.

RMAN> run {

2> allocate channel C1 type disk;

3> set limit channel C1 Kbytes 8000;

4> Backup

5> Format 'e: \ dbbackup \ dB _ % d _ % S _ % P. BCK'

6> (Database filesperset = 2 );

7>}

RMAN-03022: compiling command: Allocate

RMAN-03023: Executing command: Allocate

RMAN-08030: allocated channel: C1

RMAN-08500: Channel C1: SID = 9 devtype = Disk

RMAN-03022: compiling command: set limit

RMAN-03023: Executing command: set limit

RMAN-03022: compiling command: Backup

RMAN-03023: Executing command: Backup

RMAN-08008: Channel C1: Starting full data file backup set

RMAN-08502: set_count = 6 set_stamp = 417351064 creation_time = 26-December-00

RMAN-08010: Channel C1: Specifies the data file in the backup set

RMAN-08522: input data file fno = 00003 name = c: \ oracle \ oradata \ RMAN \ users01.dbf

RMAN-08522: input data file fno = 00005 name = c: \ oracle \ oradata \ RMAN \ tools01.dbf

RMAN-08013: Channel C1: 1 segment created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_6_1.bck comment = none

RMAN-08525: Backup set completed at: 00: 00: 03

RMAN-08008: Channel C1: Starting full data file backup set

RMAN-08502: set_count = 7 set_stamp = 417351067 creation_time = 26-December-00

RMAN-08010: Channel C1: Specifies the data file in the backup set

RMAN-08522: input data file fno = 00002 name = c: \ oracle \ oradata \ RMAN \ rbs01.dbf

RMAN-08522: input data file fno = 00006 name = c: \ oracle \ oradata \ RMAN \ indx01.dbf

RMAN-08013: Channel C1: 1 segment created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_7_1.bck comment = none

RMAN-08525: Backup set completed at: 00: 00: 04

RMAN-08008: Channel C1: Starting full data file backup set

RMAN-08502: set_count = 8 set_stamp = 417351071 creation_time = 26-December-00

RMAN-08010: Channel C1: Specifies the data file in the backup set

RMAN-08522: input data file fno = 00001 name = c: \ oracle \ oradata \ RMAN \ system01.dbf

RMAN-08011: the backup set includes the current control file

RMAN-08013: Channel C1: 1 segment created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_8_1.bck comment = none

RMAN-08013: Channel C1: 2 segments created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_8_2.bck comment = none

RMAN-08013: Channel C1: 3 segments created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_8_3.bck comment = none

RMAN-08013: Channel C1: 4 segments created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_8_4.bck comment = none

RMAN-08013: Channel C1: 5 segments created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_8_5.bck comment = none

RMAN-08013: Channel C1: 6 segments created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_8_6.bck comment = none

RMAN-08013: Channel C1: 7 segments created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_8_7.bck comment = none

RMAN-08525: Backup set completed at: 00: 00: 19

........

RMAN-08008: Channel C1: Starting full data file backup set

RMAN-08502: set_count = 9 set_stamp = 417351090 creation_time = 26-December-00

RMAN-08010: Channel C1: Specifies the data file in the backup set

RMAN-08522: input data file fno = 00004 name = c: \ oracle \ oradata \ RMAN \ temp01.dbf

RMAN-08013: Channel C1: 1 segment created

RMAN-08503: Segment handle = E: \ dbbackup \ db_rman_9_1.bck comment = none

RMAN-08525: Backup set completed at: 00: 00: 07

RMAN-03023: Executing command: Partial Resync

RMAN-08003: Start Resync for partial recovery Directories

RMAN-08005: completed partial Resync

RMAN-08031: released channel: C1

5. Use the Script Function

The purpose of using scripts is to facilitate our operations, which is similar to the stored procedure.

RMAN> Create script l0dbbackup {

2> allocate channel C1 type disk;

3> Backup

4> Format 'e: \ dbbackup \ dB _ % d _ % S _ % P. BCK'

5> (Database filesperset = 2 );

6>}

RMAN-03022: compiling command: Create script

RMAN-03023: Executing command: Create script

RMAN-08085: script l0dbbackup created

RMAN> run {execute script l0dbbackup ;}

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.