Monday, September 1, 2014

Steps to setup RMAN


This article is tested in oracle11gR2. How do we setup the RMAN in oracle? There are couple of ways, we can setup the RMAN. We can use control file to store backup catalog info or we can have separate database to store catalog info. Here I am using separate database to store backup catalog
information.

I am using Linux OS. Please remember, the directories and folder might change based on the operating system and environment. But the below steps are pretty much same for any environment.

Here i am using ORCL as primary database and CATDB as catalog database.

 Step1 Enabling Archive log. See the following link for the First step


Step2 Create the tablespace and user in catalog database to hold backup information.

SQL> CONNECT sys/password@catdb AS SYSDBA
Connected.

SQL> CREATE TABLESPACE RMAN
2 DATAFILE '/DBA_Test/d02/app/oracat/oradata/catdb/rman01.dbf' SIZE 6208K REUSE
3 AUTOEXTEND ON NEXT 64K MAXSIZE 32767M
4 EXTENT MANAGEMENT LOCAL
5 SEGMENT SPACE MANAGEMENT AUTO;

Tablespace created.

SQL> CREATE USER rman IDENTIFIED BY rman
2 TEMPORARY TABLESPACE temp
3 DEFAULT TABLESPACE rman
4 QUOTA UNLIMITED ON rman;

User created.

SQL> GRANT connect, resource, recovery_catalog_owner TO rman;

Grant succeeded.

SQL>

Step3 Create the recovery catalog in catalog database.

SQL>rman catalog=rman/rman@catdb

Recovery Manager: Release 10.2.0.1.0 - Production on Thu May 21 09:59:26 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to recovery catalog database


Sometimes you'll face the issue while trying to connect RMAN using the above mentioned command, probably the error would be 


SP2-0734: unknown command beginning "rman catal..." - rest of line ignored.

Follow the below given steps to overcome this issue.

[oracat@localhost ~]$ rman

Recovery Manager: Release 10.2.0.1.0 - Production on Thu May 21 15:59:12 2009

Copyright (c) 1982, 2005, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect catalog rman@oracat

recovery catalog database Password:

RMAN> create catalog tablespace "RMAN";

recovery catalog created

RMAN> exit

Recovery Manager complete.

[oracat@server1 ~]$

Step4 Register the database with Catalog database. Each database should be registered to catalog database to run RMAN backup.

[oracat@server1 ~]$rman target / catalog rman/rman@catdb

Recovery Manager: Release 10.2.0.1.0 - Production on Thu May 21 10:02:01 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: CATDB (DBID=1215124933)
connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

RMAN> exit

Recovery Manager complete.

[oracat@server1 ~]$

[oraint@server1 ~]$ rman target / catalog rman/rman@catdb

Recovery Manager: Release 10.2.0.1.0 - Production on Thu May 21 10:02:01 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1215124933)
connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

RMAN> exit

Recovery Manager complete.

[oraint@server1 ~]$

Step5 Configure the persistent parameters.
[oraint@server1 ~]$ rman target / catalog rman/rman@catdb

Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 19 18:46:40 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1215054467)
connected to recovery catalog database

RMAN> configure retention policy to recovery window of 2 days;

new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure default device type to disk;

new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure controlfile autobackup on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure channel device type disk format 'DBA_Test/rmanbackup/Backup%d_DB_%U_%T_%s_%t';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'DBA_Test/rmanbackup/Backup_DB_%d_DB_%U_%T_%s_%t';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>


 Step 6 Take database full backup. The full database backup should be taken        first time. Afterwards, archivelog backup will be taken.
[oraint@server1 ~]$ rman target / catalog rman/rman@catdb

Recovery Manager: Release 10.2.0.1.0 - Production on Thu May 21 10:16:09 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1215124933)
connected to recovery catalog database

RMAN> run{
2> backup database plus archivelog;
3> delete noprompt obsolete;
4> }

Starting backup at 22-SEP-05
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=21 RECID=2 STAMP=569633386
input archived log thread=1 sequence=22 RECID=3 STAMP=569642984
input archived log thread=1 sequence=23 RECID=4 STAMP=569643339
input archived log thread=1 sequence=24 RECID=5 STAMP=569643519
channel ORA_DISK_1: starting piece 1 at 22-SEP-05
channel ORA_DISK_1: finished piece 1 at 22-SEP-05
piece handle=/DBA_Test/rmanbackup/BackupORCL_DB03gv84g2_1_1_%S_%P tag=TAG20050922T021841 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 22-SEP-05
Starting backup at 22-SEP-05
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/Integration/app/oraint/oradata/orcl/system01.dbf
input datafile file number=00002 name=/Integration/app/oraint/oradata/orcl/sysaux01.dbf
input datafile file number=00008 name=/Integration/app/oraint/oradata/orcl/TEST_iasactivities.dbf
input datafile file number=00009 name=/Integration/app/oraint/oradata/orcl/TEST_urmserver.dbf
input datafile file number=00015 name=/Integration/app/oraint/oradata/orcl/TEST_ocs.dbf
input datafile file number=00005 name=/Integration/app/oraint/oradata/orcl/example01.dbf
input datafile file number=00010 name=/Integration/app/oraint/oradata/orcl/TEST_iaswebcenter.dbf
input datafile file number=00006 name=/Integration/app/oraint/oradata/orcl/TEST_ipm.dbf
input datafile file number=00003 name=/Integration/app/oraint/oradata/orcl/undotbs01.dbf
input datafile file number=00011 name=/Integration/app/oraint/oradata/orcl/TEST_ocssearch.dbf
input datafile file number=00012 name=/Integration/app/oraint/oradata/orcl/TEST_iasjive.dbf
input datafile file number=00013 name=/Integration/app/oraint/oradata/orcl/TEST_orairm.dbf
input datafile file number=00014 name=/Integration/app/oraint/oradata/orcl/TEST_mds.dbf
input datafile file number=00007 name=/Integration/app/oraint/oradata/orcl/TEST_webcenter_portlet.dbf
input datafile file number=00004 name=/Integration/app/oraint/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 22-SEP-05
channel ORA_DISK_1: finished piece 1 at 22-SEP-05
piece handle=/DBA_Test/rmanbackup/BackupORCL_DB04gv84g6_1_1_%S_%P tag=TAG20050922T021844 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 22-SEP-05

Starting backup at 22-SEP-05
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=25 RECID=6 STAMP=569643592
channel ORA_DISK_1: starting piece 1 at 22-SEP-05
channel ORA_DISK_1: finished piece 1 at 22-SEP-05
piece handle=/DBA_Test/rmanbackup/BackupORCL_DB05gv84ic_1_1_%S_%P tag=TAG20050922T021955 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 22-SEP-05

Starting Control File and SPFILE Autobackup at 22-SEP-05
piece handle=/Integration/app/oraint/product/11.2.0/dbhome_1/dbs/c-1097368849- 20050922-00 comment=NONE
Finished Control File and SPFILE Autobackup at 22-SEP-05

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 2 days
using channel ORA_DISK_1
no obsolete backups found

RMAN> exit


Recovery Manager complete.
[oraint@server1 ~]$


Now the RMAN setup is completed successfully. Here are the info about RMAN.

Primary DB = ORCL
Catalog DB = CATDB
RMAN Backup location = /DBA_Test/rmanbackup.
Now the full backup is taken. Every day, the below script should run and backup the new archive log files.

[oraint@server1 ~]$rman target / catalog rman/rman@catdb

Recovery Manager: Release 10.2.0.1.0 - Production on Thu May 21 10:25:40 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1215124933)
connected to recovery catalog database

RMAN> run{
2> delete noprompt obsolete;
3> backup archivelog all;
4> }

Enabling Archive log in RMAN


This article is tested in oracle11gR2. How do we setup the RMAN in oracle? There are couple of ways, we can setup the RMAN. We can use control file to store backup catalog info or we can have separate database to store catalog info. Here I am using separate database to store backup catalog
information.

I am using Linux OS. Please remember, the directories and folder might change based on the operating system and environment. But the below steps are pretty much same for any environment.

Here i am using ORCL as primary database and CATDB as catalog database.

Step1 Enable the archive log in ORCL database.

Step 1.1 We need to build the pfile from spfile to add new entries. If you already have recent pfile, the you do not need to do this step.

Login as sys user and execute this to create pfile.

create pfile='/Integration/app/oraint/product/11.2.0/dbhome_1/dbs/pfile.ora' from spfile;

Step 1.2 Once pfile is created, then edit the pfile and add the below two parameters.

log_archive_format=Log_%s_%t_%r.arc
log_archive_dest='/Integration/app/oraint/product/11.2.0/dbhome_1/database/archive'

In case, if you already have the below two entries in the pfile, then we need to remove or comment this below two entries. Since we can not have this below two entry with above new two parameters.

db_recovery_file_dest='/Integration/app/oraint/fast_recovery_area'
db_recovery_file_dest_size=4322230272


Till oracle9i, we use
log_archive_start=true in parameter file. Since from oracle10g, this parameter is deprecated. We should not add this entry in pfile from oracle10g. If we have this entry in oracle10g, we get the below error.

ORA-32004:obsolete and/or deprecated parameter specified.

Step 1.3 Once pfile is edited, then we need to create the spfile with modified pfile. Login as sys user and execute the below command.

create spfile = '/Integration/app/oraint/product/11.2.0/dbhome_1/dbs/XX.ORA' from pfile='/Integration/app/oraint/product/11.2.0/dbhome_1/dbs/PFILE.ORA'

Step 1.4 Rename the original SPFILEORCL.ORA to different name. Then rename the XX.ORA to SPFILEORCL.ORA.

Step 1.5 Login as sys user and shutdown the database and follow the steps.

Mount the database
alter database archivelog
alter database open;

Here is the screen output....

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 188746628 bytes
Database Buffers 415236096 bytes
Redo Buffers 7135232 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination / Integration/app/oraint/product/11.2.0/dbhome_1/ database/archive
Oldest online log sequence 2
Next log sequence to archive 4
Current log sequence 4
SQL>

IAS Cache initialization failed

 Today I faced an Issue in R12.2 instance. The solution I followed to overcome the issue is very simple, but they are more than one solution...