Rman Whole-Library backup, recovery process

Source: Internet
Author: User

has been busy writing shell scripts, ignoring Oracle's basic review, just did an rman recovery, record a deeper impression.

Oracle Full-Library backup is ideal for the mount, so there is no need to consider consistency issues. Just an ideal.

To open the database in archive mode, complete the script as follows

Log_file=/paic/hq/bk/restore/home/op11202/xionglang/investdw/full_backup_${oracle_sid}_ ' Date ' +%Y%m%d_%H%M%S '. Log
Export Log_file
Rman target/<< EOF > ${log_file} 2>&1
SQL ' alter system switch logfile ';
Run
{
Allocate channel C1 type disk;
Allocate channel C2 type disk;
Allocate channel C3 type disk;
Allocate channel C4 type disk;
Allocate channel C5 type disk;
Allocate channel C6 type disk;
Allocate channel C7 type disk;
Allocate channel C8 type disk;
BACKUP as compressed backupset full DATABASE plus archivelog FORMAT '/paic/hq/bk/restore/home/op11202/xionglang/ Investdw/full_%t-%d-%u-%p ' filesperset=10;
Backup as copy current Controlfile format '/PAIC/HQ/BK/RESTORE/HOME/OP11202/XIONGLANG/INVESTDW/CTRL_%T-%S-%P.F ';
Release channel C1;
Release channel C2;
Release channel C3;
Release channel C4;
Release channel c5;
Release channel C6;
Release channel C7;
Release channel C8;
}
Eof
echo "Backup finished at ' Date ' +%y%m%d_%h%m%s '" ">> ${log_file}

1. Generate a copy of the original development/test library Pfile
2. Use the pfile in step 1 to boot to Nomount
3.rman Target/
Rman> Restore controlfile from '/xxxx/xxxx/*****.f '; /XXXX/XXXX/*****.F for Controlfile Backup of the Production DG Library
rman> Alter database mount;
Rman> Catalog start with '/xxxx/xxxx/'; Registering a backup slice into a recovered control file

4. Perform the following restore script in the background. If you recover the archive log restore database, you need recover database;
(Note incarnation related error)
5. After the restoration is completed, shutdown instance, modifies the db_name in pfile to boot to the original test library SID to Nomount
6. Use the Create Controlfile set database command to rebuild the control file
7.alter database open resetlogs;
8. Add temporary files


Recovery scripts:

Log_file=/paic/dev/oracle/11g/odsz11g/xionglang/xionglang/d1gccrep/restore_${oracle_sid}_ ' Date ' +%Y%m%d_%H%M%S ' '. Log
Export Log_file
Rman target/<< EOF > ${log_file} 2>&1
Run
{
Allocate channel C1 type disk;
Allocate channel C2 type disk;
Allocate channel C3 type disk;
Allocate channel C4 type disk;
Allocate channel C5 type disk;
Allocate channel C6 type disk;
Allocate channel C7 type disk;
Allocate channel C8 type disk;
Set newname for datafile 1 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile one to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile 2 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for DataFile 3 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile Notoginseng to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile 4 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile 5 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile 6 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile 7 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for DataFile "+DATA_10G_D1GCCREP_MDG";
Set newname for DataFile "+DATA_10G_D1GCCREP_MDG";
Set newname for datafile to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for datafile 8 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for DataFile 9 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for Tempfile 1 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for Tempfile 2 to ' +DATA_10G_D1GCCREP_MDG ';
Set newname for Tempfile 3 to ' +DATA_10G_D1GCCREP_MDG ';
Restore database;
Switch datafile all;
Switch Tempfile all;
Release channel C1;
Release channel C2;
Release channel C3;
Release channel C4;
Release channel c5;
Release channel C6;
Release channel C7;
Release channel C8;
}
Eof
echo "Restore finished at ' Date ' +%y%m%d_%h%m%s '" ">> ${log_file}

As mentioned earlier, the recovery process may fail because it does not always cause the ALTER DATABASE open resetlogs to start the library. In this process I recommend using the Recover database using Backup controlfile utile time ' 2015-12-17 23:01:22 ' to do a incomplete recovery, This is a more likely way to return to a consistent log than to apply one. Because there may be long transactions that do not end when you switch logs. And you specify a point in time, this point may have transactions, but you can add a few seconds or more than 10 seconds to the basic can be consistent state, and then the Open database.


To see if the database is consistent: (although all are in a consistent state, but you open still have the possibility of open, so you need to append a few seconds to the back to normal library.) )

Sql> Select To_char (max (checkpoint_time), ' Yyyy-mm-dd hh24:mi:ss ') from V$datafile_header;

To_char (MAX (Checkpo

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

2015-12-16 23:01:08

Sql> Select To_char (min (checkpoint_time), ' Yyyy-mm-dd hh24:mi:ss ') from V$datafile;

To_char (MIN (Checkpo

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

2015-12-16 23:01:08

sql> Select Controlfile_time fromv$database;

Controlfile_time

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

2015-12-16 23:01:08

Sql> Select file#,checkpoint_change# from v$datafile_header where fuzzy = ' YES ';

No rows selected

Sql> ALTER DATABASE open read only;

ALTER DATABASE open Read only

*

ERROR at line 1:

Ora-16004:backup Database Requiresrecovery

Ora-01113:file 1 Needs media recovery Ifit is restored from backup, or end backup if it is not

Ora-01110:data file 1: ' +data_10g_d1gccrep_mdg/d1gccrep/datafile/system.298.898716267 '

sql> recover database using Backupcontrolfile;

Ora-00279:change 9910161874981 generatedat 12/16/2015 23:01:08 for thread 1

Ora-00289:suggestion: +FRA_10G_LARGE_MDG

Ora-00280:change 9910161874981 for Thread1 's in sequence #3085

Specify log: {<ret>=suggested |filename | AUTO | CANCEL}

Cancel

Media recovery cancelled.

In addition, if you do not want to use set newname, you can convert the path of the file name in a Db_file_name_convet way. ASM is assigned to the dbname level, and the file system is assigned to the first level directory of the filename.

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
Db_file_name_convert string +data_10g_t1gccrep_mdg/t1gccrep, +data_10g_d1gccrep_mdg/d1gccrep
Log_file_name_convert string +data_10g_t1gccrep_mdg/t1gccrep, +data_10g_d1gccrep_mdg/d1gccrep, +FRA_10 G_large_mdg/t1gccrep, +fra_10g_large_mdg/d1gccrep


Attach statement to generate set newname

Select ' Set newname for datafile ' | | file# | | ' To ' +${data_dg} ';
From V\ $datafile
Union
Select ' Set newname for tempfile ' | | file# | | ' To ' +${data_dg} ';
From V\ $tempfile;


If you want to modify the database db_name can be modified by NID. Database is required to mount state:

Syspwd= ' Od-n 4-t x4/dev/random | head-1 | awk ' {print $} '

orapwdfile= $ORACLE _home/dbs/orapw${oldsid} password= $syspwd entries=8 force=y

orapwdfile= $ORACLE _home/dbs/orapw${newsid} password= $syspwd entries=8 force=y

nidtarget=sys/$syspwd Dbname=${newsid} >> $crt _log 2>&1 <<!

Y

!



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.