RMAN Scripts


How To Configure RMAN Backups To Tape via Oracle Enterprise Manager

 Solution

+ Log in to Oracle Enterprise Manager Database Control

+ Navigate to: Maintenance -> Backup Settings -> Device

If grid control is used, we need to first select the appropriate database from Targets.

+ Now, under Tape Settings, specify the number of Tape Drives that will be available for this backup schedule/policy. RMAN will allocate that many simultaneous channels as many Tape Drives are specified.

+ On the same screen, specify the MML specific parameters under "Media Management Vendor Library Parameters" which as per our example above are:

ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)

Refer to the example script above and the screen shot below:





 + Specify preferred credentials on the same page if they are not configured already. Additionally, also configure advanced settings such as CONTROLFILE AUTOBACKUP or the backup Retention Policy under the Policy sub-tab of the Backup Settings page. Click OK to save your settings.

+ Now, navigate to: Maintenance -> Schedule Backup.




+ Select Whole Database under Customized Backup and click Schedule Customized Backup. In the screen that follows, accept the defaults though you may like to tinker with some of the settings i.e. to delete obsolete backups etc under Advanced as per your requirement. click Next.



 + In this screen, select Tape to make backups to TAPE. Notice that the MML parameters that we saved earlier are shown here:


+ Click Next.On the new page you can specify Job Name, Job Description and the job schedule. Make appropriate changes and click Next.
 


+ Click Next

+ This last page now summarizes the configuration we have specified for our backup job and the EM generated script. You might want to edit the EM generated backup script for customized tags or format (backup-piece handle). After you have ensured all settings are appropriate, click Submit Job to complete the setup.
Refference: 735953.1
 








Enabling ARCHIVELOG Mode

Check Archive is enabled or not

SQL> SELECT LOG_MODE FROM SYS.V$DATABASE;

LOG_MODE
------------
NOARCHIVELOG

Set InitSID.ora on following parameter

remote_login_passwordfile=EXCLUSIVE
log_archive_dest='/u02/oracle/backup'
log_archive_format='PROD_arch_%s_%t_%r.arc'


Create Password File

orapwd file=/u01/oramgr/PROD/db/tech_st/10.2.0/dbs/orapwPROD entries=1 password=oracle


SQL> alter database archivelog;
Database altered.

SQL> alter database open;
Database altered.


V$DATABASE

Identifies whether the database is in ARCHIVELOG or NOARCHIVELOG mode and whether MANUAL (archiving mode) has been specified.

V$ARCHIVED_LOG

Displays historical archived log information from the control file. If you use a recovery catalog, the RC_ARCHIVED_LOG view contains similar information.

V$ARCHIVE_DEST

Describes the current instance, all archive destinations, and the current value, mode, and status of these destinations.

V$ARCHIVE_PROCESSES

Displays information about the state of the various archive processes for an instance.

V$BACKUP_REDOLOG

Contains information about any backups of archived logs. If you use a recovery catalog, the
RC_BACKUP_REDOLOG contains similar information.

V$LOG

Displays all redo log groups for the database and indicates which need to be archived.

V$LOG_HISTORY

Contains log history information such as which logs have been archived and the SCN range for each archived log.

Using these tables we can verify that we are infact in ARCHIVELOG mode:

SQL> select log_mode from v$database;

LOG_MODE
------------
ARCHIVELOG

SQL> select DEST_NAME,STATUS,DESTINATION from V$ARCHIVE_DEST;
In Oracle 10.2 and above RMAN is supported by a number of new dynamic performance views including:
V$BACKUP_ARCHIVELOG_DETAILS
V$BACKUP_ARCHIVELOG_SUMMARY
V$BACKUP_CONTROLFILE_DETAILS
V$BACKUP_CONTROLFILE_SUMMARY
V$BACKUP_COPY_DETAILS
V$BACKUP_COPY_SUMMARY
V$BACKUP_DATAFILE_DETAILS
V$BACKUP_DATAFILES_SUMMARY
V$BACKUP_PIECE_DETAILS
V$BACKUP_SET_DETAILS
V$BACKUP_SET_SUMMARY
V$BACKUP_SPFILE_DETAILS
V$BACKUP_SPFILE_SUMMARY
v$archived_log
v$archived_log


RMAN> list backup summary;
list backup by datafile;
list backup of database;
list backup of archivelog all;
list backup of controlfile;

Creating a RMAN Clone Database and Apps 11i on a New Host

Primary Database SID: PROD
Duplicate Database SID: TEST
RMAN Catalog SID: RMAN


Steps

1. Backup the primary database.

2. Determine how much disk space will be required.

3. Ensuring you have enough space on your target server.

4. Making the backup available for the duplicate process.

5. Creating the init.ora & administration directories for the duplicate database.

6. Prepare RMAN duplicate script.

7. Execute the RMAN script.

1. Backup of the primary database.

Host A (Target)

Prior to creating a duplicate database you must have a backup of the target database. In this example we assume the backup media is disk. Find appropriate disk space on host A and take a full backup including archive logs and current controlfile. If you are planning to duplicate a subset of the database refer to (Figure 1b) this illustrates the RMAN command to backing up certain tablespaces.
[oracle@AIX] export ORACLE_SID=PROD

[oracle@AIX] rman target=/ catalog=rman/rman@RMAN

RMAN> run {
allocate channel d1 type disk;
backup format '/d01/backup/PROD/datafile_t%t_s%s_p%p' database;
sql 'alter system archive log current';
backup format '/d01/backup/PROD/alog_t%t_s%s_p%p' archivelog all;
release channel d1;
}
This above command will perform a full database backup including archivelogs and the current controlfile.

2. Determine how much disk space will be required.

Host A(Target) -

After deciding what you will be duplicating, calculate the entire space this will require on the new host. The full database calculation will calculate the entire space required whereas allows you to enter the tablespace names in order to calculate the space required.

SQL> select DF.TOTAL/1048576 "DataFile Size Mb",
LOG.TOTAL/1048576 "Redo Log Size Mb",
(DF.TOTAL + LOG.TOTAL)/1048576 "Total Size Mb" from dual,
(select sum(a.bytes) TOTAL from dba_data_files a) DF,
(select sum(b.bytes) TOTAL from v$log b) LOG;

Calculate space for list of tablespaces within primary database
DataFile Size Mb Redo Log Size Mb Total Size Mb
---------------- ---------------- -------------
31860 20 31880

3. Ensuring you have enough space on your target server.

Host B (TEST)

Prior to starting the duplicate process you must ensure you have enough disk space within file system to hold the database
appltest@test : /d05> df -sg
Filesystem GB blocks Free* %Used Iused %Iused Mounted on
/dev/hd4 0.25 0.18 27% 5262 11% /
/dev/hd2 2.75 0.35 88% 38731 32% /usr
/dev/hd9var 1.25 0.08 94% 1404 8% /var
/dev/hd3 1.00 0.32 68% 2860 4% /tmp
/dev/fwdump 0.50 0.50 1% 4 1% /var/adm/ras/platform
/dev/hd1 6.25 5.94 5% 4411 1% /home
/proc - - - - - /proc
/dev/hd10opt 0.75 0.25 67% 14037 20% /opt
/dev/locallv 0.25 0.25 1% 71 1% /usr/local
/dev/disk02lv 260.00 33.54 88% 2131066 18% /d05

4. Making the backup available for the duplicate process.

If your backup resides on disk you will need to copy this back up from host A to host B. Ensure you place it in the same directory as where it was created. In the example below the backup piece resides in ‘/backup/PROD’ these files need to be copied into the same directory on host B.

Furthermore also ensure than all archive log backups have also been moved and any archive logs in the archive log directory that may be require for the recovery. The archive logs required will depend on the point in time of the recovery.
RMAN> list backup;
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
22 Full 529M DISK 00:00:51 2007/08/25 12:19:05
BP Key: 22 Status: AVAILABLE Compressed: NO Tag: TAG20070825T111203
Piece Name: /backups/PROD/datafile_t598321425_s23_p1
List of Datafiles in backup set 22
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
1 Full 1393845 2007/08/25 11:12:03 /oradata/PROD/system01.dbf
2 Full 1393845 2007/08/25 11:12:03 /oradata/PROD/undotbs01.dbf
3 Full 1393845 2007/08/25 11:12:03 /oradata/PROD/sysTEST01.dbf
4 Full 1393845 2007/08/25 11:12:03 /oradata/PROD/users01.dbf
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
24 48M DISK 00:00:06 2007/08/25 12:58:55
BP Key: 24 Status: AVAILABLE Compressed: NO Tag: TAG20070825T111301
Piece Name: /backups/PROD/alog_t598321429_s25_p1
List of Archived Logs in backup set 24
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- ------------------- ---------- ---------
1 78 1344750 2007/08/24 04:55:34 1353208 2007/08/24 10:00:19
1 79 1353208 2007/08/24 10:00:19 1353213 2007/08/24 10:00:20
1 80 1353213 2007/08/24 10:00:20 1372464 2007/08/24 22:00:11
1 81 1372464 2007/08/24 22:00:11 1373291 2007/08/24 22:00:59
1 82 1373291 2007/08/24 22:00:59 1381066 2007/08/25 03:00:08
1 83 1381066 2007/08/25 03:00:08 1390685 2007/08/25 09:03:00
1 84 1390685 2007/08/25 09:03:00 1393870 2007/08/25 11:13:00
1 85 1393870 2007/08/25 11:13:00 1393929 2007/08/25 11:13:00

5. Creating the init.ora & administration directories for the duplicate database.
# +----------------------------------------+
# FILE : initTEST.ora
# DATABASE NAME : TEST
# +----------------------------------------+
# Set the below to location of the clone Duplicate database / name of
# clone database.
# Set the below to the location of the duplicate clone control file.
# Set the below for the from and to location for all data files / redo
# logs to be cloned.
db_file_name_convert =("/d05/oradata/PROD/", "/d04/oradata/TEST/")
log_file_name_convert =("/d05/oradata/PROD/", "/d04/oradata/TEST/")
#Set the below to the same as the production target
Following the creation of the initTEST.ora startup nomount the auxiliary instance.
[oracle@AIX]export ORACLE_SID=TEST

[oracle@AIX] sqlplus '/as sysdba'

SQLPLUS> startup nomount;


6. Prepare RMAN duplicate script.

In a working directory on Host B create an RMAN script file clone.rcv. The example below shows the command for a complete duplicate (figure 7b) skips the tablespaces which are not required in the duplicate andprovide the syntax required for a point in time duplicate.

run {
allocate auxiliary channel C1 device type disk;
duplicate target database to TEST;
}

7. Execute the RMAN script.

Start RMAN, connect to the production target, the catalog instance and also the TESTiliary clone. Run the RMAN duplicate script as shown below. Before doing this ensure that the Oracle SID environment variable is set to the duplicate clone database.

[oracle@AIX] export ORACLE_SID=TEST
[oracle@AIX] rman target sys/sys@PROD catalog rman/rman@rman auxiliary /
RMAN> @clone.rcv


or

run
{
allocate auxiliary channel C1 device type disk;
duplicate target database to TEST;
}

This for Apps 11i Database
After Database creation, We need to create XML file.

Step 1: perl admkappsutil.pl

$ cd $AD_TOP/bin
$ pwd
/d05/appsdev2/oracle/prodappl/ad/11.5.0/bin
$ perl admkappsutil.pl
Starting the generation of appsutil.zip
Log file located at /d05/appsdev2/oracle/prodappl/admin/log/MakeAppsUtil_08010323.log
output located at /d05/appsdev2/oracle/prodappl/admin/out/appsutil.zip

root@TEST2 # cd /d05/appsdev2/oracle/prodappl/admin/out
$ ls -lst

root@TEST2 # cp appsutil.zip /d05/oracle/9.2.3
bash-2.03$ unzip -o appsutil.zip

Archive: appsutil.zip
inflating: appsutil/java/oracle/apps/ad/autoconfig/oam/CtxSynchronizer.class

bash-2.03$ perl adbldxml.pl tier=db appsuser=apps appspasswd=apps
appsutil/java/oracle/apps/ad/autoconfig/oam/CtxSynchronizerException.class

Also the Database table GLOBAL_NAME is hosting wrong value for domain.

Enter domain name:testdm

Enter the value for Display Variable: 169.16.3.1:0.0

Context File /d05/oracle/9.2.3/appsutil/DEV_TEST2.xml
already exists.

Overwriting Context File may cause loss of existing settings, hence
backing it up as: /d05/oracle/9.2.3/appsutil/DEV_TEST2.xml.bak

The context file has been created at:
/d05/oracle/9.2.3/appsutil/DEV_TEST2.xml

The log file for this adbldxml session is located at:
/d05/oracle/9.2.3/appsutil/log/DEV_TEST2/08010337.log

bash-2.03$ pwd
/d05/oracle/9.2.3/appsutil/bin

bash-2.03$ perl adconfig.pl contextfile=/d05/oracle/9.2.3/appsutil/DEV_hostname.xml appspass=apps

AutoConfig is configuring the Database environment...
Context Value Management will now update the Context file

Updating Context file...COMPLETED

Attempting upload of Context file and templates to database...COMPLETED

Updating rdbms version in Context file to db920
Updating rdbms type in Context file to 64 bits
Configuring templates from ORACLE_HOME ...

AutoConfig completed successfully.
The log file for this session is located at: /d05/oracle/9.2.3/appsutil/log/DEV_hostname2/08011549/adconfig.log

Apps Tier Colne

bash-2.03$ pwd
cd $ORACLE_HOME/appsutil/scripts/
perl adpreclone.pl dbTier
Running Rapid Clone with command...

Configure the target system application tier server nodes
Log on to the target system as the APPLMGR user and type the following commands:
cd /clone/bin
perl adcfgclone.pl appsTier

Create Recovery Catalog

Create Recovery Catalog

First create a user to hold the recovery catalog:
STEP 1
CONNECT sys/chnangeoninstall@RMAN AS SYSDBA

-- Create tablepsace to hold repository

CREATE TABLESPACE RMAN
DATAFILE '/d05/rmancat/rmandata/RMAN01.DBF' SIZE 500M REUSE
AUTOEXTEND ON NEXT 64K MAXSIZE 32767M
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO;

create temporary tablespace TEMP tempfile '/d05/rmancat/rmandata/temp01.dbf' size 500M reuse
autoextend on next 32m maxsize 2048m
extent management local;

-- Create rman schema owner
STEP 2
CREATE USER rman IDENTIFIED BY rman
TEMPORARY TABLESPACE temp
DEFAULT TABLESPACE rman
QUOTA UNLIMITED ON rman;

STEP 3

GRANT connect, resource, recovery_catalog_owner TO rman;

STEP 4

Then create the recovery catalog:

$ rman catalog=rman/rman@RMAN

Recovery Manager: Release 9.2.0.3.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to recovery catalog database
recovery catalog is not installed

RMAN> create catalog tablespace "RMAN";

recovery catalog created

RMAN> exit

Recovery Manager complete.

Register Database
Each database to be backed up by RMAN must be registered:

$ rman catalog=rman/rman@RMANCAT target=sys/oracle@TEST
Recovery Manager: Release 9.2.0.3.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: TEST (DBID=1371963417)
connected to recovery catalog database

RMAN> register database;

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

*************************************************************************

No comments:

SHRD0014: GLLEZL - process exiting with failure

  SYMPTOMS Journal Import completes with the following error: Error ------ ORA-01653 : unable to extend table GL.GL_IMPORT_REFERENCES ORA-01...