Wednesday 26 October 2011

System Copy In SAp


SYSTEM COPY / SYSTEM REFRESH
(Using offline backup restore method)


Steps for System Copy:

v Steps for a Homogeneous system copy are briefly as below:
• Preparations on Target System.
• Restore Online/Offline Backup of Source System onto Target System.
• Create CONTROLFILE creation script on Source System.
• Modification of CONTROLFILE script and creation of CONTROLFILEs of Target                    
    system.
• Recovery of Oracle Database on Target System.
• Completion of System Copy
• Adjusting existing SAP Instance with restored oracle database.
• Post Activities.

Prerequisites:

v Following conditions must be satisfied to copy a system:
• Both Source and Target Systems must have Same Operating System
   and Database System.
• SAP kernel and Oracle Database Patch levels must be same.
• You have sufficient free space for /oracle/<SID>/sapdata<n>
   directories on target system.
• Use most current database backup in order to create almost identical
   system.

Procedure:

v Data and Log directories on target system must be cleaned before
restoring source database. Here below are the commands to clean
directories. Before doing this, you have to stop all SAP and Oracle
processes.
# su - <targetsid>adm
# stopsap all
# exit
# su – ora<targetsid>
# lsnrctl stop
# exit
# cd /oracle/<SID>/
# rm –rf sapdata?/*
# rm –rf origlog?/*
# rm –rf mirrlog?
# rm –rf sapreorg/*
# rm –rf saparch/*
# rm –rf saptrace/usertrace/*
# rm –rf saptrace/background/*
# rm –rf sapbackup/*
# rm –rf sapcheck/*

v You may need to resize the following file systems before restore process.
For this, take into account sizes of source system.
/oracle/<SID>/sapdata1
/oracle/<SID>/sapdata2
/oracle/<SID>/sapdata3
/oracle/<SID>/sapdata4
/oracle/<SID>/sapdata5
/oracle/<SID>/sapdata6
/oracle/<SID>/saparch

v After cleaning necessary file systems/directories, you have to restore most
current database backup to target system. (Refer

v After restoring datafiles and redolog files, a script must be prepared on
source system to create CONTROLFILE of target system.
We can use SQLPLUS to generate a script to create controlfile using the
current controlfile content. To do this, login to source system as ora<sid>
user and execute the following commands. Make sure that database is in
at least MOUNT state.
#sqlplus / as sysdba
#SQL>alter database backup controlfile to trace as ‘/path/for/control.sql’;
#SQL>exit;
#
As a result of the above command, a trace file named “control.sql” will be
generated to the location given in the command.
After this, copy control.sql and init<SID>.ora
(/oracle/<SSID>/102_64/dbs) to target system. Once these files are
copied on target system,
you have to edit these files to be able to use for CONTROLFILE creation on target system.

• Open CONTROL.SQL file to edit using VI editor.
• Remove all lines before “STARTUP MOUNT” line. Delete all
   Commented “#” or “---“ lines.
• Remove all lines after “CHARACTER SET WE8DEC;”.
• Change all source SID to target SID via following VI command.
• :%s/<SSID>/<TSID>/g
• Change the line “CREATE CONTROLFILE REUSE DATABASE <SSID>
    NORESETLOGS ARCHIVELOG;” as “CREATE CONTROLFILE
    RESUE SET DATABASE <TSID> RESETLOGS ARCHIVELOG;”.
• If you want to change datafile or redolog file destinations, first
   move the files on target destination at OS level, then edit
    CONTROL.SQL file for new destination.
• Rename oraHRP.ora to oraHRQ.ora and copy it to
    “/oracle/<SID>/102_64/dbs”.
• Open init<SID>.ora in VI editor and Change all source SID to
    target SID via following VI command,
    :%s/<SSID>/<TSIDD>/g

v After CONTROL.SQL script preparation, following command must be run to
create CONTROLFILE of target system.
#su – ora<sid>
#sqlplus / as sysdba
#SQL>@/path/to/CONTROL.SQL;
#SQL>statement processed.

(Above script must be executed without any errors… In case of any error, correct it
and re-run the script.)

Once the script execution is successful, try to open the database as below.
#SQL>alter database open resetlogs;
database opened.

In recovery of database using ONLINE backup, alter database command
may report error that you “must user RESETLOGS or NORESETLOGS
option for database open”. In that case you need to perform media
recovery for one or more files. To do this, use below command.
#SQL>recover database using backup controlfile until cancel;

Then provide the required files and continue recovery. Once recovery is
completed, open the database as below.
#SQL>alter database open resetlogs;
database opened.




v Once the database is opened, LISTENER process must be started.
#su – ora<sid>
#lsnrctl start

v To open the SAP system, use the following commands.
#su – <sid>adm
#startsap

Troubleshooting SAP startup after System Copy.

v To check the communication, perform the test as below.
#R3trans –d
This is R3trans version 6.14 (release 700 - 05.03.09 -
08:28:00).
unicode enabled version
R3trans finished (0000).

It should display the message similar as above. If you get “R3trans
finished (0012)”, means there is a problem in SAP and Database
communication. To resolve this issue, open and analyze the “trans.log” file,
which is available at the same location where you execute “R3trans –d”
command.

v To see the current DBA users. You may find old <SID>adm user in the
query result.

SQL> SELECT USERNAME,PASSWORD FROM DBA_USERS;

v If you find old <SID>adm user, drop it using the below command.

SQL> DROP USER OPS$<SID>ADM CASCADE;
SQL> COMMIT;

v Then create new OPS$ user as per current <SID>adm user and assign
default tablespaces. Grant privileges to the newly created user.

SQL> CREATE USER OPS$<SID>ADM IDENTIFIED BY <NEW_PASSWORD>
DEFAULT TABLESPACE PSAPUSER1D
TEMPORARY TABLESPACE PSAPTEMP
PROFILE DEFAULT;



SQL> GRANT CONNECT, RESOURCE TO OPS$<SID>ADM;
# Check if OPS$<SID>ADM.SAPUSER table is exist. You can also drop this
table as below.

SQL> DROP TABLE OPS$<SID>ADM.SAPUSER;
SQL> COMMIT;

v Recreate the above table manually.

SQL> CREATE TABLE OPS$<SID>ADM.SAPUSER
(USERID VARCHAR2(256), PASSWD VARCHAR2(256));

v Insert the SAPSR3 user and password in above table.

SQL> INSERT INTO OPS$<SID>ADM.SAPUSER VALUES ('SAPR3', 'NEW_PASSWORD');

v Change the SAPSR3 users password.

SQL> ALTER USER SAPR3 IDENTIFIED BY <NEW_PASSWORD>;

v Check if the above table is properly created and has the entry for
SAPSR3 user.

SQL> SELECT USERID,PASSWD FROM SAPUSER;

v Now run the communication test once again as below and see if it returns
error code “0000”.

#R3trans –d
This is R3trans version 6.14 (release 700 - 05.03.09 -
08:28:00).
unicode enabled version
R3trans finished (0000).

v Now open the SAP system, use the following commands.

#su – <sid>adm
#startsap





Post installation activities.

v Re-installing SAP License.
If you restored backup on another system, your SAP license likely get
invalid and will prevent you from logging on to the system. In this case
you must install a valid license in order to continue using new system.
Only “SAP*” user is allowed to login even if the license is invalid. Here are
the steps to login using “SAP*” and install the license.

a) Edit and check the below parameter in Instance Profile at OS level
(using VI editor). If it is missing, just create it as below:
login/no_automatic_user_sapstar = 0
b) Restart SAP and Login to the Client 000 as SAP* and Master Password
or source system.
c) Run “slicense” t-code.
d) Click on “New license” and then “Install” button.
e) Browse the license file, downloaded from the Service Market Place and
select “Open”.
f) Your new license is installed. It should show in GREEN color.
g) Now you can login with any user available in the system.
2) Post installation processing:
a) Run “SICK” or “SM28” to check for any errors.
b) Run “SE06” T-code and select “Database Copy or Database
Migration”.
c) Execute “Perform Post Installation Action” button.
d) Change all Source System Objects to Target System Objects as asked.

v Re-configure TMS for new system:

a) Run “STMS” T-code to re-configure TSM.
b) Delete Old TMS configuration.
c) Login to the client 000 on Transport Domain Controller using superuser.
d) Go to Transport Routes _ Configuration _ Adjust Transport Routes.
e) Go to Systems and “Update TMS configuration”.
f) Go to Extras _ Distribute and Activate Configuration (to all systems).
g) TMS is reconfigured on target system.

v Re-schedule backup jobs:

You may also need to reschedule backup jobs in DB13 transaction. Once
this is complete you can run “Check Database”, “Check and Optimize
Database Statistics” and “Verify Structure”.

v Other Miscellaneous changes:

a) Change Client setting in “SCC4” as the previous client was production
and may be protected.
b) Import and activate Profiles of Active Server (T-code: RZ10)
c) Delete all entries from table TLOCK which holds the repair requests
from your source system.
d) Check and Adjust RFC connections as required in “SM59”.
e) Configure Print Device in “SPAD”.
f) Check SAP server status in “SM51”

After all of the above steps, you have completed a System Copy using Offline
Database Backup.


v Problem Faced During Activity :-

1.      When we were restoring backup, it was found that one of the datafile was added after backup, so it was showing error while opening database.
For that, we created a dummy datafile and added it to the database and opened it.
But on the next day we faced so many problems while updating or executing some tcodes,

Corrective Action :-

Fresh backup of production system taken and the above activity performed again successfully.

Preventive Action :-

Datafile should always be added before weekly backup.


No comments:

Post a Comment