Rman Backup and Recovery oracle10g Learning Series (9)

Source: Internet
Author: User

RMAN always connects to the target database as SYSDBA, so the connection account must have SYSDBA permissions.


Features of Rman:

1. Backup database, tablespace, data file, control file, archive log and SPFile. The database is an archive mode and the target library must be in the mount or open state.

2. Store frequently performed backup and restore operations. Put in a script to execute

3. Skip unused blocks.

4. Perform incremental block-level backups

5. Specify the backup limit

6. Detect damaged blocks during backup. Check with the Dbverify tool

7. Automatic use of parallelization features to improve backup and recovery performance. Allocate multiple CPUs, multiple channels.


Use the format string:

Format strings are often used in configure commands, and format strings are often seen in other Rman commands, such as the Backup,resotre,allocate channel. RMAN provides some syntax elements associated with the format string. These elements are called placeholders, and Rman will replace them with the corresponding defined values. For example, the%u syntax element in the example tells Rman to replace the file name with a system-generated unique identifier.

The various substitution variables that can be used when using the format parameter, as shown in the following (note-case):

The activation ID of the%a:oracle database is resetlog_id.

%c: Number of copies of the backup fragment (numbered from 1, max. 256).

%d:oracle the database name.

%d: The day of the current time, formatted as DD.

%e: Archive serial number.

%f: Absolute file number.

%F: A unique name based on "dbid+ time", formatted as C-IIIIIIIIII-YYYYMMDD-QQ, where IIIIIIIIII is the date of DBID,YYYYMMDD for that database, and QQ is a 1~256 sequence.

%H: Archive log thread number.

The dbid of the%i:oracle database.

%M: The month in the current time, in mm format.

%N: Table space name.

%n: The database name, and is populated with an X character on the right, leaving it at 8 length. For example, if the database name is Jssbook, the generated name is JSSBOOKX.

%p: The number of backup fragments in the backup set, starting at 1.

%s: Backup set number.

%t: Backup set timestamp.

%T: The Month-date format (YYYYMMDD) of the current time.

%u: is a 8-character name that consists of the backup set number and the build time compression. With%u, you can generate a unique name for each backup set.

%u: The default is the abbreviated form of%u_%p_%c, which makes it possible to generate a unique name for each backup fragment (that is, the disk file), which is the most commonly used naming method, and the resulting rules are different when performing different backup operations, as follows:

When generating backup fragments,%u=%u_%p_%c;

Generate Data file image copy,%u=data-d-%d_id-%i_ts-%n_fno-%f_%u;

%u=arch-d_%d-id-%i_s-%e_t-%h_a-%a_%u when generating image copy of archive file;

%u=cf-d_%d-id-%i_%u when generating a control file mirroring replication.

%Y: The year in the current time, formatted as YYYY.

Note: If the format option is not specified in the backup command, Rman uses%u to name the backup fragment by default.


Common commands:

View environment variables: rman>show all;


List 7 days ago Backup: Rman>report need backup day 7;


List the entire database backup: rman>list backup of database;


List tablespace backups: rman>list backup of tablespace users;


List data file backups: rman>list backup of datafile N;


List control file backups: rman>list backup of Controlfile;


List archived log backups: Rman>list archivelog all;


List parameter file backups: rman>list backup of SPFile;



Check that the backup is valid: Rman>crosscheck bakup;

Delete Expired backups: Rman>delete expired backup;

Delete Invalid backups (7 days ago): Rman>delete obsolete;

Delete all backups: Rman>delete backup;


Open control File Automatic backup: Rman>configure controlfile autobackup on;

Control file path: ll/u01/oracle/flash_recovery_area/orcl/autobackup/


OMF defines the channel:

Rman>run {

Allocate channel A1 type disk;

Allocate channel A2 type disk;

Backup database;

Release channel A1;

Release channel A2;

}


Rman>backup SPFile;

Rman>bakup current Controlfile;

Rman>backup datafile 4; Backing up a fourth data file

Rman>backup tablespace users;

Rman>backup Archivelog All;

Rman>backup full database plus archivelog;

Rman>backup archivelog all Delete input;


Specify path Backup: Rman>backup database format '/u02/dbfull_%u ';



Catalog of Rman Backup:

The catalog has script creation capabilities that are more powerful than nocatalog

To create a Catlog user:

Sql>create tablespace cataorcl datafile '/u01/oracle/oradata/cataorcl.dbf ' size 100m autoextend on;

Sql>create user CATAORCL identified by CATAORCL default Tablespace CATAORCL;

Sql>grant Connect,recovery_catalog_owner to CATAORCL;


To connect to a remote database CATAORCL:

Rman>rman target Sys/[email protected] catalog Cataorcl/[email protected]

Rman>create catalog Tablespace CATAORCL;

Rman>register database;


To create a script:

Rman>create Script level0{

Allocate channel A1 type disk;

Allocate channel A2 type disk;

Backup incremental level 0 database;

Release channel A1;

Release channel A2;

}


Print Script:

Rman>print script level0;


Execute script:

Rman>run {Execute script level0;}


Log on each time you need to specify catalog mode. You need to synchronize information with the target database after logging in:

Resync Catalog, or the report schema;



Rman Recovery:

Loss of data file corruption, online recovery can be offline, not offline in the Mount phase recovery

$rman target Sys/[email protected] nocatalog equals Rman target/

Rman>backup database;

Rman>sql ' alter tablespace users offline immediate ';

Rman>restore tablespace users;

Rman>recover tablespace users;

Rman>sql ' alter tablespace users online ';



You cannot resume offline in the mount phase (for example, Undo Tablespace is gone):

Sql>shutdown immediate;

Sql>startup Mount;

Sql>sqlplus/as SYSDBA

Sql>select name.status.enabled from V$datafile; Need path or number to recover file u01/oracleoradata/orcl/undotbs01


Rman>restory datafile '/u01/oracleoradata/orcl/undotbs01 ';

Rman>recover datafile '/u01/oracleoradata/orcl/undotbs01 ';

Rman>alter database open;



To view the label, you can recover the database or table space by numbering:

rman> List Backupset summary;


To recover a database database by number:

Sql>shutdown immediate;

Sql>startup Mount;

Rman>restore database from tag tag20140725t104645;

rman> recover database from tag tag20140725t104645;

rman> ALTER DATABASE open;



not fully recovered, make a full backup before restoring :

Restore the database based on time, resetlogs need to make a full-library backup

Rman>run {

Allocate channel A1 type disk;

Allocate channel A2 type disk;

Set until time = ' 2014-06-08 10:30:10 ';

Restore database;

Recover database;

ALTER DATABASE open resetlogs;

}


Data file Renaming:

Sql>slect name from V$datafile;


Rman>run {

Allocate channel A1 type disk;

SQL ' alter tablespace users offline ';

Set newname for datafile '/u01/oracleoradata/orcl/users01.dbf ' to '/u01/oracleoradata/orcl/users.dbf ';

Restore tablespace users;

Switch datafile '/u01/oracleoradata/orcl/users.dbf ';

Recover tablespace users;

SQL ' alter tablespace users online ';

}


Time-based incomplete recovery:

$NLS _lang=american

$NLS _date_format= ' Yyyy-mm-dd:hh24:mi:ss '

Sql>alter system set nls_date_format= ' Yyyy-mm-dd:hh24:mi:ss '


Rman>run {

Allocate channel A1 type disk;

Allocate channel A2 type disk;

Set until time = ' 2014-06-08:10:30:10 ';

Restore database;

Recover database;

ALTER DATABASE open resetlogs;

Release channel A1;

Release channel A2;

}


Restore parameter file:

ls/u01/oracle/flash_recovery_area/orcl/

Rman>startup Nomuont;

Rman>restore SPFile from '/u01/oracle/flash_recovery_area/orcl/

Autobackup/a.bkp ';


Recovery control File:

Rman>startup Force Nomuont;

Rman>restore controfile from '/u01/oracle/flash_recovery_area/orcl/

Autobackup/a.bkp ';

Rman>alter database Mount;

Rman>restore database;

Rman>recover database;

rman> ALTER DATABASE open;



This article is from "Kaka West" blog, please be sure to keep this source http://whnba.blog.51cto.com/1215711/1602568

Rman Backup and Recovery oracle10g Learning Series (9)

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.