Create & Delete managed server by wlst script in Weblogic

Requirement – How to create and delete managed server by wlst script in weblogic

Solutions
As we can use wlst recording feature to generate the script.I have modified a script a little bit

Following script to create a managed server with assigning port and machine.

MakeServer.py

name=sys.argv[1]
port=int(sys.argv[2])
machine=sys.argv[3]
connect('weblogic', 'welcome1', 't3://192.168.0.123:7001')
edit()
startEdit()
cd('/')
cmo.createServer(name)
cd('/Servers/' + name)
cmo.setListenAddress("")
cmo.setListenPort(port)
activate()
startEdit()
cmo.setListenPortEnabled(true)
cmo.setJavaCompiler('javac')
cmo.setClientCertProxyEnabled(false)
cmo.setMachine(getMBean('/Machines/' + machine))
cmo.setCluster(None)
cd('/Servers/' + name + '/SSL/' + name)
cmo.setEnabled(false)
cd('/Servers/NewManagedServer/DataSource/NewManagedServer')
cmo.setRmiJDBCSecurity(None)
activate()

->Open terminal and go to
$MWHOME/wlserver_10.3/server/bin
-> . ./setWLSEnv.sh

-> open new terminal
-> go to $MWHOME/user_project/domains/ucm_domains/bin
-> execute . ./setDomainEnv.sh

:-Note it is like dot space dot/setDomainEnv.sh

Call this script as

java weblogic.WLST /u01/app/oracle/Oracle/middleware/wlserver_10.3/server/bin/MakeServer.py "servername" "portNumber" "MachineName"

___________________________________________________________________________________________________________-

Following script to delete server

DeleteServer.py

name=sys.argv[1]
connect('weblogic', 'welcome1', 't3://192.168.0.123:7001')
edit()
startEdit()
cd('/')
cd('/Servers/' + name)
cmo.setCluster(None)
cmo.setMachine(None)
editService.getConfigurationManager().removeReferencesToBean(getMBean('/Servers/' + name))

cd('/')
cmo.destroyServer(getMBean('/Servers/' + name))

activate()

->Open terminal and go to
$MWHOME/wlserver_10.3/server/bin
-> . ./setWLSEnv.sh

-> open new terminal
-> go to $MWHOME/user_project/domains/ucm_domains/bin
-> execute . ./setDomainEnv.sh

:-Note it is like dot space dot/setDomainEnv.sh

Call this script as

java weblogic.WLST /u01/app/oracle/Oracle/middleware/wlserver_10.3/server/bin/DeleteServer.py "servername"

See the video here

happy learning Weblogic with Vinay kumar in techartifact…..

Vinay

I am an Oracle ACE in Oracle ADF/Webcenter. Sr Java Consultant-working on Java/J2EE/Oracle ADF/Webcenter Portal/ content and Hibernate for several years. I'm an active member of the OTN JDeveloper/Webcenter forum. Passionate about learning new technologies. I am here to share my knowledge. Give your views and suggestion on [email protected] .

More Posts - Website

Follow Me:
TwitterLinkedInGoogle PlusYouTube