Wednesday, December 22, 2010

Stage Copy Solution for Faster Dev and Sandbox system copies

CAUTION: PLEASE DO NOT COPY AND PASTE ANY OF THE COMMANDS.

Environment: RHEL 2.6 on HP Proliant Blades, Oracle 10.2.0.4, SAP R3

The idea is to restore the online backup of DEV onto SND.
The systems in question are source DEV and target SND.

Because of time constraint we had to go for an efficient backup/restore method. And we have opted for stage_copy method.

The following procedure describes the stage copy method.
Online backup profile - initDEV_online.sap
Create a new profile based on the online backup profile for stage_copy and name it as initDEV_online_stage.sap

vi initDEV_online_stage.sap and set/modify the following parameters
backup_mode = all
restore_mode = all
backup_type = online
backup_dev_type = stage
backup_root_dir = $SAPDATA_HOME/sapbackup
stage_root_dir = /oracle/SND/sapbackup
compress = no
compress_dir = $SAPDATA_HOME/sapreorg
archive_function = save
archive_copy_dir = $SAPDATA_HOME/sapbackup
archive_stage_dir = /oracle/SND/sapbackup
new_db_home = /oracle/SND
stage_db_home = /oracle/SND
remote_host = fctfrmSND
remote_user = ‘oraSND test123’ (can be hashed in case of ssh)
stage_copy_cmd = scp
exec_parallel = 2

Preparation of filesystems in SND (target)
        1.       Validate the mount points and their permissions.
        2.      Clean up all sapdata filesystems and compare the sizes between DEV and SND
        3.      Clean up all origlog* and mirrlog* filesystems.
        4.      Clean up saparch, oraarch, sapreorg, sapbackup filesystems.
        5.      Disable the archive log and online backup scripts in the cron on both and DEV and SND.
        6.      Stop SAP and Oracle on SND (target)
        7.      cleanipc –XX remove and also remove any remaining shared memory segments using ipcrm
        8.      kill all the processes running with SNDadm and oraSND
Initiate online restore from DEV to SND using stage_copy profile
  Ø       Ensure ssh is setup on SND (target) for the user oraSND and oraDEV.
  Ø       Login to DEV as oraDEV and issue the following command.
  Ø       brbackup -p initDEV_online_stage.sap -t online -c -u / &
  
 Upon successful completion of the brbackup, the online backup of DEV is restored into the directories of SND system. Now, we need to transfer the archive log files from DEV to SND depending upon PITR requested (Point-in-Time recovery). Use sftp from DEV to SND and copy the required archive logs to /oracle/SND/oraarch. And rename them from DEV* to SND*.

Restore archive log files from tape
  Ø  If the required archive log files are copied to tape and are not available in oraarch then issue the following command.
  Ø  brrestore -a 9921-9929 -p initDEV_arch.sap


Enable archive log and online backup scripts on DEV server.

Control file creation
  Ø  Login to SND and rename the existing control files.
o    mv /oracle/SND/origlogA/cntrl/cntrlSND.dbf /oracle/SND/origlogA/cntrl/cntrlSND.dbf.old
o    mv /oracle/SND/saparch/cntrl/cntrlSND.dbf /oracle/SND/saparch/cntrl/cntrlSND.dbf.old
o    mv /oracle/SND/sapdata1/system_1/cntrl/cntrlSND.dbf /oracle/SND/sapdata1/system_1/cntrl/cntrlSND.dbf.old
  Ø  Login to DEV and create the control file trace
  Ø  alter database backup controlfile to trace; replace DEV with SND;
  Ø  CREATE CONTROLFILE SET DATABASE "SND" RESETLOGS NOARCHIVELOG
o    SQL> @controlSND.sql
o    ORACLE instance started.
o    Total System Global Area 2600468480 bytes
o    Fixed Size                  2086192 bytes
o    Variable Size            1308625616 bytes
o    Database Buffers         1275068416 bytes
o    Redo Buffers               14688256 bytes
o    Control file created.
Recovery Steps
  Ø  Now, the database is in mount state. Issue the following command to start the recovery.
  Ø  recover database using backup controlfile until time ‘2010-11-17:09:00:00’;
o    SQL> recover database using backup controlfile until time '2010-11-17:09:00:00';
o    ORA-00279: change 4326224613 generated at 11/17/2010 08:18:44 needed for thread 1
o    ORA-00289: suggestion : /oracle/SND/oraarch/SNDarch1_9930_721386457.dbf
o    ORA-00280: change 4326224613 for thread 1 is in sequence #9930
o    Specify log: {=suggested | filename | AUTO | CANCEL}
o    AUTO
o    Log applied.
o    Media recovery complete.
  Ø  Open the database using the following command.
o    alter database open resetlogs ;
o    lsnrctl start LISTENER_SND;
Post Recovery Steps
  Ø  Download and execute ORADBUSR.SQL (SAPNote: 50088 )with the following command
  Ø  sqlplus /nolog @ORADBUSR.SQL SAPR3E UNIX SND X
  Ø  Add the temp datafiles.
o    ALTER TABLESPACE PSAPTEMP ADD TEMPFILE '/oracle/SND/sapdata1/temp_1/temp.data1' SIZE 5000M REUSE AUTOEXTEND OFF;
o    ALTER TABLESPACE PSAPTEMP ADD TEMPFILE '/oracle/SND/sapdata3/temp_2/temp.data2' SIZE 5000M REUSE AUTOEXTEND OFF;
  Ø  Run the statistics
o    brconnect -u / -c -f stats -t oradict_stats
o    brconnect -u / -c -f stats -t system_stats
o    brconnect -c -u / -f stats -t all -f collect -p 4
  Ø  Enable the archive log for SND oracle database.

Ensure TSM backups are running fine and enable the archive log and online backup scripts.