http://jianmingli.com/wp/?p=2132
Overview
* A command line scripting tools for WebLogic domain management:
- create
- manage
- monitor
* Based on Jython
WSLT Online
* Is a JMX client
* Equivalent to Admin Console
- needs running Admin Server and active WebLogic domain
* Can
- view performance data
- manage security data
* Can NOT
- modify config data for managed servers
WSLT Offline
* Provides read/write access to config data
* Should NOT be used on active WebLogic domain (ignored/overwritten otherwise)
* Can
- create domain templates
- create a new domain based on existing templates
- extend an existing, inactive domain
* Can NOT
- view performance data
- modify security data
Command Modes
Interactice Mode
Script Mode
* Script needs .py file extension
* Can
- automate server config and application deployment
- apply same config setings across multiple nodes of a topology
- script scheduling
- automate complex procedures
- config an application in a hands free data center
Embedded Mode
* WLST interpreter is instantiated in Java code.
* WLST commands and scripts are then run from within Java code.
Secure WLST Connection
Admin Port
* WLST connects to a server instance via admin port.
* Default to 9002
* SSL enabled
Secure Access from WLST Online
* Use user name and password as defined in the active WebLogic security realm.
- From command line
connect('weblogic', 'welcome1', 'localhost:7001')
- From password file
# Prepare password files
connect('weblogic', 'welcome1', 'localhost:7001')
storeUserConfig('c:/myFiles/myuserconfigfile.secure',
'c:/myFiles/myuserkeyfile.secure')
# Use password files
connect(userConfigFile='c:/myfiles/myuserconfigfile.secure',
userKeyFile='c:/myfiles/myuserkeyfile.secure')
- Use boot.properties file
# boot.properties file in current directory
connect()
Main Steps for Using WLST in Interactive or Script Mode
Invoking WLST
* Execute the appropriate shell script for your environment.
- UNIX
cd WL_HOME/common/bin
./wlst.sh
- Windows
cd WL_HOME\common\bin
wlst.cmd
* Execute the java weblogic.WLST command.
java
[ -Dweblogic.security.SSL.ignoreHostnameVerification=true
-Dweblogic.security.TrustKeyStore=DemoTrust ]
[ -Dweblogic.security.JavaStandardTrustKeyStorePassPhrase=password]
[ -Dweblogic.security.CustomTrustKeyStoreFileName=filename
-Dweblogic.security.TrustKeystoreType=jks
[ -Dweblogic.security.CustomTrustKeyStorePassPhrase=password]]
[ -Dweblogic.security.SSL.hostnameVerifier=classname]
weblogic.WLST
[ -loadProperties propertyFilename ]
[ -skipWLSModuleScanning ]
[ [-i] filePath.py ]
- Example:
jjava weblogic.WLST c:/Oracle/Middleware/wlserver/templates/scripts/wlst/distributeQueues.py
java -Dweblogic.security.SSL.ignoreHostnameVerification=true
-Dweblogic.security.TrustKeyStore=DemoTrust weblogic.WLST
c:/Oracle/Middleware/wlserver/templates/scripts/wlst/distributeQueues.py
* Run a WLST script.
- Use Java command line:
java weblogic.WLST c:/Oracle/Middleware/wlserver/templates/scripts/wlst/distributedQueues.py
- From WLST interactive mode:
wls:offline> execfile('c:/Oracle/Middleware/wlserver/templates/scripts/wlst/distributedQueues.py')
* Execute the WebLogic Scripting Tool command from the Start menu (Windows only).
* Running WLST from Ant.
- Set env:
WL_HOME\server\bin\setWLSEnv.cmd (or setWLSEnv.sh on UNIX)
- Import task:
classname="weblogic.ant.taskdefs.management.WLSTTask" />
- Examples
fileName="./myscript.py">
fileName="./myscript.py" failOnError="true">
Exiting WLST
wls:/mydomain/serverConfig> exit()
Exiting WebLogic Scripting Tool ...
Syntax for WLST Commands
* Case sensitive.
* Enclose arguments in single or double quotes.
* Escape character: \
* String as is: r
- Example: readTemplate(r'c:\userdomains\mytemplates\mytemplate.jar')
* If you need to cd to a management object whose name includes a forward slash (/), surround the object name in parentheses.
- For example:cd('JMSQueue/(jms/REGISTRATION_MDB_QUEUE)')
Redirecting Error and Debug Output to a File
* To redirect stdout, stderr to a file:
redirect(outputFile,[toStdOutAsWell])
* Stop redirect:
stopRedirect()
* Example:
wls:/mydomain/serverConfig> redirect('./logs/wlst.log')
Getting Help
help
help('online')
help('offline')
help('get*')
Importing WLST as a Jython Module
* Invoke WLST:
c:\>java weblogic.WLST
wls:/(offline)>
* Use the writeIniFile command to convert WLST definitions and method declarations to a .py file:
wls:/(offline)> writeIniFile("wl.py")
The Ini file is successfully written to wl.py
* Open a new command shell and invoke Jython directly by entering the following command:
c:\>java org.python.util.jython
* Import the WLST module into your Jython module using the Jython import command.
>>>import wl
*Now you can use WLST methods in the module. For example, to connect WLST to a server instance:
wl.connect('username','password')
....
Customizing WLST
*
Adding Integrated Help for Custom Commands
* Define help text entries:
_ShortDescription
_Description
_Example
_Syntax
* Example:
navigate_ShortDescription=\
Lists commands for navigating the hierarchy of beans.
navigate_Description=\
\n Navigates the hierarchy of beans and controls the prompt display. \n
*
*
*
No comments:
Post a Comment