WLST script to create domain and servers

Oracle Weblogic Server

Save the below script as createDomain.py and run it through WLST in offline mode to create below details. You can use below wlst script to create domain and managed servers, etc.

# This is an Offline WLST script to create a WLS 10.3.4 (Oracle Weblogic Server 11gR1) Domain
#
# Domain consists of:
# 1. Admin Server
# 2. Two Managed Servers for a Cluster
# 3. One Standalone Managed Server
# 4. A Cluster for Two Managed Server
# 5. One Machine which all Managed Servers will be configured
# Read a domain template
# Change the path to wls.jar according to your setup
print('Reading Template - /apps/Oracle/Middleware/wlserver_10.3/common/templates/domains/wls.jar')
readTemplate('/apps/Oracle/Middleware/wlserver_10.3/common/templates/domains/wls.jar')

# Admin Server SSL and Non-SSL
print('Creating Server - Admin Server')
cd('Servers/AdminServer')
set('ListenAddress','10.212.15.2')
set('ListenPort', 7001)

create('AdminServer','SSL')
cd('SSL/AdminServer')
set('Enabled', 'True')
set('ListenPort', 7002)

# Security
print('Creating Password')
cd('/')
cd('Security/base_domain/User/weblogic')
cmo.setPassword('weblogic1')

# Start Up
print('Setting StartUp Options')
setOption('CreateStartMenu', 'false')
setOption('ServerStartMode', 'prod')
# Setting the JDK home. Change the path to your installed JDK for weblogic
setOption('JavaHome','/apps/Oracle/Middleware/Java/jdk')
setOption('OverwriteDomain', 'true')

# Create Domain to File System
print('Writing Domain To File System')
# Change the path to your domain accordingly
writeDomain('/apps/Oracle/Middleware/user_projects/domains/TPDomain')
closeTemplate()

# Read the Created Domain
print('Reading the Domain from In Offline Mode')
readDomain('/apps/Oracle/Middleware/user_projects/domains/TPDomain')

# Creating Managed Servers
#Change the ports accordingly for TPMS1,TPMS2 and TPMS3
print('Creating Server - TPMS1 on Port # 12000')
cd('/')
create('TPMS1', 'Server')
cd('Server/TPMS1')
set('ListenPort', 12000)
set('ListenAddress', '10.211.55.2')

print('Creating Server - TPMS2 on Port # 11000')
cd('/')
create('TPMS2', 'Server')
cd('Server/TPMS2')
set('ListenPort', 11000)
set('ListenAddress', '10.211.55.2')

print('Creating Server - TPMS3 on Port # 10001')
cd('/')
create('TPMS3', 'Server')
cd('Server/TPMS3')
set('ListenPort', 10001)
set('ListenAddress', '10.211.55.2')

# Create and configure a cluster and assign the TPMS1 and TPMS2 Managed Servers to that cluster.
print('Creating Cluster - test_cluster and adding TPMS1, TPMS2')
cd('/')
create('test_cluster', 'Cluster')
assign('Server', 'TPMS1,TPMS2','Cluster','test_cluster')
cd('Cluster/test_cluster')
set('ClusterMessagingMode', 'multicast')
set('MulticastAddress', '237.0.0.101')
set('MulticastPort', 5555)
set('WeblogicPluginEnabled', 'true')

# Create and configure a machine and assign the Managed Servers to that Machine
print('Creating Machine - test_machine and adding TPMS1, TPMS2')
cd('/')
create('test_machine', 'Machine')
assign('Server', 'TPMS1,TPMS2,TPMS3','Machine','test_machine')
cd('Machines/' + 'test_machine/')
create('test_machine', 'NodeManager')
cd('NodeManager/' + 'test_machine')
set('NMType', 'SSL')
set('ListenAddress', '10.211.55.2')
set('DebugEnabled', 'false')

# updating the changes
print('Finalizing the changes')
updateDomain()
closeDomain()

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

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

6 Responses

  1. Kavitha says:

    Thanks for the great article. I am new to wlst scripting. I am trying to add users into the domain and add to the group Administrator. .Can you please post if you have some sample wlst commands. thanks .KN

  2. Faheem says:

    this script works.. thanks

  3. Pavan says:

    Thanks for script..It is very userful…

  4. JATIN C RATHOD says:

    I want to create Admin server first then start the server and then create managed server

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.