Create and use RMAN catalog

Source: Internet
Author: User

-- Create and use RMAN catalog
-- ======================================

 

1. Create a recovery directory
There are three steps to create a recovery directory:
Create a database for storing the recovery directory (or use an existing database)

Create the owner of the recovery directory
Create recovery directory

For details about how to create a database, refer to Oralce 10g. Use DBCA to create a database.

 

Create a tablespace in the database storing the recovery directory to store the recovery directory schema and Restore directory data (This article uses the created database catadb to store the recovery directory)

 

SQL> create tablespace tbs_rman datafile '/u01/app/oracle/oradata/catadb/tbs_rman01.dbf' -- create rman recovery directory tablespace
2 size 200 m autoextend on;

SQL> create user rman identified by rman -- create rman schema

2 temporary tablespace temp

3 default tablespace tbs_rman

4 quota unlimited on tbs_rman;

 

SQL> grant recovery_catalog_owner to rman; -- grant a role
 

SQL> conn rman/rman

SQL> select * from session_privs;

 

PRIVILEGE

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

CREATE SESSION

ALTER SESSION

CREATE TABLE

CREATE CLUSTER

CREATE SYNONYM

CREATE VIEW

CREATE SEQUENCE

CREATE DATABASE LINK

CREATE PROCEDURE

CREATE TRIGGER

CREATE TYPE

SQL> select * from session_roles;

 

ROLE

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

RECOVERY_CATALOG_OWNER

 

RMAN> connect catalog rman/rman @ catadb -- connect to the recovery directory
 

Connected to recovery catalog database

 

RMAN> create catalog tablespace tbs_rman; -- create a recovery directory
 

Recovery catalog created

 

[Oracle @ oradb ~] $ Rman target sys/redhat @ orcl catalog rman/rman @ catadb -- connect to the target database and restore the Directory
 

Connected to target database: ORCL (DBID = 1260850162)

Connected to recovery catalog database

 

RMAN> register database; -- register the target database to the recovery directory.
 

Database registered in recovery catalog

Starting full resync of recovery catalog

Full resync complete

 

Ii. Directory-based Backup Recovery

 

1. View related information
RMAN> list incarnation;

 

List of Database Incarnations

DB Key Inc Key DB Name db id status Reset SCN Reset Time

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

1 8 ORCL 1260850162 PARENT 1 30-JUN-05

1 2 ORCL 1260850162 CURRENT 446075 22-oc-10

 

Bytes ----------------------------------------------------------------------------------------------------

 

RMAN> crosscheck copy; -- verify copy

RMAN> delete expired copy; -- delete expired copy

 

2. Full backup
RMAN> run {

2> allocate channel specified device type disk;

3> backup as compressed backupset

4> database plus archivelog delete input

5> format = '/u01/app/oracle/bk/rmbk/Whole _ % d _ % U'

6> tag = 'whole _ Bak ';

7> release channel success ;}

 

3. Incremental Backup (Level 0)

RMAN> run {

2> allocate channel specified device type disk;

3> allocate channel ch2 device type disk;

4> backup as compressed backupset

5> incremental level 0

6> database plus archivelog delete input

7> format = '/u01/app/oracle/bk/rmbk/Inc_0 _ % d _ % U'

8> tag = 'inc _ 0 ';

9> release channel restart;

10> release channel ch2 ;}

 

RMAN> list backup summary;

 

4. Incremental Backup (level 1)

RMAN> run {

2> allocate channel specified device type disk;

3> allocate channel ch2 device type disk;

4> backup as compressed backupset

5> incremental level 1 database

6> format = '/u01/app/oracle/bk/rmbk/Inc_1 _ % d _ % U'

7> tag = 'inc _ 1 ';

8> release channel restart;

9> release channel ch2 ;}

 

RMAN> list backup by file;

 

5. Cumulative Incremental Backup (level 1)

RMAN> run {

2> allocate channel specified device type disk;

3> backup as compressed backupset

4> incremental level 1 cumulative database

5> format '/u01/app/oracle/bk/rmbk/Cum_1 _ % d _ % U'

6> tag = 'yum _ 1 ';

7> release channel success ;}

 

6. Backup tablespace
RMAN> run {

2> allocate channel specified device type disk;

3> backup as compressed backupset

4> tablespace users, example

5> format = '/u01/app/oracle/bk/rmbk/tbs _ % d _ % U'

6> tag = 'tbs ';

 

RMAN> list backupset tag = tbs;

 

7. Back up data files
RMAN> run {

2> allocate channel specified device type disk;

3> backup as compressed backupset

4> datafile 3

5> format = '/u01/app/oracle/bk/rmbk/df _ % d _ % U'

6> tag = 'df ';

7> release channel success ;}

 

8. Back up archived logs
Before backing up archived logs, we recommend that you use crosscheck for verification.
Crosscheck is usually used to check whether the backup is deleted. If it is deleted, it is marked with a delete tag.
RMAN> crosscheck archivelog all;

 

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: sid = 148 devtype = DISK

Validation succeeded for archived log

Archive log filename =/u01/app/oracle/oradata/orcl/arch/log_2017117_733069427.arc recid = 111 stamp = 733171369

Crosschecked 1 objects

 

RMAN> SQL 'alter system switch logfile ';

 

SQL statement: alter system switch logfile

 

RMAN> SQL 'alter system switch logfile ';

 

SQL statement: alter system switch logfile

 

RMAN> list archivelog all;

 

List of Archived Log Copies

Key Thrd Seq S Low Time Name

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

465 1 117 A 22--10 -10/u01/app/oracle/oradata/orcl/arch/log_2017117_733069427.arc

553 1 118 A 23--10 -10/u01/app/oracle/oradata/orcl/arch/log_2017118_733069427.arc

569 1 119 A 23--10 -10/u01/app/oracle/oradata/orcl/arch/log_2017119_733069427.arc

9. Back up and archive logs based on SCN
RMAN> run {

2> allocate channel specified device type disk;

3> backup as compressed backupset

4> archivelog from scn 848043

5> format = '/u01/app/oracle/bk/rmbk/arc _ % d _ % U'

6> tag = 'arc ';

7> release channel restart;

8>}

 

10. Image backup
RMAN> run {

2> allocate channel specified device type disk;

3> backup as copy datafile 1, 4

4> format '/u01/app/oracle/bk/rmbk/df _ % d _ % U'

5> tag 'copybak ';

6> release channel success ;}

11. Others
RMAN> crosscheck backupset;

 

RMAN> change backupset 1

 

RMAN> validate backupset

 

RMAN> validate backupset 635;

12. For catalog-based database recovery, see: catalog-based RMAN backup and recovery

Iii. More references
For user-managed backup and recovery concepts, see:
Oracle cold backup

Oracle Hot Backup

Concept of Oracle backup recovery

Oracle instance recovery

Oracle recovery based on user management (describes media recovery and processing in detail)

For recovery and management of RMAN, see:
RMAN overview and architecture

RMAN configuration, Monitoring and Management

Detailed description of RMAN backup

RMAN restoration and recovery

For the Oracle architecture, see:
Oracle instances and Oracle databases (Oracle Architecture)

Oracle tablespace and data files

Oracle Password File

Oracle parameter file
Oracle database instance startup and Shutdown Process
Oracle ONLINE redo LOG FILE)

Oracle Control File)

Oracle archiving logs

 

This article from the CSDN blog, reproduced please indicate the source: http://blog.csdn.net/robinson_0612/archive/2010/11/29/6043649.aspx

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.