WebLogic‎ > ‎Domain Creation‎ > ‎

Cluster Creation by using the WLST

# Create the domian with the one Admin Server along with the
# two managed servers

# Created a Cluster and assaign the servers to that cluster
# Create a domain from the weblogic domain template

readTemplate('/export/home/wlsuser/bea/weblogic92/common/templates/domains/wls.jar')

# Configure the Administration Servers with out using SSL Port

cd('Servers/AdminServer')
set('ListenAddress','WLSAdminIP') // WLSAdminIP replace with admin server IP
set('ListenPort', 9913)

cd('/')
cd('Security/base_domain/User/weblogic')
cmo.setPassword('weblogic')

setOption('OverwriteDomain', 'true')
writeDomain('/export/home/wlsuser/domains/wlscldom')
closeTemplate()
readDomain('/export/home/wlsuser/domains/wlscldom')

# Create the Managed Servers and  configuration them

cd('/')
create('app01','Server')
cd('Server/app01')
set('ListenPort',8101)
set('ListenAddress','WLSAdminIP')

cd('/')
create('app02','Server')
cd('Server/app02')
set('ListenPort',8102)
set('ListenAddress','WLSAdminIP')

#Create and Configure a Cluster and assian the Managed Servers to that cluster

cd('/')
create('appclst','Cluster')
assign('Server', 'app01,app02','Cluster','appclst')
cd('Clusters/appclst')
set('MulticastAddress','237.0.0.101')
set('MulticastPort',7204)

#Write the domain and Close the domain template

updateDomain()
closeDomain()

exit()
 

 Create a Cluster Domain with NODE MANAGER

Createing a clustered domain with an Admin server and 2 managed servers environment including Node Manager setup.
 
#=======================================================================================
# Usage:
#      java weblogic.WLST createclusnm.py <domain name> <cluster name>
#=======================================================================================
# Installation directories
JAVA_HOME = '/export/home/wluser/bea/jdk150_10'
# Administration server configuration
AdminIP= 'AIP'
AdminPort = 7913
AdminHttpsPort = 8913
AdminPasswd = 'weblogic'
# Server 1 configuration
Machine1IP = 'M1IP'
Machine1Name = 'MName'
mgport= 9013
mgHttpsPort= 9213
Server1Name = 'app0101'
# Server 2 configuration
Machine2IP =  'M2IP'
Machine2Name = 'M2Name'
Server2Name = 'app0102'
#=======================================================================================
# Create a domain from the weblogic domain template.
#=======================================================================================
readTemplate('/export/home/wluser/bea/weblogic92/common/templates/domains/wls.jar')
#=======================================================================================
# Configure the Administration Server and SSL port.
# Note: The argument '-Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0'
#       is required for WebLogic servers to run under some versions of Sun JDK 1.5
#=======================================================================================
cd('Servers/AdminServer')
set('ListenAddress',AdminIP)
set('ListenPort', AdminPort)
create('AdminServer','SSL')
cd('SSL/AdminServer')
set('Enabled', 'True')

set('ListenPort', AdminHttpsPort)
set('HostNameVerificationIgnored', 'True')
cd('../..')
create('AdminServer','ServerStart')
cd('ServerStart/AdminServer')
set('Arguments', '-XX:MaxPermSize=196m -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0')
#=======================================================================================
# Define the password for user weblogic. You must define the password before you
# can write the domain.
#=======================================================================================
cd('/')
cd('Security/base_domain/User/weblogic')
cmo.setPassword(AdminPasswd)
#=======================================================================================
# Set domain save options:
# - CreateStartMenu:    Enable creation of Start Menu shortcut.
# - ServerStartMode:    Set mode to development.
# - JavaHome:           Sets home directory for the JVM used when starting the server.
# - OverwriteDomain:    Overwrites domain, when saving, if one exists.
#=======================================================================================
setOption('CreateStartMenu', 'false')
setOption('ServerStartMode', 'dev')
setOption('JavaHome', JAVA_HOME)
setOption('OverwriteDomain', 'true')
#=======================================================================================
# Write the domain, close the domain template, and reopen the saved domain.
#=======================================================================================
DOMAIN_PATH = '/export/home/wluser/domains/' + sys.argv[1]
writeDomain(DOMAIN_PATH)
closeTemplate()
readDomain(DOMAIN_PATH)
#=======================================================================================
# Create the machines to associate the managed servers with, so they can be controlled
# by the node manager.
#=======================================================================================
cd('/')
create(Machine1Name, 'Machine')
cd('Machine/' + Machine1Name)
create(Machine1Name, 'NodeManager')
cd('NodeManager/' + Machine1Name)
set('ListenAddress', Machine1IP)
cd('/')
create(Machine2Name, 'Machine')
cd('Machine/' + Machine2Name)
create(Machine2Name, 'NodeManager')
cd('NodeManager/' + Machine2Name)
set('ListenAddress', Machine2IP)
#=======================================================================================
# Create two Managed Servers (nodes in the cluster) and configure them.
#
# Note: The argument '-Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0'
#       is required for WebLogic servers to run under some versions of Sun JDK 1.5
#=======================================================================================
cd('/')
create(Server1Name, 'Server')
cd('Server/' + Server1Name)
set('ListenPort', mgport)
set('ListenAddress', Machine1IP)
set('Machine', Machine1Name)
create(Server1Name,'SSL')
cd('SSL/' + Server1Name)
set('Enabled', 'True')
set('ListenPort',  mgHttpsPort)
set('HostNameVerificationIgnored', 'True')
cd('../..')
create(Server1Name,'ServerStart')
cd('ServerStart/' + Server1Name)
set('Arguments', '-XX:MaxPermSize=196m -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0')
cd('/')
create(Server2Name, 'Server')
cd('Server/' + Server2Name)
set('ListenPort', mgport)
set('ListenAddress', Machine2IP)
set('Machine', Machine2Name)
create(Server2Name,'SSL')
cd('SSL/' + Server2Name)
set('Enabled', 'True')
set('ListenPort', mgHttpsPort)
set('HostNameVerificationIgnored', 'True')
cd('../..')
create(Server2Name,'ServerStart')
cd('ServerStart/' + Server2Name)
set('Arguments', '-XX:MaxPermSize=196m -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0')
#=======================================================================================
# Create and configure a cluster and assign the Managed Servers to that cluster.
#=======================================================================================
ClusterName = sys.argv[2]
cd('/')
create(ClusterName, 'Cluster')
assign('Server', Server1Name + ', ' + Server2Name, 'Cluster', ClusterName)
cd('Clusters/' + ClusterName)
set('MulticastAddress', '237.0.0.101')
set('MulticastPort', 9200)
set('WeblogicPluginEnabled', 'true')
#=======================================================================================
# Write the domain and close the domain template.
#=======================================================================================
updateDomain()
closeDomain()
exit()

#The following are the Explanation of used commands in the createCluster.py file (Given by using the help() command)


help('readTemplate')      

Description:  Opens an existing domain template for domain creation.
 
When you open a domain template, you are placed into the configuration bean hierarchy for that domain template, and the prompt is updated to reflect the current location in the configuration hierarchy. For example:
 
 wls:/offline/wls>
 
WebLogic Server configuration beans exist within hierarchical structures. In the WLST file system, configuration bean hierarchies correspond to drives; types and instances are directories; attributes and operations are files. WLST traverses the hierarchical structure of configuration
beans using commands such as cd, ls, and pwd in a similar way that you would navigate a file system in a UNIX or Windows command shell. After navigating to an configuration bean instance, you interact with the bean using WLST commands. For more information 


NOTE: Using WLST and a domain template, you can only create and access security information when you are creating a new domain. When you are updating a domain, you cannot access security information through WLST.
 
In the event of an error, the command returns a WLSTException.

Syntax:

readTemplate(templateFileName)
- templateFileName = Name of the JAR file corresponding to the domain  template.

Example:

wls:/offline>readTemplate('c:/bea/weblogic90/common/templates/domains/wls.jar')
wls:/offline/base_domain>


help('addTemplate')

Description: Extends the current domain using the specified application or service extension template. In the event of an error, the command returns a WLSTException.

Syntax:

addTemplate(templateFileName)
- templateFileName = Name of the application or service extension  template.

Example:

wls:/offline/wlw>addTemplate('c:/bea/weblogic90/common/templates/applications/DefaultWebApp.jar')

 

help('closeTemplate')

Description: Closes the current domain template. The domain template is no longer available once it is closed. In the event of an error, the command
returns a WLSTException.

Syntax:

closeTemplate()

Example:

wls:/offline/wls> closeTemplate()
wls:/offline>

 

help('writeTemplate')

Description: Writes the domain configuration information to the specified domain template. You can use the domain template to recreate the domain.

Once your write the configuration information to the domain template, you can continue to update the domain or domain template object
that exists in memory, and reissue the writeDomain or writeTemplate command to store the domain configuration to a new or existing domain or domain template file. For more information, see help('writeDomain') or help('writeTemplate'), respectively.

In the event of an error, the command returns a WLSTException.

Note that the writeTemplate command is similar in functionality to the pack command, as described in "Creating Templates and Domains Using the pack and unpack Commands" at http://download.oracle.com. However, writeTemplate does not support creating a Managed Server template.

Syntax:

writeTemplate(templateName)
- domainTemplate = Name of the domain template to store the domain configuration information.

Example:

wls:/offline/base_domain> writeTemplate('c:/bea/user_projects/templates/myTemplate.jar')

Creation Of WLDomain Commands

Description: Creates a domain using the specified template. In the event of an error, the command returns a WLSTException.

Note the following:
o If you wish to modify the domain configuration settings when creating a domain,

o The createDomain command is similar in functionality to the unpack command, as described in "Creating Templates and Domains Using the pack and unpack Commands" at http://e-docs.bea.com/common/docs92/pack/index.html.

Syntax:

createDomain(domainTemplate, domainDir, user, password)
- domainTemplate = Name and location of the domain template from which you want to create a domain.

- domainDir = Name of the directory to which you want to write the domain configuration information.

- user = Name of the default user.

- password = Password of the default user.

Example:

wls:/offline> createDomain('c:/bea/weblogic90/common/templates/domains
/wls_medrec.jar','c:/bea/user_projects/domains/medrec', 'weblogic', 'weblogic')


For Read Domain commands:


Description: Opens an existing domain for updating. When you open a domain, you are placed into the configuration bean hierarchy for that domain, and the prompt is updated to reflect the current location in the configuration hierarchy. For example:

wls:/offline/wls>

WebLogic Server configuration beans exist within a hierarchical structure. In the WLST file system, configuration bean hierarchies correspond to drives; types and instances are directories; attributes and operations are files. WLST traverses the hierarchical structure of configuration beans using commands such as cd, ls, and pwd in a similar way that you would navigate a file system in a UNIX or Windows command shell. After navigating to a configuration bean instance, you interact with the bean using WLST commands.

In the event of an error, the command returns a WLSTException.

Syntax:

readDomain(domainDirName)
- domainDirName = Name of the domain directory that you wish to open.

Example:

wls:/offline> readDomain('c:/bea/user_projects/domains/medrec')
wls:/offline/medrec>


To Update Domain Command


Description:


Updates and saves the current domain. The domain continues to be editable after you update and save it.

In the event of an error, the command returns a WLSTException.

Syntax:

updateDomain()

Example:

wls:/offline/medrec> updateDomain()

 

To Write Domain Command:

Description:


Writes the domain configuration information to the specified directory.

Once your write the domain to the file system, you can continue to update the domain template object that exists in memory, and reissue the writeDomain command to store the domain configuration to a new or existing file.

By default, when you write a domain, the associated applications are written to BEAHOME/user_projects/applications/domainname, where BEAHOME specifies the BEA home directory and domainname specifies the name of the domain. This directory must be empty; otherwise, WLST displays an error.

When you have finished using the domain template object in memory, close it using the closeTemplate command. For more information, see help('closeTemplate'). If you want to edit the domain that has been saved to disk, you can open it using the readDomain command. For more information, see help('readDomain').

NOTE: The name of the domain is derived from the name of the domain directory. For example, for a domain saved to c:/bea/user_projects/domains/myMedrec, the domain name is myMedrec.

Before writing the domain, you must define a password for the default user, if it is not already defined. For example:
cd('/Security/base_domain/User/weblogic')
cmo.setPassword('weblogic')

In the event of an error, the command returns a WLSTException.

Syntax:

writeDomain(domainDir)
- domainDir = Name of the directory to which you want to write the domain
configuration information.

Example:

wls:/offline/wls_medrec> writeDomain('c:/bea/user_projects/domains/medrec')

For Close Domain:


Description:


Closes the current domain. The domain is no longer available for editing once it is closed. In the event of an error, the command returns a WLSTException.

Syntax:

closeDomain()

Example:

wls:/offline/medrec> closeDomain()
wls:/offline> 
 
 help('cd')

Description: Navigates the hierarchy of configuration or runtime beans. This command uses a model that is similar to navigating a file system in a Windows or UNIX command shell. For example, to navigate back to a parent configuration or runtime bean, enter cd('..'). The
character string .. (dot-dot), refers to the directory immediately above the current directory. To get back to the root configuration
bean after navigating to a configuration or runtime bean that is deep in the hierarchy, enter cd('/').

You can navigate to configuration or runtime beans in the current hierarchy and to any child or instance.

The cd command returns a stub of the configuration or runtime bean instance, if one exists. If you navigate to a type, this command
returns a stub of the configuration or runtime bean instance from which you navigated. In the event of an error, the command returns
a WLSTException.

Note that the cmo variable is initialized to the root of all domain configuration beans when you first connect WLST to a server instance. It reflects the parent bean type until you navigate to a bean instance. For more information about the cmo variable
Syntax:

cd(mbeanName)
- mbeanName = Path to the configuration or runtime bean in the namespace.

Example:

wls:/mydomain/serverConfig> cd('Servers')
wls:/mydomain/serverConfig/Servers> cd('myserver')
wls:/mydomain/serverConfig/Servers/myserver> cd('../..')
wls:/mydomain/serverConfig>


help('cmo')

Description: Current Management Object. The cmo variable is set to the configuration bean instance to which you navigate using WLST. You use this variable to perform any create, get, set, or invoke method on the current configuration bean instance. By default, this variable
is initialized to the root of all configuration management objects, DomainMBean.

Example:

wls:/mydomain/edit> cmo.getAdministrationPort()
9002
 

 

ċ
wlstClusteringScripts.zip
(7k)
BHAVANI SHEKHAR,
Mar 25, 2009, 1:31 AM
Comments