Tuesday, January 12, 2016

SOA 12.2.1 Clustered Domain Using WLST Script

Hey!

Namaste from Oracle Fusion Middleware world!! In this post, I would like to share the experiment on the SOA domain using WLST for a high availability imposed Clustered Domain.

Prerequisites for SOA cluster domain configuration



  1. Oracle Fusion Middleware Infrastructure
  2. Oracle SOA 12.2.1 Installation
  3. Oracle OSB 12.2.1 Installation

Clustered SOA Domain using WLST preparation

High availability can be achived when we configured multiple WebLgoic managed servers and they are part of a cluster. Here in this case 'soa_server1', 'soa_server2' are configured into the 'soa_cluster'.

Step 1: Create the below soa_domain.properties file
WLHOME      = /home/oracle/products/12.2.1/Oracle_Home/wlserver
ORACLE_HOME = /home/oracle/products/12.2.1/Oracle_Home
DOMAIN      = soa_qa_domain
DOMAIN_PATH = /home/oracle/wls_domains/domains/soa_qa_domain
APP_PATH    = /home/oracle/wls_domains/applications/soa_qa_domain
 
SERVER_ADDRESS = 192.168.xxx.xxx
LOG_FOLDER     = /var/log/weblogic/
 
JSSE_ENABLED     = true
DEVELOPMENT_MODE = true
WEBTIER_ENABLED  = false
 
ADMIN_SERVER   = AdminServer
ADMIN_USER     = weblogic
ADMIN_PASSWORD = weblogic1
 
JAVA_HOME      = /home/oracle/jdk1.8.0_65
 
ADM_JAVA_ARGUMENTS = -XX:PermSize=256m -XX:MaxPermSize=512m -Xms1024m -Xmx1532m 
OSB_JAVA_ARGUMENTS = -XX:PermSize=256m -XX:MaxPermSize=512m -Xms1024m -Xmx1024m 
SOA_JAVA_ARGUMENTS = -XX:PermSize=256m -XX:MaxPermSize=752m -Xms1024m -Xmx1532m 
BAM_JAVA_ARGUMENTS = -XX:PermSize=256m -XX:MaxPermSize=512m -Xms1024m -Xmx1532m 
 
 
SOA_REPOS_DBURL = jdbc:oracle:thin:@192.168.xxx.xxx:1521/DBSCHEMA
SOA_REPOS_DBUSER_PREFIX  = QA
SOA_REPOS_DBPASSWORD     = welcome1
 
BPM_ENABLED=false
BAM_ENABLED=true
B2B_ENABLED=true
ESS_ENABLED=true
 
ADMIN_PORT=6001
MANAGED_SOA_PORT=6100
MANAGED_BAM_PORT=6200
MANAGED_OSB_PORT=6300

Note here all properties defined are string values, when port numbers are read from this properties need to convert to integer type using int() funciton.


Then we need to create the below script create_soa_clustered_doamin.py
loadProperties('clustersoa_osb_domain.properties')
ADM_JAVA_ARGUMENTS = '-XX:PermSize=256m -XX:MaxPermSize=512m -Xms1024m -Xmx1532m -Dweblogic.Stdout='+LOG_FOLDER+'AdminServer.out -Dweblogic.Stderr='+LOG_FOLDER+'AdminServer_err.out'
def createBootPropertiesFile(directoryPath,fileName, username, password):
  serverDir = File(directoryPath)
  bool = serverDir.mkdirs()
  fileNew=open(directoryPath + '/'+fileName, 'w')
  fileNew.write('username=%s\n' % username)
  fileNew.write('password=%s\n' % password)
  fileNew.flush()
  fileNew.close()

def createAdminStartupPropertiesFile(directoryPath, args):
  adminserverDir = File(directoryPath)
  bool = adminserverDir.mkdirs()
  fileNew=open(directoryPath + '/startup.properties', 'w')
  args=args.replace(':','\\:')
  args=args.replace('=','\\=')
  fileNew.write('Arguments=%s\n' % args)
  fileNew.flush()
  fileNew.close()

def changeDatasourceToXA(datasource):
  print 'Change datasource '+datasource
  cd('/')
  cd('/JDBCSystemResource/'+datasource+'/JdbcResource/'+datasource+'/JDBCDriverParams/NO_NAME_0')
  set('DriverName','oracle.jdbc.xa.client.OracleXADataSource')
  set('UseXADataSourceInterface','True') 
  cd('/JDBCSystemResource/'+datasource+'/JdbcResource/'+datasource+'/JDBCDataSourceParams/NO_NAME_0')
  set('GlobalTransactionsProtocol','TwoPhaseCommit')
  cd('/')

def changeManagedServer(server,port,java_arguments):
  cd('/Servers/'+server)
  set('Machine'      ,'LocalMachine')
  set('ListenAddress',SERVER_ADDRESS)
  set('ListenPort'   ,port)

  create(server,'ServerStart')
  cd('ServerStart/'+server)
  set('Arguments' , java_arguments+' -Dweblogic.Stdout='+LOG_FOLDER+server+'.out -Dweblogic.Stderr='+LOG_FOLDER+server+'_err.out')
  set('JavaVendor','Sun')
  set('JavaHome'  , JAVA_HOME)

  cd('/Server/'+server)
  create(server,'SSL')
  cd('SSL/'+server)
  set('Enabled'                    , 'False')
  set('HostNameVerificationIgnored', 'True')

  if JSSE_ENABLED == true:
    set('JSSEEnabled','True')
  else:
    set('JSSEEnabled','False')  

  cd('/Server/'+server)
  create(server,'Log')
  cd('/Server/'+server+'/Log/'+server)
  set('FileName'     , LOG_FOLDER+server+'.log')
  set('FileCount'    , 10)
  set('FileMinSize'  , 5000)
  set('RotationType' ,'byTime')
  set('FileTimeSpan' , 24)

  print('Start...wls domain with template /home/oracle/products/12.2.1/Oracle_Home/wlserver/common/templates/wls/wls.jar')
readTemplate(ORACLE_HOME+'/wlserver/common/templates/wls/wls.jar')

cd('/')
print('Set domain log')
create('base_domain','Log')

cd('/Log/base_domain')
set('FileName'    ,LOG_FOLDER+DOMAIN+'.log')
set('FileCount'   ,10)
set('FileMinSize' ,5000)
set('RotationType','byTime')
set('FileTimeSpan',24)

cd('/Servers/AdminServer')
# name of adminserver
set('Name',ADMIN_SERVER )

cd('/Servers/'+ADMIN_SERVER)

# address and port
set('ListenAddress',SERVER_ADDRESS)
set('ListenPort',int(ADMIN_PORT))

setOption( "AppDir", APP_PATH )

create(ADMIN_SERVER,'ServerStart')
cd('ServerStart/'+ADMIN_SERVER)
set('Arguments' , ADM_JAVA_ARGUMENTS)
set('JavaVendor','Sun')
set('JavaHome'  , JAVA_HOME)

cd('/Server/'+ADMIN_SERVER)
create(ADMIN_SERVER,'SSL')
cd('SSL/'+ADMIN_SERVER)
set('Enabled'                    , 'False')
set('HostNameVerificationIgnored', 'True')

if JSSE_ENABLED == true:
  set('JSSEEnabled','True')
else:
  set('JSSEEnabled','False')


cd('/Server/'+ADMIN_SERVER)

create(ADMIN_SERVER,'Log')
cd('/Server/'+ADMIN_SERVER+'/Log/'+ADMIN_SERVER)
set('FileName'    ,LOG_FOLDER+ADMIN_SERVER+'.log')
set('FileCount'   ,10)
set('FileMinSize' ,5000)
set('RotationType','byTime')
set('FileTimeSpan',24)

print('Set password...')
cd('/')
cd('Security/base_domain/User/weblogic')

# weblogic user name + password
set('Name',ADMIN_USER)
cmo.setPassword(ADMIN_PASSWORD)

if DEVELOPMENT_MODE == true:
  setOption('ServerStartMode', 'dev')
else:
  setOption('ServerStartMode', 'prod')

setOption('JavaHome', JAVA_HOME)

print('write domain...')
# write path + domain name
writeDomain(DOMAIN_PATH)
closeTemplate()

createAdminStartupPropertiesFile(DOMAIN_PATH+'/servers/'+ADMIN_SERVER+'/data/nodemanager',ADM_JAVA_ARGUMENTS)
createBootPropertiesFile(DOMAIN_PATH+'/servers/'+ADMIN_SERVER+'/security','boot.properties',ADMIN_USER,ADMIN_PASSWORD)
createBootPropertiesFile(DOMAIN_PATH+'/config/nodemanager','nm_password.properties',ADMIN_USER,ADMIN_PASSWORD)

es = encrypt(ADMIN_PASSWORD,DOMAIN_PATH)

readDomain(DOMAIN_PATH)

print('set domain password...') 
cd('/SecurityConfiguration/'+DOMAIN)
set('CredentialEncrypted',es)

print('Set nodemanager password')
set('NodeManagerUsername'         ,ADMIN_USER )
set('NodeManagerPasswordEncrypted',es )

cd('/')

setOption( "AppDir", APP_PATH )

print('Extend...osb domain with template /opt/oracle/middleware12c/osb/common/templates/wls/oracle.osb_template.jar')
addTemplate(ORACLE_HOME+'/oracle_common/common/templates/wls/oracle.wls-webservice-template.jar')
addTemplate(ORACLE_HOME+'/osb/common/templates/wls/oracle.osb_template.jar')

print 'Adding ApplCore Template'
addTemplate(ORACLE_HOME+'/oracle_common/common/templates/wls/oracle.applcore.model.stub_template.jar')

print 'Adding SOA Template'
addTemplate(ORACLE_HOME+'/soa/common/templates/wls/oracle.soa_template.jar')

if BAM_ENABLED == true:
  print 'Adding BAM Template'
  addTemplate(ORACLE_HOME+'/soa/common/templates/wls/oracle.bam.server_template.jar')

if BPM_ENABLED == true:
  print 'Adding BPM Template'
  addTemplate(ORACLE_HOME+'/soa/common/templates/wls/oracle.bpm_template.jar')

if WEBTIER_ENABLED == true:
  print 'Adding OHS Template'
  addTemplate(ORACLE_HOME+'/ohs/common/templates/wls/ohs_managed_template.jar')

if B2B_ENABLED == true:
  print 'Adding B2B Template'
  addTemplate(ORACLE_HOME+'/soa/common/templates/wls/oracle.soa.b2b_template.jar')

if ESS_ENABLED == true:
  print 'Adding ESS Template'
  addTemplate(ORACLE_HOME+'/oracle_common/common/templates/wls/oracle.ess.basic_template.jar')
  addTemplate(ORACLE_HOME+'/em/common/templates/wls/oracle.em_ess_template.jar')

dumpStack()

print 'Change datasources'

print 'Change datasource LocalScvTblDataSource'
cd('/JDBCSystemResource/LocalSvcTblDataSource/JdbcResource/LocalSvcTblDataSource/JDBCDriverParams/NO_NAME_0')
set('URL',SOA_REPOS_DBURL)
set('PasswordEncrypted',SOA_REPOS_DBPASSWORD)
cd('Properties/NO_NAME_0/Property/user')
set('Value',SOA_REPOS_DBUSER_PREFIX+'_STB')

print 'Call getDatabaseDefaults which reads the service table'
getDatabaseDefaults()    

changeDatasourceToXA('EDNDataSource')
changeDatasourceToXA('wlsbjmsrpDataSource')
changeDatasourceToXA('OraSDPMDataSource')
changeDatasourceToXA('SOADataSource')

if BAM_ENABLED == true:
  changeDatasourceToXA('BamDataSource')

print 'end datasources'
setOption( "AppDir", APP_PATH )

print('Create machine LocalMachine with type UnixMachine')
cd('/')
create('LocalMachine','UnixMachine')
cd('UnixMachine/LocalMachine')
create('LocalMachine','NodeManager')
cd('NodeManager/LocalMachine')
set('ListenAddress',SERVER_ADDRESS)

print 'Change AdminServer'
cd('/Servers/'+ADMIN_SERVER)
set('Machine','LocalMachine')

cd('/')
if ESS_ENABLED == true:
  delete('ess_server1', 'Server')

if BAM_ENABLED == true:
  delete('bam_server1', 'Server')

delete('soa_server1', 'Server')
delete('osb_server1', 'Server')

print 'Create SoaCluster'
cd('/')
create('SoaCluster', 'Cluster')
for i in range (1,3):
 print 'Create SoaServer'+str(i)
 cd('/')
 create('SoaServer'+str(i), 'Server')
 changeManagedServer('SoaServer'+str(i),int(MANAGED_SOA_PORT)+i,SOA_JAVA_ARGUMENTS)
 cd('/')
 assign('Server','SoaServer'+str(i),'Cluster','SoaCluster')
 
if BAM_ENABLED == true:
 print 'Create BamCluster'
 cd('/')
 create('BamCluster', 'Cluster')
 for i in range (1,3):
   print 'Create BamServer'+str(i)
   cd('/')
   create('BamServer'+str(i), 'Server')
   changeManagedServer('BamServer'+str(i),int(MANAGED_BAM_PORT)+i,BAM_JAVA_ARGUMENTS)
   cd('/')
   assign('Server','BamServer'+str(i),'Cluster','BamCluster')
 
print 'Create OsbCluster'
cd('/')
create('OsbCluster', 'Cluster')
for i in range (1,3):
 print 'Create OsbServer'+str(i)
 cd('/')
 create('OsbServer'+str(i), 'Server')
 changeManagedServer('OsbServer'+str(i),int(MANAGED_OSB_PORT)+i,OSB_JAVA_ARGUMENTS)
 cd('/')
 assign('Server','OsbServer'+str(i),'Cluster','OsbCluster')

print 'Add server groups WSM-CACHE-SVR WSMPM-MAN-SVR JRF-MAN-SVR to AdminServer'
serverGroup = ["WSM-CACHE-SVR" , "WSMPM-MAN-SVR" , "JRF-MAN-SVR"]
setServerGroups(ADMIN_SERVER, serverGroup)                      

if ESS_ENABLED == true:
  print 'Add server group SOA-MGD-SVRS,ESS-MGD-SVRS to soa_server1'
  cd('/')
  serverGroup = ["SOA-MGD-SVRS","ESS-MGD-SVRS"]
else:
  print 'Add server group SOA-MGD-SVRS to SoaServer1 2'
  serverGroup = ["SOA-MGD-SVRS"]

setServerGroups('SoaServer1', serverGroup)                      
setServerGroups('SoaServer2', serverGroup)                      

if BAM_ENABLED == true:
  print 'Add server group BAM12-MGD-SVRS to BamServer1 2'
  serverGroup = ["BAM12-MGD-SVRS"]
  setServerGroups('BamServer1', serverGroup)                      
  setServerGroups('BamServer2', serverGroup)                      

print 'Add server group OSB-MGD-SVRS-COMBINED to OsbServer1 2'
serverGroup = ["OSB-MGD-SVRS-COMBINED"]
setServerGroups('OsbServer1', serverGroup)                      
setServerGroups('OsbServer2', serverGroup)                      

print 'end server groups'

updateDomain()
closeDomain();

createBootPropertiesFile(DOMAIN_PATH+'/servers/SoaServer1/security','boot.properties',ADMIN_USER,ADMIN_PASSWORD)
createBootPropertiesFile(DOMAIN_PATH+'/servers/SoaServer2/security','boot.properties',ADMIN_USER,ADMIN_PASSWORD)

if BAM_ENABLED == true:
  createBootPropertiesFile(DOMAIN_PATH+'/servers/BamServer1/security','boot.properties',ADMIN_USER,ADMIN_PASSWORD)
  createBootPropertiesFile(DOMAIN_PATH+'/servers/BamServer2/security','boot.properties',ADMIN_USER,ADMIN_PASSWORD)

createBootPropertiesFile(DOMAIN_PATH+'/servers/OsbServer1/security','boot.properties',ADMIN_USER,ADMIN_PASSWORD)
createBootPropertiesFile(DOMAIN_PATH+'/servers/OsbServer2/security','boot.properties',ADMIN_USER,ADMIN_PASSWORD)

print('Exiting...')
exit()


Run wlst create_soa_clustered_domain.py

Finally you see the below output

SOA domain


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.