Category Archives: RMAN

Oracle 12c -RMAN Backup Overview

Oracle provides the Recovery Manager utility (RMAN) to perform two types of database backups: Image Backup and Backup Set.    RMAN command BACKUP AS COPY command creates an image copy or bit for bit copy of the data files, archived redo log and controlfiles.

 

RMAN> BACKUP AS COPY DEVICE TYPE DISK DATABASE;

 

You can set the default backup to image copy with CONFIGURE DEVICE TYPE command

 

RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY;

 

Backup sets are the other type of RMAN backups, each backup set has one or more binary files called backup pieces, in proprietary format that can be restored by RMAN.  You can limit the size of size of backup pieces by the MAXPIECESIZE option.   Use the RMAN command BACKUP AS BACKUPSET to create backup copy of database.

 

RMAN> BACKUP AS BACKUPSET DATABASE.

 

You can set the default backup to backup set with the CONIFGURE DEVICE TYPE command.

 

RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET;

 

You can backup the entire database with the command:

 

RMAN> BACKUP DATABASE;

 

Add PLUS ARCHIVELOGS clause will cause a log switch that allows for full media recovery to the point of starting the backup.

 

RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

 

Incremental Backups are part of a backup set that only contains changes to the database since the last full backup.   The benefit of an incremental backup is size of the backup and time required to tack the backup.   Incremental Backups are only good if combined with the last full backup and any incremental backup between the last full backup.

 

You can create an incremental backup with the RMAN command BACKUP INCREMENTAL in three ways

 

Level 0 – Identical to full back

Level 1 Differential – backups all changed blocks since most recent incremental backup.

Level 1 Cumulative – backups all changed block since most recent Level 0 incremental backup

 

Restoring incremental backup use level 0 at start and apply level 1 cumulative or all differential.

 

Example of incremental Level 1:

 

RMAN> backup incremental level 1 cumulative database;

 

RMAN> backup incremental level 1 database;

 

 

Larry Catt

OCP

Oracle 12c – Recovery Manager (RMAN) Utility Commands

RMAN is the preferred method used for backup and recovery of Oracle database.   This article gives a brief overview of commands used to Configure, Display Configurations, Reset to Default, and take simple backups.

 

 

 

  • The SHOW command gives current settings for RMAN utility to the associate target database.
  • The CLEAR command resets to RMAN defaults.
  • The following command allows for three backup copies of all data files and control files. the forth oldest will be considered obsolete and deleted. default is 1.
    • RMAN> configure retention policy to redundancy 3;
  • The following ensures that backup window of recovery is at least 7 days in the past, backups will be kept to allow for this regardless of redundancy policy.
    • RMAN> configure retention policy to recovery window of 7 days;
  • The following changes the default device type to tape, the default is disk.
    • RMAN> configure default device type to sbt;
  • Regardless of default device type, you can perform backup to specific backup with ‘device type’ clause.
    • RMAN> backup device type sbt database;
    • RMAN> backup device type disk database;
  • RMAN can backup as an image copy or backup set.
    • RMAN> configure device type disk backup type to backupset;
    • RMAN> configure device type disk backup type to copy;
  • TAPE backups can only be backup sets.
  • binary compression can be used with backupsets with COMPRESSED option.
    • RMAN> configure device type disk backup type to compressed backupset;
    • RMAN> configure device type sbt backup type to compressed backupset;
  • An RMAN channel is a connection to db server process, use the configure channel command to create and change channel settings.
    • RMAN> configure channel device type disk maxpiecesize 1g;
    • RMAN> configure channel device type disk format /tmp/%U;
  • By default RMAN allocates a single disk channel for all operations, you can specify a distinct file name for a channel, but RMAN does not create a backup in the fast recovery area.
    • RMAN> configure channel device type disk format ‘/u01/oradata/orcl_df%t_s%s_s%p’;
    • RMAN> configure channel device type disk format ‘+dgroup1’;
  • You can perform parallel backups by defining multiple channels for use.
    • RMAN> RUN
    • {
    • allocate channel u01 device type disk format ‘/u01/%u’;
    • allocate channel u02 device type disk format ‘/u02/%u’;
    • backup database plus archivelog;
    • }
  • RMAN can be configured to autobackup control files and if in archivelog mode and a change occurs to controlfiles, they will be automatically backed up.
    • RMAN> configure controlfile autobackup on;
    • RMAN> configure controlfile autobackup off;
  • RMAN configuration can be reset to default values by using the CLEAR option.
    • RMAN> configure default device type clear;
    • RMAN> configure retention policy clear;
    • RMAN> configure controlfile autobackup clear;
  • When RMAN optimization is enabled, it will skip files that have not changed since the last backup set. RMAN determines this by:
    • Datafile must have same DBID, checkpoint SCN, creation SCN, resetlogs scn and time as one already in backup set.
    • Datafile must be offline, read-only or closed.
    • Archived log – must have same DBID, thread, sequence number, resetlogs scn and time.
    • Backup Set – must have the same DBID, backup set record id, and stamp.
  • RMAN will still take a backup of retention policy requires and if TO DESTINATION is used with BACKUP RECOVERY AREA or BACKUP RECOVERY FILES.
  • Turn RMAN optimization on and off with:
    • RMAN> configure backup optimization on;
  • Once optimization is enabled, backup will not be performed, if nothing has changed since the last valid backup.
  • Backup optimization can be overridden by the FORCE option.
    • RMAN> backup database force;
    • RMAN> backup archivelog all force;

 

 

 

Larry Catt

OCP

Oracle 12c – Recover Database with RMAN

 

This article gives the steps in performing a RMAN recovery of a database in 12c.    This procedure was performed on a OEL 7.2 and assumes that a full backup has already successfully completed.

 

 

  1. Logon to your database server as the Oracle software owner.

 

mylinux# su – oracle

Password:

Last login: Sun Sep 18 13:45:52 UTC 2016 on pts/1

mylinux# 

 

  1. Start RMAN and connect to target database.

 

mylinux# rman

Recovery Manager: Release 12.1.0.2.0 – Production on Mon Sep 19 13:46:06 2016

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

RMAN> connect target /

connected to target database: ORCL (DBID=3153769526)

RMAN>

 

  1. Issue a startup mount command, do not open the database.

 

RMAN> startup mount;

 

  1. Use the SHOW command to determine channels to use, or the CONFIGURE command to create channel.

 

RMAN> show all;

 

  1. Issue the RESTORE command.

 

RMAN> restore database;

 

  1. Issue the RECOVER command.

 

RMAN> recover database;

 

  1. Issue the database OPEN command.

 

RMAN> alter database open;

 

  1. This completes the recovery of Oracle 12c database.

Larry Catt

OCP

Oracle 12c – Enabling Flashback Database

In Oracle 12c Flashback Database must be configured which allow for tracking of changes for the database to revert to.   This article details the steps in enabling flashback database feature.

 

 

  1. Logon to server as the oracle software owner.

 

[root@orclc-db1 devadmin]# su – oracle

Last login: Mon Feb 19 18:31:43 UTC 2016 on pts/0

mylinux#

 

  1. Open or mount the oracle database.

 

mylinux# sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Feb 20 12:41:43 2016

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

Connected to an idle instance.

SQL> startup mount

ORACLE instance started.

Total System Global Area 5.1540E+10 bytes

Fixed Size                  2938792 bytes

Variable Size            3.4628E+10 bytes

Database Buffers         1.6777E+10 bytes

Redo Buffers              131276800 bytes

Database mounted.

SQL>

 

  1. Set the DB_FLASHBACK_RETENTION_TARGET initialization parameter to time period of recovery, default is 1440 minutes or 1 day.

SQL> alter system set DB_FLASHBACK_RETENTION_TARGET=2880 scope=both;

System altered.

SQL>

 

  1. Set the initialization parameter DB_RECOVERY_FILE_DEST_SIZE to a suitable size. NOTE:  This is simple a test system so we area setting the recovery size to 4GB,  a real system will require a larger size.

 

SQL> alter system set db_recovery_file_dest_size = 4g scope=both;

System altered.

 

  1. Set the initialization parameter DB_RECOVERY_FILE_DEST to a suitable large enough space one disk.

 

SQL> alter system set db_recovery_file_dest=’ /u04/oradata/ORCL/flash_recovery_area’ scope=both;

System altered.

SQL>

 

  1. Ensure that archivelog mode is enabled and enable if not.

 

SQL> archive log list

Database log mode              No Archive Mode

Automatic archival             Disabled

Archive destination            /opt/app/oracle/orcl_db/dbs/arch

Oldest online log sequence     1613

Current log sequence           1633

 

  1. Archiving log is not currently enabled, restart the database in mount mode and enable archiving.

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

 

Total System Global Area  549453824 bytes

Fixed Size                  2926616 bytes

Variable Size             268437480 bytes

Database Buffers          272629760 bytes

Redo Buffers                5459968 bytes

Database mounted.

SQL> alter database archivelog;

 

Database altered.

 

SQL>

 

  1. Enable flashback for database with ALTER DATABASE command, before opening database.

 

SQL> alter database flashback on;

Database altered.

SQL>

 

  1. Alter the database to open.

 

SQL> alter database open;

Database altered.

SQL>

 

  1. This completes enabling flashback for your Oracle RDBMS.

 

Larry Catt

OCP

 

Oracle 12c New Feature – RMAN

Table Level Recovery from backup – 12c now has the ability to recover a single table from an RMAN backup with the user of RECOVER TABLE option.

 

RMAN Command-Line SQL – RMAN utility now allows for the execution of SQL commands against target database without using SQL key word.   RMAN also now support the SQLPLUS DESCRIBE command for tables and views.

 

Active Database Duplication – RMAN supports the ability to clone a source database to an auxiliary database over the network.   Retrieving all backup sets from source database over network and allows for use of block compression during the duplication process.

 

NOOPEN option for Duplicate database creation, which allows for recovered database to not be open with resetlogs before administrative tasks can be performed.

 

duplicate target database

to newdatabase

from active database

noopen;

 

SECTION SIZE option with Image Copies – RMAN now allows you to divide data files into subsections and split upon multiple recovery channels.

 

backup

as copy

section size 500M

database;

 

Incremental Backups can include the SECTION SIZE option which allows for parallel channels to be used, thus reducing the time for backup.

 

backup

incremental level 1

section size 500m

Datafile ‘/u01/oradata/orcl/data01.dbf’;

 

SNAPSHOT with the use of BACKUP mode, 12c allows for the use of VM snapshots or storage snapshot without placing database in backup mode.   The snapshot requires 3 things for use:

  1. Database is consistent at time of snapshot.
  2. Write order is maintained for snapshot.
  3. Snapshot stores time of snapshot.

 

SNAPSHOT TIME option has become part of RECOVER command which allows for recovery from OS snapshot to a consistent point.

 

 

Larry Catt

OCP

 

RMAN Backup of PDB in Oracle 12c Multitenant Database

RMAN backup of a PDB in Oracle 12c Multitenant Database can be performed from the Recovery Manager utility or EM Cloud Control.    This procedure shows the steps of performing a PDB backup from RMAN utility.

 

  1. Logon to your oracle database server as the oracle software owner.

 

[root@linux2 larry]# su – oracle

Last login: Thu Jan  3 11:02:25 EDT 2016 on pts/1

[oracle@linux2 ~]$

 

  1. Enter the RMAN utility.

 

[oracle@linux2 ~]$ rman

 

Recovery Manager: Release 12.1.0.2.0 – Production on Tue Jan 15 12:26:22 2016

 

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

 

RMAN>

 

 

  • You can now either connect to the CDB and issue BACKUP PLUGGABLE DATABASE command or connect directly to PDB and use BACKUP DATABASE

 

  1. Connect to your target CDB database with SYSBACKUP privilege.

 

RMAN> connect target ‘”sys/@cdb1 as sysbackup”‘

 

target database Password:

connected to target database: CDB1 (DBID=898165058)

 

RMAN>

 

  1. From the CDB issue BACKUP PLUGGABLE DATABASE
    • Single PDB backup

 

RMAN>  BACKUP PLUGGABLE DATABASE PDB1;

 

  • Or multiple PDB backup

 

RMAN>  BACKUP PLUGGABLE DATABASE PDB1, PDB2;

 

  1. Additionally you can connect directly to the PDB. To do this you must connect as a common user with sysdba or sysbackup privilege,  in this example we are using C##DBA.

 

RMAN> connect target ‘”c##dba/@pdb1 as sysdba”‘

 

target database Password:

connected to target database: CDB1 (DBID=898165058)

 

RMAN> backup database;

 

 

  1. This completes backup of PDBs in the Oracle 12c Multitenant Database.

 

 

 

Larry Catt

OCP

RMAN Backup of CDB in Oracle 12c Multitenant Database

RMAN backup of a CDB in Oracle 12c Multitenant Database can be performed from the Recovery Manager utility or EM Cloud Control.    This procedure shows the steps of performing a CDB backup from RMAN utility.

 

  1. Logon to your oracle database server as the oracle software owner.

 

[root@linux2 larry]# su – oracle

Last login: Thu Jan  3 11:02:25 EDT 2016 on pts/1

[oracle@linux2 ~]$

 

  1. Enter the RMAN utility.

 

[oracle@linux2 ~]$ rman

 

Recovery Manager: Release 12.1.0.2.0 – Production on Tue Jan 15 12:26:22 2016

 

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

 

RMAN>

 

  1. Connect to your target CDB database with SYSBACKUP privilege.

 

RMAN> connect target ‘”sys/@cdb1 as sysbackup”‘

 

target database Password:

connected to target database: CDB1 (DBID=898165058)

 

RMAN>

 

  1. Validate the database you are connected to with SQL command: select name from v$database.

 

RMAN> select name from v$database;

 

using target database control file instead of recovery catalog

NAME

———

CDB1

 

RMAN>

 

  1. Now that you are connected to the database you can perform the following backups:
    • Example of entire CDB backup and all PDBs:

RMAN> BACKUP DATABASE;

  • Example of CDB backup and all PDBs, switch online redo logs and include archivelog.

RMAN>  BACKUP DATABASE PLUS ARCHIVELOG;

  • Backup just the root.

RMAN>  BACKUP DATABASE ROOT;

 

  1. This completes backup of CDB using RMAN utility.

 

Larry Catt

OCP

 

 

Recovery of CDB in Oracle 12c Multitenant Database

Oracle 12c multitenant database can use the Recovery Manager utility or EM Cloud control to recover a database from a previously taken backup set.   This procedure outlines the general steps to recover a database using the RMAN utility.

 

 

  1. Logon to your database server as the oracle software owner.

 

[root@linux2 etc]# su – oracle

Last login: Wed Nov 30 11:45:07 EST 2015 on pts/1

[oracle@linux2 ~]$

 

  1. Logon to RMAN utility with sysbackup privileges.

 

[oracle@linux2 ~]$ rman target ‘”/ as sysbackup”‘

Recovery Manager: Release 12.1.0.2.0 – Production on Thu Dec 1 09:26:07 2015

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

connected to target database: CDB1 (DBID=898155058)

 

RMAN>

 

  1. Place the database in mount mode.

 

RMAN> shutdown immediate

Oracle instance shut down

 

RMAN> startup mount

connected to target database (not started)

Oracle instance started

database mounted

Total System Global Area     734003200 bytes

Fixed Size                     2928728 bytes

Variable Size                524292008 bytes

Database Buffers             201326592 bytes

Redo Buffers                   5455872 bytes

 

RMAN>

 

  1. Issue the command RESTORE DATABASE;

 

RMAN> restore database;

 

Starting restore at 01-DEC-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=22 device type=DISK

 

skipping datafile 5; already restored to file /u01/oradata/cdb1/pdbseed/system01.dbf

skipping datafile 7; already restored to file /u01/oradata/cdb1/pdbseed/sysaux01.dbf

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 00001 to /u01/oradata/cdb1/system01.dbf

…………….

…………….

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:45

Finished restore at 01-DEC-15

 

RMAN>

 

  1. Issue the command RECOVER DATABASE;

 

RMAN> RECOVER DATABASE;

 

Starting recover at 01-DEC-15

using channel ORA_DISK_1

 

starting media recovery

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

 

Finished recover at 01-DEC-15

 

RMAN>

 

 

  1. You can remove any database archive redo logs after they are no longer needed using command: RECOVER DATABASE DELETE ARCHIVELOG;

 

RMAN> RECOVER DATABASE DELETE ARCHIVELOG;

 

Starting recover at 01-DEC-15

using channel ORA_DISK_1

 

starting media recovery

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

 

Finished recover at 01-DEC-15

 

RMAN>

 

  1. Open the database for normal operation with command: alter database open;

 

RMAN> alter database open;

 

Statement processed

 

RMAN>

 

 

  1. This completes recovery of CDB database with all PDBs.

 

Larry Catt

OCP

Recovery of PDB in Oracle 12c Multitenant Database

Oracle 12c multitenant database can use the Recovery Manager utility or EM Cloud control to recover a database from a previously taken backup set.   This procedure outlines the general steps to recover a PDB database using the RMAN utility.

 

 

  1. Logon to your database server as the oracle software owner.

 

[root@linux2 etc]# su – oracle

Last login: Wed Nov 30 11:45:07 EST 2015 on pts/1

[oracle@linux2 ~]$

 

  1. Logon to RMAN utility with sysbackup privileges.

 

[oracle@linux2 ~]$ rman target ‘”/ as sysbackup”‘

 

Recovery Manager: Release 12.1.0.2.0 – Production on Thu Dec 1 09:26:07 2015

 

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

 

connected to target database: CDB1 (DBID=898155058)

 

RMAN>

 

  1. Place the database in mount mode.

 

RMAN> shutdown immediate

Oracle instance shut down

 

RMAN> startup mount

connected to target database (not started)

Oracle instance started

database mounted

Total System Global Area     734003200 bytes

Fixed Size                     2928728 bytes

Variable Size                524292008 bytes

Database Buffers             201326592 bytes

Redo Buffers                   5455872 bytes

 

RMAN>

 

  1. Issue the command; RESTORE PLUGGABLE DATABASE <PDB>;

 

RMAN> RESTORE PLUGGABLE DATABASE pdb1;

 

Starting restore at 01-DEC-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=22 device type=DISK

 

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 00008 to /u01/oradata/cdb1/pdb1/system01.dbf

channel ORA_DISK_1: restoring datafile 00009 to /u01/oradata/cdb1/pdb1/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00010 to /u01/oradata/cdb1/pdb1/pdb1_users01.dbf

channel ORA_DISK_1: restoring datafile 00015 to /opt/app/oradata/pdb1_users.dbf

channel ORA_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB1/3F4D938FE2151097E0534B0F1E0A4221/backupset/2015_12_01/o1_mf_nnndf_TAG20151201T092735_d40dy1qr_.bkp

channel ORA_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB1/3F4D938FE2151097E0534B0F1E0A4221/backupset/2015_12_01/o1_mf_nnndf_TAG20151201T092735_d40dy1qr_.bkp tag=TAG20151201T092735

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:45

Finished restore at 01-DEC-15

 

RMAN>

 

  1. Issue the command RESTORE PLUGGABLE DATABASE <PDB>;

 

RMAN> RESTORE PLUGGABLE DATABASE pdb1;

 

Starting restore at 01-DEC-15

using channel ORA_DISK_1

 

skipping datafile 8; already restored to file /u01/oradata/cdb1/pdb1/system01.dbf

skipping datafile 9; already restored to file /u01/oradata/cdb1/pdb1/sysaux01.dbf

skipping datafile 10; already restored to file /u01/oradata/cdb1/pdb1/pdb1_users01.dbf

skipping datafile 15; already restored to file /opt/app/oradata/pdb1_users.dbf

restore not done; all files read only, offline, or already restored

Finished restore at 01-DEC-15

 

RMAN>

 

 

  1. You can remove any database archive redo logs after they are no longer needed using command: RECOVER DATABASE DELETE ARCHIVELOG;

 

RMAN> RECOVER DATABASE DELETE ARCHIVELOG;

 

Starting recover at 01-DEC-15

using channel ORA_DISK_1

starting media recovery

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

 

Finished recover at 01-DEC-15

 

RMAN>

 

 

  1. Examine RMAN logs for errors and if no errors open root and PDBs.

 

ALTER DATABASE OPEN;

ALTER PLUGGABLE DATABASE ALL OPEN;

 

RMAN> ALTER DATABASE OPEN;

Statement processed

 

RMAN> ALTER PLUGGABLE DATABASE ALL OPEN;

Statement processed

 

RMAN>

 

  1. This completes recovery of PDB database.

 

Larry Catt

OCP

Oracle 12c – Detect and repair data failures with Data Recovery Advisor

In Oracle 12c the Data Recovery Advisor is a part of Support Workbench which provides data corruption repair, database health checks, and RMAN functions.  It can perform the following:

  • Display data corruption problems.
  • Assess extent and impact.
  • Recommend repair options.
  • Automate repair processes.

Health checks are diagnostic procedures that assess the health of the database, they are executed reactively by an error occurring or manually.   The Data Recovery Advisor can diagnosis the following failures:

  • Datafiles or control files not accessible to database.
  • Physical corruption of datafiles.
  • Inconsistent datafile timestamps.
  • I/O failures such as hardware, OS drivers, exceeding OS resource limits.
  • Logical corruptions will require support interaction in general.

Failures are a persistent data corruption detected by a health check, normally found reactively when a problem is encountered and recorded in ADR.  The Data Recovery Advisor only after it occurs and assigns a priority of:

  • Critical – immediate action required to avoid database failure and corrupt.
  • High – importance may make some of database unavailable or corrupt.
  • Low – Failure can be ignored and will not cause database failure.

DRA Repairs are options which may include block media recovery, datafile media recovery, or Oracle Flashback Database.   DRA normally will provide both automated and manual recovery operations.   In automated repair DRA performance fix, verifies and clears error.

 

RMAN utility provides the ability to LIST, ADVISE and REPAIR failures.  RMAN is extracting this information from the ADR activities running in the database.  Commands used in RMAN for displaysing, advising, repairing, and changing failure check variables.

 

 

  • LIST FAILURE

 

RMAN> list failure;

using target database control file instead of recovery catalog

Database Role: PRIMARY

no failures found that match specification

RMAN>

 

  • ADVISE FAILURE – Displays repair options for failures.

 

RMAN> advise failure;

Database Role: PRIMARY

no failures found that match specification

RMAN>

 

  • REPAIR FAILURE – Allows you to repair failure with options, if there are automatic repairs from advise failure.

 

  • CHANGE FAILURE – allows you to set different priority to failure

 

RMAN> Change Failure 3 priority low;

 

 

Larry Catt

OCP