What is this Site!!

All about Real time requirements in Orale Stay Tune!!
Showing posts with label EBU/Rman. Show all posts
Showing posts with label EBU/Rman. Show all posts

Friday, October 12, 2007



Recover database to a different host using legato & RMAN

Create the directories where datafiles will be restored. Set up the OFA structure on new host and copy the init.ora, config.ora files. Create the link in ORACLE_HOME/dbs directory for init.ora file. Add entry in /etc/oratab and /etc/ORACLE.PROFILE for the database. Change init.ora and config.ora to reflect new directories.


If link is not created then startup_pfile parameter should be specified to give the location of parameter file to be used Create a password file for this new instance and specify password for internal. Create symbolic link for the old online redo log directory to point to new online redo log directory.
Rman scipt should be as folows for latest database backup restore.


Unix Shell Script:


#!/bin/ksh
today=`date +%y%m%d%H%M`
export ORACLE_SID=TEST804
export ORACLE_HOME=/oracle/app/oracle/product/8.0.4
export PATH=/users/oracle/bin:/oracle/app/oracle/bin:/oracle/app/oracle/product/8.0.4/bin:/usr/bin:/usr/bin/X11:/usr/dt/bin:/usr/local/bin:.
export NLS_LANG=american
export NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'

svrmgrl <<>
connect internal
startup nomount restrict
EOF
rman target internal/sys rcvcat rman/rman@rcat1 cmdfile restore_test804.txt
svrmgrl <<>
connect internal
shutdown
EOF


Following points need to be taken note of:


  • Make sure that your target database connection is to the new database. If is is connect to the database on HOST_A then the backup will be restored on HOST_A instead of HOST_C.
  • NLS_DATE_FORMAT is used for "set until command" to specify the time to which you want to go back
  • Symbolic link is needed because after restore is done and "OPEN RESETLOGS" needs to be done, at that time controlfile is still pointing to old locaion of online redo logs because "SWITCH DATAFILE" command works only on datafiles and not on redo logs. Thus "OPEN RESETLOGS" needs to have old directory accessible.
RMAN Script:

run {
set newname for datafile '/sales1/oradata/TEST804/TEST804_system01.dbf' to '/sm1/oradata/TEST804/TEST804_system01.dbf';
set archivelog destination to '/sm1/oradata/TEST804';
allocate channel t1 type 'sbt_tape'
parms 'ENV=(NSR_SERVER=host_b,NSR_CLIENT=host_a)';
allocate channel d2 type disk;
set until time 'Mar 18 1999 18:40:00';
restore controlfile to '/sm1/oradata/TEST804/control01.ctl';
replicate controlfile from '/sm1/oradata/TEST804/control01.ctl';
sql 'alter database mount';
restore (database);
switch datafile all;
}


Following points should be noted in this script:


  • set newname is used to give the new location for the datafiles. This command restores the file to new location but does not vhange the control file. Unlike EBU, for Rman each file needs to be specified separatly instead of a global change
  • set archivelog destination specifies the directory where archivelogs will be restored.
  • NSR_CLIENT and NSR_SERVER work as specified in earlier sections
  • NSR_DEBUG_FILE can be used to specify location and file name for a debug file to be generated. Moreover a log file sbtio.log is generated in ??/udump directory if any errors are encountered.
  • A channel to disk should be allocated if restored controlfile is being replicated to the locations specified by config.ora file.
  • switch datafile changes the control file to specify new location and filenames of restored datafiles.
  • Whenever a datafile is restored using "set newname" command a datafilecopy record is created in the catalog. This record will prevent you from restoring the same backup again. Thus after the restore is done identify the primary_key of these copies using



    List copy of ‘filename’;

    Or

    Using following query on catalog database
    Select name,cdf_key
    from rc_datafile_copy where db_name=upper(‘&database_name’);

    And then remove it from the catalog using

    Change datafilecopy primary_key uncatalog;

Recover database to a different host using legato & EBU

Legato Steps

Install legato client only (server not needed) on the new node and copy usr/opt/networker/bin/libobk.so to /usr/shlib/libobk.so . NSR_CLIENT should be set up to the name of host whose data is being restored. For ex. If Database is on HOST_A and it has been backed up to tapes on HOST_B and the restore is being done to HOST_C, then NSR_CLIENT should be A (called client in legato jargon). NSR_SERVER should be set up to the name of host that backed up the data of the client. Thus in above example NSR_SERVER would be B (called server in legato jargon). C must be defined in remote access list of client A on HOST_B.


EBU Steps

Create the directories where datafiles will be restored. Set up the OFA structure on new host and copy the init.ora, config.ora files. Create the link in ORACLE_HOME/dbs directory for init.ora file. Add entry in /etc/oratab and /etc/ORACLE.PROFILE for the database. Change init.ora and config.ora to reflect new directories. If link is not created then startup_pfile parameter should be specified to give the location of parameter file to be used
EBU scipt should be as folows for latest cold database restore. db_name is not used to determine the database to be restored. ORACLE_SID determines that.

restore database
db_name = "DTSPD"
backup_host=host_b
parallel=3
rename
remap_path = "/dts/oradata/DTSPD" to "/disk3/oradata/DTSPD","/its/oradata/DTSPD" to "/disk3/oradata/DTSPD"
archivelog = "/disk3/oradata/DTSPD"
log = "/users/oracle/dba/legato/log/restore_dtspd.log"

remap_path parameter should be used to specify the directories where files are to be restored. One target directory can be specified for each source directory.

rename parameter should be used for automatic renaming of data and logfiles in the controlfile. As EBU renamed online redo logs first and datafiles next so if dummy (because neither EBU nor Rman backs up online redo logs) online redo logs are not created prior to restore then the automatic renaming will fail. In that case either created a new controlfile using backup create controfile script or rename all the datafiles manually using ‘alter database rename file ’ command.

backup_host parameter should be used to specify the host which had done the backup, which is being restored. Thus in our example it would be HOST_B. (Test this one)