Search Articles

Showing posts with label RMAN. Show all posts
Showing posts with label RMAN. Show all posts

Script to Monitor RMAN Backup Status and Timings

Being a DBA, you often asked to check the status of  RMAN backup job details. There are many ways to monitor the progress of the backup but you can use the below scripts to monitor the status of the RMAN job like full, incremental & archivelog backups.

You can use views like v$rman_backup_job_details and V$SESSION_LONGOPS to monitor the current executing RMAN jobs and the status of the previously completed backups.


RMAN STATUS

SQL> desc v$rman_backup_job_details
 Name                                 Null?        Type
 ----------------------------- -------- --------------------
 SESSION_KEY                              NUMBER
 SESSION_RECID                          NUMBER
 SESSION_STAMP                         NUMBER
 COMMAND_ID                             VARCHAR2(33)
 START_TIME                                DATE
 END_TIME                                    DATE
 INPUT_BYTES                             NUMBER
 OUTPUT_BYTES                         NUMBER
 STATUS_WEIGHT                       NUMBER
 OPTIMIZED_WEIGHT                  NUMBER
 OBJECT_TYPE_WEIGHT                    NUMBER
 OUTPUT_DEVICE_TYPE                     VARCHAR2(17)
 AUTOBACKUP_COUNT                       NUMBER
 BACKED_BY_OSB                          VARCHAR2(9)
 AUTOBACKUP_DONE                        VARCHAR2(9)
 STATUS                                 VARCHAR2(69)
 INPUT_TYPE                             VARCHAR2(39)
 OPTIMIZED                              VARCHAR2(9)
 ELAPSED_SECONDS                        NUMBER
 COMPRESSION_RATIO                      NUMBER
 INPUT_BYTES_PER_SEC                    NUMBER
 OUTPUT_BYTES_PER_SEC                   NUMBER
 INPUT_BYTES_DISPLAY                    VARCHAR2(4000)
 OUTPUT_BYTES_DISPLAY                   VARCHAR2(4000)
 INPUT_BYTES_PER_SEC_DISPLAY            VARCHAR2(4000)
 OUTPUT_BYTES_PER_SEC_DISPLAY           VARCHAR2(4000)
 TIME_TAKEN_DISPLAY                     VARCHAR2(4000)


This script will report status of current as well as completed backup details like full, incremental and archivelog backups:

col STATUS format a9
col hrs format 999.99
select
SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,
to_char(END_TIME,'mm/dd/yy hh24:mi')   end_time,
elapsed_seconds/3600                   hrs
from V$RMAN_BACKUP_JOB_DETAILS
order by session_key;


SESSION_KEY INPUT_TYPE    STATUS    START_TIME     END_TIME           HRS
----------- ------------- --------- -------------- -------------- -------
        585 ARCHIVELOG    COMPLETED 01/08/15 06:00 01/08/15 06:02     .03
        591 ARCHIVELOG    COMPLETED 01/08/15 12:00 01/08/15 12:01     .02
        596 ARCHIVELOG    COMPLETED 01/08/15 18:01 01/08/15 18:02     .03
        601 DB INCR       FAILED    01/08/15 20:00 01/09/15 01:47    5.79
        603 ARCHIVELOG    COMPLETED 01/09/15 06:00 01/09/15 06:07     .12
        608 ARCHIVELOG    COMPLETED 01/09/15 12:00 01/09/15 12:09     .16
        613 ARCHIVELOG    COMPLETED 01/09/15 15:07 01/09/15 15:25     .29




Below script will report you the percentage of completion along with sid and serial#.

SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK,
ROUND (SOFAR/TOTALWORK*100, 2) "% COMPLETE"
FROM V$SESSION_LONGOPS
WHERE OPNAME LIKE 'RMAN%' AND OPNAME NOT LIKE '%aggregate%'
AND TOTALWORK! = 0 AND SOFAR <> TOTALWORK;


 SID       SERIAL#    CONTEXT    SOFAR      TOTALWORK  %COMPLETE
---------- ---------- ---------- ---------- ---------- ----------
 22        31         1          8225460    18357770   45.21

Read more ...

How to Enable/Disable ARCHIVELOG Mode in Oracle 11g/12c

When you run the database in NOARCHIVELOG mode, you disable the archiving of the redo log. If you want to take the backup of the database using RMAN then your database must be in ARCHIVELOG mode.

A database backup, together with online and archived redo log files, guarantees that you can recover all committed transactions in the event of OS or disk faluer.


Below are the steps required to enable archive log mode on an Oracle 10g/11g or 12c database.


Verify the database log mode.

[oracle@orahow ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Feb 03 04:05:02 2015

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options


SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     25
Current log sequence           27


From the above output you can see that your database is in No Archive Mode. Note that Archive destination is USE_DB_RECOVERY_FILE_DEST. You can determine the path by looking at the parameter RECOVERY_FILE_DEST.


SQL> show parameter recovery_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      /u01/app/oracle/flash_recovery
                                                 _area
db_recovery_file_dest_size           big integer 2728M


By default, archive logs will be written to the flash recovery area also called FRA. If you don't want to write archive logs to the FRA then you can set the parameter LOG_ARCHIVE_DEST_n to the new location where you wish to write the archive logs.


To set new new archive log destination, you can use the following command.

SQL> alter system set log_archive_dest_1='LOCATION=/u01/app/oracle/oradata/orahow/arch' scope = both;

System altered.

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/oradata/orahow/arch
Oldest online log sequence     26
Current log sequence           28
SQL>


Now we shutdown the database and bring it backup in mount mode.

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

SQL> startup mount
ORACLE instance started.

Total System Global Area  606806016 bytes
Fixed Size                  1376268 bytes
Variable Size             394268660 bytes
Database Buffers          205520896 bytes
Redo Buffers                5640192 bytes
Database mounted.
SQL>

Now set the database in archive log mode

SQL> alter database archivelog;

Database altered.

Finally open the database.
SQL> alter database open;

Database altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/oradata/orahow/arch
Oldest online log sequence     26
Next log sequence to archive   28
Current log sequence           28


From the above output you can see that database is in archive log mode and automatic archival is also enabled.

For experiment or confirmation you can switch the log file to see that an archive is written to archive log location.


SQL> alter system switch logfile;

System altered.

SQL> host
[oracle@orahow ~]$ ls /u01/app/oracle/oradata/orahow/arch
1_28_812359664.dbf
[oracle@orahow ~]$ exit
exit


Disabling Archive Log Mode


The following are the steps required to disable archive log mode on an Oracle 10g/11g or 12c database.

Verify the database log mode.

[oracle@orahow ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Feb 03 04:05:02 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options


SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/oradata/orahow/arch
Oldest online log sequence     26
Next log sequence to archive   28
Current log sequence           28


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


SQL> startup mount
ORACLE instance started.

Total System Global Area  606806016 bytes
Fixed Size                  1376268 bytes
Variable Size             394268660 bytes
Database Buffers          205520896 bytes
Redo Buffers                5640192 bytes
Database mounted.
SQL>


To disable archive log mode use the below command.

SQL> alter database noarchivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/oradata/orahow/arch
Oldest online log sequence     26
Current log sequence           28
SQL>
As you can see, ARCHIVELOG mode has been disabled.

Read more ...

5 Steps to Move Control File from File System to ASM Disk

Moving Control File to ASM



Moving controlfile from filesystem to ASM disk using RMAN in RAC.


You can migrate controlfile from file system to asm disk or to different diskgroup in ASM. For that you have to stop the database and startup in nomount state.


STEP 1: Stop the Database and startup in nomount state
SQL> shutdown immediate;
SQL> startup nomount;


STEP 2:Connect the target database using RMAN
$ rman
RMAN>connect target /
RMAN>restore controlfile to '<DISKGROUP_NAME>' from '<OLD_PATH>';
RMAN> restore controlfile to '+DATA' from '/oradatao1/test11/oradata/san/control01.ctl';

You can also multiplex controlfile to FRA like:
RMAN> restore controlfile to '+FRA' from '/oradatao1/test11/oradata/san/control01.ctl';


STEP 3: Show Location Of New Control Files
ASMCMD> find -t controlfile . *
+DATA/DG/CONTROLFILE/current.321.780791421
+FRA/DG/CONTROLFILE/current.368.870851527


STEP 4: On the database side:
 Modify init.ora or spfile, replacing the new path to the init parameter control_files.
 if using init<SID>.ora, just modify the control_files parameter and restart the database.
 If using spfile, Change Parameter for new locations.
alter system set control_files='+DATA/DG/CONTROLFILE/current.321.780791421','+FRA/DG/CONTROLFILE/current.368.870851527' scope=spfile;


STEP 5: Shutdown the database and open for use
SQL>shutdown immediate
SQL> alter database open;


Verify that new control file has been recognized. If the new controlfile was not used, the complete procedure needs to be repeated.

If you do not use ASM and If you want to new control file in file system, you can copy – paste controlfile to clone after stop database. And you have to change control_files parameter when database is nomount mode or stop.

Read more ...

ORA-27211: Failed to load Media Management Library

RMAN backup failed With below error:

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of allocate command on ch1 channel at 06/20/2015 09:17:05
ORA-19554: error allocating device, device type: SBT_TAPE, device name:
ORA-27211: Failed to load Media Management Library
Additional information: 4005


How to fix ORA-19554 and ORA-27211 errors?


CAUSE:

Before using RMAN with a media manager, media management software must be installed and configured on the target host or production network.

When allocating or configuring channels for RMAN to use to communicate with a media manager, specify the SBT_LIBRARY parameter to provide the path to the media management software library. When RMAN allocates channels to communicate with a media manager, it attempts to load the library indicated by the SBT_LIBRARY parameter.

If you do not provide a value for this parameter, RMAN looks in a platform-specific default location. On Linux/UNIX, the default library filename is $ORACLE_HOME/lib/libobk.so, with the extension name varying according to platform: .so, .sl, .a, and so on. On Windows the default library location is %ORACLE_HOME%\bin\orasbt.dll.

If the database is unable to locate a media management library in the location specified by the SBT_LIBRARY parameter or the default location, then RMAN issues an ORA-27211 error and exits.


Resolving "Failed to load Media Management Library" Issue

Link libobk.so to your backup vendor supplied rman library using symbolic link.

Go to <ORACLE_HOME/lib/> directory.

$ pwd
/ora/app/oracle12c/product/12.1.0.2/dbhome_1/lib
$ cd  /usr/openv/netbackup/bin
$ ls -ltr libobk.so64
-r-xr-xr-x 1 root bin 1567895 Jun  20  2015 libobk.so64

$ cd /ora/app/oracle12c/product/12.1.0.2/dbhome_1/lib
$ ln -s /usr/openv/netbackup/bin/libobk.so64 libobk.so
$ ls -ltr libobk.so
lrwxrwxrwx 1 oracle dba 36 Jun 20 09:27 libobk.so -> /usr/openv/netbackup/bin/libobk.so64

Now start backup, if it gets completed successfully then no issues, if fail again then create below link in the same location as above.

$ ln -s /usr/openv/netbackup/bin/libobk.so64 libobk.a
$ ln -s /usr/openv/netbackup/bin/libobk.so64 libobk.so64
$ ls -lrt libobk*
lrwxrwxrwx 1 oracle dba 36 Jun 20 09:45 libobk.so -> /usr/openv/netbackup/bin/libobk.so64
lrwxrwxrwx 1 oracle dba 36 Jun 20 10:00 libobk.a -> /usr/openv/netbackup/bin/libobk.so64
lrwxrwxrwx 1 oracle dba 36 Jun 20 10:00 libobk.so64 -> /usr/openv/netbackup/bin/libobk.so64


For "ORA-19554: error allocating device, device type: SBT_TAPE" 
and "ORA-27211: Failed to load Media Management Library" you can get more info at: Backup and Recovery

Read more ...

Resolving ORA-19588: archived log recid stamp is no longer valid

ORA-19588: archived log recid 14859 stamp 747949646 is no longer valid

channel dev_0: starting archive log backupset
released channel: dev_0
RMAN-00571: ===============================================
RMAN-00569: ============ ERROR MESSAGE STACK FOLLOWS =====
RMAN-00571: ===============================================
RMAN-03009: failure of backup command on dev_0 channel at 05/20/2015 07:22:55
ORA-19588: archived log recid 14859 stamp 747949646 is no longer valid



ORA-19588: archived log stamp is not longer valid


There are few possible causes for ORA-19588

-----------------------------------------------------------------------
  • Archive logfile which this process is trying to take backup, is already been backed up by another process and file is deleted.
  • Invalid or deleted records in the controlfile. 


This situation occur if both archive backup job and full database backup (including archives) are executing at the same time or two archive backup jobs executing at same time.


Look at the below command
---------------------------------------
RMAN> backup archivelog all archivelog until time 'sysdate -1' delete input ; 
             
The backup command being used is correct by 'syntax', however incorrect by 'logic' because RMAN will try to backup some archivelogs (archivelogs which completed till 'sysdate-1')  twice in the same command:

Here both jobs are trying to backup and delete the SAME archivelog set, one of which failed eventually as the other job had already backed up and deleted the log.

If we don't specify 'DELETE INPUT', the command will be succeeded, however, backup twice (ful archivelog and completed one day before) doesn't seem to be the intention of above command.


SOLUTION
-----------------------
Run the below command to synchronize the controlfile with the current status of the backup-related information.
RMAN> crosscheck archivelog all;


No concurrent RMAN backups
-----------------------------------------
Make sure that concurrent backups of the archivelogs of the SAME database are not run. You can find it using the below command.
$ ps -ef | grep rman

Don’t schedule archive backup job during full database backup (including archivelog). Always make sure you have only one RMAN backup in process.


Useful Commands

If we want to take backup of all archivelogs, then:
------------------------------------------------------------------
RMAN> backup archivelog all delete input ;


If we want to take backup of all archivelogs until time 'sysdate -1', then:
--------------------------------------------------------------------------------------------
RMAN> backup archivelog until time 'sysdate -1' delete input ;


Note
ORA-19588 may be seen with 'datafile copy' as well
like:
.
RMAN-03009: failure of backup command on ch01 channel at 02/01/2013 21:30:59
ORA-19588: datafile copy RECID 1019958 STAMP 806188828 is no longer valid
Read more ...

ORA-00245: Control File Backup Failed; Target is Likely on a Local File System

In alert log I got an issue ORA-00245: control file backup failed; target is likely on a local file system. Regarding this issue, I checked the snapshot control file location on rman prompt and observed that it was on local file system. In RAC environment, Snapshot control file backup location should be on a shared disk group so that it can be visible or accessible to all RAC nodes.


Check the configured snapshot controlfile default location.


RMAN> show snapshot controlfile name;

starting full resync of recovery catalog
full resync complete
RMAN configuration parameters for database with db_unique_name ORAHOW are:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_ORAHOW2.f'; # default

Here you can see that controlfile is on a local file system, so to fix this issue configure it to a shared location.

To Configure the snapshot controlfile to a shared disk

Connect to target database, and issue the following command on RMAN prompt.
rman target /

RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '<shared_disk>/snapcf_<DBNAME>.f';

Let us take an example,

RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+RC_DATA/ORAHOW/snapcf_orahow.f';

new RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+RC_DATA/ORAHOW/snapcf_orahow.f';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete


Due to the changes made to the controlfile backup mechanism any instances in the cluster may write to the backup controlfile when making changes to the current controlfile. Therefore, the backup file needs to be visible to all instances.


Read more ...

CONTACT

Name

Email *

Message *