Search This Blog

Showing posts with label NodeManager. Show all posts
Showing posts with label NodeManager. Show all posts

Saturday, April 8, 2017

WebLogic 12c Cluster Domain configuration using WLST offline

Objective of this script is to Leverage the time takes to configure the WebLogic Domain and after starting the admin server then following list need to be configured for HA/reliability.
Everytime I work on new project there is a need of creation of the clustered domain. From my past experiences collected all basic requirements together list them over here.

  • AdminServer configuration includes Name, Listen Address, ListenPort
  • User credentials username, password
  • After writing basic domain going for create machine which include Name, type of machine
  • Nodemaager includes NMTypes such as plain, ssl, hosted node, nodemanager port
  • Managed servers have Name, ListenAddress, ListenPort, set machine
  • Cluster includes name, ClusterAddress, Servers part of the cluster interesting part here
Assumptions for this task:

WebLogic 12.2.1 cluster domain creation with WLST
WLST Configuring WebLogic Cluster Domain


In the script as per my convenience some of them are hardcoded, My hardcoded values:
  1. Managed Server list
  2. Cluster list
In this script lots of Python sequence functions are used.

  • List index, 
  • Dictionary keys
  • String startwith

Lets begin the fun of WLST HERE...
# purpose:  Create the domian with the one Admin Server along with the
# two managed servers in each cluster. app_cluster, web_cluster
# Assumption here all managed servers runs on the same machine
# Modified date: 07-April-2017
# File name     :       create_clusterdomain.py
# Dependencies  :       cluster_domain.properties
# Note this names of managed servers, cluster, hostname all hard coded
#
def printline(s):
    print "-"*10 + s

loadProperties('/u01/app/software/scripts/pybin/cluster_domain.properties')

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

WLHOME=os.environ["WL_HOME"]
readTemplate(WLHOME+'/common/templates/wls/wls.jar')
printline("reading template completed")

# Configure the Administration Servers with out using SSL Port

cd('Servers/AdminServer')
set('ListenAddress',WLSAdminIP)
set('ListenPort', int(AdminPort))

printline("AdminServer ListenAddress, port set")

cd('/')
cd('Security/base_domain/User/weblogic')
cmo.setPassword(AdminPasswd)
printline("User credentials set")

setOption('OverwriteDomain', 'true')
writeDomain(DomainPath+'/'+DomainName)
printline("Domain creation done.")

closeTemplate()
readDomain(DomainPath+'/'+DomainName)
machines={'myM100':'192.168.33.100', 'myM110':'192.168.33.110'}

for m in machines.keys():
        cd('/')
        create(m, 'UnixMachine')
        cd('Machine/' + m)
        create(m, 'NodeManager')
        cd('NodeManager/' + m)
        set('ListenAddress', machines[m])
        set('NMType','ssl')

# Create the Managed Servers and  configuration them
ManagedServerList=['app01','app02','web01','web02']

app_ca=""
web_ca=""
for s in ManagedServerList:
        cd('/')
        create(s,'Server')
        cd('Server/'+s)
        i=ManagedServerList.index(s)
        lp=8101+i
        set('ListenPort', int(lp))
        j=int(s[-1])
        m=machines.keys()[j-1]
        set('ListenAddress', machines[m])
        set('Machine', m)

        if s.startswith('app') :
                if j%2==0:
                        app_ca+=','
                app_ca+=machines[m]+':'+str(lp)

        elif s.startswith('web'):
                if j%2==0:
                        web_ca+=','
                web_ca+=machines[m]+':'+str(lp)

        printline("Managed server :"+s+" created")

printline("configured managed servers done.")
printline("app cluster address:"+app_ca)
printline("Web cluster address:"+web_ca)

# Create and Configure a Cluster and assian the Managed Servers to that cluster
clusters={'app_clustr1':'app01,app02', 'web_clustr1':'web01,web02'}
clstrs=clusters.keys()
for c in clstrs:
        cd('/')
        create(c,'Cluster')
        assign('Server', clusters[c],'Cluster', c)
        cd('Clusters/'+c)
        set('ClusterMessagingMode','multicast')
        if c.startswith('app'):
                set('ClusterAddress',app_ca)
        elif c.startswith('web'):
                set('ClusterAddress',web_ca)
        set('MulticastAddress','237.0.0.101')
        set('MulticastPort',7200+clstrs.index(c))
        printline("cluster "+c+" created")

printline("Configured clusters and assigned managed servers done.")
#Write the domain and Close the domain template

updateDomain()
closeDomain()

printline("Task completed successfully, exiting!!!")
exit()

Now the properties file which you can enhance with your limitations
WLSAdminIP=192.168.33.100
AdminPort=8001
AdminPasswd=welcome1
DomainPath=/u01/app/oracle/domains
DomainName=uat_domain


Lets have the execution screen for you:





Please write your valuable feedback on this post, so that we can keep improve further to have more interesting fun stuff soon for you.

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

Sunday, September 5, 2010

NodeManager Experiments using WLST

Create Machine configure NodeManager using WLST

This blog post is renovated with latest WebLogic 12.2.1 version execution output here. We have more generic reusable functions, three different functions each one has independent task. Where the pre condition for this is you must have a domain configured and admin server is running.

  1. create a machine and setup the Nodemanager 
  2. delete machine from the domain
  3. show all machines in the domain


 

#==========================================================================
# FileName      : createMachine.py
# Updated       : 11/22/2015
# Description:
# This simple script will create multiple machines
# and also set the NodeManager properties
# use demo.properties file loadProperties command line argument expected
#
# You can add this function block to full domain
#==========================================================================

def createMachine(machineName, machineIP,nmPort=5556):
        """
        This function takes three arguments machineName, machineIP, nmPort
        The default nmPort is 5556 and nmType as Plain
        """
        cd('/')
        cmo.createUnixMachine(machineName)

        cd('/Machines/'+machineName+'/NodeManager/'+machineName)
        cmo.setNMType('Plain')
        cmo.setListenAddress(machineIP)
        cmo.setListenPort(nmPort)
        cmo.setDebugEnabled(false)

def deleteMachine(machineName):
        """
        This function takes machineName as argument
        It will delete the Machine MBean from the Domain
        """
        cd('/')
        editService.getConfigurationManager().removeReferencesToBean(getMBean('/Machines/'+machineName))
        cmo.destroyMachine(getMBean('/Machines/'+machineName))

def printMachineList():
        """
        This function will display the machines configured on a domain
        No arguments required
        """
        cd('/')
        redirect('/dev/null', toStdOut='false')
        machineslist=ls('Machines',returnMap='true')
        for m in machineslist: print m
        stopRedirect()

def main():
        """
        Here we can expect ConnectionException, WLSTException
        and also BeanAlreadyExist for createMachine function
        """
        connect(ADMINUSER,ADMINPASSWD, ADMINURL)

        print "Before machines creation..."
        printMachineList()

        edit()
        startEdit()

        for i in range(1,5):
                try:
                        createMachine('machine'+str(i), '192.168.33.'+str(100+i),5566)
                except:
                        print 'Machine creation failed...'+'machine'+str(i)
        activate()

        print "After creation..."
        printMachineList()

        HitKey=raw_input('Press any key to continue...')

        startEdit()
        for i in range(1,5):
                try:
                        deleteMachine('machine'+str(i))
                except:
                        print 'Unable to remove machine...'
        activate()

        print "After removing machines..."
        printMachineList()
main()

Excecution of the Machine configuration is as follows....


java weblogic.WLST  -loadProperties demo.properties createMachine.py

create, delete and show machines in WebLogic 12.2.1 domain

Double confirmation with Admin console

Machine in WebLogic Domain configured with WLST


Start n Stop the Server using NodeManager by WLST

Manage the Server Life Cycle continues...
[2] Configure a NodeManager to start WebLogic Server instances (using console and command-line)

Start n Stop Server using NodeManager by WLST:

In the sun Solaris environment we need to change few nodemanager.properties to run the NodeManager. There are two kinds of Node Managers available
Java based Node manager
Script based Node manager

while connecting to nodemanager we have received an error as below:

Error encounter when the java native
bash-3.00$ tail -100f nodemanager.log


weblogic.nodemanager.common.ConfigException: Native version is enabled but node manager native library could not be loaded
at weblogic.nodemanager.server.NMServerConfig.initProcessControl(NMServerConfig.java:239)
at weblogic.nodemanager.server.NMServerConfig.(NMServerConfig.java:179)
at weblogic.nodemanager.server.NMServer.init(NMServer.java:177)
at weblogic.nodemanager.server.NMServer.(NMServer.java:142)
at weblogic.nodemanager.server.NMServer.main(NMServer.java:327)
at weblogic.NodeManager.main(NodeManager.java:31)
Caused by: java.lang.UnsatisfiedLinkError: no nodemanager in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at weblogic.nodemanager.util.UnixProcessControl.(UnixProcessControl.java:16)
at weblogic.nodemanager.util.Platform.getProcessControl(Platform.java:108)
at weblogic.nodemanager.server.NMServerConfig.initProcessControl(NMServerConfig.java:237)
... 5 more

java weblogic.WLST startAdmin.py wcludomNM

connect('weblogic', 'weblogic', 't3://wlhost:7913')
nmEnroll('/home/wluser/domains/WLclsnm')
CLASSPATH to set for NodeManager:
export NM_HOME = $WL_HOME/common/nodemanager

CLASSPATH=/export/home/wladmin/wl813/bea/jdk142_04/jre/lib/rt.jar:/export/home/wladmin/wl813/bea/jdk142_04/lib/rt.jar:/export/home/wladmin/wl813/bea/patches/CR204958_810sp3_v1.jar:/export/home/wladmin/wl813/bea/weblogic81/server/lib/weblogic.jar

startNodeManager(verbose='true',NodeManagerHome='/home/wluser/bea/weblogic92/common/nodemanager')

To Check the log of nodemanager.log
tail -100f /home/wluser/bea/weblogic92/common/nodemanager/nodemanager.log

/home/wluser/bea/weblogic92/common/nodemanager/nodemanager.domains>

nmConnect('weblogic', 'weblogic', 'wlshostname','5556', 'WLclsnm', '/home/wluser/domains/WLclsnm')

prps = makePropertiesObject('weblogic.ListenPort=9013')
wls:/WLclsnm/serverConfig>
wls:/WLclsnm/serverConfig> nmStart('app01',props=prps)
Starting server app02 ...
Error Starting server app02: weblogic.nodemanager.NMException:
Exception while starting server 'app02': java.io.IOException: Server failed to start up. See server output log for more details.

prps = makePropertiesObject('weblogic.ListenPort=9013')

start('wlctr', 'Cluster')

nmStart('app02',props=prps)
Starting server AdminServer...
Server AdminServer started successfully

nmConnect('weblogic', 'weblogic', 'remotehostnameofmanagedserver' '5556','WLclsnm', '/home/wluser/domains/','plain')

Still workin progress to start the remotemanaged server by using wlst
(I am getting some errors when I tried ...will update this site Once it will done successfully if anybody is done plz post it as comment.)
Posted by Pani at 9:44 AM 1 comments:


Archana said...
Hi,
We are also facing the same issue. Not able to start managed servers using makepropertiesobject.

Did u get any solution.
Yes, Archana, We found the Solution as using PLAIN type for NodeManager is good to go.

Popular Posts