Thursday, December 29, 2011

OTM 6.2 Cloning


In this post I am going to discuss how to do a OTM cloning (App server, Web Server and Database).I will be using 2 tier architecture for source and for target. 2 Tier = 1 server for DB and 1 server for APP and WEB server. This clone will not have the cluster and will not be changing the source passwords to target (That is easy and documented in many places Docs and in the web). User discretion is highly advised as I will be breaking all Oracle Rules here and Oracle will not be happy about this. Please note that this exercise will be done on Linux x86-64 machine. All the commands and path will be according to this.


Following are the references I will be using throughout this document:


WEB and APP Server( otmapp source):


GLOG_HOME=/u01/otmapp/otm62
WL_HOME=/u01/otmapp/Middleware/wlserver_10.3
ORACLE_HOME=/u01/otmapp/11.2.0
JAVA_HOME=/u01/otmapp/jdk1629
JRE_HOME=$JAVA_HOME/jre
BEA_HOME=/u01/otmapp/Middleware




WEB and APP Server( app1 target):


GLOG_HOME=/d01/otmapp/otm62
WL_HOME=/d01/otmapp/Middleware/wlserver_10.3
ORACLE_HOME=/d01/otmapp/11.2.0
JAVA_HOME=/d01/otmapp/jdk1629
JRE_HOME=$JAVA_HOME/jre
BEA_HOME=/d01/otmapp/Middleware




DB Server(dbserver for source and db-1 for target):


ORACLE_HOME=/u01/oracle/11.2.0
ORACLE_SID=otmt




Lets begin:


Steps:


A- DB Server:


1- go to the source "dbserver" and tar the oracle home as

cd $ORACLE_HOME/../
tar cvf otmdbhome.tar 11.2.0
gzip otmdbhome.tar


2- While on dbserver  run a full cold backup as rman


RMAN> backup as compressed backupset full database;
RMAN> backup as compressed backupset archivelog all;


3- Now copy the files from step1 and 2 to db-1 target server.


4- First  deflate the oracle home in selected directory on db-1 as:


cd /u01/oracle
zcat /tmp/otmdbhome.tar.gz |tar xvf -


5- Now set the ORACLE_HOME and cd $ORACLE_HOME/oui/bin and run the following command.


./runInstaller -clone -silent ORACLE_BASE=/u01/oracle ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME="OTMTST_11gR2"


(Please note that you should have some short of Xwindows server running - I had xvfb running on this machine before executing the above command)


Once above is done the run the root.sh from $ORACLE_HOME


6- Now set the ORACLE_SID as it was in the source DB, for example


export ORACLE_SID=OTMPRD


now run the restore as


  a- sqlplus  and startup nomount
  b- exit from sqlplu
  c- run rman as:
   RMAN> restore controlfile from '/tmp/rmanbup/c-*****';   -- please note that this is the c file from the backup - you can also use the snapshot file to do this.
  RMAN> alter database mount;
  RMAN> catalog backuppiece '/tmp/rmanbup/OTMPRD_20111129_610_1' -- You need to catalog all the backup pieces here what I did is I made the cat.rman for cataloging all the pieces (including the archive log backup pieces)
  RMAN>@res.rman     -- here what I am doing is to restoing the original DB to different location than it was there in the dbserver. You can simply have the same path as in the dbserver and in that case you need to just type following command as:


restore database;
recover database;
alter database open resetlogs;


However my script looks like :


run{
set newname for datafile '<source path>/MSG_LOB_TBS101.dbf' to '<target path>/MSG_LOB_TBS101.dbf';
.....
...  rest of the file
restore database;
switch datafile all;
recover database;
alter databse open resetlogs;
}


d- since DB is restored but it is samea s in the dbserver - so let change the name to what we need.


     cd $ORACLE_HOME/dbs
     cp initOTMPRD>ora  initOTMT.ora
     replace all the reference in nthe initOTMT.ora  from old to new
      now  run "nid target=/  DBNAME=OTMT"
      This will change the DB NAME to OTMT
      now set the ORACLE_SID=OTMT and start the db in mount stage and then "alter database open resetlogs";
   
7- Now we need to fix one table for application- login as glogowner and run following statement.


SQL> update I_TRANSMISSION set SENDER_HOST_NAME=replace(SENDER_HOST_NAME,'http://otmapp.domain.com','http://app1.domain.com');


commit;


If you have a server with domain name then put domain after the server in abover SQL.




--- The DB portion is done.


Please note that you can alsod achieve this by RMAN DUPLICATE command from either source or target. Personal choices !!






B- APP and WEB Server:


1- login to source otnapp server and make a copy  ORACLE_HOME, GLOG_HOME, WL_HOME,  JAVA_HOME. For me it was easy as all of them were located in /u01/otmapp directory, so I did this on otmapp server.


cd /u01/otmapp
tar cvf otm-all.tar jdk1629 Middleware otm62 11.2.0
gzip otm-all.tar




2- Now copy the above file to app1 server and deflate them as:


cd  /d01/otmapp


zcat /tmp/otm-all.tar.gz|tar xvf -


Once this is done - let make some changes


set the GLOG_HOME,WL_HOME,JAVA_HOME and ORACLE_HOME. Please note that this ORACLE_HOME is used as client that will have tnsnames.ora that points to OTMT DB.


3- cd $GLOG_HOME/glog/config and edit the glog.properties  as  described below:


gc3.dir=
appserver=
appserver.port=
webserver=
glog.webserver.URL=<filel in the server name>:80$glog.webserver.urlprefix$
dbserver=
glog.database.sid=otmt
glog.database.connectstring=otmt
glog.database.port=1528
appserver.port.webservice.weblogic=
glog.scalability.thisTarget=gc3-app1
glog.mail.smtp.host=
glog.workflow.notify.defaultSmtphost=
glog.workflow.notify.advisor.name=
glog.workflow.notify.advisor.email=
glog.workflow.notify.advisor.fax=
glog.workflow.notify.faxmaker.email=




If you have ROD then:


glog.database.ods.sid
glog.ods.connectstring
glog.ods.database.port
glog.database.ods.schema




If you have FTI then:


aa_webserver=
glog.database.FTI.t2client.driverClassName=oracle.jdbc.driver.OracleDriver




Mile Maker then:


milemaker.host=
milemaker.port=


KWILL then:


glog.RatingEngine.Kewill.URL=
glog.RatingEngine.Kewill.port=
glog.RatingEngine.Kewill.RefnumQual=






Maps then:


intelliroute.host=
intelliroute.port=
intelliroute.user=
intelliroute.password=
intelliroute.location=




4-  cd $GLOG_HOME/apache/bin and edit apachectl,apr-config, apxs,envvars, rotatelogs.sh  for the new paths.


5- cd $GLOG_HOME/apache/conf and edit httpd.conf and workers.properties  -- httpd for path and Listen (its an IP address and username )


6- cd $GLOG_HOME/tomcat/bin and edit tomcat.conf and tomcat.sh for GLOG_HOME, ORACLE_HOME  and launcher.host


7- cd $GLOG_HOME/tomcat/conf and server.xml for following:


 <Engine name="Catalina" defaultHost="gc3-app1">


 <Host name="gc3-app1" appBase="webapps" unpackWARs="true" autoDeploy="true"


 <Context path="/GC3" docBase="/d01/otmapp/otm62/glog/gc3webapp" privileged="true" cookies="true" workDir="work/GC3">


<Context path="/xsql" docBase="/d01/otmapp/otm62/apache/htdocs/xsql" privileged="true" workDir="work/xsql"> 


8- cd $GLOG_HOME/weblogic and edit weblogic.conf and weblogic.sh file for HOME PATHS.(ORACLE_HOME,WL_HOME.GLOG_HOME and -Dbea.home which is /d01/otmapp/Middleware)


9- cd $GLOG_HOME/weblogic/domains/otm/config and edit config.xml  and config.xml.fresh -- there  is IP address as well for the application server so look for that  apart from domain and path. Also look for gc3-<hostname without domain name>, which I changed to gc3-app1.


10- cd $GLOG_HOME/weblogic/domains/otm/config/jdbc and PRIMARY_JTS-8636-jdbc.xml  for DB connection


11- cd $GLOG_HOME/weblogic/domains/otm/servers and run " rm -fr gc3-*"


12- cd $GLOG_HOME/weblogic/domains/otm/servers/domain_bak/config_prev and edit the config.xml  for path and  app name as gc3-. It is gc3-app1 for me.


13- cd $GLOG_HOME/../Middleware -- this will take in my environment to /d01/otmapp/Middleware Or if you have set BEA_HOME then this is what it would be 
  edit registry.xml file here for path and name of the server.


14- cd $BEA_HOME/coherence_3.5/inventory/ContentsXML and edit comps.xml for path 


15- cd $BEA_HOME/coherence_3.5/uninstall and edit ocp_uninstall.xml   -- not required but to just keep things tidy


16-  cd $BEA_HOME/utils/bsu and edit bsu.sh for javahome


17-  cd $BEA_HOME/utils/ccr and edit domainlocation.properties


18- cd $BEA_HOME/utils/ccr /bin and edit unregister.sh


19- cd $BEA_HOME/utils/config/10.3 and edit setHomeDirs.sh file.


20 - cd $BEA_HOME/utils/uninstall and edit uninstall.sh


21- cd $BEA_HOME/utils/uninstall/extftr and edit uninstall.xml


22- cd $BEA_HOME/utils/uninstall/WebLogic_Platform_10.3.3.0 and edit  uninstall.xml


23- cd $BEA_HOME/utils/quickstart and edit quickstart.sh


24- cd $WL_HOME/inventory/ContentsXML and edit comps.xml for path.


25- $WL_HOME/common/bin  and edit config.sh, commEnv.sh start* , pack.sh,wlst.sh wlscontrol.sh unpack.sh stop* 


26- $WL_HOME/common/derby  and edit README.txt - not required but for not to have any previous references.


27- $WL_HOME/common/quickstart  and edit quickstart.sh  and wls_qsConfig.xml


28- $WL_HOME/server/bin  and edit setWLSEnv.sh and startNodeManager.sh


29- $WL_HOME/uninstall amd edit wls_uninstall.xml and  uninstall.sh


30- Now we need to go to the ORACLE_HOME and clone it. This is the client ORACLE_HOME - for me it is /d01/otmapp/11.2.0 - so


  cd /d01/otmapp/11.2.0/oui/bin
./runInstaller -clone -silent ORACLE_BASE=/d01/otmapp ORACLE_HOME=/d01/otmapp/11.2.0 ORACLE_HOME_NAME="11gR2_Client_Home"


once finished - run root.sh  and fix the tnsnames.ora in $ORACLE_HOME/network/admin  and test the connection to OTMT DB on db-1 server.




The cloning is done here. However, Please note that all the username and password will remain the same - one can choose to change them by using the oracle provided scripts in $GLOG_HOME/glog/oracle/script8.


31- This is the last step - Now copy  from /etc/init.d directory of the otmapp server to app1 server's /etc/init.d and edit them to change the HOMES. You will require root access to do that. Once done, start the otm and have a smiley face.


Hope this Helps...