Tuesday, March 3, 2015

WLST script commands part-I

For wlst build on jython scripting(Jython is based on Python).

To create Domain using wlst script: (offline mode)

readTemplate('mybasetemplate.jar')
setOption('DomainName','mydomain')
setOption('JavaHome','/home/myjdk')
setOption('ServerStartMode','prod')
writeDomain('/home/mydomains')
closeTemplate()







Online mode --> this mode is useful to access once you create domain and your domain is on started state.


connect('myuser','mypass','localhost:7001')
>cd('Servers')
>ls()
dr–- AdminServer
dr–- ServerA
>cd('ServerA')
>ls()
dr–- Log
dr–- SSL
-r–- ListenPort   7011
-r–- StartupMode  RUNNING
>cd('Log/ServerA/StdoutFilter')

---------------------------------------------------------------------------------------------------------
How to start and stop admin server using Wlst script:

    nmConnect('weblogic','12345678','localhost','5556','test','/root/Oracle/Middleware/user_projects/domains/test','plain');
    nmKill('AdminServer');
    nmDisconnect();
    exit();

or
connect('weblogic','weblogic','t3://wls-sysadm.example.com:7001')
ls('Servers')
shutdown('MedRecSvr1')
shutdown('MedRecAdmSvr')
exit()
---------------------------------------------------------------------------------------------------------
    nmConnect('weblogic','12345678','localhost','5556','test','/root/Oracle/Middleware/user_projects/domains/test','plain');
    nmStart('AdminServer');
    nmDisconnect();
    exit();

-----------------------------------------------------------------------------------------------------
How to save password into your remote managed server using nodemanager:

connect('username','passwd','url')
 nmConnect('username','passwd','nmhost','nmport','domain name','domain path','type')
nmEnroll('domain path')
------------------------------------------------------------------------------------------------------

How to create Managed serverusing wlst:

java weblogic.WLST
wls:/offline> connect('weblogic','mypassword','t3://localhost:7020')
 Connecting to t3://localhost:7020 with userid weblogic ...
 Successfully connected to Admin Server 'MedRecAdmSvr' that belongs to domain 'MedRecDomain'.
wls:/MedRecDomain/serverConfig> cd('Servers')
wls:/MedRecDomain/serverConfig/Servers> edit()
wls:/MedRecDomain/edit> startEdit()
wls:/MedRecDomain/edit !> server1=create('MedRecSvr3','Server')
 MBean type Server with name MedRecSvr3 has been created successfully.
wls:/MedRecDomain/edit !> server1.getName()
 'MedRecSvr3'
wls:/MedRecDomain/edit !> ls('Servers')
 drw-   MedRecAdmSvr
 drw-   MedRecSvr1
 drw-   MedRecSvr2
 drw-   MedRecSvr3
wls:/MedRecDomain/edit !> save()
wls:/MedRecDomain/edit !> activate()
wls:/MedRecDomain/edit !> stopEdit()
wls:/MedRecDomain/edit> exit()
[oracle@wls-sysadm /]$

--------------------------------------------------------------------------------------------------------------
Creating managed server using wlst scripting.

wls:/mydomain/edit> startEdit()
wls:/mydomain/edit !> create('MedRecMch3','Machine')
wls:/mydomain/edit !> save()
----------------------------------------------------------------------------------------------------------------

How to deploy using wlst script:


connect('myuser','mypass1','t3://adminserver:7001')
name = "HRServices"
location = "/usr/myapplications/HRServices.ear"

deploy(name, location, targets='serverA')


distributeApplication(location, targets='serverA')
startApplication(name)
redeploy(name)
stopApplication(name)
listApplications()