Pre-backup steps
1. at oktinfa1, create user rman_<oracle_sid>, and grant the same privileges as other ‘RMAN_ ‘ users
select * from dba_users where username like 'RMAN%'
e.g create user rman_oktcf3 identified by back1th0t default tablespace RMAN_D_A01 temporary tablespace TEMP;
select * from dba_role_privs where grantee = ‘RMAN_OKDCF2’
grant CONNECT, RECOVERY_CATALOG_OWNER, RESOURCE to rman_oktcf3;
2. At targeted DB, using oracle user account, sign in as sysdba,
su - oracle
. seaenv
input : oracle_sid
Login to as sysdba : sqlplus "/as sysdba"
3. Create user rbackup < follow other db for the privileges and password>
- its just a dummy account, it can be used because of the catalogue
- update the ‘rbackup’, and ‘rman_oraclesid’ user password at readpwd, location: /usr/local/sysbin/upd_orasystem.passwd using root account
4. Check archive log list, enable archive log if it’s in disable mode
archive log list;
In order to enable archivelog mode, you’ll need to first shutdown the DB, before you proceed with the steps:
SQL> startup mount
ORACLE instance started.
Total System Global Area 184549376 bytes
Fixed Size 1300928 bytes
Variable Size 157820480 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
5. Connect to RMAN and register the database.
connect rman with command rman target rbackup/<password>
RMAN > create catalog;
RMAN > connect rcvcat rman_oktcf3/back1th0t@oktinfa1;
RMAN> register database;
RMAN> show all;
At directory /seamnt/bck101/backups/<Oracle_sid>
Create same directory as ARCH, CTLFLE, FULL
Backup script
Create the script and locate it the same directory , /seamnt/bck101/backups/, amend it accordingly, set it as executable file and execute it.
Sample Script : Reference from Subra
set command id to 'okpbox1_FULL_0';
run {
allocate channel d1 type disk format '/seamnt/bck101/backups/okpbox1/FULL/okpbox1_%Y-%M-%D_%U';
allocate channel d2 type disk format '/seamnt/bck102/backups/okpbox1/FULL/okpbox1_%Y-%M-%D_%U';
allocate channel d3 type disk format '/seamnt/bck103/backups/okpbox1/FULL/okpbox1_%Y-%M-%D_%U';
allocate channel d4 type disk format '/seamnt/bck104/backups/okpbox1/FULL/okpbox1_%Y-%M-%D_%U';
allocate channel d5 type disk format '/seamnt/bck105/backups/okpbox1/FULL/okpbox1_%Y-%M-%D_%U';
allocate channel d6 type disk format '/seamnt/bck106/backups/okpbox1/FULL/okpbox1_%Y-%M-%D_%U';
sql 'alter system switch logfile';
sql 'alter database backup controlfile to trace';
backup as compressed backupset database tag 'okpbox1_FULL_L0' ;
backup as copy current controlfile tag 'cf_okpbox1_FULL_0' format '/seamnt/bck106/backups/okpbox1/CTLFLE/okpbox1_CF_FULL_0-D_%d_%u';
release channel d1;
release channel d2;
release channel d3;
release channel d4;
release channel d5;
release channel d6;
}
exit;
Sample 2: Reference from Eric
#!/bin/ksh
export ORACLE_HOME=/u01/oracle/product/11.2.0.4
export ORACLE_SID=oktcf3
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
RDRBPW=`/usr/local/sysbin/readpwd oktcf3 rbackup`
RDRMPW=`/usr/local/sysbin/readpwd oktinfa1 rman_oktcf3`
rman log=/seamnt/bck101/backups/oktcf3/FULL/rman_backup_`date +"%m%d%y"`.log <<EOF
connect target rbackup/${RDRBPW}
connect rcvcat rman_oktcf3/${RDRMPW}@oktinfa1
set command id to 'OKTCF3_FULL_0';
run {
sql 'alter session set optimizer_mode=RULE';
sql 'alter session set db_file_multiblock_read_count = 128';
crosscheck archivelog all;
allocate channel d1 type disk format '/seamnt/bck101/backups/oktcf3/FULL/oktcf3_%Y-%M-%D_%U';
sql 'alter system switch logfile';
sql 'alter database backup controlfile to trace';
backup as compressed backupset database tag 'oktcf3_FULL_L0';
backup as copy archivelog all format '/seamnt/bck101/backups/oktcf3/ARCH/oktcf3_ARCH_FULL_0-D_%d_%u' delete input;
backup as copy current controlfile tag 'cf_oktcf3_FULL_0' format '/seamnt/bck101/backups/oktcf3/CTLFLE/oktcf3_CF_FULL_0-D_%d_%u';
delete obsolete;
}
exit;
Note : For 12c database, you maybe encounter the error during the ‘create catalog’ step
Reference copied from Grepora.com
Error : RMAN-07539: insufficient privileges to create or upgrade the catalog schema
Solution:
– Connect on the catalog database with the 12c (local) OH:
(and don’t worry about the error on alter session).
SQL> @?/rdbms/admin/dbmsrmansys.sql
alter session set "_ORACLE_SCRIPT" = true
*
ERROR at line 1:
ORA-02248: invalid option for ALTER SESSION
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
alter session set "_ORACLE_SCRIPT" = false
*
ERROR at line 1:
ORA-02248: invalid option for ALTER SESSION
– Then try to upgrade catalog again:
[oracle@databasesrvr dbs]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Jul 21 14:21:27 2015
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: MYDB (not mounted)
RMAN> connect catalog catalog_mydb/catalog_mydb@catalogdb
connected to recovery catalog database
PL/SQL package CATALOG_MYDB.DBMS_RCVCAT version 11.02.00.03 in RCVCAT database is too old
RMAN> upgrade catalog;
recovery catalog owner is CATALOG_MYDB
enter UPGRADE CATALOG command again to confirm catalog upgrade
RMAN> upgrade catalog;
recovery catalog upgraded to version 12.01.00.02
DBMS_RCVMAN package upgraded to version 12.01.00.02
DBMS_RCVCAT package upgraded to version 12.01.00.02.