Monday, September 23, 2013

Cloning EBS r12 Applications & DB 11gR2

The following are the steps I did while preparing a clone of Oracle E-Business Suite Release 12.1.3 application with Database 11.2.0.3 on Linux 5.7 OS.

STEP 1: Preparing the target server on which clone has to be created.

Following is the target server configuration,
OS= Oracle Enterprise Linux 5.7 Server
ServerName= ed-olsrvlin1

On this target server database software 11.2.0.3 is already installed. If the software is not installed then you can follow below article of mine to clone the database home itself by copying the database home from production server.

http://samiora.blogspot.ae/2012/10/cloning-oracle-database-home.html

Now source the environment,

[oracle@ed-olsrvlin1 ~]$ vi .bash_profile

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/u03/research/product/11.2.0/dbhome_1/bin
export PATH

[oracle@ed-olsrvlin1 ~]$ .  /u03/research/product/11.2.0/dbhome_1/research_ebsdlxsrv1.env

export ORACLE_SID=research;
export ORACLE_HOME=/u03/research/product/11.2.0/dbhome_1;

[oracle@ed-olsrvlin1 ~]$ . .bash_profile

[oracle@ed-olsrvlin1 ~]. /u01/research/product/11.2.0/dbhome_1/research_ed-olsrvlin1.env

export ORACLE_SID=research

STEP 2: Create initRESEARCH.ora file and add the below parameters,
[oracle@ed-olsrvlin1 dbs]$ vi initresearch.ora

*.sga_target=8589934592
*.aq_tm_processes=1
*.cluster_database=FALSE
*.compatible='11.2.0.3.0'
*.control_files='/u01/research/oradata/control01.ctl'
*.cursor_sharing='EXACT'
*.db_block_checking='FALSE'
*.db_block_checksum='TRUE'
*.db_block_size=8192
*.db_create_file_dest='/u01/research/oradata'
*.db_files=512# Max. no. of database files
*.db_name='research'
*.db_recovery_file_dest_size=40960m
*.db_recovery_file_dest='/u01/research/archives'
*.diagnostic_dest='/u01/research/product/11.2.0/dbhome_1/admin'
*.dml_locks=10000
*.instance_number=1
*.job_queue_processes=0
#*.log_archive_dest_1='LOCATION=/u01/research/archives'
*.log_archive_format='%t_%s_%r.arc'
#*.log_archive_start=TRUE
*.log_buffer=10485760
*.log_checkpoint_interval=100000
*.log_checkpoint_timeout=1200# Checkpoint at least every 20 mins.
*.log_checkpoints_to_alert=TRUE
*.max_dump_file_size='20480'# trace file size
*.nls_comp='binary'# Required 11i setting
*.nls_date_format='DD-MON-RR'
*.nls_length_semantics='BYTE'# Required 11i setting
*.nls_numeric_characters='.,'
*.nls_sort='binary'# Required 11i setting
*.nls_territory='america'
*.o7_dictionary_accessibility=FALSE
*.olap_page_pool_size=4194304
*.open_cursors=2000# Consumes process memory, unless using MTS.
*.optimizer_secure_view_merging=false
*.OS_AUTHENT_PREFIX=''
*.parallel_max_servers=8
*.parallel_min_servers=0
*.pga_aggregate_target=1G
*.plsql_code_type='INTERPRETED'# Default 11i setting
*.plsql_optimize_level=2# Required 11i setting
*.processes=5000# Max. no. of users x 2
*.sec_case_sensitive_logon=FALSE
*.session_cached_cursors=500
*.sessions=10000# 2 X processes
*.sga_target=8G
*.shared_pool_reserved_size=500M
*.shared_pool_size=2000M
*.SQL92_SECURITY=TRUE
undo_management='AUTO'# Required 11i setting
undo_tablespace='UNDOTS1'
*.utl_file_dir='/usr/tmp','/u01/research/product/11.2.0/dbhome_1/appsutil/outbound'
*.workarea_size_policy='AUTO'# Required 11i setting

STEP 3: Create password file,

[oracle@ed-olsrvlin1 dbs]$ orapwd file=pwdresearch.ora password=oracle entries=5

STEP 4: Add the below entry,

[oracle@ed-olsrvlin1 dbs]$ vi /etc/oratab
research:/u01/research/product/11.2.0/dbhome_1:N

STEP 5: Start preparing the database,

[oracle@ed-olsrvlin1 u01]$ echo $ORACLE_HOME
/u01/research/product/11.2.0/dbhome_1
[oracle@ed-olsrvlin1 u01]$ echo $ORACLE_SID
research

[oracle@ed-olsrvlin1 u01]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 11 16:42:09 2013
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> startup nomount;

[oracle@ed-olsrvlin1 u01]$ rman target /
RMAN> restore controlfile from '/u01/research/backup_dump/s_820506531.7639.820506533';
RMAN> alter database mount;
RMAN> catalog start with '/u01/research/backup_dump' noprompt;

SQL> select file#,name from v$datafile;

file# NAME
--------------------------------------------------------
1 +DATA1/research/datafile/system.697.818755525
2 +DATA1/research/datafile/system.699.818755511

SQL> select 'set newname for datafile ' || file# || ' to ' || '''' || '/u01/research/oradata' || ''';'  from v$datafile;

RMAN> RUN
{
set newname for datafile 1 to '/u01/research/oradata/system.697.818755525';
set newname for datafile 2 to '/u01/research/oradata/system.699.818755511';
restore database;
switch datafile all;
recover database;
}

Starting recover at 11-JUL-13
using channel ORA_DISK_1
starting media recovery
Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/research/oradata/system.697.818755525'
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/11/2013 17:52:40
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 2 with sequence 6203 and starting SCN of 8212807471834 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 6202 and starting SCN of 8212807421416 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 6162 and starting SCN of 8212807589317 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 6161 and starting SCN of 8212807516248 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 6160 and starting SCN of 8212807466762 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 6159 and starting SCN of 8212807415098 found to restore

STEP 6: Copy few archive files that are required from production. If you want to skip this step then you can initially take the backup of archive log along with the database backup.

asmcmd>

cp thread_1_seq_6159.7633.820505169 '/tmp/xxaarcs/thread_1_seq_6159.7633.820505169'
cp thread_1_seq_6160.7635.820505485 '/tmp/xxaarcs/thread_1_seq_6160.7635.820505485'
cp thread_1_seq_6161.7636.820505729 '/tmp/xxaarcs/thread_1_seq_6161.7636.820505729'
cp thread_2_seq_6234.7514.820528047 '/tmp/xxaarcs/thread_2_seq_6234.7514.820528047'

Now copy archives to the destination server where we are cloning and where the archive files are missing while doing the recovery,

[root@proddbsrv1 tmp]# scp * oracle@ed-olsrvlin1:/u01/research/archives/

STEP 7: Now on the target server, start the recovery,
RMAN> CATALOG START WITH '/u01/research/archives';
RMAN> RECOVER DATABASE;

RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/11/2013 20:57:50
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 6252 and starting SCN of 8212809557297

STEP 8: Once RMAN restore/recovery finishes, you will want to rename the online redolog files before opening the database in case the production path of redo log files is not available on the new host.
After renaming the redolog files, the database can be opened with RESETLOGS

SQL>  select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA1/research/onlinelog/group_1.671.818755739
+DATA1/research/onlinelog/group_2.670.818755739
+DATA1/research/onlinelog/group_3.669.818755739
+DATA1/research/onlinelog/group_4.668.818755739
+DATA1/research/onlinelog/group_5.667.818755739
+DATA1/research/onlinelog/group_6.676.818755743
+DATA1/research/onlinelog/group_7.675.818755743
+DATA1/research/onlinelog/group_8.674.818755743
+DATA1/research/onlinelog/group_9.673.818755743
+DATA1/research/onlinelog/group_10.672.818755743

alter database rename file '+DATA1/research/onlinelog/group_1.671.818755739' TO '/u01/research/onlinelog/group_1.671.818755739';
alter database rename file '+DATA1/research/onlinelog/group_2.670.818755739' TO '/u01/research/onlinelog/group_2.670.818755739';
alter database rename file '+DATA1/research/onlinelog/group_3.669.818755739' TO '/u01/research/onlinelog/group_3.669.818755739';
alter database rename file '+DATA1/research/onlinelog/group_4.668.818755739' TO '/u01/research/onlinelog/group_4.668.818755739';
alter database rename file '+DATA1/research/onlinelog/group_5.667.818755739' TO '/u01/research/onlinelog/group_5.667.818755739';
alter database rename file '+DATA1/research/onlinelog/group_6.676.818755743' TO '/u01/research/onlinelog/group_6.676.818755743';
alter database rename file '+DATA1/research/onlinelog/group_7.675.818755743' TO '/u01/research/onlinelog/group_7.675.818755743';
alter database rename file '+DATA1/research/onlinelog/group_8.674.818755743' TO '/u01/research/onlinelog/group_8.674.818755743';
alter database rename file '+DATA1/research/onlinelog/group_9.673.818755743' TO '/u01/research/onlinelog/group_9.673.818755743';
alter database rename file '+DATA1/research/onlinelog/group_10.672.818755743' TO '/u01/research/onlinelog/group_10.672.818755743';

SQL> select THREAD#, STATUS, ENABLED from v$thread;

   THREAD# STATUS ENABLED
---------- ------ --------
         1 OPEN   PUBLIC
         2 CLOSED PUBLIC

SQL> select group# from v$log where THREAD#=2;

    GROUP#
----------
         6
         7
         8
         9
        10

SQL> alter database disable thread 2;

SQL> alter database drop logfile group 6;
alter database drop logfile group 6
*
ERROR at line 1:
ORA-00350: log 6 of instance research2 (thread 2) needs to be archived
ORA-00312: online log 6 thread 2: '/u01/research/onlineloggroup_6.676.818755743'

sql>alter database clear unarchived logfile group 6;

sql> alter database drop logfile group 6;
SQL>  alter database drop logfile group 7;
SQL> alter database drop logfile group 8;
SQL> alter database drop logfile group 9;
SQL> alter database drop logfile group 10;

SQL> select THREAD#, STATUS, ENABLED from v$thread;

   THREAD# STATUS ENABLED
---------- ------ --------
         1 OPEN   PUBLIC

STEP 9: Now you can remove the undo tablespaces of other instances and create a new temporary tablespace to complete the activity.

SQL> show parameter undo

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      UNDOTS1

SQL> select tablespace_name from dba_tablespaces where contents='UNDO';

TABLESPACE_NAME
------------------------------
UNDOTS1
UNDOTBS2

SQL>  drop tablespace UNDOTBS2 including contents and datafiles;

SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/research/oradata/research/datafile/o1_mf_temp_8xxsm1bt_.tmp
/u01/research/oradata/research/datafile/o1_mf_temp_8xxsm19v_.tmp
/u01/research/oradata/research/datafile/o1_mf_temp_8xxsm18d_.tmp
/u01/research/oradata/research/datafile/o1_mf_temp_8xxsm179_.tmp
/u01/research/oradata/research/datafile/o1_mf_temp_8xxsm15x_.tmp

SQL> select tablespace_name from dba_tablespaces where contents='TEMPORARY';
TABLESPACE_NAME
------------------------------
TEMP

SQL> create temporary tablespace TEMP1 tempfile '/u01/research/oradata/temp01.dbf' size 4096m;

SQL> alter database default temporary tablespace TEMP1;

SQL> ALTER TABLESPACE TEMP1 ADD TEMPFILE '/u01/research/oradata/temp02.dbf' size 4096m;

SQL> ALTER TABLESPACE TEMP1 ADD TEMPFILE '/u01/research/oradata/temp03.dbf' size 4096m;

SQL> drop tablespace temp including contents and datafiles;

STEP 10: So till here the database is configured successfully. You can once shutdown and startup the
database. Now clear the production node entries from this new cloned database. So connect as APPS database user and execute,

conn apps/appspassword
select node_name from fnd_nodes;
select host_name from v$instance;
execute fnd_conc_clone.setup_clean;
commit;

@/tmp/cmclean.sql
commit;

STEP 11: Disable database archiving.

conn / as sysdba
shutdown immediate;
startup mount;
alter database noarchivelog;
alter database open;
archive log list;

STEP 12: Now fix the LISTENER.ORA, TNSNAMES.ORA files in /u01/research/product/11.2.0/dbhome_1/network/admin/research_ed-olsrvlin1 directory.

export TNS_ADMIN=/u01/research/product/11.2.0/dbhome_1/network/admin/research_ed-olsrvlin1

Then bounce the listener.

lsnrctl stop research
lsnrctl start research

[oracle@ed-olsrvlin1 admin]$ cd /u01/research/product/11.2.0/dbhome_1/appsutil/bin/

STEP 13: Now create the database context file,

[oracle@ed-olsrvlin1 bin]$ which perl
/usr/bin/perl
[oracle@ed-olsrvlin1 bin]$ perl adbldxml.pl

Starting context file generation for db tier..
Using JVM from /u01/research/product/11.2.0/dbhome_1/jdk/jre/bin/java to execute java programs..
APPS Password: appspassword
The log file for this adbldxml session is located at:
/u01/research/product/11.2.0/dbhome_1/appsutil/log/adbldxml_07032128.log
AC-20010: Error: File - listener.ora could not be found at the location:
        /listener.ora
indicated by TNS_ADMIN. Context file can not be generated.
Could not Connect to the Database with the above parameters, Please answer the Questions below

Enter Hostname of Database server: ed-olsrvlin1
Enter Port of Database server: 1526
Enter SID of Database server: research
Enter the value for Display Variable: 1
The context file has been created at:
/u01/research/product/11.2.0/dbhome_1/appsutil/research_ed-olsrvlin1.xml

STEP 14: Now run AUTOCONFIG on database server.

[oracle@ed-olsrvlin1 bin]$ ./adconfig.sh

Enter the full path to the Context file: /u01/research/product/11.2.0/dbhome_1/appsutil/research_ed-olsrvlin1.xml

STEP 15: Once all above steps are executed successfully, then start cloning the application tier,
On APPLICATION TIER Server ed-olsrvlin1
COPY ALL THE APPLICATION FILES FROM PRODUCTION TO ed-olsrvlin1 SERVER.
FROM PRODUCTION APPLICATION SERVER RUN THE BELOW COPY COMMAND

[root@prodappsrv1 research] pwd
/u01/research

[root@prodappsrv1 research] scp -r * applmgr@ed-olsrvlin1:/u02/research/

STEP 16: Once the application files are copied then with 'root' user, change the ownership of all the folders,

[root@ed-olsrvlin1 u02]# chown -R applmgr:dba research/

[applmgr@ed-olsrvlin1 bin]
export PATH=/u02/research/apps/tech_st/10.1.3/perl/bin:$PATH
export PERLBIN=/u02/research/apps/tech_st/10.1.3/perl/bin
export PERL5LIB=/u02/research/apps/tech_st/10.1.3/perl/lib/5.8.3:/u02/research/apps/tech_st/10.1.3/perl/lib/site_perl/5.8.3:/u02/research/apps/apps_st/appl/au/12.0.0/perl:/u02/research/apps/tech_st/10.1.3/Apache/Apache/mod_perl/lib/site_perl/5.8.3/i686-linux-thread-multi

STEP 17: Now run the config clone and complete the cloning procedure.

[applmgr@ed-olsrvlin1 bin]cd /u02/research/apps/apps_st/comn/clone/bin
[applmgr@ed-olsrvlin1 bin] ./adcfgclone.pl appsTier

Here complete all the prompts that appears, like
basepath=/u01/research
display to null: n
display=ebsdxlsrv1:0.0

These steps will help you prepare a cloned instance of both database and application tier for Oracle E-Business Suite Release 12 R12.1.3.

For any queries or assistance please email me on samiappsdba@gmail.com.