Friday, 6 January 2017

RMAN CheatSheet

Connect:
CONNECT TARGET /
CONNECT TARGET sys/pwd@tgt;
CONNECT CATALOG rman/pwd@catdb;
CONNECT AUXILIARY /
CONNECT AUXILIARY rman/pwd@auxdb;

CREATE CATALOG command:
CREATE CATALOG;
CREATE CATALOG TABLESPACE rmants;
CREATE VIRTUAL CATALOG;
SQL "EXEC catown.DBMS_RCVCAT.CREATE_VIRTUAL_CATALOG";

DROP CATALOG command:
DROP CATALOG;

RESYNC CATALOG command:
RESYNC CATALOG;
RESYNC CATALOG FROM DB_UNIQUE_NAME prod_db;
RESYNC CATALOG FROM DB_UNIQUE_NAME ALL;

UPGRADE CATALOG command:
UPGRADE CATALOG;

IMPORT CATALOG command:
IMPORT CATALOG cat@srcdb DBID=1844750987, 61738563;
IMPORT CATALOG cat@srcdb DB_NAME=prod3, prod4;
IMPORT CATALOG rman/rman@catdb1 DB_NAME=prod1 NO UNREGISTER;

REGISTER command:
REGISTER DATABASE;
REGISTER CATALOG;
REGISTER CATALOG TABLESPACE tbs-name;

UNREGISTER command:
UNREGISTER DATABASE;
UNREGISTER DATABASE prod1;
UNREGISTER DB_UNIQUE_NAME prod2;
UNREGISTER DB_UNIQUE_NAME prod2 INCLUDING BACKUPS;

GRANT command:
GRANT CATALOG FOR DATABASE prod1 TO vpc1;
GRANT REGISTER DATABASE TO bckop2;
GRANT RECOVERY_CATALOG_OWNER TO rmanop1, rmanop3;

REVOKE command:
REVOKE CATALOG FOR DATABASE prod1 FROM vpc1;
REVOKE REGISTER DATABASE FROM bckop2;
REVOKE RECOVERY_CATALOG_OWNER FROM bckop;

RESET DATABASE command:
RESET DATABASE TO INCARNATION 3;

SHOW command:
SHOW
{ RETENTION POLICY
| BACKUP OPTIMIZATION
| [DEFAULT] DEVICE TYPE
| CONTROLFILE AUTOBACKUP [FORMAT]
| [AUXILIARY] CHANNEL [FOR DEVICE TYPE deviceSpecifier]
| MAXSETSIZE
| DATAFILE BACKUP COPIES
| ARCHIVELOG [BACKUP COPIES|DELETION POLICY]
| AUXNAME
| EXCLUDE
| ENCRYPTION {ALGORITHM | FOR [DATABASE|TABLESPACE]}
| COMPRESSION ALGORITHM
| SNAPSHOT CONTROLFILE NAME
| DB_UNIQUE_NAME
| ALL
} FOR [DB_UNIQUE_NAME [‘db_unique_name’|ALL]];

Catalog create, connect, register:

Connect to catalog database
1. CONNECT SYS/oracle@catdb AS SYSDBA

Create a user and schema for the recovery catalog
2. CREATE USER rman IDENTIFIED BY cat TEMPORARY TABLESPACE temp DEFAULT TABLESPACE tools QUOTA UNLIMITED ON tools;

Grant the recovery_catalog_owner role to the user
3. GRANT RECOVERY_CATALOG_OWNER TO rman;

Connect to rman catalog and create catalog
4. rman CATALOG rman/cat@catdb
   CREATE CATALOG;


Register database to catalog
5. rman TARGET sys/oracle@ault1 CATALOG rman/cat@rmandb
   REGISTER DATABASE;
   report schema;  


Check database registered in RMAN catalog
6. select * from rc_database where name = ‘TESTDB’;

Register Older Backups to RMAN Catalog
7. CATALOG START WITH '/disk1/backups/'; 


RMAN Hot Backup Script:
configure controlfile autobackup on;
ALLOCATE CHANNEL c1 DEVICE TYPE disk;
backup AS COMPRESSED BACKUPSET full database tag ORCL_FULL format '/opt/oracle/backups/ORCL/%d_%T_%s_%p_FULL' ;
sql 'alter system archive log current';
backup tag ORCL_ARCHIVE format '/opt/oracle/backups/ORCL/%d_%T_%s_%p_ARCHIVE' archivelog all delete all input ;
backup tag ORCL_CONTROL current controlfile format '/opt/oracle/backups/ORCL/%d_%T_%s_%p_CONTROL';
release channel c1;






No comments:

Post a Comment