Before You Begin
Purpose
Time to Complete
Background
This tutorial introduces you to WLST. It gives you a chance to practice basic commands and to change server attributes from the command line.
What Do You Need?
You should have completed the following Oracle by Example tutorials:
-
WebLogic Server 12c (12.2.1): Installing WebLogic Server Using the Generic Installer
-
WebLogic Server 12c (12.2.1): Creating and Starting a Basic Domain
- . This tutorial assumes that Oracle WebLogic Server 12c (12.2.1) has been installed successfully.
Running WLST in Interactive Mode
The administration server does not have to be running to access WLST. However, in this tutorial, because WLST connects to the administration server, it must be running.
To run WLST in interactive mode, perform the following steps:
- If the administration server of the domain is
not already running, open a Terminal window and
navigate to the domain directory for this
tutorial:
$ cd /scratch/u01/app/fmw/user_projects/domains/mydomain
- At the prompt, enter the following command:
$ ./startWebLogic.sh
- At the prompt, enter the domain administrator's
credentials.
Enter username to boot WebLogic server:weblogic
Enter password to boot WebLogic server:<welcome1>Note:The password is not visible for security reasons.
- In a new Terminal window, navigate to middleware
home for this tutorial:
$ cd /scratch/u01/app/fmw/
- Change the directory:
$ cd oracle_common/common/bin
- Run the wlst.sh script.
$ ./wlst.sh
Initializing WebLogic Scripting Tool (WLST) ... Welcome to WebLogic Server Administration Scripting Shell Type help() for help on available commands wls:/offline>If you are accessing WLST for the first time, Jython scans the Java Archive (JAR) files that the WLST depends on before the welcome message and the WLST offline prompt are displayed.
Changing a Server Property
To change a server property by using WLST in interactive mode, perform the following steps:
- At the WLST prompt, enter the following command
to connect to the running administration server:
Replace the sample argument values with those that match your domain environment. In this tutorial, the command is:wls:/offline>connect('<USERNAME>','<PASSWORD>','t3://<ADMIN_HOST>:<ADMIN_PORT>')
wls:/offline>connect('weblogic','welcome1','t3://localhost:7001')
Connecting to t3://localhost:7001 with userid weblogic ... Successfully connected to Admin Server "AdminServer" that belongs to domain "mydomain". Warning: An insecure protocol was used to connect to the server. To ensure on-the-wire security, the SSL port or Admin port should be used instead. wls:/mydomain/serverConfig/>
Note: WLST always uses the t3 (or t3s) proprietary protocol to connect to a server.
- Change to edit mode:
wls:/mydomain/serverConfig/>edit() Location changed to edit tree. This is a writable tree with DomainMBean as the root. To make changes you will need to start an edit session via startEdit(). For more help, use help('edit').
wls:/mydomain/edit/> - Start an edit session to lock the configuration:
wls:/mydomain/edit>startEdit() Starting an edit session ... Started edit session, be sure to save and activate your changes once you are done. wls:/mydomain/edit/ !>
- Change to the Log directory of your
administration server:
wls:/mydomain/edit!>cd('Servers/<SERVER_NAME>/Log/<SERVER_NAME>')
Replace the sample argument values with those that match your domain environment. In this tutorial, the command is:
wls:/mydomain/edit!>cd('Servers/AdminServer/Log/AdminServer') wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer !>
- Set the
FileCount
property of the administration server log file to8
, and then use thels()
command to check whether the server property was changed.wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer!>set('FileCount','8') wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer !>
wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer!>ls() dr-- DomainLogBroadcastFilter dr-- LogFileFilter dr-- MemoryBufferFilter dr-- StdoutFilter -rw- BufferSizeKB 8 -rw- DateFormatPattern MMM d, yyyy h:mm:ss a z -rw- DomainLogBroadcastFilter null -rw- DomainLogBroadcastSeverity Notice -rw- DomainLogBroadcasterBufferSize 10 -r-- DynamicallyCreated false -rw- FileCount 8 -rw- FileMinSize 5000 -rw- FileName logs/AdminServer.log -rw- FileTimeSpan 24 -r-- Id 0 -rw- Log4jLoggingEnabled false -rw- LogFileFilter null -rw- LogFileRotationDir null -rw- LogFileSeverity Trace -rw- LogMonitoringEnabled true -rw- LogMonitoringIntervalSecs 30 -rw- LogMonitoringThrottleMessageLength 50 -rw- LogMonitoringThrottleThreshold 1500 -rw- LoggerSeverity Info -rw- LoggerSeverityProperties null -rw- MemoryBufferFilter null -rw- MemoryBufferSeverity Trace -rw- MemoryBufferSize 500 -rw- Name AdminServer -rw- Notes null -rw- NumberOfFilesLimited true -rw- PlatformLoggerLevels null -rw- RedirectStderrToServerLogEnabled false -rw- RedirectStdoutToServerLogEnabled false -rw- RotateLogOnStartup false -rw- RotationTime 00:00 -rw- RotationType bySize -rw- ServerLoggingBridgeUseParentLoggersEnabled false -rw- StdoutFilter null -rw- StdoutFormat standard -rw- StdoutLogStack true -rw- StdoutSeverity Notice -rw- Tags null -r-- Type Log -r-x addTag Boolean : String(tag) -r-x freezeCurrentValue Void : String(attributeName) -r-x getInheritedProperties String[] : String[](propertyNames) -r-x isInherited Boolean : String(propertyName) -r-x isSet Boolean : String(propertyName) -r-x removeTag Boolean : String(tag) -r-x restoreDefaultValue Void : String(attributeName) -r-x unSet Void : String(propertyName) wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer !>
-
Save and activate the changes:
wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer!>save() Saving all your changes ... Saved all your changes successfully. wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer !>
wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer!>activate() Activating all your changes, this may take a while ... The edit lock associated with this edit session is released once the activation is completed. Activation completed wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer>
Shutting Down the Administration Server
To shut down the administration server of the domain by using WLST in interactive mode, perform the following steps:
- At the WLST prompt, enter the following
command:
wls:/mydomain/edit/Servers/AdminServer/Log/AdminServer>shutdown() Shutting down the server AdminServer with force=false while connected to AdminServer ... Disconnected from weblogic server: AdminServer WLST lost connection to the WebLogic Server that you were connected to. This may happen if the server was shut down or partitioned. You will have to re-connect to the server once the server is available. Disconnected from weblogic server: AdminServer wls:/offline>
Note: By default, the WLST shutdown() command shuts down the server to which it is connected.
- At the prompt, enter the following command to
exit WLST:
wls:/offline> exit() Exiting WebLogic Scripting Tool. $
Want to Learn More?
-
For documentation on Oracle WebLogic Server 12c (12.2.1), visit the Oracle WebLogic Server Documentation Library.
-
For more information on the WebLogic Scripting Tool, see the WLST Command Reference for WebLogic Server document.
-
To learn more about Oracle WebLogic Server, refer to additional OBEs in the Oracle Learning Library
Credits
- Lead Curriculum Developer: Tom Eliason, Veerabhadra Rao Putrevu
- Other Contributors: Susan Moxley
Version
- 01-32-001-UsingWLST