[Mr. Zhao Qiang] using WLST tool of Weblogic

Time:2021-6-9

[Mr. Zhao Qiang] using WLST tool of Weblogic

1、 What is Weblogic WLST?

Weblogic scripting tool (WLST) is a command-line scripting interface, which is used by system administrators and operators to monitor and manage WebLogic Server instances and domains. WLST provides the following functions:

  • New WLS domain
  • Check and update WLS domain
  • Configure deployment applications
  • Gets the statistics of the runtime server

2、 Working mode and startup of WLST

(1) Online mode

characteristic:

  • Connect to a running server
  • Access to all WLS configuration and runtime properties
  • Create and activate change sessions (similar to using the console)

(2) Offline mode

characteristic:

  • Domain not started
  • Only persistent domain configuration (config. XML) can be accessed
  • Create or update domains (similar to using the configuration wizard)

(3) Start WLST script tool

  • Execute script command: wlst.sh
  • Execute Java program: Java weblogic.wlst (need to call setdomainenv to set environment variable in advance)

3、 Basic command of WLST

(1) Online help

[Mr. Zhao Qiang] using WLST tool of Weblogic

(2) Offline command

[Mr. Zhao Qiang] using WLST tool of Weblogic

Example:

① Open an existing domain on the file system
readDomain('/home/oracle/Oracle/Middleware/user_projects/domains/base_domain')

You can also use variables:
base_domain='/home/oracle/Oracle/Middleware/user_projects/domains/base_domain'
readDomain(base_domain)
After opening the domain, you can browse the structure information of the domain, that is, config.xml.

② Create domain
Syntax: create domain (domaintemplate, domaindir, user, password)

③ Open an existing domain template
readTemplate('/home/oracle/Oracle/Middleware/wlserver_10.3/common/templates/domains/wls.jar')

④ Create a template for the domain
Step 1: open an existing template
Step 2: modify the template
Step 3: save the template

eg:
readTemplate('/home/oracle/Oracle/Middleware/wlserver_10.3/common/templates/domains/wls.jar')
create('newServer','Server')
cd('Servers')
ls()
writeTemplate('/home/oracle/mytemplate.jar')

(3) Online command

[Mr. Zhao Qiang] using WLST tool of Weblogic

In the following example, we change the domain mode to production mode, and create a managed server MS2.

connect('weblogic','welcome1','t3://localhost:7001')
get('ProductionModeEnabled')
edit()
startEdit()
set('ProductionModeEnabled',Boolean(true))
isRestartRequired()
cd('Servers')
create('ms2','Server')
showChanges()
save()
activate()

[Mr. Zhao Qiang] using WLST tool of Weblogic