Sunday, December 12, 2010

Scripting your Oracle SOA 11g Cluster

Did you ever tried to create your own WLST script to create a SOA 11g clustered domain? I did :-) By default the SOA 11g comes out with his own template. The bad thing about this template, it contains a predefined managed server and local machine and all the targetted objects (libraries, applications, JDBC, JMS, startup and shutdown classess.

It took me some time to find out what I need to create a clusted domain, based on my own specification. I wanna share you the information that is needed to create a SOA domain with the correct targets.

Before you begin you have to do some things. I expect you use the out-of-the-box SOA 11g template to create your domain. This will result in a domain, that contains all the applications, libraries, etc. But it also contains a managed server named 'soa_server1' and an machine 'LocalMachine'. These object will not have your settings regarding to logging, naming-convention, memory and many other settings. They are not usefull. 

If you remove these objects, you loose the SOA 11g configuration, the targetted libraries/application/classes/jdbc and JMS.

For JMS it is even worse, the default configuration is based on a non-clustered setup. Therefore you need to run a seperate script to migrate these JMS configuration to a clustered aware configuration.
If you do not use the GUI interface, but you only wanna use WLST scripting, this is my approach:
  • Create a SOA domain based on the default templates.
  • Start the Administration Server.
  • Execute the next script.
  • Perform the 'soa-createUDD.py' to create the JMS Cluster:
  • $WLS_SERVER/common/bin/wlst.sh $ORACLE_HOME/bin/soa-createUDD.py --domain_home /data/user_projects/domains/MyDomain --soacluster My-Cluster --create_jms true
  • Apply the Java Object Caching script, configure-joc.py
  • Pack and Unpack the domain configuration to the other server
  • Start the Managed Servers.

Happy SOA-ing :-)

targetClusters=['My-Cluster']

targetLibraries=[
  'adf.oracle.domain#1.0@11.1.1.2.0'
, 'adf.oracle.domain.webapp#1.0@11.1.1.2.0'
, 'jsf#1.2@1.2.9.0'
, 'jstl#1.2@1.2.0.1'
, 'ohw-rcf#5@5.0'
, 'ohw-uix#5@5.0'
, 'UIX#11@11.1.1.1.0'
, 'oracle.adf.dconfigbeans#1.0@11.1.1.2.0'
, 'oracle.adf.management#1.0@11.1.1.2.0'
, 'oracle.dconfig-infra#11@11.1.1.1.0'
, 'oracle.jrf.system.filter'
, 'oracle.jsp.next#11.1.1@11.1.1'
, 'oracle.pwdgen#11.1.1@11.1.1.2.0'
, 'oracle.rules#11.1.1@11.1.1'
, 'oracle.sdp.client#11.1.1@11.1.1'
, 'oracle.sdp.messaging#11.1.1@11.1.1'
, 'oracle.soa.b2b#11.1.1@11.1.1'
, 'oracle.soa.bpel#11.1.1@11.1.1'
, 'oracle.soa.composer.webapp#11.1.1@11.1.1'
, 'oracle.soa.ext#11.1.1@11.1.1'
, 'oracle.soa.mediator#11.1.1@11.1.1'
, 'oracle.soa.rules_dict_dc.webapp#11.1.1@11.1.1'
, 'oracle.soa.rules_editor_dc.webapp#11.1.1@11.1.1'
, 'oracle.soa.workflow#11.1.1@11.1.1'
, 'oracle.soa.workflow.wc#11.1.1@11.1.1'
, 'oracle.soa.worklist#11.1.1@11.1.1'
, 'oracle.soa.worklist.webapp#11.1.1@11.1.1'
, 'oracle.wsm.seedpolicies#11.1.1@11.1.1'
, 'orai18n-adf#11@11.1.1.1.0'
]

targetApplications=[
  'AqAdapter'
, 'DbAdapter'
, 'DefaultToDoTaskFlow'
, 'FileAdapter'
, 'FtpAdapter'
, 'JmsAdapter'
, 'MQSeriesAdapter'
, 'OracleAppsAdapter'
, 'OracleBamAdapter'
, 'SocketAdapter'
, 'b2bui'
, 'composer'
, 'soa-infra'
, 'usermessagingdriver-email'
, 'usermessagingserver'
, 'worklistapp'
, 'wsil-wls'
, 'wsm-pm'
, 'DMS Application#11.1.1.1'
]

targetJDBC=[
  'EDNDataSource'
, 'EDNLocalTxDataSource'
, 'mds-owsm'
, 'mds-soa'
, 'OraSDPMDataSource'
, 'SOADataSource'
, 'SOALocalTxDataSource'
]

targetShutdownClass=[
  'JOC-Shutdown'
, 'DMSShutdown'
]

targetStartupClass=[
  'JPS Startup Class'
, 'JRF Startup Class'
, 'ODL-Startup'
, 'Audit Loader Startup Class'
, 'AWT Application Context Startup Class'
, 'JMX Framework Startup Class'
, 'JOC-Startup'
, 'DMS-Startup'
, 'OWSM Startup class'
, 'SOAStartupClass'
]

targetWorkManagers=[
  'wm/SOAWorkManager'
]

targetSystemResources=[
  'Module-FMWDFW'
]

undeployApps=['FMW Welcome Page Application#11.1.0.0.0']

def connectToAdminsServer():
  connect('weblogic', 'welcome1', 't3://node1.vijfhuizen.com:7001')

def undeployApplications(listofobjects):
  cd ('/AppDeployments')

  listofcurrentobjects = ls(returnMap='true')
  for o in listofcurrentobjects:
    targetit = false
    for i in listofobjects:
      if i == o:
        targetit = true
    if targetit == true:
      print 'Undeploy -> ' + o
      undeploy(o)

def setNewTarget(newtarget, newobject, listofobjects):
  cd('/Clusters/' + newtarget)
  cl_target = cmo
  cd(newobject)
  listofcurrentobjects = ls(returnMap='true')
  for o in listofcurrentobjects:
    targetit = false
    cd(o)
    curobject = cmo
    curobjectname = cmo.name
    for i in listofobjects:
      if i == curobjectname:
        targetit = true
    if targetit == true:
      print curobjectname + ' -> ' + cl_target.name
      curobject.addTarget(cl_target)
    
    cd('..')

def destroyOOTBComponents():
  print "@@@ Remove dummy soa_server @@@"
  cd('/Servers/soa_server1')
  cmo.setCluster(None)
  cmo.setMachine(None)
  cd('/')
  editService.getConfigurationManager().removeReferencesToBean(getMBean('/Servers/soa_server1'))
  cmo.destroyServer(getMBean('/Servers/soa_server1'))

  print "@@@ Remove dummy machine @@@"
  editService.getConfigurationManager().removeReferencesToBean(getMBean('/Machines/LocalMachine'))
  cmo.destroyMachine(getMBean('/Machines/LocalMachine'))

  print "@@@ Remove JMS Stuff @@@"

  cmo.destroyJMSSystemResource(getMBean('/SystemResources/SOAJMSModule'))
  cmo.destroyJMSSystemResource(getMBean('/SystemResources/UMSJMSSystemResource'))
  cmo.destroyJMSServer(getMBean('/Deployments/SOAJMSServer'))
  cmo.destroyJMSServer(getMBean('/Deployments/UMSJMSServer'))
  cmo.destroyFileStore(getMBean('/FileStores/SOAJMSFileStore'))
  cmo.destroyFileStore(getMBean('/FileStores/UMSJMSFileStore'))

# 
# It starts all here
#

mycluster = 'My-Cluster'
connectToAdminsServer()
edit()
startEdit()

destroyOOTBComponents()

for lCluster in targetClusters:
  print "@@@ Remove uneeded applications @@@"
  undeployApplications(undeployApps)
  print "@@@ Retarget @@@"
  setNewTarget(mycluster, '/Libraries', targetLibraries)
  setNewTarget(mycluster, '/AppDeployments', targetApplications)
  setNewTarget(mycluster, '/JDBCSystemResources', targetJDBC)
  setNewTarget(mycluster, '/StartupClasses', targetStartupClass)
  setNewTarget(mycluster, '/ShutdownClasses', targetShutdownClass)
  setNewTarget(mycluster, '/SelfTuning/KIMPTC/WorkManagers', targetWorkManagers)
  setNewTarget(mycluster, '/SystemResources', targetSystemResources)

save()
activate()

The Linux script to call all the post actions.

#!/bin/bash

#
# Post SOA Configuration
#
$WLS_SERVER/common/bin/wlst.sh postsoa.py

#
# Recreate SOA JMS Queues
#
$WLS_SERVER/common/bin/wlst.sh $ORACLE_HOME/bin/soa-createUDD.py --domain_home /data/user_projects/domains/MYDOMAIN --soacluster My-Cluster --create_jms true

#
# Create Java Object Cache (Changes hostnames/ports!)
# Using inline input (note the empty lines!)
#
$ORACLE_HOME/common/bin/wlst.sh <<!EOF
connect('weblogic', 'welcome1', 't3://node1.vijfhuizen.com:7001')
execfile('/opt/weblogic/Middleware/oracle_common/bin/configure-joc.py')
node1.vijfhuizen.com,node2.vijfhuizen.com

KIMPTC-Cluster
9991


exit()
EOF

Post a Comment