Friday 26 July 2019

Backing Up Control Files

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN> BACKUP TABLESPACE users INCLUDE CURRENT CONTROLFILE;

Starting backup at 25-JUL-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 25-JUL-19
channel ORA_DISK_1: finished piece 1 at 25-JUL-19
piece handle=+FRA/RAC/BACKUPSET/2019_07_25/ncnnf0_tag20190725t192423_0.401.1014578667 tag=TAG20190725T192423 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA/RAC/DATAFILE/users.259.1011960169
channel ORA_DISK_1: starting piece 1 at 25-JUL-19
channel ORA_DISK_1: finished piece 1 at 25-JUL-19
piece handle=+FRA/RAC/BACKUPSET/2019_07_25/nnndf0_tag20190725t192423_0.325.1014578671 tag=TAG20190725T192423 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-JUL-19

Starting Control File and SPFILE Autobackup at 25-JUL-19
piece handle=+FRA/RAC/AUTOBACKUP/2019_07_25/s_1014578672.326.1014578675 comment=NONE
Finished Control File and SPFILE Autobackup at 25-JUL-19

RMAN> BACKUP CURRENT CONTROLFILE;

Starting backup at 25-JUL-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 25-JUL-19
channel ORA_DISK_1: finished piece 1 at 25-JUL-19
piece handle=+FRA/RAC/BACKUPSET/2019_07_25/ncnnf0_tag20190725t194446_0.327.1014579891 tag=TAG20190725T194446 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 25-JUL-19

Starting Control File and SPFILE Autobackup at 25-JUL-19
piece handle=+FRA/RAC/AUTOBACKUP/2019_07_25/s_1014579893.328.1014579895 comment=NONE
Finished Control File and SPFILE Autobackup at 25-JUL-19



RMAN> BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/u01/Backup/control.bk';

Starting backup at 25-JUL-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/Backup/control.bk tag=TAG20190725T194626 RECID=11 STAMP=1014579993
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 25-JUL-19

Starting Control File and SPFILE Autobackup at 25-JUL-19
piece handle=+FRA/RAC/AUTOBACKUP/2019_07_25/s_1014579997.331.1014579999 comment=NONE
Finished Control File and SPFILE Autobackup at 25-JUL-19

RMAN>

####################### Snapshot Controlfile #####################



RMAN> SHOW SNAPSHOT CONTROLFILE NAME;

RMAN configuration parameters for database with db_unique_name RAC are:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+FRA/RAC/CONTROLFILE/snapcf_rac1.f';

RMAN>

################  Backing Up the Control File to a Trace File ###########################

SQL> alter database backup controlfile to trace;

Database altered.

SQL>
SQL> sho parameter dump

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
background_core_dump                 string      partial
background_dump_dest                 string      /u01/app/oracle/product/12.1.0
                                                 /dbhome_2/rdbms/log
core_dump_dest                       string      /u01/app/oracle/diag/rdbms/rac
                                                 /rac1/cdump
max_dump_file_size                   string      unlimited
shadow_core_dump                     string      partial
user_dump_dest                       string      /u01/app/oracle/product/12.1.0
                                                 /dbhome_2/rdbms/log
SQL>
[oracle@srv1 trace]$ cat rac1_ora_22067.trc
Trace file /u01/app/oracle/diag/rdbms/rac/rac1/trace/rac1_ora_22067.trc
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_2
System name:    Linux
Node name:      srv1.example.com
Release:        3.8.13-68.3.4.el6uek.x86_64
Version:        #2 SMP Tue Jul 14 15:03:36 PDT 2015
Machine:        x86_64
Instance name: rac1
Redo thread mounted by this instance: 1
Oracle process number: 39
Unix process pid: 22067, image: oracle@srv1.example.com (TNS V1-V3)


*** 2019-07-25 19:53:18.714
*** SESSION ID:(94.33629) 2019-07-25 19:53:18.714
*** CLIENT ID:() 2019-07-25 19:53:18.714
*** SERVICE NAME:(SYS$USERS) 2019-07-25 19:53:18.714
*** MODULE NAME:(sqlplus@srv1.example.com (TNS V1-V3)) 2019-07-25 19:53:18.714
*** CLIENT DRIVER:(SQL*PLUS) 2019-07-25 19:53:18.714
*** ACTION NAME:() 2019-07-25 19:53:18.714

-- The following are current System-scope REDO Log Archival related
-- parameters and can be included in the database initialization file.
--
-- LOG_ARCHIVE_DEST=''
-- LOG_ARCHIVE_DUPLEX_DEST=''
--
-- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
--
-- DB_UNIQUE_NAME="rac"
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=4
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- STANDBY_ARCHIVE_DEST=?/dbs/arch
-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST'
-- LOG_ARCHIVE_DEST_1='MANDATORY REOPEN=300 NODELAY'
-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_1='NOREGISTER NOALTERNATE NODEPENDENCY'
-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'
-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'
-- LOG_ARCHIVE_DEST_STATE_1=ENABLE
--
-- Below are two sets of SQL statements, each of which creates a new
-- control file and uses it to open the database. The first set opens
-- the database with the NORESETLOGS option and should be used only if
-- the current versions of all online logs are available. The second
-- set opens the database with the RESETLOGS option and should be used
-- if online logs are unavailable.
-- The appropriate set of statements can be copied from the trace into
-- a script file, edited as necessary, and executed when there is a
-- need to re-create the control file.
--
--     Set #1. NORESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "RAC" NORESETLOGS  ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 (
    '+DATA/RAC/ONLINELOG/group_1.262.1011960239',
    '+FRA/RAC/ONLINELOG/group_1.257.1011960241'
  ) SIZE 50M BLOCKSIZE 512,
  GROUP 2 (
    '+DATA/RAC/ONLINELOG/group_2.263.1011960241',
    '+FRA/RAC/ONLINELOG/group_2.258.1011960245'
  ) SIZE 50M BLOCKSIZE 512,
  GROUP 3 (
    '+DATA/RAC/ONLINELOG/group_3.266.1011961119',
    '+FRA/RAC/ONLINELOG/group_3.259.1011961121'
  ) SIZE 50M BLOCKSIZE 512,
  GROUP 4 (
    '+DATA/RAC/ONLINELOG/group_4.267.1011961123',
    '+FRA/RAC/ONLINELOG/group_4.260.1011961125'
  ) SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '+DATA/RAC/DATAFILE/system.258.1011960053',
  '+DATA/RAC/DATAFILE/sysaux.257.1011959959',
  '+DATA/RAC/DATAFILE/undotbs1.260.1011960171',
  '+DATA/RAC/DATAFILE/undotbs2.265.1011960859',
  '+DATA/RAC/DATAFILE/users.259.1011960169'
CHARACTER SET AL32UTF8
;
-- Configure snapshot controlfile filename
EXECUTE SYS.DBMS_BACKUP_RESTORE.CFILESETSNAPSHOTNAME('+FRA/RAC/CONTROLFILE/snapcf_rac1.f');
-- Configure RMAN configuration record 1
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('SNAPSHOT CONTROLFILE NAME','TO ''+FRA/RAC/CONTROLFILE/snapcf_rac1.f''');
-- Configure RMAN configuration record 2
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('RMAN OUTPUT','TO KEEP FOR 21 DAYS');
-- Configure RMAN configuration record 3
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP','ON');
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '+FRA';
-- ALTER DATABASE REGISTER LOGFILE '+FRA';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE
-- All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
-- Database can now be opened normally.
ALTER DATABASE OPEN;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '+DATA/RAC/TEMPFILE/temp.264.1011960267'
     SIZE 224395264  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
-- End of tempfile additions.
--
--     Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "RAC" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 (
    '+DATA/RAC/ONLINELOG/group_1.262.1011960239',
    '+FRA/RAC/ONLINELOG/group_1.257.1011960241'
  ) SIZE 50M BLOCKSIZE 512,
  GROUP 2 (
    '+DATA/RAC/ONLINELOG/group_2.263.1011960241',
    '+FRA/RAC/ONLINELOG/group_2.258.1011960245'
  ) SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '+DATA/RAC/DATAFILE/system.258.1011960053',
  '+DATA/RAC/DATAFILE/sysaux.257.1011959959',
  '+DATA/RAC/DATAFILE/undotbs1.260.1011960171',
  '+DATA/RAC/DATAFILE/undotbs2.265.1011960859',
  '+DATA/RAC/DATAFILE/users.259.1011960169'
CHARACTER SET AL32UTF8
;
-- Configure snapshot controlfile filename
EXECUTE SYS.DBMS_BACKUP_RESTORE.CFILESETSNAPSHOTNAME('+FRA/RAC/CONTROLFILE/snapcf_rac1.f');
-- Configure RMAN configuration record 1
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('SNAPSHOT CONTROLFILE NAME','TO ''+FRA/RAC/CONTROLFILE/snapcf_rac1.f''');
-- Configure RMAN configuration record 2
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('RMAN OUTPUT','TO KEEP FOR 21 DAYS');
-- Configure RMAN configuration record 3
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP','ON');
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '+FRA';
-- ALTER DATABASE REGISTER LOGFILE '+FRA';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
-- Create log files for threads other than thread one.
ALTER DATABASE ADD LOGFILE THREAD 2
  GROUP 3 (
    '+DATA/RAC/ONLINELOG/group_3.266.1011961119',
    '+FRA/RAC/ONLINELOG/group_3.259.1011961121'
  ) SIZE 50M BLOCKSIZE 512 REUSE,
  GROUP 4 (
    '+DATA/RAC/ONLINELOG/group_4.267.1011961123',
    '+FRA/RAC/ONLINELOG/group_4.260.1011961125'
  ) SIZE 50M BLOCKSIZE 512 REUSE;
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '+DATA/RAC/TEMPFILE/temp.264.1011960267'
     SIZE 224395264  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
-- End of tempfile additions.
--
[oracle@srv1 trace]$



No comments:

Post a Comment