Note that turns from a great God.
RMAN Beginner's Guide
This article was written last year, originally published in Chinaunix.net's Oracle forum, included in the old version of the anthology, may not be seen, there is always someone to write to, today by the revision of the occasion to take it out alone.
RMAN (Recovery Manager) is an important tool for DBAs to back up, restore and restore the Oracle database, a period of time before a netizen to find me, but no time, while these two days on business out of nothing, wrote a bit, for beginners friends reference. This article describes the basic operations of Rman, for more information, refer to the Oracle8i Backup & Recovery Guide and the Rman Manual, or the OCP Student guides M09096 Backup and Recovery Wor Kshop "Volume 2, can also be [email protected] and I contact. The Oracle comes with an example that references the *.RCV script in the $oracle_home/rdbms/demo directory.
I. Introduction of RMAN
RMAN can be used to back up and restore database files, archive logs and control files, or to perform full or incomplete database recovery. Rman has three different user interfaces: COMMAND line, GUI (integrated with the backup manager in the OEM), API mode (for integration into third-party backup software). Has the following characteristics:
1) function similar to physical backup, but powerful than physical backup n times, from the following features can be seen;
2) can compress empty blocks;
3) The increment can be achieved at the block level;
4) The output of the backup can be packaged as a backup set, or the backup set can be segmented by a fixed size;
5) The process of backup and recovery can be automatically managed;
6) can use script (exists in recovery catalog)
7) can do bad block monitoring
Ii. interpretation of relevant terms
1) backup sets back up set
The backup set, as its name implies, is a collection of backups that contain all the backup slices for this backup and are saved in Oracle's proprietary format. A backup set may constitute a full or incremental backup, depending on the type of backup.
2) Backup pieces back up tablets
A backup set consists of several backup slices. Each backup slice is a separate output file. The size of a backup slice is limited, and if there is no size limit, the backup set consists of only one backup slice. The size of the backup slice cannot be greater than the maximum number of file lengths supported by your file system.
3) Image copies backup
Image backup is not compressed, not packaged, directly copy independent files (data files, archive logs, control files), similar to the operating system-level file backup. and can only copy to disk, not to tape. Can be used as an incremental backup of level 0, typically to back up control files.
4) Full backup
A full backup is a data block used in the data file to be backed up, unused data blocks are not backed up, that is, RMAN backup is compressed.
5) Incremental Backup incremental Backups
An incremental backup is a block of data in the backup data file that has been modified since the last backup of the same level or lower level. As with full backups, incremental backups are also compressed. Incremental backup is a good concept, backup is simple, but recovery is another matter, not only cumbersome and error-prone, so the actual less use, to the Oracle 9i has been recommended to no longer use, the future version will gradually cancel the support for incremental backup.
6) Recovery Catalog Recovery Directory
The recovery catalog is used to record control information during Rman use, and the recovery directory should be frequently synchronized (as described later). Although we can use Rman in the Nocatalog way, control information is logged in the control file of the target database, but it is not safe after all because the control file corruption of the target database means that all Rman backups are invalidated. The same goes for the recovery directory should be built in another database, in the following example we call "directory database".
Iii. Creating a Recovery Directory
1. Create a table space for the recovery directory in the catalog database
sql> Create tablespace rmants datafile ' c:\oracle\oradata\cc\rmants.ora ' size 20M;
The tablespace has been created.
2. Create Rman users in the catalog database and authorize
Sql> create user Rman identified by rman default tablespace rmants temporary tablespace temp Quota
Unlimited on rmants;
User has created
Sql> Grant Recovery_catalog_owner to Rman;
Authorization is successful.
3. Create a recovery directory in the catalog database
C:\>rman Catalog Rman/rman
Recovery Manager: Version 8.1.7.0.0-production
RMAN-06008: Connecting to the Recovery catalog database
RMAN-06428: Recovery directory not installed
Rman>create catalog Tablespace rmants;
RMAN-06431: Recovery Catalog created
4. Register the target database to the recovery directory
Note Oh, here my target database uses the service name 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/[email protected]
Recovery Manager: Version 8.1.7.0.0-production
RMAN-06005: Connecting to the target database: RMAN (dbid=1303772234)
Rman>connect Catalog rman/[email protected]
RMAN-06008: Connecting to the Recovery catalog database
Rman>register database;
RMAN-03022: Compiling command: Register
RMAN-03023: Executing command: Register
RMAN-08006: Registering a database in the recovery directory
RMAN-03023: Executing command: Full resync
RMAN-08002: Starting resync of all recovery directories
RMAN-08004: Complete All resync
OK, so far the preparation is done, so you can use Rman for backup and recovery.
Iv. Use of Rman
The following is a concrete example of the use of Rman, which will involve all Rman operations except recovery, and for recovery using Rman, please refer to another article I wrote earlier: RMAN recovery practice.
1. Backing up the entire database
Rman>run {
2> Allocate channel C1 type disk;
3> Backup Datab
ASE format ' e:\dbbackup\2db.dmp ';
4>}
2. Copying 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 replication information
Rman>list backup;
RMAN-03022: Compiling command: List
Backup set list
Keyword RECID flag LV collection Tag collection count finish time
------- ---------- ---------- -- ---------- ---------- ----------------------
216 1 417347013 0 417346992 1 2 June-December-00
Backup Segment List
Keyword pc# cp# status completion time period name
------- --- --- ----------- ---------------------- ------------------------
217 1 1 AVAILABLE 2 June-December -00 E:\DBBACKUP\2DB. CM7
Data files include lists
File name LV Type checkpoint SCN Check point time
---- ------------------------------------- -- ---- ---------- -------------
1 C:\ORACLE\ORADATA\RMAN\SYSTEM01. DBF 0 Full 33224 2 June-December-00
2 C:\ORACLE\ORADATA\RMAN\RBS01. DBF 0 Full 33224 2 June-December-00
3 C:\ORACLE\ORADATA\RMAN\USERS01. DBF 0 Full 33224 2 June-December-00
4 C:\ORACLE\ORADATA\RMAN\TEMP01. DBF 0 Full 33224 2 June-December-00
5 C:\ORACLE\ORADATA\RMAN\TOOLS01. DBF 0 Full 33224 2 June-December-00
6 C:\ORACLE\ORADATA\RMAN\INDX01. DBF 0 Full 33224 2 June-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 2 June-December-00 33226 2 June-December -00 E:\DBBACKUP\U.DBF
4, in the backup is to set the relevant parameters
Format--File output formats,
%d--database name,
%s--backup Sets Sequence number,
%p--backup pieces Sequence Number
Filesperset-the number of files included in each backup set
Please refer to the books listed at the beginning of this article for more parameters.
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-12 Month-00
RMAN-08010: Channel C1: Specifying data files 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: Created 1 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_6_1.bck Comment=none
RMAN-08525: Backup set complete, elapsed time: 00:00:03
RMAN-08008: Channel C1: Starting full data file backup set
rman-08502:set_count=7 set_stamp=417351067 creation_time=26-12 Month-00
RMAN-08010: Channel C1: Specifying data files 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: Created 1 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_7_1.bck Comment=none
RMAN-08525: Backup set complete, elapsed time: 00:00:04
RMAN-08008: Channel C1: Starting full data file backup set
rman-08502:set_count=8 set_stamp=417351071 creation_time=26-12 Month-00
RMAN-08010: Channel C1: Specifying data files in the backup set
RMAN-08522: Input data file fno=00001 Name=c:\oracle\orada
Ta\rman\system01. Dbf
RMAN-08011: The backup set includes the current control file
RMAN-08013: Channel C1: Created 1 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_1.bck Comment=none
RMAN-08013: Channel C1: Created 2 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_2.bck Comment=none
RMAN-08013: Channel C1: Created 3 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_3.bck Comment=none
RMAN-08013: Channel C1: Created 4 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_4.bck Comment=none
RMAN-08013: Channel C1: Created 5 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_5.bck Comment=none
RMAN-08013: Channel C1: Created 6 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_6.bck Comment=none
RMAN-08013: Channel C1: Created 7 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_7.bck Comment=none
RMAN-08525: Backup set complete, elapsed time: 00:00:19
.... ....
RMAN-08008: Channel C1: Starting full data file backup set
Rman-08502:set_count=9 set_stamp=417351090 creation_time=26-12 Month-00
RMAN-08010: Channel C1: Specifying data files in the backup set
RMAN-08522: Input data file fno=00004 name=c:\oracle\oradata\rman\temp01. Dbf
RMAN-08013: Channel C1: Created 1 segment
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_9_1.bck Comment=none
RMAN-08525: Backup set complete, elapsed time: 00:00:07
RMAN-03023: Executing command: Partial resync
RMAN-08003: Resync to start a partial recovery directory
RMAN-08005: Complete Partial resync
RMAN-08031: Released Channel: C1
5. Using the script function
The purpose of using the script is to facilitate our operation, and the operation 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 created L0dbbackup
Rman>run {Execute script l0dbbackup;}
RMAN Beginner's Guide