Transferred from Poly-Hyun Zhuang Author: gototop
============================================
This article was written last year, originally published in the Chinaunix.net Oracle Forum, included in the old version of the anthology, may be many did not see, there is always someone to write to, today on the occasion of the revision took it out alone. (Gototop 2003.6.24 Note)
RMAN (Recovery Manager) is an important tool for DBAs to back up, restore and restore Oracle databases, some time ago, a netizen to find me, unfortunately no time, while the two days of business trip outside nothing, wrote a little, for beginners friend reference. This article describes the basic operations of Rman, more information refer to the Oracle8i Backup & Recovery Guide and the Rman manual, or OCP Student Guide M09096 "Backup and Recovery Wor Kshop "Volume 2, also can through gototop@ncn.cn and I contact. Oracle's own examples refer to the *.RCV script in the $oracle_home/rdbms/demo directory.
A brief introduction of RMAN
RMAN can be used to back up and restore database files, archive logs, and control files, or to perform complete or incomplete database recovery. Rman has three different user interfaces: COMMAND line, GUI (integrated in OEM, Backup manager), API approach (for integration into Third-party backup software). Has the following characteristics:
1 function similar to physical backup, but stronger than physical backup n times, from the following features can be seen;
2) can compress the empty block;
3 The increment can be realized on the block level;
4 The backup output can be packaged into a backup set, or the backup set can be separated by a fixed size;
5 The process of backup and recovery can be automatically managed;
6 can use the script (Exists recovery catalog)
7) can do bad block monitoring
Ii. interpretation of relevant terms
1 Backup Set Sets
A backup set, as the name suggests, is a collection of backups that contain all the backup slices of this backup and are saved in an Oracle-proprietary format. Depending on the type of backup, a backup set may constitute a full or incremental backup.
2 Backup pieces back-up Slice
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 is made up of only one backup slice. The size of the backup slice cannot be greater than the maximum file length that your file system supports.
3 Image copies images backup
Image backups are uncompressed, not packaged, directly copy standalone files (data files, archive logs, control files), and are similar to operating system-level file backups. and can only copy to disk, not to tape. Can be an incremental backup of level 0, typically used to back up control files.
4 Full backup
Full backup refers to the data files used in the data block backup, no use of data blocks are not backed up, that is, RMAN for backup is compressed.
5) Incremental Backup incremental Backups
An incremental backup is a block of data in a backup data file that has been modified since it was last backed up at the same level or at a lower level. As with a full backup, incremental backups are also compressed. Incremental backups, while the concept is good, the backup is simple, but the recovery is a different thing, not only troublesome and error prone, so the actual less use, to the Oracle 9i has been recommended no longer use, later versions will gradually eliminate the support for incremental backups.
6) Recovery Catalog Recovery Directory
The recovery directory is used to record control information during Rman usage, and the recovery directory should often be synchronized (which is described later). Although we can use Rman in a nocatalog way, control information is recorded in the control file of the target database, but this is unsafe after all, because once the control file of the target database is corrupted, all Rman backups are invalidated. The same thing. The recovery directory should be built into another database, and in the following example we call it "catalog 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 table space has been created.
2. Create the Rman user 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;
The authorization was 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 directory database
RMAN-06428: Recovery directory not installed
Rman>create catalog Tablespace rmants;
RMAN-06431: Restore directory created
4, register the target database to the recovery directory
Attention, here. The service name used by 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: Connecting to target database: RMAN (dbid=1303772234)
Rman>connect Catalog RMAN/RMAN@CC
RMAN-06008: Connecting to the Recovery directory database
Rman>register database;
RMAN-03022: Compiling command: Register
RMAN-03023: Executing command: Register
RMAN-08006: Registers the database in the recovery directory
RMAN-03023: Executing command: Full resync
RMAN-08002: Starting resync for full recovery directory
RMAN-08004: Complete All resync
All right, all the prep work is done, so you can use Rman for backup and recovery.
Iv. Use of Rman
The following concrete examples illustrate the use of Rman, which involves all rman operations other than recovery, as well as the contents of recovery using Rman please refer to another article I wrote earlier: RMAN recovery practice.
1, backup the entire database
Rman>run {
2> Allocate channel C1 type disk;
3> Backup Database format ' E:\DBBACKUP\2DB.DMP ';
4>}
2. Copy data file
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 the backup and replication information
Rman>list backup;
RMAN-03022: Compiling command: List
Backup set list
Keyword recid Mark LV collection Mark collection count finish time
------- ---------- ---------- -- ---------- ---------- ----------------------
216 1 417347013 0 417346992 1 2 June-December-00
Backup Segment List
Keyword pc# cp# state completion Time segment name
------- --- --- ----------- ---------------------- ------------------------
217 1 1 AVAILABLE 2 June-December -00 E:\DBBACKUP\2DB. DMP
Data files include lists
File name LV Type Check Point SCN checkpoint time
---- ------------------------------------- -- ---- ---------- -------------
1 C:\ORACLE\ORADATA\RMAN YSTEM01. 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 state completion time checkpoint SCN checkpoint time name
------- ---- - --------------- ---------- --------------- ------
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 Backup set
RMAN-08522: Enter data file fno=00003 name=c:\oracle\oradata\rman\users01. Dbf
RMAN-08522: Enter data file fno=00005 name=c:\oracle\oradata\rman\tools01. Dbf
RMAN-08013: Channel C1:1 Segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_6_1.bck Comment=none
RMAN-08525: Backup set completed, after 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 Backup set
RMAN-08522: Enter data file fno=00002 name=c:\oracle\oradata\rman\rbs01. Dbf
RMAN-08522: Enter data file fno=00006 name=c:\oracle\oradata\rman\indx01. Dbf
RMAN-08013: Channel C1:1 Segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_7_1.bck Comment=none
RMAN-08525: Backup set completed, after 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 Backup set
RMAN-08522: Enter data file fno=00001 Name=c:\oracle\oradata\rman YSTEM01. Dbf
RMAN-08011: The backup set includes the current control file
RMAN-08013: Channel C1:1 Segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_1.bck Comment=none
RMAN-08013: Channel C1:2 segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_2.bck Comment=none
RMAN-08013: Channel C1:3 Segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_3.bck Comment=none
RMAN-08013: Channel C1:4 Segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_4.bck Comment=none
RMAN-08013: Channel C1:5 Segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_5.bck Comment=none
RMAN-08013: Channel C1:6 Segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_6.bck Comment=none
RMAN-08013: Channel C1:7 Segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_8_7.bck Comment=none
RMAN-08525: Backup set completed, after 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 Backup set
RMAN-08522: Enter data file fno=00004 name=c:\oracle\oradata\rman\temp01. Dbf
RMAN-08013: Channel C1:1 Segments created
RMAN-08503: Duan Handle=e:\dbbackup\db_rman_9_1.bck Comment=none
RMAN-08525: Backup set completed, after time: 00:00:07
RMAN-03023: Executing command: Partial resync
RMAN-08003: Start the resync of the partial recovery directory
RMAN-08005: Complete Part resync
RMAN-08031: Freed Channel: C1
5, the use of scripting features
The purpose of scripting is to facilitate the convenience of our operation, similar to the stored procedures in operation.
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;}
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.