Technical

Creating an OSB domain using WLST

One of the main use cases of WLST is to automate the creation of your domains. Using WLST you can add all the configuration you need for your domain and ensure that it will be created exactly the same each time you build it (as opposed to relying on your infrastructure team member to remember to configure everything through the weblogic console). Also, you can add your WLST script into your version control repository to ensure that all changes are tracked and that everyone can always have the most up-to-date configuration.

To give you an idea of how to create a domain in WLST let’s create a simple OSB domain. We’ve created a script ‘osb_domain.py’ that will create the domain and configure the JDBC data sources (among other things). This will create a fully working OSB domain for us to work with. In our next post we will create a WLST script to start up this domain, but for the time being we can start it the old fashioned way (./startWebLogic.sh)

The full code is up at GitHub: https://github.com/Joelith/wlst/blob/master/OSB/osb_domain.py

The contents of this post will be discussed at the upcoming Oracle Middleware Forum in Canberra. Why not come along and pick up some more WLST tips?

Step by step

First we use templates to add the basic configuration for our domain. We could do this from scratch, but why re-invent the wheel?

readTemplate(WL_HOME + '/common/templates/domains/wls.jar')
cd('/Security/base_domain/User/weblogic')
cmo.setPassword(WEBLOGIC_PASSWORD)
writeDomain(DOMAIN_HOME)
closeTemplate()

readDomain(DOMAIN_HOME)
addTemplate(OSB_HOME + '/common/templates/applications/wlsb.jar')
addTemplate(OSB_HOME + '/common/templates/applications/wlsb_owsm.jar')
addTemplate(MW_HOME + '/oracle_common/common/templates/applications/oracle.em_11_1_1_0_0_template.jar')

Here we load the basic wls.jar template and configure our weblogic user. Then write the domain to the filesystem and then add the extra templates we need to support OSB:

  • wlsb.jar: Configures the domain for OSB, includes the sbconsole deployment and an osb_server1 server by default
  • wlsb_owsm.jar: Adds support for Oracle Web Services Manager (OWSM)
  • oracle.em_11_1_1_0_0_template.jar: Adds Enterprise Manager to the domain

The next step is to configure the MDS and OWSM JDBC data sources. You should have already created these schemas in your Oracle database using RCU. The script is pretty self-explanatory here, it just goes through all the necessary steps to configure a JDBC data source.

create('wlsbjmsrpDataSource', 'JDBCSystemResource')
cd('/JDBCSystemResource/wlsbjmsrpDataSource')
set('DescriptorFileName','jdbc/wlsbjmsrpDataSource-jdbc.xml')
set('Target',ADMIN_SERVER + ',' + MANAGED_SERVER)
cd('/JDBCSystemResource/wlsbjmsrpDataSource/JdbcResource/wlsbjmsrpDataSource')
cmo.setName('wlsbjmsrpDataSource')

Then we configure the machines on the domain so they have the correct listen ports. You can use the defaults, but it’s always good to configure these in your scripts in case you need to change ports later (or host two domains on the one machine for instance)

cd ('/')
cmo.setConfigBackupEnabled(True)
cmo.setArchiveConfigurationCount(25)

cd('/Server/' + ADMIN_SERVER)
cmo.setListenAddress(LISTEN_ADDRESS)
cmo.setListenPort(ADMIN_SERVER_PORT)

cd('/Server/' + MANAGED_SERVER)
cmo.setListenAddress(LISTEN_ADDRESS)
cmo.setListenPort(MANAGED_SERVER_PORT)

cd ('/SecurityConfiguration/' + DOMAIN)
cmo.setNodeManagerUsername(NODE_MANAGER)
cmo.setNodeManagerPasswordEncrypted(NODE_MANAGER_PASSWORD)

And then we create some machines and associate the Admin and OSB servers with them.

print('Creating machines')
cd ('/')
create(MACHINE, 'UnixMachine')
cd('/Machines/' + MACHINE)
create(MACHINE, 'NodeManager')
cd('NodeManager/' + MACHINE)
set('NMType', 'Plain')
set('ListenAddress', NODE_MANAGER_LISTEN_ADDRESS)
set('ListenPort', NODE_MANAGER_PORT)

cd('/Server/' + ADMIN_SERVER)
set('Machine',MACHINE)

cd('/Server/' + MANAGED_SERVER)
set('Machine',MACHINE)

Finally we apply all our changes to the domain through the updateDomain() function. We run the script with:

java weblogic.WLST osb_domain.py

Troubleshooting/Tips

The script is pretty to easy to use, but here’s some problems you might encounter:

  • Make sure you’ve installed OSB into your weblogic folder otherwise the templates won’t be available!
  • Before running your script you will need to set your domain environment variables. Use the ./setWLSTEnv.sh file in the WL_HOME/common/bin folder
  • You can run this script as an executable without the need to call java before hand by adding the following to the first line of the script. This will set the environment variables for you and allow you to call the script as ./osb_domain.py (Note: your path to wlst.sh may be different)
    • #!/usr/bin/env /oracle/product/middleware/Oracle_OSB1/common/bin/wlst.sh
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s