Script to Manage Cluster in Websphere

ibm websphere
Below JACL script can be used to manage clusters in IBM websphere ND
#----------------------------------------------------------------------
#-- Manage Clusters (WebSphere Application Server Network Deployment)
#-- Listing clusters 
#---------------------------------------------------------------------

set clusters [$AdminConfig list ServerCluster]
  puts "There are [llength $clusters] clusters:"
  foreach aCluster $clusters {
     puts $aCluster
  }

#------------------------------------------------------------------
#--Starting clusters 
#------------------------------------------------------------------

set clusterMgr [$AdminControl queryNames cell=myCell,type=ClusterMgr,*]
$AdminControl invoke $clusterMgr retrieveClusters
set clusters [$AdminControl queryNames cell=myCell,type=Cluster,*]
foreach aCluster $clusters {
if {[$AdminControl getAttribute $aCluster state] == "websphere.cluster.stopped"} {
$AdminControl invoke $aCluster start
}
}

#--------------------------------------------------------------------
#-- Stopping running clusters 
#---------------------------------------------------------------------

set clusters [$AdminControl queryNames type=Cluster,cell=myCell,*]
foreach aCluster $clusters {
if {[$AdminControl getAttribute $aCluster state] == "websphere.cluster.running"} {
$AdminControl invoke $aCluster stop
}
}

#--------------------------------------------------------------------
#--Ripple starting clusters 
#--------------------------------------------------------------------

set clusters [$AdminControl queryNames type=Cluster,cell=myCell,*]
foreach aCluster $clusters {
if {[$AdminControl getAttribute $aCluster state] == "websphere.cluster.running"} {
$AdminControl invoke $aCluster rippleStart
}
}

#---------------------------------------------------------------------
#--Immediate stopping clusters 
#----------------------------------------------------------------------

set clusters [$AdminControl queryNames type=Cluster,cell=myCell,*]
foreach aCluster $clusters {
if {[$AdminControl getAttribute $aCluster state] == "websphere.cluster.running"} {
$AdminControl invoke $aCluster stopImmediate
}
}

#---------------------------------------------------------------------
#--Creating a new cluster 
#---------------------------------------------------------------------
set aServerTemplate [$AdminConfig listTemplates Server]
set aNode [$AdminConfig getid /Node:myNode/]
set aNewServer [$AdminConfig createUsingTemplate Server $aNode {{name newClusterServer}} $aServerTemplate]
set aCluster [$AdminConfig convertToCluster $aNewServer myCluster]
set anotherNode [$AdminConfig getid /Node:anotherNode/]
set aClusterTemplate [$AdminConfig listTemplates ClusterMember]
$AdminConfig createClusterMember $aCluster $anotherNode {{memberName anotherClusterMember}} $aClusterTemplate
$AdminConfig save

#---------------------------------------------------------------------
#-- Deleting a cluster 
#---------------------------------------------------------------------
set aRunningCluster [$AdminControl queryNames type=Cluster,cell=myCell,name=myCluster,*]
if {[$AdminControl getAttribute $aCluster state] == "websphere.cluster.running"} {
$AdminControl invoke $aRunningCluster stop
}
set aConfigCluster [$AdminControl getConfigId $aRunningCluster]
$AdminConfig remove $aConfigCluster
$AdminConfig save

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

Leave a Reply

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