[Repost] RMAN recovery practice

zhaozj2021-02-16  42

[Repost] RMAN recovery practice

Rman Restore Practice

Source: (ncn.cn) Views: (248) Update Time: (2003-6-18 18:02:00)

Keywords: oracle, recovery, RMAN

Talking about recovery and definitely inseparable, but today, our focus is not here, I am here to divide the backups into two categories: operating system backup and database backup, and the database backup work we are doing with RMAN. For use of RMAN, I strongly recommend using Catalog Mode.

Test environment: Win2k Adv Oracle817

Rman: Target Database Named ORA, Catalog Database Named RCVDB

First, Control File recovery

Note: RMAN's backup must be made under Catalog Mode, otherwise the Control File is not used; but even if it is sometimes possible, there will be many problems. Recommendation: Control File makes backup and recovery with SQL or operating systems.

1, RMAN backup recovery

Backup:

Run {

ALLOCATE CHANNEL C1 TYPE DISK;

Backup current controlfile;

}

restore:

Run {

ALLOCATE CHANNEL C1 TYPE DISK;

Restore ControlFile to '/oracle/oradata/ora/control01.ctl';

Replicate controlfile from '/oracle/oradata/ora/control01.ctl';

Restore Database;

SQL 'ALTER DATABASE MOUNT';

Recover Database Until Cancel;

SQL 'ALTER DATABASE OPEN RESETLOGS'

Release channel C1;

}

After using ResetLogs, you need to perform RESET DATABASE on the Catalog Database, and the original backup information will not be available, so you need to make new full backups in time.

2, SQL backup recovery

Backup:

Alter Database Backup ControlFile to TRACE;

restore:

First copy the database Shutdown, then copy out the SQL used to create the recovery from the backup.

I.e. If you have not doing this backup, it doesn't matter, the form is as follows, you can write one:

# ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------

# The Following Commands Will Create A New Control File and Use IT

# To open the database.

# Data Used by The Recovery Manager Will Be Lost. Additional Logs MAY

# Be Required for Media Recovery Of Offline Data Files. Use this

# Only if The Current Version of All Online logs is available.

Startup Nomount

Create ControlFile Reuse Database "ORA" NoreSetlogs

NoarchiveLogMaxLogfiles 32

MaxLogmembers 2

MaxDataFiles 32

Maxinstances 16

MaxLoghistory 680

Logfile

GROUP 1

'C: /oracle/oradata/ora/redo01.log',

'C: /oracle/oradata/ora/redo01_1.log'

Size 1M,

GROUP 2

'C: /oracle/oradata/ora/redo02.log',

'C: /oracle/oradata/ora/redo02_1.log'

Size 1M,

GROUP 3

'C: /oracle/oradata/ora/redo03_1.log',

'C: /oracle/oradata/ora/redo03_2.log'

Size 1M

DataFile

'C: /oracle/oradata/ora/system01.dbf',

'C: /oracle/oradata/ora/rbs01.dbf',

'C: /oracle/oradata/ora/Users01.dbf',

'C: /oracle/oradata/ora/temp01.dbf',

'C: /oracle/oradata/ora/tools01.dbf',

'C: /oracle/oradata/ora/indx01.dbf'

Character set zhs16gbk

;

# Recovery Is Required if any of the datafiles area restackups,

# or if the last shutdown was not normal or immediate.

Recover Database

# Database can now be opened normally.

ALTER DATABASE OPEN

# ----------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------

3, the recovery of OS backup

Backup:

OS COPY

restore:

OS COPY is coming back, it is important to note that this backup must be the latest.

Second, Database recovery

A, to restore the database from host_a to host_b with the same file system

# Use Recovery Catalog;

# If it is not a Catalog Mode, use the OS Copy to directly Control File

#Copy Come and Mount Database.

1, copy the init.ora file from host_a to host_b using o / s utility

2, Rman Target Sys / Sys @ host_b catalog rman / rman @ rcat

3, Startup Nomount

4, Run {

ALLOCATE CHANNEL C1 TYPE DISK;

Restore ControlFile;

SQL 'ALTER DATABASE MOUNT';

}

5, SELECT MIN (SCN) from "

SELECT MAX (Next_Change #) SCN from V $ Archived_log

GROUP BY THREAD #);

6, Run {

SET Until SCN = 500; #use appropriate SCN for Incomplete Recovery

Allocate Channel C1 Type 'SBT_TYPE'; RESTORE DATABASE;

Recover data;

SQL 'ALTER DATABASE OPEN RESETLOGS'

}

B, TO RESTORE THE DATABASE from host_a to host_b with a different filesystem

Steps and A are almost, different, to modify all and path-related parameters in the init.ora file before starting the database.

Such as: * _ dest, * _ Path, etc. Then perform the following script:

Run {

Set Until SCN = 500;

ALLOCATE CHANNEL C1 TYPE DISK;

Set NewName for DataFile 1 to '/ disk' /% u ';

Set NewName for DataFile 2 to '/ disk' /% u ';

Set NewName for DataFile 3 to '/ disk' /% u ';

Set NewName for DataFile 4 to '/ disk' /% u ';

Set NewName for DataFile 5 to '/ disk' /% u ';

Set NewName for DataFile 6 to '/ disk' /% u ';

Set NewName for DataFile 7 to '/ disk' /% u ';

SQL 'ALTER DATABASE MOUNT';

Restore Database;

Switch DataFile All; #points the control file to the renamed datafiles

Recover data;

.... ....

SQL 'ALTER DATABASE OPEN RESETLOGS'

}

Third, TABLESPACE AND DATAFILE recovery

Run {

ALLOCATE CHANNEL C1 TYPE DISK;

SQL 'ALTER TABLESPACE USERS OFFLINE IMMEDIATE'; #must be in Archive Log Mode

# 如 改 改 d 位置 位置

Set newname for datafile 'c: /oracle/oradata/ora/users01.dbf'

To 'c: /oacle/oradata/orabk/user01.dbf';

RESTORE TABLESPACE;

Switch DataFile All;

Recover TableSpace User;

SQL 'ALTER TABLESPACE USERS online';

}

If not under Archive Log Mode, it will be wrong when you perform the above SQL: ORA-01145. You will have to shutdown.

Fourth, About Set Until Options

SET Until can be followed by TIME, SCN, and Logseq three different options, when the database is running in NOARCHIVELOG

You can use the UnTil Cancel option to use the UnTil Cancel option at Mode. All of these specific processes and above

Database recovery is similar, no longer described.

转载请注明原文地址:https://www.9cbs.com/read-19396.html

New Post(0)