Introduction to RMAN instances, backup and recovery

Source: Internet
Author: User

This article describes how to use RMAN in step by step mode. Generally, the directory database and target database of the Backup directory should be stored on different machines, where the two databases are on the same machine.
Add in listener. ora
(SID_DESC =
(GLOBAL_DBNAME = rmtgt)
(ORACLE_HOME = D: \ oracle \ product \ 10.2.0 \ db_1)
(SID_NAME =)
)
The tns configuration is as follows: (set target to static registration, so that it can be connected from rman when startup nomount is enabled)
Target =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = NBK-DAL-625040.ap.bt.com) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rmtgt)
)
)
Catalog =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = NBK-DAL-625040.ap.bt.com) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
 
1. Create an rman user in the directory database that stores the Backup Directory and create the corresponding permissions.
Sqlplus sys/sys @ catalog as sysdba
Create tablespace rmants datafile 'd: \ oracle \ product \ 10.2.0 \ oradata \ orcl \ rmants. dbf' size 20 M;
Create user rman identified by rman default tablespace rmants temporary tablespace temp quota unlimited on rmants;
Grant recovery_catalog_owner to rman;
Grant connect, resource to rman;
 
2. Create a recovery directory in the directory database
 
C: \> rman catalog rman/rman @ catalog
Recovery Manager: Release 10.2.0.1.0-Production on Thu Jan 12 15:02:22 2012
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connected to recovery catalog database
RMAN> create catalog tablespace rmants;
Recovery catalog created
 
Register the target database to the recovery directory. Note that the connection string here is targe.
C: \> rman target sys/sys @ target
Recovery Manager: Release 10.2.0.1.0-Production on Thu Jan 12 15:08:42 2012
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connected to target database: BUT (DBID = 1215064705)
 
Connect to the directory database and register the target database
RMAN> connect catalog rman/rman @ catalog;
Connected to recovery catalog database
 
RMAN> register database;
Database registered in recovery catalog
Starting full resync of recovery catalog
Full resync complete
 
So far, the preparations have been completed. Now we can use RMAN for backup and recovery.
 
Perform the following Backup:
1. Create a Directory D: \ oracle \ rmanrep
2, C: \> rman target sys/sys @ target catalog rman/rman @ catalog
3, RMAN> run {
2> allocate channel c1 type disk;
3> backup database format 'd: \ oracle \ rmanrep \ butdb. dmp ';
4>}
 
The target database backup is D: \ oracle \ rmanrep \ butdb. dmp.
RMAN> list backup; you can view the backup information.
If you want to delete the backup, (194 is the BS key of the backup)
RMAN> allocate channel for delete type disk;
RMAN> change backupset 194 delete;
 
Next we will restore
1. Shut down the target database and rename the USERS01.DBF file to USERS01.DBF. bak to simulate data file loss.
2. Set the target database to startup mount.
3. Recovery under rman
A, C: \> rman target sys/sys @ target catalog rman/rman @ catalog
Recovery Manager: Release 10.2.0.1.0-Production on Thu Jan 12 17:59:50 2012
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connected to target database: BUT (DBID = 3712141887, not open)
 
Note that the database is not open, and the network string 'target' must be statically registered before it can be connected.
Open Database
B, RMAN> alter database open;
Using target database control file instead of recovery catalog
RMAN-00571: ========================================================== ==============================
RMAN-00569: ==================== error message stack follows ==========================
RMAN-00571: ========================================================== ==============================
RMAN-03002: failure of alter db command at 01/12/2012 18:01:42
ORA-01157: cannot identify/lock data file 4-see DBWR trace file
ORA-01110: data file 4: 'd: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ BUT \ USERS01.DBF'
We can see that datafile 4 cannot be found.
C,
RMAN> restore datafile 4;
Starting restore at 12-JAN-12
Using channel ORA_DISK_1
 
Channel ORA_DISK_1: starting datafile backupset restore
Channel ORA_DISK_1: specifying datafile (s) to restore from backup set
Restoring datafile 00004 to D: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ BUT \ USERS01.DBF
Channel ORA_DISK_1: reading from backup piece D: \ ORACLE \ RMANREP \ BUTDB. DMP
Channel ORA_DISK_1: restored backup piece 1
Piece handle = D: \ ORACLE \ RMANREP \ BUTDB. DMP tag = tag20112t172743
Channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 12-JAN-12
D,
RMAN> recover datafile 4;
Starting recover at 12-JAN-12
Using channel ORA_DISK_1
Starting media recovery
Media recovery complete, elapsed time: 00:00:04
Finished recover at 12-JAN-12
E. The database is successfully restored. Open the database,
RMAN> alter database open;
Database opened



From kkdelta

Related Article

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.