Look in:

Web oracle-core-dba.blogspot.com

Wednesday, March 19, 2008

Rman Recovery Scenarios

Rman recovery scenarios require that the database
is in archive log mode, and that backups of datafiles,
control files and archived redolog files are made using
Rman. Incremental Rman backups may be used also.

Rman can be used with the repository installed on the
archivelog, or with a recovery catalog that may be
installed in the same or other database.

Configuration and operation recommendations:

Set the parameter controlfile autobackup to ON
to have with each backup a controlfile backup also:

rman>configure controlfile autobackup on;

Set the parameter retention policy to the recovery
window you want to have, i.e redundancy 2 will keep
the last two backups available, after executing
delete obsolete commands:

rman>configure retention policy to redundancy 2;

Execute your full backups with the option
'plus archivelogs' to include your
archivelogs with every backup:

rman>backup database plus archivelog;

Perform daily maintenance routines to maintain on
your backup directory the number of backups you need only:

rman>crosscheck backup;
rman>crosscheck archivelog all;
rman>delete noprompt obsolete backup;

To work with Rman and a database based
catalog follow these steps:
1. sqlplus /
2. create tablespace repcat;
3. create user rcuser identified by rcuser default tablespace repcat
temporary tablespace temp;
4. grant connect, resource, recovery_catalog_owner to rcuser;
5. exit
6. rman catalog rcuser/rcuser # connect to rman catalog as the rcuser
7. create catalog # create the catalog
8. connect target / #
=============================================
Complete Closed Database Recovery. System tablespace is missing
---------------------------------------------
In this case complete recovery is performed, only the
system tablespace is missing, so the database can be
opened without reseting the redologs.
1. rman target /
2. startup mount;
3. restore database;
4. recover database;
5. alter database open;
=============================================
Complete Open Database Recovery. Non system tablespace
is missing,database is up
---------------------------------------------
1. rman target /
2. sql 'alter tablespace offline immediate';
3. restore datafile 3;
4. recover datafile 3;
5. sql 'alter tablespace online';
=============================================
Complete Open Database Recovery (when the database
is initially closed). Non system tablespace is missing
---------------------------------------------
A user datafile is reported missing when trying to
startup the database. The datafile can be turned offline
and the database started up. Restore and recovery are
performed using Rman. After recovery is performed
the datafile can be turned online again.
1. sqlplus /nolog
2. connect / as sysdba
3. startup mount
4. alter database datafile '' offline;
5. alter database open;
6. exit;
7. rman target /
8. restore datafile '';
9. recover datafile '';
10. sql 'alter tablespace online';
=============================================
Recovery of a Datafile that has no backups (database is up).
---------------------------------------------
If a non system datafile that was not backed up since
the last backup is missing, recovery can be performed
if all archived logs since the creation of the missing
datafile exist. Since the database is up you can check
the tablespace name and put it offline. The option offline
immediate is used to avoid that the update of the datafile header.

Pre requisites: All relevant archived logs.
1. sqlplus '/ as sysdba'
2. alter tablespace offline immediate;
3. alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf;
4. exit
5. rman target /
6. recover tablespace ;
7. sql 'alter tablespace online';
If the create datafile command needs to be executed to place
the datafile on a location different than the original use:
alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf' as
'/user/oradata/u02/dbtst/newdata01.dbf'
=============================================
Restore and Recovery of a Datafile to a different location. Database is up.
---------------------------------------------
If a non system datafile is missing and its original
location not available, restore can be made to a different
location and recovery performed.

Pre requisites: All relevant archived logs, complete cold or hot backup.
1. Use OS commands to restore the missing or corrupted datafile to the new
location, ie:
cp -p /user/backup/uman/user01.dbf /user/oradata/u02/dbtst/user01.dbf
2. alter tablespace offline immediate;
3. alter tablespace rename datafile
'/user/oradata/u01/dbtst/user01.dbf' to '/user/oradata/u02/dbtst/user01.dbf';
4. rman target /
5. recover tablespace ;
6. sql 'alter tablespace online';
=============================================
Control File Recovery
---------------------------------------------
Always multiplex your controlfiles. If you loose only one
controlfile you can replace it with the one you have in place,
and startup the Database. If both controlfiles are missing,
the database will crash.

Pre requisites: A backup of your controlfile and all relevant
archived logs. When using Rman alway set configuration parameter
autobackup of controlfile to ON. You will need the dbid to
restore the controlfile, get it from the name of the backed up
controlfile. It is the number following the 'c-' at the start of the name.
1. rman target /
2. set dbid
3. startup nomount;
4. restore controlfile from autobackup;
5. alter database mount;
6. recover database;
7. alter database open resetlogs;
8. make a new complete backup, as the database is open in a new incarnation and
previous archived log are not relevant.
=============================================
Incomplete Recovery, Until Time/Sequence/Cancel
---------------------------------------------
Incomplete recovery may be necessaire when the database
crash and needs to be recovered, and in the recovery process
you find that an archived log is missing. In this case recovery
can only be made until the sequence before the one that is missing.

Another scenario for incomplete recovery occurs when an important
object was dropped or incorrect data was committed on it.
In this case recovery needs to be performed until before the
object was dropped.

Pre requisites: A full closed or open database backup and archived
logs, the time orsequence that the 'until' recovery
needs to be performed.
1. If the database is open, shutdown it to perform full restore.
2. rman target \
3. startup mount;
4. restore database;
5. recover database until sequence 8 thread 1; # you must pass the thread, if a
single instance will always be 1.
6. alter database open resetlogs;
7. make a new complete backup, as the database is open in a new incarnation and
previous archived log are not relevant.
Alternatively you may use instead of until sequence, until time, ie: '2008-03-
16:01:01:10'.

Saturday, March 15, 2008

How to change the root password of a linux server.

Use this information at your own risk,

Please note that you cannot perform this remotely,
you must be physically at the machine.

1. The first step is to reboot server.

2. Since the server I inherit has GRUB, wait until
the grub splash screen comes on and hit the letter 'e'
on your keyboard. this will stop grub.

3. hit 'e' again and this will take you to another screen

4. you should see one of the choices has "kernel"
select the one with "kernel

5. hit 'e' on your keyboard

6. type ' single' or 1 (make sure to include a space before "single/1")
and hit enter. then enter 'b' to boot.

7. your system should boot up in single mode as root

8. now that you are logged in single mode you can
change the root password by sending this command:
-->> passwd
Give the new password

9. after you have changed the root password, reboot server
and you should be able to login with the new password.

DONE

LILO ----------------------------

1. If you have LILO, its different, first reboot server and when you
see the LILO: prompt type "linux single" and hit enter.
this will log you in as root in single user mode.

2. Once booting is complete, you can change your password with this command:
-->> passwd
Give the new password
and reboot server.

DONE

Usage of Split command in Linux.

Split, have a large file that you need to split into smaller chucks? A Oracle dump maybe? split is your command. Below I split a 110MB file into 30 megabyte chunks.

Split works just fine on both text, and binary (even compressed) files. An example is worth a thousand words of man page (that don't have examples). Here I have TBL_LOSANGELES_CA.dmp, a 109MB Oracle export dump file.

[root@oracle11gr1 ~]# mkdir split
[root@oracle11gr1 ~]# mv /share/TBL_LOSANGELES_CA.dmp split/
[root@oracle11gr1 ~]# cd split/
[root@oracle11gr1 split]# ll
total 111284
-rwxrw-r-- 1 vshare vshare 113836032 Oct 11 22:43 TBL_LOSANGELES_CA.dmp

[root@oracle11gr1 split]#split -b 30m TBL_LOSANGELES_CA.dmp TBL_LOSANGELES_CA_part_
[root@oracle11gr1 split]# ll
total 222584
-rwxrw-r-- 1 vshare vshare 113836032 Oct 11 22:43 TBL_LOSANGELES_CA.dmp
-rw-r--r-- 1 root root 31457280 Mar 14 14:07 TBL_LOSANGELES_CA_part_aa
-rw-r--r-- 1 root root 31457280 Mar 14 14:07 TBL_LOSANGELES_CA_part_ab
-rw-r--r-- 1 root root 31457280 Mar 14 14:07 TBL_LOSANGELES_CA_part_ac
-rw-r--r-- 1 root root 19464192 Mar 14 14:07 TBL_LOSANGELES_CA_part_ad

Cat command is used to join the files split by above split command.

[root@oracle11gr1 split]#cat TBL_LOSANGELES_CA_part_aa TBL_LOSANGELES_CA_part_ab TBL_LOSANGELES_CA_part_ac TBL_LOSANGELES_CA_part_ad >TBL_LOSANGELES

[root@oracle11gr1 split]# ls -lh
total 327M
-rw-r--r-- 1 root root 109M Mar 14 14:15 TBL_LOSANGELES
-rwxrw-r-- 1 vshare vshare 109M Oct 11 22:43 TBL_LOSANGELES_CA.dmp
-rw-r--r-- 1 root root 30M Mar 14 14:07 TBL_LOSANGELES_CA_part_aa
-rw-r--r-- 1 root root 30M Mar 14 14:07 TBL_LOSANGELES_CA_part_ab
-rw-r--r-- 1 root root 30M Mar 14 14:07 TBL_LOSANGELES_CA_part_ac
-rw-r--r-- 1 root root 19M Mar 14 14:07 TBL_LOSANGELES_CA_part_ad

You can check whether the files are identical are not by using the DIFF command.

[root@oracle11gr1 split]# diff -s TBL_LOSANGELES TBL_LOSANGELES_CA.dmp
Files TBL_LOSANGELES and TBL_LOSANGELES_CA.dmp are identical
[root@oracle11gr1 split]#

The cat command can be broken into parts (this is useful if each part is on a separate disk, like one each on CDs). Take note that the first time, a single > is used to make sure that the data from this first part overwrites the destination file (if it already exists), but that each time after that, a double > is used to append to the destination file.

cat TBL_LOSANGELES_CA_part_aa > TBL_LOSANGELES
cat TBL_LOSANGELES_CA_part_ab >> TBL_LOSANGELES
cat TBL_LOSANGELES_CA_part_ac >> TBL_LOSANGELES
cat TBL_LOSANGELES_CA_part_ad >> TBL_LOSANGELES

Thursday, March 13, 2008

RMAN - Recovery Manager for Oracle Database 10g

WHAT IS RMAN ?

Recovery Manager is a tool that: manages the process of creating backups and also manages the process of restoring and recovering from them.

WHY USE RMAN ?

No extra costs …Its available for free
RMAN introduced in Oracle 8 it has become simpler with
newer versions and easier than user managed backups Proper security
You are 100% sure your database has been backed up.
Its contains detail of the backups taken etc in its central repository
Facility for testing validity of backups also commands like crosscheck to Check the status of backup.
Faster backups and restores compared to backups without RMAN
RMAN is the only backup tool which supports incremental backups.
Oracle 10g has got further optimized incremental backup which has
resulted in improvement of performance during backup and recovery time
Parallel operations are supported
Better querying facility for knowing different details of backup
No extra redo generated when backup is taken..compared to online backup
without RMAN which results in saving of space in hard disk
RMAN is an intelligent tool
Maintains repository of backup metadata
Remembers backup set location
Knows what need to backed up
Knows what is required for recovery
Knows what backup are redundant

UNDERSTANDING THE RMAN ARCHITECTURE

An oracle RMAN comprises of RMAN EXECUTABLE
This could be present and fired even through
client side TARGET DATABASE.
(Target)This is the database which needs to be backed up
RECOVERY CATALOG is optional otherwise backup
details are stored in target database controlfile
It is a repository of information queried and updated by Recovery Manager
It is a schema or user stored in Oracle database
One schema can support many databases
It contains information about physical schema of target database datafile and archive log, backup sets and pieces

Recovery catalog is a must in following scenarios
In order to store scripts
For tablespace point in time recovery

Media Management Software

Media Management software is a must if you are using
RMAN for storing backup in tape drive directly.

Backups in RMAN

Oracle backups in RMAN are of the following type

RMAN complete backup OR RMAN incremental backup

These backups are of RMAN proprietary nature

IMAGE COPY

Its again a kind of backup. The advantage of uing Image copy is its not in RMAN proprietary format.

Backup Format

RMAN backup is not in oracle format but in RMAN format.
Oracle backup comprises of backup sets and it consists
of backup pieces. Backup sets are logical entity.
In oracle 9i it gets stored in a default location.

There are two type of backup sets
Datafile backup sets,
Archivelog backup sets

One more important point of data file backup sets
is it do not include empty blocks. A backup set
would contain many backup pieces. A single backup piece
consists of physical files which are in RMAN proprietary format.

You can go to RMAN prompt by just typing rman.
RMAN executable is present in ORACLE_HOME/bin location.

bash-2.05$ rman

Recovery Manager: Release 10.1.0.5.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.


RMAN>

You can use target connect to connect to database.
The database it will connect to depends on the environment variable ORACLE_HOME.

RMAN> connect target

connected to target database: ORCL (DBID=1176834246)

Alternatively you can use “rman TARGET SYS/sys@test NOCATALOG”
to connect to the RMAN of “test” instance.

Here we will be using target database control file
to store all the information required for RMAN,
like backupsets and backup image information etc.

Backup Database:

RMAN> shutdown immediate

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area 1660944384 bytes

Fixed Size 1322112 bytes
Variable Size 686019456 bytes
Database Buffers 973078528 bytes
Redo Buffers 524288 bytes

RMAN> backup database;

Starting backup at 13-MAR-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=166 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-MAR-08
channel ORA_DISK_1: finished piece 1 at 13-MAR-08
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2008_03_13/

o1_mf_nnndf_TAG20080313T031455_3b8zv57d_.bkp tag=TAG20080313T031455 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:36
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 13-MAR-08
channel ORA_DISK_1: finished piece 1 at 13-MAR-08
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2008_03_13/

o1_mf_ncsnf_TAG20080313T031455_3b8zy7xr_.bkp tag=TAG20080313T031455 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:06
Finished backup at 13-MAR-08
Creating RMAN Catalog

You can also create a repository for RMAN to store all this
information. Repository will be just another small
database which can store the catalog information.
Creating a catalog is a 3 step process

1) Create database which will hold the catalog.
Else you can use the existing database also.
All you need is to create a seperate tablespace
for holding the information about RMAN catalog.

2) Create RMAN tablespace and RMAN user

SQL> create tablespace rman_tbs datafile ‘/u01/app/oracle/oradata/TEST/rman01.dbf’ size 240M EXTENT MANAGEMENT LOCAL segment SPACE MANAGEMENT AUTO ;

Tablespace created.

SQL> create user rcat identified by rcat
default tablespace rman_tbs
TEMPORARY TABLESPACE TEMPTS1
QUOTA UNLIMITED ON rman_tbs account unlock;

User created.

After creating user, you need to grant RECOVERY_CATALOG_OWNER role to that user.

3) Create RMAN catalog.

bash-2.05$ rman catalog rcat/rcat@test

Recovery Manager: Release 10.1.0.5.0 - Production on Thu Mar 13 02:47:16 2008

Copyright (c) 1995, 2004, Oracle. All rights reserved.

connected to recovery catalog database

RMAN> create catalog

recovery catalog created

For registering the database, you need to get connected
to database as well as catalog at the same time. Here is how you can do.

RMAN> connect target

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20001: target database not found in recovery catalog

The above error is because the database we connected to is not found in the catalog database. We can register the database in catalog.

RMAN> register database;

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

Registering database will also resynch the information present
in the target database control file and catalog database.
Since we have taken 1 backup early, it will synchup that
information with RMAN catalog. We can check the same using
LIST BACKUP command at RMAN prompt.

RMAN> list backup;

List of Backup Sets
===================

BS Key Type LV Size Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
18 Full 573.48M DISK 00:01:26 13-MAR-08
BP Key: 20 Status: AVAILABLE Compressed: NO Tag: TAG20080313T031355
Piece Name: /u01/app/oracle/oradata/ORCL/backupset/2008_03_13/
o1_mf_nnndf_TAG20080313T031355_3b8zv57d_.bkp

List of Datafiles in backup set 18
File LV Type Ckp SCN Ckp Time Name
—- — —- ———- ——— —-
1 Full 562487 13-MAR-08 /u01/app/oracle/oradata/ORCL/system01.dbf
2 Full 562487 13-MAR-08 /u01/app/oracle/oradata/ORCL/undotbs01.dbf
3 Full 562487 13-MAR-08 /u01/app/oracle/oradata/ORCL/sysaux01.dbf
4 Full 562487 13-MAR-08 /u01/app/oracle/oradata/ORCL/users01.dbf
5 Full 562487 13-MAR-08 /u01/app/oracle/oradata/ORCL/example01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
19 Full 6.80M DISK 00:00:05 13-MAR-08
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20080313T031355
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2008_03_13/
o1_mf_ncsnf_TAG20080313T031355_3b8zy7xr_.bkp

Control File Included: Ckp SCN: 562487 Ckp time: 13-MAR-08
SPFILE Included: Modification time: 13-MAR-08

RMAN Command line

Backing up the Controlfile and Spfile

The control file can be automatically backed up after each
RMAN backup and database structure change as a way to protect
the RMAN repository (when we are not using a seperate catalog for RMAN).

RMAN> configure controlfile autobackup on;

Backing up control file

RMAN> backup current controlfile;

Creating Image copy of all datafiles in database

These are the image copies and are stored in ORACLE format
and not in RMAN format. Backupsets and backuppieces are
stored in internal RMAN format. Hence these image copies can be
used for manual restore and recovery as well.

RMAN> backup as copy database;

Creating backupsets of all datafiles in database

If you specify BACKUP AS BACKUPSET, then RMAN stores its backups
in backup sets. A backup set, consisting of one or more backup pieces,
contains the physical file data being backed up. This backupset
is written in a format that only RMAN can access. Only RMAN can
create and restore backup sets. Backup sets can be written to disk
or tape, and they are the only type of backup which RMAN can use
to write backups to tape.

RMAN> backup as backupset database;

Backup individual tablespace as backupsets

RMAN> backup tablespace system, HTMLDB;

Backup individual tablespace as image copies

RMAN> backup as copy tablespace system;

Backup individual files as image copies

RMAN> backup as copy datafile ‘/u01/app/oracle/oradata/test/system01.dbf’;

Backup individual files as Backupsets

RMAN> backup datafile ‘/u01/app/oracle/oradata/test/system01.dbf’;

Backup archivelogs

We can backup the archive logs according to the output of some
search condition. Example we want to backup only those
archivelogs which starts with “ARCH_616814159_”.

RMAN> backup acrchivelog like '%ARCH_616814159_%';

Copy archivelogs from some time stamp.

Suppose we want to copy the archivelogs of last 2 days,
then we can use the following commands.

RMAN> BACKUP ARCHIVELOG from time 'sysdate-2';

Backup all archivelog files

RMAN> Backup archivelog all;

Backup archivelog between some time.

RMAN> BACKUP ARCHIVELOG FROM TIME 'SYSDATE-30' UNTIL TIME 'SYSDATE-7';

Specifying copies while backing up.

RMAN> backup copies 2 datafile '/u01/app/oracle/oradata/test/cs_tbs01.dbf';

Remember that copies option cannot be used with image copies.
It can be used only with backupsets.

Giving tags to backups

RMAN> BACKUP TAG ‘weekly_full_db_bkup’ DATABASE MAXSETSIZE 100M;

Backing up backupsets
RMAN> BACKUP BACKUPSET ALL;

Backup imagecopies

RMAN> Backup as copy backupset all;

List Imagecopies

RMAN> list copy;

List Backupsets

RMAN> list backup;

Restoring and Recovering the database

Use the RESTORE and RECOVER commands for RMAN restore and
recovery of physical database files.

RMAN> STARTUP FORCE MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN;

Recovering Current Tablespaces

RMAN> SQL ‘ALTER TABLESPACE users OFFLINE’;
RESTORE TABLESPACE users;
RECOVER TABLESPACE users;
SQL ‘ALTER TABLESPACE users ONLINE;

Recovering Current Datafiles

RMAN> SQL ‘ALTER DATABASE DATAFILE 7 OFFLINE’;
RESTORE DATAFILE 7;
RECOVER DATAFILE 7;
SQL ‘ALTER DATABASE DATAFILE 7 ONLINE’;

Recovering Individual Data Blocks

RMAN can recover individual corrupted datafile blocks.
When RMAN performs a complete scan of a file for a backup,
any corrupted blocks are listed in V$DATABASE_BLOCK_CORRUPTION.
Corruption is usually reported in alert logs, trace files or
results of SQL queries. Use BLOCKRECOVER to repair all corrupted blocks:

RMAN> BLOCKRECOVER CORRUPTION LIST;

You can also recover individual blocks, as shown in this example:
RMAN> BLOCKRECOVER DATAFILE 7 BLOCK 233, 235 DATAFILE 4 BLOCK 101;

Managing RMAN repository

As you know that if you do not use a recovery catalog, then
control file of the target database is used as RMAN repository
and eventually after some time the control file records
for RMAN information will get overwritten.Set this initialization
parameter in the parameter file of the target database to
determine how long records are kept:

CONTROL_FILE_RECORD_KEEP_TIME =

You can configure a retention policy to be used by RMAN
to determine which backups are considered obsolete.
This allows you to remove files from the repository that
are no longer needed to meet your retention requirements.
This policy can be based on a recovery window (the maximum number
of days into the past for which you can recover) or redundancy
(how many copies of each backed-up file to keep).

Two Parameters are used to set retention policies.

You can specify the days days between the current time and the
earliest point of recoverability, this is called RECOVERY WINDOW.
RMAN does not consider any full or level 0 incremental backup
as obsolete if it falls within the recovery window.
Alternatively the REDUNDANCY parameter will instruct to store the
number of copies of backup in RMAN repository. If the number of
backups for a specific datafile or control file exceeds the REDUNDANCY
setting considers the extra backups as obsolete.

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 3;

This will make the REDUNDANCY setting to 3. Meaning that it will
at max store 3 copies of backups and ikmages of datafile.
Any more images or backups are consider obsolete.

When we run the below command

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

it will configure new retention policy based on the RECOVERY WINDOW
of 7 days. This means that all the backups which falls outside this
window will be considered obsolute. So in this case you need to have
backup scheduled every week to have atleast 1 valid backup.

Remember that at any point of time, only one policy can be active.
It can be either REDUNDANCY or RECOVERY WINDOW.

When you change the retention policy to another one, it will suspend
the previous policy as shown below.

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

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

Cross checking the available backups

RMAN> CROSSCHECK BACKUP;

Crosscheck is needed when an archivelog file or backup is manually
removed, i.e., not deleted by RMAN. This command ensures that data
about backups in the recovery catalog or control file is synchronized
with corresponding data on disk or in the media management catalog.
The CROSSCHECK command operates only on files that are recorded in
the recovery catalog or the control file.

The CROSSCHECK command does not delete any files that it is
unable to find, but updates their repository records to EXPIRED.
Then, you can run DELETE EXPIRED to remove the repository records
for all expired files as well as any existing physical files whose
records show the status EXPIRED.

If some backup pieces or copies were erroneously marked as EXPIRED,
for example, because the media manager was misconfigured, then after
ensuring that the files really do exist in the media manager, run
the CROSSCHECK BACKUP command again to restore those files to AVAILABLE
status.

RMAN> CROSSCHECK COPY;

This will validate the image copies.

Deleting the backups

The DELETE command removes RMAN backups and copies from DISK marks
the records in control file as DELETED or removes the records from the
recovery catalog (if you use a catalog).

RMAN> DELETE BACKUPSET 101, 102, 103;

RMAN> delete controlfilecopy ‘%ctl’; # Pattern search is allowed.

RMAN> delete archivelog until sequence 20;

This will delete all the archives from the oldest one till the
sequence we have specified.

RMAN> delete backup of tablespace system;

RMAN> DELETE ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE DISK;

List commands

RMAN> list backup;

RMAN> list copy;

RMAN> list incarnation of database;

RMAN> list expired backupset;

RMAN> list expired copy;

RMAN> list backup of tablespace sysaux;

RMAN> list copy of datafile 3;

Reporting in RMAN

RMAN> report need backup;

Reports which database files need to be backed up to meet a configured
or specified retention policy

RMAN> report unrecoverable;

Reports which database files require backup because they have been
affected by some NOLOGGING operation such as a direct-path insert

RMAN> report need backup recovery window of 7 days;

Displays objects requiring backup to satisfy a recovery window-based
retention policy.

Suppose in the above command we want to skip a perticular tablespace
like perfstat then we can use the below command.

RMAN> report need backup recovery window of 2 days database skip tablespace perfstat;

RMAN> report need backup redundancy 3;

Displays objects requiring backup to satisfy a redundancy-based
retention policy.

RMAN> report need backup days 7;

Displays files that require more than n days’ worth of archived
redo log files for recovery.

RMAN> report need backup incremental 7;

Displays files that require application of more than n incremental
backups for recovery.

RMAN> report need backup redundancy 2 datafile 3;

Gives report of files with less than 2 redundant backups.

RMAN> report need backup tablespace htmldb;

Report of files that must be backed up to satisfy current
retention policy for this tablespace (htmldb)

RMAN> report need backup incremental 2;

Report of files that need more than 2 incrementals during recovery

RMAN> report need backup device type disk;

Report of files that must be backed up to satisfy current
retention policy for database

RMAN> report obsolete;
Shows backups that are obsolete according to the current
retention policy.

You can add the options RECOVERY WINDOW and REDUNDANCY with
this command as given below.

RMAN> report obsolete recovery window of 3 days;

RMAN> report obsolete redundancy 2;

RMAN> report schema;

This command lists and displays information about the database files.

RMAN> report schema at time 'sysdate - 14';

This command gives report on schema 14 days ago.

RMAN> report schema at SCN 10000;

This gives report on schema at scn 10000.

RMAN> report schema at sequence 55 thread 1;

Gives report of schema at sequence 55.

RMAN configuration

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘%F’; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM ‘AES128′; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘/u01/app/oracle/oradata/test/dbs/snapcf_test.f’; # default

We can change each of these parameters as per our requirements.

You can return any setting to its default value by using CONFIGURE… CLEAR

RMAN> CONFIGURE BACKUP OPTIMIZATION CLEAR;

RMAN> CONFIGURE RETENTION POLICY CLEAR;

By default, RMAN sends all backups to an operating system
specific directory on disk. So default setting for DEVICE
TYPE is DISK. You can configure to make backups by default
on tape or any other device as given below.

RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt;

You can configure backup sets or image copies as the default
for a particular device type, using either of the following commands:

RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY; # Default becomes image copies
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET; # Default becomes uncompressed

You can configure RMAN to use compressed backupsets by
default on a particular device type, by using the CONFIGURE
DEVICE TYPE command with the BACKUP TYPE TO COMPRESSED BACKUPSET
option, as shown in the following examples.

RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;

RMAN> CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO COMPRESSED BACKUPSET;

To disable compression you can use below command

RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET;

RMAN> CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO BACKUPSET;

You can configure the parallelism for a device type.

RMAM> CONFIGURE DEVICE TYPE sbt PARALLELISM 2;

You can turn on/off controlfile autobackup using

RMAN> configure controlfile autobackup off;

RMAN> configure controlfile autobackup on;

We can configure RMAN channel to write backups and images in a specific format.

The following command configures RMAN to write disk backups to the /backup directory

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/backup/ora_df%t_s%s_s%p’;

%t is replaced with a four byte time stamp,
%s with the backup set number, and
%p with the backup piece number.

You can also configure format for controlfile autobackup as well.
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE deviceSpecifier TO ’string’;

For example, you can run the following command:

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘?/oradata/cf_%F’;

Here %F will be replaced by following

c-IIIIIIIIII-YYYYMMDD-QQ, where:

IIIIIIIIII stands for the DBID.
YYYYMMDD is a time stamp of the day the backup is generated
QQ is the hex sequence that starts with 00 and has a maximum of FF

You can clear the format using following command.
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;



References:

Metalink Note ID: 360416.1

http://advait.wordpress.com/2007/08/10/rman-recovery-manager-for-oracle-database-10g/

http://download-uk.oracle.com/docs/cd/B19306_01/backup.102/b14192/toc.htm

Tuesday, March 04, 2008

Network Related Files

Oracle uses three files (listener.ora, tnsnames.ora & sqlnet.ora) for network configuration.

Listener.ora
The listerner.ora file contains server side network configuration parameters.

It can be found in the ORACLE_HOME/network/admin directory on the server.

EXAMPLE Listener.ora file:

-------------LINUX----------------
# listener.ora Network Configuration File: /u01/app/oracle/product/10.1.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.1.0/db_1)
(PROGRAM = extproc)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = edrserver)(PORT = 1521))
)
)
)
-------------WINDOWS----------------

# listener.ora Network Configuration File: D:\oracle\product\10.1.0\Db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.1.0\Db_1)
(PROGRAM = extproc)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = Ntws205.rmsi.com)(PORT = 1521))
)
)
)
==================================================================================
After any changes/modifications in the listener.ora file
the listener should be restarted or reloaded to allow the new configuation to take effect.
[oracle@edrserver admin]$lsnrctl stop
[oracle@edrserver admin]$lsnrctl start
or
[oracle@edrserver admin]$lsnrctl reload

Tnsnames.ora

The tnsnames.ora file contains client side network configuration parameters. It can be found in the ORACLE_HOME/network/admin directory on the client. This file will also be present on the server if client style connections are used on the server itself.

Example of a tnsnames.ora file:

--------------WINDOWS--------------------
# tnsnames.ora Network Configuration File: D:\oracle\product\10.2.0\client_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.

EDR_205 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ntws205.rmsi.com)(PORT = 1521))
)
(CONNECT_DATA =
(SID = edr)
(SERVER = DEDICATED)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)

----------------LINUX----------------------
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.1.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

EDR =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = edrserver)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = edr)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)

NOTE: There are two names “EDR_205” which is called as “TNS_ENTRY” which we use with the connect string like “username/pwd@TNS_ENTRY” & “EDR” which is the service_name (instance_name).
=================================================================================
Sqlnet.ora

The sqlnet.ora file contains client side network configuration parameters. It can be found in the ORACLE_HOME/network/admin directory on the client. This file will also be present on the server if client style connections are used on the server itself.

Example of an sqlnet.ora file:

# sqlnet.ora Network Configuration File: D:\oracle\product\10.1.0\Db_1\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.

SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

====================================

You can find some of the Network related issues and their solutions in the following link:

Error codes and solutions