Chat with us, powered by LiveChat
Create Managed Servers using WLST
This day I would like to share with you, how we can create a new MANAGED SERVER in Weblogic server 11g, using WebLogic Scripting Tool.

But first we have to define and be clear that it is Weblogic Scripting Tool (WLST), it is a scripting tool that allows us to perform a complete administration on Weblogic instances and Weblogic Domains both ONLINE and OFFLINE.

Well, let's get to work.
LogonWLS
First we have to have a Weblogic Domain already created where we will create the MANAGED SERVER. We log in to the Admin Server console only to confirm that the managed server does not yet exist in the Domain
ConsolaWLS
Once entered in the administration console we validate the existing ones, in my case there is only the AdminServer.
We create the script CreateManagedServer.py which will be responsible for doing the WLST operations to create the managed server we want.
 
#!/usr/bin/python
# createManagedServer.py

import time
import getopt
import sys
import re

# Obtenemos la ubicacion del archivo de propiedades.

properties = ''
try:
   opts, args = getopt.getopt(sys.argv[1:],"p:h::",["properies="])
except getopt.GetoptError:
   print 'createManagedServer.py -p '
   sys.exit(2)
for opt, arg in opts:
   if opt == '-h':
      print 'createManagedServer.py -p '
      sys.exit()
   elif opt in ("-p", "--properties"):
      properties = arg
print 'properties=', properties

# Cargamos el archivo de propiedades.

from java.io import FileInputStream
 
propInputStream = FileInputStream(properties)
configProps = Properties()
configProps.load(propInputStream)

# Seteamos las variables con sus respectivos valores.

adminUsername=configProps.get("admin.username")
adminPassword=configProps.get("admin.password")
adminURL=configProps.get("admin.url")
msName=configProps.get("ms.name")
msAddress=configProps.get("ms.address")
msPort=configProps.get("ms.port")
msCluster=configProps.get("ms.cluster")
msSSLPort=configProps.get("ms.sslport")
msMachine=configProps.get("ms.machine")

# mostramos los valores de las variables.

print 'adminUsername=', adminUsername
print 'adminPassword=', adminPassword
print 'adminURL=', adminURL
print 'msName=', msName
print 'msAddress=', msAddress
print 'msPort=', msPort
print 'msMachine=', msMachine

# Nos conectamos al AdminServer.
connect(adminUsername, adminPassword, adminURL)

edit()
startEdit()

# Creamos el managed Server.

cd('/')
cmo.createServer(msName)
cd('/Servers/' + msName)
cmo.setListenAddress(msAddress)
cmo.setListenPort(int(msPort))

# Salida stdout / stderr.

cd('/Servers/' + msName + '/Log/' + msName)
cmo.setRedirectStderrToServerLogEnabled(true)
cmo.setRedirectStdoutToServerLogEnabled(true)
cmo.setMemoryBufferSeverity('Debug')

# Asociamos el Manejado a una maquina.

cd('/Servers/' + msName)
cmo.setMachine(getMBean('/Machines/' + msMachine))

# logging de Managed Server.

cd('/Servers/' + msName + '/Log/' + msName)
cmo.setRotationType('byTime')
cmo.setFileCount(30)
cmo.setRedirectStderrToServerLogEnabled(true)
cmo.setRedirectStdoutToServerLogEnabled(true)
cmo.setMemoryBufferSeverity('Debug')
cmo.setLogFileSeverity('Notice')

save()
activate()

disconnect()
exit()
 
We create the properties file rinnovoDomain-ms1.properties which will have all the details of connection to the WebLogic application server and the data of the server managed to create.
 
# Detalles de Conexion AdminServer.

admin.username=weblogic
admin.password=welcome1
admin.url=t3://apps.rinnovocorp.com:7001

ms.name=myServer_1
ms.address=apps.rinnovocorp.com
ms.port=7002
ms.machine=apps.rinnovocorp.com
 
ExportVars
We export Environment Variables. This point is very important since this will allow to execute the WLST command to use, without needing to be located in the directory that is the Java. In the WebLogic Server 11g domains the environment variable file is the setDomainEnv.sh which is located at $ DOMAIN_HOME / bin
ExecuteCommand
We execute command to perform the Handled Creation operation:
java weblogic.WLST /u01/scripts/createManagedServer.py -p /u01/scripts/rinnovoDomain-ms1.properties
validateManaged
Once executed, we validate that it was created correctly, and that the session has not been active.

Comments are closed.