Oracle Restore database

Source: Internet
Author: User
There are two common faults in the database: medium damage, human error prevention, and medium damage. Generally, DataGuard and other technologies are used to prevent human errors. The Oracle flash back function can be used.

There are two common faults in the database: medium damage and human error prevention. Generally, Data Guard and other technologies are used to prevent human errors. The Oracle flash back function can be used.

Databases generally have two common faults.
Medium damage
Human error

Data Guard and other technologies are generally used to prevent medium damages.
To prevent human errors, you can use the Oracle flash back function.

However, once a human error cannot be restored through Flash recovery, Rman must be used for recovery.
Using Rman to recover, think about the recovery speed and embarrassment. There are three layers of bosses, leaders, and colleagues ..

To avoid this problem, you can use another server to restore the database from Oracle.
The master database pushes the archived logs to the specified directory of the restored database at intervals (scp, rsync, we use the monitoring software of Xiaohua raccoon)
Restore the database to archive logs at intervals.
That is to say, restoring database data always lags behind the production database, which is similar to a delayed replicuard.

The restored database we configured lags behind the production database for 6-9 hours.
Recover a human error from the restored database, which can be controlled within 30 minutes.
However, it may take 4-5 hours to recover from Rman.

The following steps are generally taken to create a restoration database:
1. unmount the database that already exists in the restoration database (if the restoration inventory is in the database instance)

Shutdown abort;

Startup mount exclusive restrict;

Alter system enable restricted session;

Drop database;
2. Use Rman to back up the production database

Configure device type disk parallelism 5 backup type to backupset;

SQL 'alter system archive log current ';

Backup as compressed backupset database;

3. Create a new file (init $ SID. ora) in the $ ORACLE_HOME/dbs directory)
Only one row of SID is configured in the file.
Db_name = mvbox

4. Restore spfile

Recover the spfile from the Rman backup.

[Oracle @ localhost/data/IP/2015_09_25] $ rman target/

Recovery Manager: Release 10.2.0.4.0-Production on Fri Sep 25 17:26:40 2015

Copyright (c) 1982,200 7, Oracle. All rights reserved.

Connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area 171966464 bytes

Fixed Size 2082496 bytes
Variable Size 113248576 bytes
Database Buffers 50331648 bytes
Redo Buffers 6303744 bytes

RMAN> restore spfile to '/home/oracle/app/oracle/product/10.2.0/db_1/dbs/spfilemvbox. ora 'from'/data/IP/2015_09_25/o1_mf_nnsnf_TAG20150925T134231_c09s9rq2 _. bkp ';

Starting restore at 25-SEP-15
Using channel ORA_DISK_1

Channel ORA_DISK_1: autobackup found:/data/IP/2015_09_25/o1_mf_nnsnf_TAG20150925T134231_c09s9rq2 _. bkp
Channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 25-SEP-15
Convert spfile to pfile, and then modify the related directory

Create pfile = '/tmp/pfile. ora' from spfile;

Vim/tmp/pfile. ora is mainly used to modify the relevant path.

Use pfile to start the database to the nomount state, and then generate the spfile from the modified pfile.

5. Restore Control File

RMAN> restore controlfile from '/data/IP/2015_09_25/o1_mf_ncnnf_TAG20150925T134231_c09s9pms _. bkp ';

Starting restore at 25-SEP-15
Using target database control file instead of recovery catalog
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: sid = 1640 devtype = DISK

Channel ORA_DISK_1: restoring control file
Channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Output filename =/data/oracledata/flash_recovery_area/control01.ctl
Finished restore at 25-SEP-15

RMAN> shutdown

Oracle instance shut down

RMAN> startup mount;

Connected to target database (not started)
Oracle instance started
Database mounted

Total System Global Area 53687091200 bytes

Fixed Size 2184048 bytes
Variable Size 4546628752 bytes
Database Buffers 49123688448 bytes
Redo Buffers 14589952 bytes

RMAN>

6. Restore the data file and restore it.
Copy the archived logs of the production database to the specified directory.

RMAN> catalog start with '/data/ip ';
All production database files are stored in/dbdata/oracledata/mvbox/mount point.
The restored database data files are stored at/data/oracledata/oradata/mvbox/mount point.

Run query in production database
Select
'Set newname for datafile' | file_id |
'To ''' |
Replace (file_name, '/dbdata/oracledata/mvbox','/data/oracledata/oradata/mvbox') | ''';'
From dba_data_files;


Then, based on the query results, spell out the commands executed by the Restore database.

Restore data files first

Run {
Configure device type disk parallelism 5 backup type to backupset;
Set newname for datafile 4 to '/data/oracledata/oradata/mvbox/users01.dbf ';
Set newname for datafile 3 to '/data/oracledata/oradata/mvbox/sysaux01.dbf ';
Set newname for datafile 1 to '/data/oracledata/oradata/mvbox/system01.dbf ';
Set newname for datafile 5 to '/data/oracledata/oradata/mvbox/system02.dbf ';
Set newname for datafile 6 to '/data/oracledata/oradata/mvbox/sysaux02.dbf ';
Set newname for datafile 7 to '/data/oracledata/oradata/mvbox/users02.dbf ';
Set newname for datafile 8 to '/data/oracledata/oradata/mvbox/users03.dbf ';
Set newname for datafile 9 to '/data/oracledata/oradata/mvbox/users04.dbf ';
Set newname for datafile 10 to '/data/oracledata/oradata/mvbox/users05.dbf ';
Set newname for datafile 12 to '/data/oracledata/oradata/mvbox/users06.dbf ';
Set newname for datafile 13 to '/data/oracledata/oradata/mvbox/system03.dbf ';
Set newname for datafile 14 to '/data/oracledata/oradata/mvbox/sysaux03.dbf ';
Set newname for datafile 27 to '/data/oracledata/oradata/mvbox/users19.dbf ';
Set newname for datafile 15 to '/data/oracledata/oradata/mvbox/users07.dbf ';
Set newname for datafile 16 to '/data/oracledata/oradata/mvbox/users08.dbf ';
Set newname for datafile 17 to '/data/oracledata/oradata/mvbox/users09.dbf ';
Set newname for datafile 18 to '/data/oracledata/oradata/mvbox/users10.dbf ';
Set newname for datafile 19 to '/data/oracledata/oradata/mvbox/users11.dbf ';
Set newname for datafile 20 to '/data/oracledata/oradata/mvbox/users12.dbf ';
Set newname for datafile 21 to '/data/oracledata/oradata/mvbox/users13.dbf ';
Set newname for datafile 22 to '/data/oracledata/oradata/mvbox/users14.dbf ';
Set newname for datafile 23 to '/data/oracledata/oradata/mvbox/users15.dbf ';
Set newname for datafile 24 to '/data/oracledata/oradata/mvbox/users16.dbf ';
Set newname for datafile 25 to '/data/oracledata/oradata/mvbox/users17.dbf ';
Set newname for datafile 26 to '/data/oracledata/oradata/mvbox/users18.dbf ';
Set newname for datafile 28 to '/data/oracledata/oradata/mvbox/users+dbf ';
Set newname for datafile 33 to '/data/oracledata/oradata/mvbox/users21.dbf ';
Set newname for datafile 34 to '/data/oracledata/oradata/mvbox/users22.dbf ';
Set newname for datafile 35 to '/data/oracledata/oradata/mvbox/undotbs. dbf ';
Restore database;
Switch datafile all;
}

Find the archive log file transmitted from the production database and find the last file.

Restore to the last archived Log File sequence.

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.