Search This Blog

Saturday, February 3, 2018

Remotely domain extension using WLST

WebLogic latest version 12.2.x come up with different WebLogic domain templates and their usage methods in WLST. Usually WebLogic domain can be created with base domain template using wls.jar. Then after that domain need to be customized as the projects where we need the extended domain.

  1. When the domain spread across multiple machines/nodes
  2. One successful configuration domain reuse to create new domains
Here is small experiment with the domain template, here we have two nodes associated with  192.168.33.100 - Machine100 and 192.168.33101 - Machine101 IP addresses and machine. The admin server configured in the Machine100 and also two web servers in webcluster, two app servers in appcluster. The whole configuration we need in Machine101.

Earlier to WebLogic 12.2 version we have pack and unpack option only for the domain expansion in the remote machine otherwise copy the domain folder need to copy. 

In the latest versions of WebLogic 12.2.x above are having different WLST methods that relates to template usage.
Remotely extension of WebLogic Domain using WLST and pack-unpack
Lets explore options available in WLST

selectTemplate() in WLST

There are multiple domain templates, extension templates for domains are available in Oracle WebLogic installation media pack it self. Some of the application specific templates also available with the media pack.

selectCustomTemplate() in WLST

We can create our own WebLogic domain template using writeTemplate() that will be containing the project specific configurations such as - servers, cluster, JDBC, JMS are pre-configured and reusable. The select custom template method followed by loadTemplate command.

loadTemplates() in WLST

The loadTemplates(0 is the command always used after selectTemplate or selectCustomTemplate commands.

Automation solution: Create domain template and configure domain


Like here we need to create extension domain in the Machine101, you may need to to do for multiple machines in production environments.

The process is simplified into few steps
  1. connect to the existing domain
  2. Read the domain and generate the custom domain template
  3. Create the extended domain enter the same domain name and path or fresh domain can be configured with the new domain name, listen address modification as required

#======================================
# 
# File: remoteDomain.py
# Applicable WebLogic version: 12.2.x
# This will solve pack and unpack strange issues
#
#===============================================
def printline(s):
    print "-"*10 + s
 
def createDomainTemplate(templateLocation):
    
    ''' Generate the custom domain template  '''
    connect(admuser,admpass,admurl)
    
    print ("Writing Custom Template...")
    writeTemplate(templateLocation)
    print ("Writing Template...: Completed")
    disconnect()
    
def create_Domain(templateLocation, domainPath):
 ''' Creating extended domain remotely 
 selectCustomTemplate, loadTemplates will get the inputs
 then writeDomain will create the domain '''
 
 selectCustomTemplate(templateLocation)
 loadTemplates()
 print ("Creating extended domain...")
 writeDomain (domainPath)
 closeTemplate()
 print ("Creating domain...: Completed")
       
       
def main():
 '''
 Change the following values according to your domain
 user security better to use storeuserconfig
 and domain template 
 you can move these variables into properties file
 '''
 templateLocation ='/u01/app/oracle/prod_domain_template.jar'
 domainPath='/u01/app/oracle/prod_domain'
 admuser='weblogic'
 admpass='welcome1'
 admurl='192.168.33.100:8001'
 
 createDomainTemplate(templateLocation)
 create_Domain(templateLocation, domainPath)
    
if __name__ == "__main__":
    printline()
    print("SCRIPT BEING RUN DIRECTLY")
    printline()
    main()
 printline()

Remotely execution of script

WLST SCRIPT

Popular Posts