Cold Backup Steps and restoring it into destination server

Scenario:-Create a new oracle database on your local system(192.168.72.169) from existing database 'prim' on ip (192.168.72.172) using oracle cold backup

Source database ip :-     192.168.72.169
Destination database ip:- 192.168.72.172
Database version:-        Oracle 11g
Os version:-               Rhel 6


IN SOURCE DATABASE :

# To take a cold backup first I have to get location of pfile,datafiles,controlfiles,redolog files from
source database. As I have  got location like below:-

[oracle@server1 ~]$ sqlplus / as sysdba

SQL>select count(*) from dba_objects;

  COUNT(*)
----------
     72476

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/11.2.0
                                                 /db_1/dbs/spfileprim.ora

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


SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prim/control01.ctl
/u01/app/oracle/flash_recovery_area/prim/control02.ctl

SQL> select group#, member from v$logfile;
---------- ----------------------------------------------------------------------
         3 /u01/app/oracle/oradata/prim/redo03.log
         2 /u01/app/oracle/oradata/prim/redo02.log
         1 /u01/app/oracle/oradata/prim/redo01.log


IN DESTINATION DATABASE(192.168.72.172) :

# Install Oracle Binaries only. Don't Create Database on Destination Server.

# Create folder in target database same as source database and give ownership to oracle user and oinstall group.
[oracle@server1 ~]$ mkdir -p /u01/app/oracle/oradata/prim
[oracle@server1 ~]$ mkdir -p /u01/app/oracle/flash_recovery_area/prim
[oracle@server1 ~]$ mkdir -p /u01/app/oracle/admin/prim/adump
[oracle@server1 ~]$ mkdir -p /u01/app/oracle/product/11.2.0/db_1/dbs
[oracle@server1 ~]$ chown -Rf oracle:oinstall  /u01

IN SOURCE DATABASE :
# Shut Down the database.
SQL> shut immediate;

Copy controlfiles, datafiles, logfiles and pfile from source to destination in the same location as oracle user :-

# scp -r /u01/app/oracle/oradata/prim/* oracle@192.168.72.172:/u01/app/oracle/oradata/prim
# scp /u01/app/oracle/flash_recovery_area/prim/control02.ctl oracle@192.168.72.172:/u01/app/oracle/flash_recovery_area/prim/
# scp /u01/app/oracle/product/11.2.0/db_1/dbs/initprim.ora oracle@192.168.72.172:/u01/app/oracle/product/11.2.0/db_1/dbs/

IN DESTINATION DATABASE :

# Set Oracle SID
export ORACLE_SID=prim
# Login as sysdba
sqlplus / as sysdba
# Start the database in nomount stage using pfile.
SQL> STARTUP nomount PFILE =/u01/app/oracle/product/11.2.0/db_1/dbs/initprim.ora
# Enter in mount stage :-
SQL> alter database mount;
# Open database:-
SQL> alter database open;
# Create spfile from pfile
SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initprim.ora';
# Restart the database to use default spfile.
SQL> shut immediate;
SQL> startup;

SQL>select count(*) from dba_objects;

  COUNT(*)
----------
     72476

IN SOURCE DATABASE :
# Start the source Database
SQL> startup;


Hence we can say the database has been successfully restored from source database using cold backup.

No comments:

Post a Comment