Oracle RMAN Monitoring Script

Hi,

You can monitor your RMAN session using v$session_longops view.

Here is a script :

SELECT SID,
START_TIME,
TOTALWORK,
SOFAR,
(SOFAR / TOTALWORK) * 100 done,
SYSDATE + TIME_REMAINING / 3600 / 24 EST_END_TIME,
OPNAME
FROM V$SESSION_LONGOPS
WHERE TOTALWORK > SOFAR AND OPNAME LIKE '%backup%' AND OPNAME LIKE 'RMAN%'
/

Advertisements

Checking RMAN backup using Shell Script

Hi ,

Here is a shell script for checking your RMAN backup operation status.

Usage :

[oracle@ora1 ~]$ chmod 755 backup_check.sh


[oracle@ora1 ~]$ backup_check.sh ORA1 (This is your ORACLE_SID)

Oracle Database Backup and Recovery User’s Guide ‘s¬† “To query details about past and current RMAN jobs” section is here.

Good Luck ūüôā

[oracle@ora1 ~]$ cat backup_check.sh
#!/bin/bash


#If you will schedule this script oracle's crontab then you do not need export both SID and HOME variables
export ORACLE_SID=$1
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1


#Formatting date
MYDATE=`date +%Y-%m-%d:%H:%M:%S`


#Credentials
USER=system
PASSW=oracle


#Query FAILED Backup Operations
$ORACLE_HOME/bin/sqlplus $USER/$PASSW <<EOF
set feed off
set linesize 400
set pagesize 200
spool backup.alert
SELECT   INPUT_TYPE,STATUS
FROM V\$RMAN_BACKUP_JOB_DETAILS where STATUS ='FAILED';
spool off
exit
EOF


#Check if there is any FAILURE
ISFAIL=`cat backup.alert|grep FAILED |grep -v RMAN_BACKUP_JOB_DETAILS|wc -l`

if [ $ISFAIL -gt 0 ]
then
#Fetch Backup Type if any failure occured. For DB Full Backup BTYPE = DB , For ARCHIVELOG BTYPE= ARCHIVELOG etc.
BTYPE=`cat backup.alert|grep FAILED |grep -v RMAN_BACKUP_JOB_DETAILS|awk '{print $1}'`
echo $BTYPE " Backup ERROR"  > backup_check_$MYDATE.log
fi
exit 0

Backup Oracle Database in Noarchivelog Mode

If your database in noarchivelog mode, you have to startup your database in mount state to take COLD backup.

When you perform “backup database” command in RMAN, you hit¬† an error like "ORA-19602:¬†cannot¬†backup¬†or¬†copy¬†active¬†file¬†in¬†NOARCHIVELOG¬†mode".

For taking a backup you can follow this procedure :
1- shutdown immediate;
2- startup mount;
3- backup database;
4- alter database open;

This type of backups are called COLD backup and as you see while you are taking backup, your database is out of service.

Have a nice day.

Data Recovery Advisor – The Easiest Way of Data Recovery

The Data Recovery Advisor is a new adviser to repair data failures and corruptions. You can use the Data Recovery Advisor via Enterprise Manager, Grid Control or RMAN cli.

Lets look the Data Recovery Advisory commands

  • List Failure¬† : List the failure with its priority and status.

Here is an example :  

RMAN> list failure;

List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
———- ——– ——— ————- ——-
342        HIGH     OPEN      10-JUL-14     One or more non-system datafiles are missing

  • Advise Failure¬† : Shows manual and automatic repair options.

Lets see the advice for the failure 342:

RMAN> advise failure;

List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
———- ——– ——— ————- ——-
342        HIGH     OPEN      10-JUL-14     One or more non-system datafiles are missing

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=125 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
=======================
1. If file /u01/app/oracle/oradata/ORA/sysaux01.dbf was unintentionally renamed or moved, restore it

Automated Repair Options
========================
Option Repair Description
—— ——————
1      Restore and recover datafile 2
  Strategy: The repair includes complete media recovery with no data loss
  Repair script: /u01/app/oracle/diag/rdbms/ora/ORA/hm/reco_4130221454.hm

¬†My sysaux01.dbf corrupted as you see :). Output of “advise failure” command has 3 sections. In my example “Optional Manual Actions” section has an advise if file can be restored manually. However we have a script for restoring and recoving the data file in the last section of the output called “Automated Repair Options”. Lets have a look at the script.

$ more /u01/app/oracle/diag/rdbms/ora/ORA/hm/reco_668670694.hm
   # restore and recover datafile
¬†¬† sql ‘alter database datafile 2 offline’;
   restore datafile 2;
   recover datafile 2;
¬†¬† sql ‘alter database datafile 2 online’;

Running this RMAN script will resolve the problem with no data loss.

  • Repair Failure¬† : If you don’t want to run RMAN script manually, Oracle can do it for you:). After runninng “advise failure” , please run “repair failure” command and write down “YES”. Here is the example for another datafile failure:

RMAN> repair failure ;

Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/ora/ORA/hm/reco_946200588.hm

contents of repair script:
   # restore and recover datafile
¬†¬† sql ‘alter database datafile 6 offline’;
   restore datafile 6;
   recover datafile 6;
¬†¬† sql ‘alter database datafile 6 online’;

Do you really want to execute the above repair (enter YES or NO)? YES
executing repair script

sql statement: alter database datafile 6 offline

Starting restore at 10-JUL-14
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/ORA/sg01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORA/backupset/2014_07_10/o1_mf_nnndf_TAG20140710T111214_9vwlpyl0_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/ORA/backupset/2014_07_10/o1_mf_nnndf_TAG20140710T111214_9vwlpyl0_.bkp tag=TAG20140710T111214
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 10-JUL-14

Starting recover at 10-JUL-14
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 10-JUL-14

sql statement: alter database datafile 6 online
repair failure complete

That’s All.

  • Change Failure : Sometimes we may want to change the priority of failure. Because of dummy monitoring systems,dummy check scripts etc. In such cases, you can use this command to change the priority.

RMAN> CHANGE FAILURE <#ofFailure> PRIORITY LOW;

Example :

RMAN> CHANGE FAILURE 324 PRIORITY LOW;