Search This Blog

Showing posts with label SOA. Show all posts
Showing posts with label SOA. Show all posts

Saturday, June 15, 2013

SOA & ADF Bounce script


We were working on SOA doamin for automation with WLST. After woring on the retiring and activation  of  the composites of SOA_Infra we are ready for shutdown the managed servers. Now the task is simple we have break-down the task into two simple functions.

  1. stop the cluster
  2. start the cluster
  3. Main program
Here the main program uses the logic of fetching the cluster list from the admin server. The functions are made in such a way that each cluster control operation can be tracked with state command, that will tell about all the managed servers in the cluster state. Once we did a trial found that there could be some time required for shutdown the managed servers. Double checked the state with Console as well. Re-run the same script with the menu option to start the Cluster.

Here NodeManager is independently running on each machines where the cluster spread across the  managed servers are running. So, this script only controls the clustered managed servers.

You can extend the same script to turn down the Admin server as well. after cluster down you can have that action. The command is shutdown('AdminServer', 'Server')



If you want more stories on the automation go thru the recommended book!
  
#====================================
# 
# Description: This script objective is to provide the choices to perform operation
#    1 is for stop the cluster
#    2 is for start the cluster
#    other is for exit from this script
#  this uses two functions startClstr and stopClstr which takes parameter as 'cluster name'.
#
#====================================
# Stop all instances of a Cluster 
#====================================
def stopClstr(clstrName):
 try:
  shutdown(clstrName,"Cluster")
  java.lang.Thread.sleep(25000)
  state(clstrName,"Cluster")
 except Exception, e:
  print 'Error while shutting down cluster ',e
 
#====================================
# Startp all instances of a Cluster 
#====================================
def startClstr(clstrName):
 try:
  start(clstrName,"Cluster")
  state(clstrName,"Cluster")
 except Exception, e:
  print 'Error while shutting down cluster ',e
 

if __name__== "main":
 connect('weblogic','welcome1','t3://localhost:7001')
 print "1.To Stop Instances"
 print "2.To Start Instances"
 print "3.Exit from Menu"
 ch=input('Enter Your Choice: ')
 cd("Clusters")
 clstrList=ls(returnMap='true')
 if ch== 1 :
  for clstr in clstrList:
   stopClstr(clstr)
 elif ch == 2 :
  for clstr in clstrList:
   startClstr(clstr)
 else:
  exit()

SOA Retire Activate Composites


Why we need retire and activate composites?

Before you go for bouncing the SOA Suite Domain which contains SOA, ADF Clusters with multiple managed servers, where each Weblogic server hosted all the sessions which are in execution state on them must be persisted to a restore further when Servers back to RUNNING state. To make this possible we need to use the retire composites and then after RUNNING servers bring them back to activate state for service.

Here is a sample trail script where the SOA application composites management. Here you need to navigate to the wlst.sh or cmd path. To access SCA function you must start WLST from /common/bin. When trying to run the SOA WLST command from regular 'java weblogic.WLST' cannot execute the SCA functions. When you try to execute the sca_retireComposite() it could throw the 'NameError'. So the cause is started WLST from the wrong location, to avoid that our PATH is to change and run the script from the following path: $SOA_ORACLE_HOME/common/bin/wlst.sh will work on Unix/Linux environments. Similarly you choose for Windows environment instead of using executing the shell script you need to use 'call' in the batch script.

Here the major task we have proceeding with the following two functions.

  1. Retire is to retire the composites .
  2. Activate is to activate the composites.
loadProperties('/user/test/scripts/composites.properties')
def retireComposites(Soahost,port, username,password,scacompositename, ver):
        sca_retireComposite(Soahost, port, username, password, scacompositename, revision=ver, partition='default') 
def activateComposites(Soahost,port, username,password,scacompositename, ver):
        sca_activateComposite(Soahost, port, username, password, scacompositename, revision=ver, partition='default')
if __name__== "main":
        print "1.To retire composites"
        print "2.To activate composites"
        print "3.Exit from Menu"
        ch=input('Enter Your Choice: ')
        f=open('/user/test/scripts/composites.txt','r')
        if ch== 1 :
                for c in f:
                        c=c.rstrip('\n')
                        retireComposites(Soahost,port, username,password,c, ver)
        elif ch == 2 :
                for c in f:
                        c=c.rstrip('\n')
                        activateComposites(Soahost,port, username,password,c, ver)
        else:
                exit()
        f.close()

Here is the composite.txt sample, where you can specify your composites configured in the SOA partition. Which are usually visible on enterprise manager(em) console. Oracle must given a easy module for displaying the deployed SCA composites list. Anyway we have stored in a separate file as shown below. You have flexibility of changing the order when you use this composite.txt file.

B2B_BPEL_TEST_Sub_reccive
B2B_BPEL_TIBCO_PUB_invoke

The actual trouble started when we tried to use a separate composite.txt file. each line can be read and the value always having at the end an EOL ( \n ). To supress that escape sequance we have used python scring function rtrip function.

The regular properties file which is loaded on the fist line can be created as follows:


Soahost=localhost
port=8001
username=weblogic
password=welcome1
ver=1.0



Please share this with your friends and collegues, comment if you already tried or successfully implemented on your SOA environment.

Video References:

Iris Li demonstrates how to deploy a SOA composite application using the Oracle Enterprise Manager 11g

SOA Composites references :

Saturday, December 18, 2010

Bounce Servers with NodeManager using WLST

NodeManager using WLST
Any Middleware admin can make their life easy with WLST, to play with Server Life Cycle we can use NodeManager WLST commands. WLST provides us

  • start the NodeManager
  • connect to the NodeManager, then we can use them to start or stop the WebLogic servers on the machine.

Start Node Manager

Usually, as part of configuring Node Manager, you create a Windows service or a daemon that automatically starts Node Manager when the host computer starts.

If Node Manager is not already running, you can logon to the host computer and use WLST to start it as shown:
c:\>java weblogic.WLST 
wls:/offline> startNodeManager()
We can connect from the WLST SHELL to a NodeManager by entering the nmConnect command. 
wls:/offline>nmConnect('username','password','nmHost','nmPort','domainName','domainDir','nmType')
For example, 
nmConnect('weblogic', 'secret', 'localhost', '5556', 'mydomain','c:/bea/user_projects/domains/mydomain','ssl')
 
Connecting to Node Manager ... 
Successfully connected.
 

BEA-090403 :Authentication for user denied

If you are not configured the NodeManager running WebLogic domain then, You never know what is the nodemanager user, password for that domain. By default the WebLogic admin Console must works. One of my experiance that there could be multiple users access the WebLogic admin role in such situations we need to check the initial domain configuration made up with the user credential that will help you to start the Node Manager. If it doesn't works for you then update the Node Manager username and password in the WebLogic Console and then connect.
nmDisconnect() command will do, disconnect WLST from a Node Manager session.
nm() command - You may execute many WLST commands in between nmStart and nmDisconnect then, you wonder that is it connected to NodeManager or not. To check this at WLST Shell prompt we have nm command

wls:/offline> nm()
Not connected to Node Manager

nmStart - Starts a server in the current domain using Node Manager, Conditionas applyed !! Java Node Managed will work here the Node Manager running on the different machine cannot execute this command.
Let use the nmStart command to start the Admin server as it is known as a best practice. 
wls:/nm/mydomain>nmStart('AdminServer')
starting server AdminServer ... 
Server AdminServer started successfully

nmKill command - will kills the specified WebLogic server instance that was started with the Node Manager only. 
wls:/nm/mydomain>nmKill('AdminServer')
Killing server AdminServer
Server AdminServer killed successfully

Best Practices with Nodemanager


  • Use the nodemanager to start the admin server
  • connect to the admin server
  • start the managed servers with regular WLST lifecycle commands
  • Don't kill the managed server with UNIX kill command when it is started with a Node Manager or with WLST nmStart command

WLST Life cycle commands will enables you to start all managed servers in the domain with single connection to the admin server, regardless of which machines host these Managed Servers.


My online buddy asked me to publish a WLST script for Node maneger that bounces WebLogic server. Its really wonderful thought having this idea with WLST.


Have it your way
This script you can customized as per your environment.
Here you need to do the following which are instructed by buddy because I don't have NodeManager environment test this script. But strongly confident that this will work for you,
* please change the AdminServer's Listen address, Listen port in connection module.

#===========================================
# This module will starts the NodeManager
# Author: Sumanth Krishna
#========================================
def startnm():
 try:
  progress=startNodemanger()
  progress.printStatus()
 except:
  print 'FAILED TO START NODE MANAGER'
  print dumpStack()
# The module NodeManager connects to the AdminServer
def connectnm():
  try:
     progress=nmConnect(user,passwd,WLHOST,NMPORT,domainname,domainpath,plain)
     progress.printStatus()
 except:
     print 'FAILED TO CONNECT NODE MANAGER'
     print dumpStack()

# This module is for starting the AdminServer pass AdminServer name
def startAdminServer(svrName):
   try:
      nmStart(svrName)
  except:
      print "Problem starting the Admin server "+svrName

# This module for starting the managed server
def startManagedServers():
 try:
     mbeans = home.getMBeansByType("ServerLifeCycleRuntime")
     for i in mbeans:
        svrName = i.getName()
        if svrName != serverName:
          if i.getState() != "RUNNING":
            nmStart(svrName)
 except:
     print "Problem starting the managed server "+svrName

#Main functaion i.e., all functions used to call from here
if __name__== "main":
   startnm()
   connectnm()
   startAdminServer()
   startManagedServers()
   print 'DONE'

Review this script and write back comments and suggestions to me your trial outputs and issues... whatever you have with this

Good Reference Links:
1. James Bayer blog

Related Posts

Popular Posts