Sunday, August 15, 2021

RMAN(recovery manager) in oracle

  

 

RMAN BACKUP

 

Recovery Manager:

Using Oracle RMAN, you can take a hot backup for your database, which will take a consistent backup even when your DB is up and running.

Advantages of RMAN

  • Selects the most appropriate backup for database recovery.
  • Uses simple commands to perform backup operations.
  • User can automatically backup the database on tape.
  • A database can be recovered in the data block level.
  • Only changed data blocks can be recovered using incremental backup functionality which reduces the backup time.
  • Secure backups can be created using the Encryption feature.
  • Clone of the database can be created on the remote host by using the duplicate command of RMAN.
  • Physical standby databases can be created simply

Connect rman       

 

[oracle@sample ~]$ rman target/

 

Recovery Manager: Release 19.0.0.0.0 - Production on Mon Aug 16 01:48:09 2021

Version 19.3.0.0.0

 

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

 

connected to target database: ORCL (DBID=1608294549)                           

 

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

 

help parameter in rman

 

[oracle@sample ~]$ rman help=yes

 

Argument     Value          Description

-----------------------------------------------------------------------------

target       quoted-string  connect-string for target database

catalog      quoted-string  connect-string for recovery catalog

auxiliary    quoted-string  connect-string for auxiliary database

nocatalog    none           if specified, then no recovery catalog

cmdfile      quoted-string  name of input command file

log          quoted-string  name of output message log file

trace        quoted-string  name of output debugging message log file

append       none           if specified, log is opened in append mode

debug        optional-args  activate debugging

msgno        none           show RMAN-nnnn prefix for all messages

send         quoted-string  send a command to the media manager

pipe         string         building block for pipe names

script       string         name of catalog script to execute

using        list of args   arguments for rman variables

timeout      integer        number of seconds to wait for pipe input

checksyntax  none           check the command file for syntax errors

-----------------------------------------------------------------------------

Both single and double quotes (' or ") are accepted for a quoted-string.

Quotes are not required unless the string contains embedded white-space.

 

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

View Current RMAN Configuration

To view current RMAN configurations, execute “show all”.

RMAN> show all;

RMAN configuration parameters for database with db_unique_name ORCL are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP ON; # default

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 CHANNEL DEVICE TYPE DISK FORMAT   '/backup/rman/full_%u_%s_%p';

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default

CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/19.0.0/dbhome_1/dbs/snapcf_orcl.f'; # default

RMAN>

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

create a directory  to rman backup location

[root@sample oracle]# cd

[root@sample ~]# mkdir -p /backup/rman

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

 Backup Oracle Database

1.with out archive logs

Use the “BACKUP AS BACKUPSET DATABASE” command to backup a database. So, to take a full backup of the database without the archive logs

RMAN> BACKUP AS BACKUPSET DATABASE ;

Starting backup at 16-AUG-21

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=64 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00005 name=/u01/app/oracle/oradata/ORCL/datafile/vignesh.dbf

input datafile file number=00001 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_jkf9yp7l_.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_jkf9zt6p_.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_jkfb0n4d_.dbf

input datafile file number=00007 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_jkfb0psc_.dbf

channel ORA_DISK_1: starting piece 1 at 16-AUG-21

channel ORA_DISK_1: finished piece 1 at 16-AUG-21

piece handle=/backup/rman/full_0806k8r8_8_1 tag=TAG20210816T014824 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

Finished backup at 16-AUG-21

Starting Control File and SPFILE Autobackup at 16-AUG-21

piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2021_08_16/o1_mf_s_1080697750_jklxoypo_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 16-AUG-21

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

Check the backup file created in correct location

[oracle@sample ~]$ cd /backup/rman/

[oracle@sample rman]$ ls

full_0806k8r8_8_1

[oracle@sample rman]$ ls -lrth

total 1.3G

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

2. with archive log

Check the database archive log mode is enabled

SQL> archive log list;

Database log mode            Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     2

Next log sequence to archive   4

Current log sequence         4

If the archive log not enabled do the following steps

Step 1- shutdown the database

Sql>shutdown;                                     

Step2-start the database with mount stage

Sql>startup mount;

Step3-using alter command to change log mode

Sql>alter database archivelog;

Step4-using alter command to open database

Sql>alter database open;

To take a full backup of the database with the archive logs, do the following:

RMAN> BACKUP AS BACKUPSET DATABASE PLUS ARCHIVELOG;

Starting backup at 16-AUG-21

current log archived

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=66 device type=DISK

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=4 RECID=1 STAMP=1080698906

channel ORA_DISK_1: starting piece 1 at 16-AUG-21

channel ORA_DISK_1: finished piece 1 at 16-AUG-21

piece handle=/backup/rman/full_0a06ka0r_10_1 tag=TAG20210816T020827 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07

Finished backup at 16-AUG-21

Starting backup at 16-AUG-21

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00005 name=/u01/app/oracle/oradata/ORCL/datafile/vignesh.dbf

input datafile file number=00001 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_jkf9yp7l_.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_jkf9zt6p_.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_jkfb0n4d_.dbf

input datafile file number=00007 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_jkfb0psc_.dbf

channel ORA_DISK_1: starting piece 1 at 16-AUG-21

channel ORA_DISK_1: finished piece 1 at 16-AUG-21

piece handle=/backup/rman/full_0b06ka13_11_1 tag=TAG20210816T020834 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46

Finished backup at 16-AUG-21

Starting backup at 16-AUG-21

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=5 RECID=2 STAMP=1080698961

channel ORA_DISK_1: starting piece 1 at 16-AUG-21

channel ORA_DISK_1: finished piece 1 at 16-AUG-21

piece handle=/backup/rman/full_0c06ka2h_12_1 tag=TAG20210816T020921 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 16-AUG-21

Starting Control File and SPFILE Autobackup at 16-AUG-21

piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2021_08_16/o1_mf_s_1080698962_jklyvvdx_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 16-AUG-21

RMAN>

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

Backup tablespace using rman

we can also take a backup of only a specific table space. The following example takes backup of only vignesh tablespace.

RMAN> BACKUP AS BACKUPSET TABLESPACE vignesh;

Starting backup at 16-AUG-21

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00005 name=/u01/app/oracle/oradata/ORCL/datafile/vignesh.dbf

channel ORA_DISK_1: starting piece 1 at 16-AUG-21

channel ORA_DISK_1: finished piece 1 at 16-AUG-21

piece handle=/backup/rman/full_0e06ka8v_14_1 tag=TAG20210816T021247 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

Finished backup at 16-AUG-21

Starting Control File and SPFILE Autobackup at 16-AUG-21

piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2021_08_16/o1_mf_s_1080699169_jklz298m_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 16-AUG-21

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

View all RMAN Backups summary

To view all the RMAN backups, execute “list backup summary” as shown below.

RMAN> LIST BACKUP SUMMARY;

List of Backups

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

Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

------- -- -- - ----------- --------------- ------- ------- ---------- ---

1       B  F  A DISK        16-AUG-21       1       1       NO         TAG20210816T014824

2       B  F  A DISK        16-AUG-21       1       1       NO         TAG20210816T014910

3       B  A  A DISK        16-AUG-21       1       1       NO         TAG20210816T020827

4       B  F  A DISK        16-AUG-21       1       1       NO         TAG20210816T020834

5       B  A  A DISK        16-AUG-21       1       1       NO         TAG20210816T020921

6       B  F  A DISK        16-AUG-21       1       1       NO         TAG20210816T020922

7       B  F  A DISK        16-AUG-21       1       1       NO         TAG20210816T021247

8       B  F  A DISK        16-AUG-21       1       1       NO         TAG20210816T021249

9       B  F  A DISK        16-AUG-21       1       1       NO         TAG20210816T022401

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

 

View rman backup status

RMAN backup is running, if you want to see the proress, you can query the V$RMAN_STATUS table from sql*plus as shown below.

SQL> SELECT OPERATION, STATUS, MBYTES_PROCESSED, START_TIME, END_TIME from V$RMAN_STATUS;

SQL> SELECT OPERATION, STATUS, MBYTES_PROCESSED from v$rman_status;

OPERATION                                      STATUS                    MBYTES_PROCESSED

---------------------------------                  -----------------------                       ----------------

RMAN                                                  RUNNING WITH ERRORS                      0

RMAN                                                  COMPLETED WITH ERRORS           1506

RMAN                                                  COMPLETED WITH ERRORS                 0

BACKUP                                             FAILED                                                       0

RMAN                                                  COMPLETED WITH ERRORS                 0

RMAN                                                  COMPLETED WITH ERRORS                 0

BACKUP                                             FAILED                                                       0

BACKUP                                             COMPLETED                                         164

BACKUP                                             FAILED                                                       0

BACKUP                                             FAILED                                                       0

BACKUP                                             COMPLETED                                        1486

RMAN                                                  COMPLETED WITH ERRORS                  0

CONTROL FILE AND SPFILE

AUTOBACK                                     COMPLETED                                                10

LIST                                                      COMPLETED                                             0

BACKUP                                             FAILED                                                         0

BACKUP                                             COMPLETED                                              0

RMAN                                                  COMPLETED                                              0

RMAN                                                  COMPLETED WITH ERRORS                  0

BACKUP                                             COMPLETED                                              22

BACKUP                                            FAILED                                                       0

CONTROL FILE AND SPFILE

AUTOBACK                                         COMPLETED                                            10

RMAN                                                  COMPLETED                                              0

RMAN                                                  COMPLETED WITH ERRORS                  0

BACKUP                                             FAILED                                                       0

RMAN                                                  COMPLETED WITH ERRORS                  0

BACKUP                                             FAILED                                                       0

BACKUP                                             COMPLETED                                              0

BACKUP                                             COMPLETED                                        1496

RMAN                                                  COMPLETED WITH ERRORS                  0

CONTROL FILE AND

SPFILE AUTOBACK                       COMPLETED                                                10

BACKUP                                             FAILED                                                       0


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

 

 


No comments:

Post a Comment

Oracle Cloud Guard – Features, Architecture & Real-World Use Cases

Securing cloud environments is no longer just a compliance requirement — it has become a continuous operational responsibility. Oracle Cloud...