Here i'm trying to do the disaster recovery using RMAN.
Primary machine:192.168.2.102
Secondary Machine:192.168.2.104
In primary machine:-
[oracle@server1 ~]$ sqlplus / as sysdba
SQL> select name from v$database;
NAME
---------
PRIM
Now creating a table and we will check it on the secondary machine which i would use for distaster recovery.
SQL> create table students (name varchar(20));
Table created.
SQL> insert into students values ('soumya');
1 row created.
SQL> commit;
Commit complete.
#Now I will take rman backup of the database.Also i need to make sure
control autobackup on option is enabled.
rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Sun Jan 11 12:05:08 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRIM (DBID=4130009889)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PRIM are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/%F';
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 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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_prim.f'; # default
As we can see CONTROLFILE AUTOBACKUP ON OPTION IS ENABLED.NOW we will start taking the backup.
RMAN> backup database plus archivelog;
#Now we need to create the directory structures for datafile, controlfile, redolog file and spfile in secondary database as of primary database.
To get the list of directory structure we will check the data dictionary view.
[oracle@server1 ~]$ sqlplus / as sysdba
#To list all datafiles location:-
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/system01.dbf
/u01/app/oracle/oradata/prim/sysaux01.dbf
/u01/app/oracle/oradata/prim/undotbs01.dbf
/u01/app/oracle/oradata/prim/users01.dbf
/u01/app/oracle/oradata/prim/example01.dbf
/u01/app/oracle/oradata/prim/testtbs.dbf
/u01/app/oracle/oradata/prim/testtbs1.dbf
#To list all redolog file's location:-
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/redo03.log
/u01/app/oracle/oradata/prim/redo02.log
/u01/app/oracle/oradata/prim/redo01.log
#To list the all controlfile's location:-
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/control01.ctl
/u01/app/oracle/flash_recovery_area/prim/control02.ctl
#To list the directory where tracefile resides:-
SQL> show parameter dump_dest;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
background_dump_dest string /u01/app/oracle/diag/rdbms/pri
m/prim/trace
core_dump_dest string /u01/app/oracle/diag/rdbms/pri
m/prim/cdump
user_dump_dest string /u01/app/oracle/diag/rdbms/pri
m/prim/trace
#Now we would create the directory structure for secondary database:-
In seondary database:-
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/oradata/prim/
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/flash_recovery_area/prim
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim/adump
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim/bdump
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim/cdump
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim/udump
[oracle@server2 ~]$ chown -Rf oracle:oinstall /u01
#Now we can delete all the datafiles from the primary database if we want to.
#Now we will copy all the backup files into the secondary database machine.
[oracle@server2 ~]$ export ORACLE_SID=prim
[oracle@server2 ~]$ cd $ORACLE_HOME
[oracle@server2 db_1]$ pwd
/u01/app/oracle/product/11.2.0/db_1
We would like to paste the backup file into /tmp/backup location.
[oracle@server1 ~]$ mkdir -p /tmp/backup
#Now transferring backup from primary database server to secondary
#In primary database server:-
[oracle@server1 ~]$ cd /u01/app/oracle/flash_recovery_area/PRIM/backupset/2015_01_11
[oracle@server1 2015_01_11]$ scp -r * oracle@192.168.2.104:/tmp/backup/
#copy the archivelogs:-
[oracle@server1 2015_01_11]$ cd /u01/app/oracle/flash_recovery_area/PRIM/archivelog/2015_01_11
[oracle@server1 2015_01_11]$ scp * oracle@192.168.2.104:/tmp/backup/
#Now in secondary database server:-
[oracle@server2 u01]$ export ORACLE_SID=prim
[oracle@server2 u01]$ rman target /
#We are starting the database in nomount stage using dummy parameter file
RMAN> startup nomount
Oracle instance started
Total System Global Area 413372416 bytes
Fixed Size 2213896 bytes
Variable Size 318769144 bytes
Database Buffers 88080384 bytes
Redo Buffers 4308992 bytes
#Now we will restore spfile from our rman backup set
RMAN> restore spfile from '/u01/c-4130009889-20150111-00';
Starting restore at 11-JAN-15
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /tmp/backup/c-4130009889-20150111-00
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 11-JAN-15
#Now restore controlfile from Autobackup:-
MAN> shutdown
Oracle instance shut down
RMAN> startup nomount
connected to target database (not started)
Oracle instance started
Total System Global Area 413372416 bytes
Fixed Size 2213896 bytes
Variable Size 327157752 bytes
Database Buffers 79691776 bytes
Redo Buffers 4308992 bytes
RMAN> restore controlfile from ' /tmp/backup/c-4130009889-20150111-00';
Starting restore at 11-JAN-15
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/prim/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/prim/control02.ctl
Finished restore at 11-JAN-15
#Now open database in mount stage
RMAN> startup mount force
Oracle instance started
database mounted
Total System Global Area 413372416 bytes
Fixed Size 2213896 bytes
Variable Size 327157752 bytes
Database Buffers 79691776 bytes
Redo Buffers 4308992 bytes
#Now restore the datafiles
RMAN> restore database;
Starting restore at 11-JAN-15
Starting implicit crosscheck backup at 11-JAN-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
Crosschecked 17 objects
Finished implicit crosscheck backup at 11-JAN-15
Starting implicit crosscheck copy at 11-JAN-15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 11-JAN-15
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/11/2015 13:57:48
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore
#we can see the above error while trying to restore the datafiles.Cause rman cant find the datafiles
in its repository.
RMAN> catalog start with '/tmp/backup';
searching for all files that match the pattern /tmp/backup
List of Files Unknown to the Database
=====================================
File Name: /tmp/backup/o1_mf_nnndf_TAG20150111T121621_bc471yc8_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121747_bc474ms3_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471w8w_.bkp
File Name: /tmp/backup/c-4130009889-20150111-00
File Name: /tmp/backup/o1_mf_1_1_bc45yfkg_.arc
File Name: /tmp/backup/o1_mf_1_2_bc471lpp_.arc
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471v5c_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471mz6_.bkp
File Name: /tmp/backup/o1_mf_1_3_bc474md4_.arc
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /tmp/backup/o1_mf_nnndf_TAG20150111T121621_bc471yc8_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121747_bc474ms3_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471w8w_.bkp
File Name: /tmp/backup/c-4130009889-20150111-00
File Name: /tmp/backup/o1_mf_1_1_bc45yfkg_.arc
File Name: /tmp/backup/o1_mf_1_2_bc471lpp_.arc
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471v5c_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471mz6_.bkp
File Name: /tmp/backup/o1_mf_1_3_bc474md4_.arc
RMAN> restore database;
#Once restoring of datafiles are done, we will recover the database.
RMAN> recover database;
#The above step will recover the database along with backed up archivelogs.Now we will open the database with resetlogs option.
RMAN> alter database open resetlogs;
database opened
#Now check the table which we created at primary database.
[oracle@server2 backup]$ sqlplus / as sysdba
SQL> select * from students;
NAME
--------------------
soumya
Done...
Primary machine:192.168.2.102
Secondary Machine:192.168.2.104
In primary machine:-
[oracle@server1 ~]$ sqlplus / as sysdba
SQL> select name from v$database;
NAME
---------
PRIM
Now creating a table and we will check it on the secondary machine which i would use for distaster recovery.
SQL> create table students (name varchar(20));
Table created.
SQL> insert into students values ('soumya');
1 row created.
SQL> commit;
Commit complete.
#Now I will take rman backup of the database.Also i need to make sure
control autobackup on option is enabled.
rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Sun Jan 11 12:05:08 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRIM (DBID=4130009889)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PRIM are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/%F';
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 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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_prim.f'; # default
As we can see CONTROLFILE AUTOBACKUP ON OPTION IS ENABLED.NOW we will start taking the backup.
RMAN> backup database plus archivelog;
#Now we need to create the directory structures for datafile, controlfile, redolog file and spfile in secondary database as of primary database.
To get the list of directory structure we will check the data dictionary view.
[oracle@server1 ~]$ sqlplus / as sysdba
#To list all datafiles location:-
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/system01.dbf
/u01/app/oracle/oradata/prim/sysaux01.dbf
/u01/app/oracle/oradata/prim/undotbs01.dbf
/u01/app/oracle/oradata/prim/users01.dbf
/u01/app/oracle/oradata/prim/example01.dbf
/u01/app/oracle/oradata/prim/testtbs.dbf
/u01/app/oracle/oradata/prim/testtbs1.dbf
#To list all redolog file's location:-
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/redo03.log
/u01/app/oracle/oradata/prim/redo02.log
/u01/app/oracle/oradata/prim/redo01.log
#To list the all controlfile's location:-
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/control01.ctl
/u01/app/oracle/flash_recovery_area/prim/control02.ctl
#To list the directory where tracefile resides:-
SQL> show parameter dump_dest;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
background_dump_dest string /u01/app/oracle/diag/rdbms/pri
m/prim/trace
core_dump_dest string /u01/app/oracle/diag/rdbms/pri
m/prim/cdump
user_dump_dest string /u01/app/oracle/diag/rdbms/pri
m/prim/trace
#Now we would create the directory structure for secondary database:-
In seondary database:-
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/oradata/prim/
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/flash_recovery_area/prim
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim/adump
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim/bdump
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim/cdump
[oracle@server2 ~]$ mkdir -p /u01/app/oracle/diag/rdbms/prim/prim/udump
[oracle@server2 ~]$ chown -Rf oracle:oinstall /u01
#Now we can delete all the datafiles from the primary database if we want to.
#Now we will copy all the backup files into the secondary database machine.
[oracle@server2 ~]$ export ORACLE_SID=prim
[oracle@server2 ~]$ cd $ORACLE_HOME
[oracle@server2 db_1]$ pwd
/u01/app/oracle/product/11.2.0/db_1
We would like to paste the backup file into /tmp/backup location.
[oracle@server1 ~]$ mkdir -p /tmp/backup
#Now transferring backup from primary database server to secondary
#In primary database server:-
[oracle@server1 ~]$ cd /u01/app/oracle/flash_recovery_area/PRIM/backupset/2015_01_11
[oracle@server1 2015_01_11]$ scp -r * oracle@192.168.2.104:/tmp/backup/
#copy the archivelogs:-
[oracle@server1 2015_01_11]$ cd /u01/app/oracle/flash_recovery_area/PRIM/archivelog/2015_01_11
[oracle@server1 2015_01_11]$ scp * oracle@192.168.2.104:/tmp/backup/
#Now in secondary database server:-
[oracle@server2 u01]$ export ORACLE_SID=prim
[oracle@server2 u01]$ rman target /
#We are starting the database in nomount stage using dummy parameter file
RMAN> startup nomount
Oracle instance started
Total System Global Area 413372416 bytes
Fixed Size 2213896 bytes
Variable Size 318769144 bytes
Database Buffers 88080384 bytes
Redo Buffers 4308992 bytes
#Now we will restore spfile from our rman backup set
RMAN> restore spfile from '/u01/c-4130009889-20150111-00';
Starting restore at 11-JAN-15
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /tmp/backup/c-4130009889-20150111-00
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 11-JAN-15
#Now restore controlfile from Autobackup:-
MAN> shutdown
Oracle instance shut down
RMAN> startup nomount
connected to target database (not started)
Oracle instance started
Total System Global Area 413372416 bytes
Fixed Size 2213896 bytes
Variable Size 327157752 bytes
Database Buffers 79691776 bytes
Redo Buffers 4308992 bytes
RMAN> restore controlfile from ' /tmp/backup/c-4130009889-20150111-00';
Starting restore at 11-JAN-15
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/prim/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/prim/control02.ctl
Finished restore at 11-JAN-15
#Now open database in mount stage
RMAN> startup mount force
Oracle instance started
database mounted
Total System Global Area 413372416 bytes
Fixed Size 2213896 bytes
Variable Size 327157752 bytes
Database Buffers 79691776 bytes
Redo Buffers 4308992 bytes
#Now restore the datafiles
RMAN> restore database;
Starting restore at 11-JAN-15
Starting implicit crosscheck backup at 11-JAN-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
Crosschecked 17 objects
Finished implicit crosscheck backup at 11-JAN-15
Starting implicit crosscheck copy at 11-JAN-15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 11-JAN-15
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/11/2015 13:57:48
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore
#we can see the above error while trying to restore the datafiles.Cause rman cant find the datafiles
in its repository.
RMAN> catalog start with '/tmp/backup';
searching for all files that match the pattern /tmp/backup
List of Files Unknown to the Database
=====================================
File Name: /tmp/backup/o1_mf_nnndf_TAG20150111T121621_bc471yc8_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121747_bc474ms3_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471w8w_.bkp
File Name: /tmp/backup/c-4130009889-20150111-00
File Name: /tmp/backup/o1_mf_1_1_bc45yfkg_.arc
File Name: /tmp/backup/o1_mf_1_2_bc471lpp_.arc
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471v5c_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471mz6_.bkp
File Name: /tmp/backup/o1_mf_1_3_bc474md4_.arc
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /tmp/backup/o1_mf_nnndf_TAG20150111T121621_bc471yc8_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121747_bc474ms3_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471w8w_.bkp
File Name: /tmp/backup/c-4130009889-20150111-00
File Name: /tmp/backup/o1_mf_1_1_bc45yfkg_.arc
File Name: /tmp/backup/o1_mf_1_2_bc471lpp_.arc
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471v5c_.bkp
File Name: /tmp/backup/o1_mf_annnn_TAG20150111T121611_bc471mz6_.bkp
File Name: /tmp/backup/o1_mf_1_3_bc474md4_.arc
RMAN> restore database;
#Once restoring of datafiles are done, we will recover the database.
RMAN> recover database;
#The above step will recover the database along with backed up archivelogs.Now we will open the database with resetlogs option.
RMAN> alter database open resetlogs;
database opened
#Now check the table which we created at primary database.
[oracle@server2 backup]$ sqlplus / as sysdba
SQL> select * from students;
NAME
--------------------
soumya
Done...
Nenhum comentário:
Postar um comentário