Creating Cluster And adding Servers To Cluster Using WLST
Below is a simple WLST Script which allows us to test a cluster existing or not, creates the cluster and adds the specified managed servers to the created cluster.
We need to edit the file according to our environment and execute the script.
--------------------------------Start-----------------------------------------------
connect('weblogic','weblogic', 't3://localhost:7001')
try:
print 'Checking for the existence of the cluster, TestCluster.'
cd('Clusters/TestCluster')
print 'The TestCluster already exists.'
exit()
except WLSTException:
pass
edit()
startEdit(-1,-1,'false')
cd('/')
cmo.createCluster('TestCluster')
cd('/Clusters/TestCluster')
set('MulticastAddress','239.198.0.0')
set('MulticastPort','5050')
cd('/')
cd('/Servers/MS1')
cmo.setCluster(getMBean('/Clusters/TestCluster'))
cd('/Servers/MS2')
cmo.setCluster(getMBean('/Clusters/TestCluster'))
cd('/Servers/MS3')
cmo.setCluster(getMBean('/Clusters/TestCluster'))
activate()
disconnect()
exit()
------------------------------------End-------------------------