Questo sito utilizza i cookie per migliorare l'esperienza di navigazione. Continuando la navigazione acconsenti all'utilizzo dei cookie.

Build a Weblogic CLUSTER with WLST script

Build a Weblogic CLUSTER with WLST script

For the following let's assume you already have a weblogic server domain with admin server up and running in RUNNING MODE.
To have that work done manually you have to set some env. variable like MW_HOME, JAVA_HOME, and WL_HOME and launch $WL_HOME/common/bin/config.sh.
Answer some easy question about the listening address af the admin server and so on. Finally Start the admin server and node manager. That's all.


Naturally you can write some script to build the domain from zero. Infact WLST tool can also work "offline" and read a "domain template" ( basicly a jar archive containing some XML files )
and write that domain on the file system. But we will do that stuff in the future. For now we suppose we have a basic domain with anything else that
an admin server up and running.


The gol is to run  a Jython script based on  WLST and build on our domain a CLUSTER of two managed server.

A Weblogic cluster is essentially made of a set of "machine" that host innstances of weblogic managed server that share the same applications.
So fisrt of all we have to create a machine. Let's go scripting:

this is to read from a properties file script.properties ( in the same directory ) the admin user and password, and the address and connect to the admin server:

import sys
from java.io import FileInputStream

propInputStream = FileInputStream("script.properties")
configProps = Properties()
configProps.load(propInputStream)
adminListenAddress=configProps.get("adminListenAddress")
adminListenPort=configProps.get("adminListenPort")
url = 't3://' + adminListenAddress + ':' + adminListenPort
systemUser=configProps.get("systemUser")
systempwd=configProps.get("systemPassword")
connect(systemUser,systempwd,url)


to create the machine :

edit()
startEdit(-1,-1,'false')
cd('/')
debian=create('Debian','UnixMachine')
cmo=debian
cmo.setAddresses(['1.1.1.1'])
cmo.setName("Debian")
cmo.setNotes("machine created by WLST script")
cd('/Machines/Debian/NodeManager/Debian')
set('NMType','Plain')
save()
activate()


to create the cluster :

edit()
startEdit(-1,-1,'false')
cd('/')
cmo.createCluster('tutorialCluster')
cd('Clusters/tutorialCluster')
set('MulticastAddress','239.196.0.0')
set('MulticastPort','7070')
save()
activate()


finally we create the server 1:

edit()
startEdit(-1,-1,'false')
cd('/')
srvmngd1=cmo.createServer('srvmngd1')
#cd('/Servers/srvmngd1')
srvmngd1.setListenAddress(adminListenAddress)
srvmngd1.setListenPort(7011)
srvmngd1.setCluster(getMBean('/Clusters/tutorialCluster'))
srvmngd1.setMachine(debian)
srvmngd1.getServerStart().setJavaHome('/home/massimo/sw/java/jdk1.7.0_17')
srvmngd1.getServerStart().setJavaVendor('Oracle')
srvmngd1.getServerStart().setArguments('-Xms128m -Xmx128m -Xns32m -Xgcprio:throughput');
srvmngd1.setAutoKillIfFailed(true);
save()
activate()

and server 2:

edit()
startEdit(-1,-1,'false')
cd('/')
srvmngd2=cmo.createServer('srvmngd2')
#cd('/Servers/srvmngd2')
srvmngd2.setListenAddress(adminListenAddress)
srvmngd2.setListenPort(7021)
srvmngd2.setMachine(debian)
srvmngd2.setCluster(getMBean('/Clusters/tutorialCluster'))
srvmngd2.getServerStart().setJavaHome('/home/massimo/sw/java/jdk1.7.0_17')
srvmngd2.getServerStart().setJavaVendor('Oracle')
srvmngd2.getServerStart().setArguments('-Xms128m -Xmx128m -Xns32m -Xgcprio:throughput');     
srvmngd2.setAutoKillIfFailed(true);
save()
activate()

Enjoy it


Share
Allegati:
Scarica questo file (createMngtSrv.py.gz)createMngtSrv.py.gz[script Jython to build a weblogic cluster ]0.8 Kb

Aggiungi commento


Codice di sicurezza
Aggiorna