WebLogic Scripting Tool
Managing the Server Life Cycle
During its lifetime, a server can transition through a number of operational states, such as shutdown, starting, standby, admin, resuming, and running. For more information about the server life cycle, see Understanding Server Life Cycle in Managing Server Startup and Shutdown.
The following sections describe how to use WebLogic Scripting Tool (WLST) to manage and monitor the server life cycle:
For information on other techniques for starting and stopping server instances, see Starting and Stopping Servers in Managing Server Startup and Shutdown.
Using WLST and Node Manager to Manage Servers
Node Manager is a utility that enables you to control the life cycles of multiple servers through a single WLST session and a single network connection. (It can also automatically restart servers after a failure.) For more information about Node Manager, see the Node Manager Administrator's Guide.
You can use WLST to do the following with Node Manager:
- Start a Node Manager.
- Connect to a Node Manager, then use the Node Manager to start and stop servers on the Node Manager machine. See Figure 4-1. Figure 4-1 Starting Servers on a Machine
A Node Manager process is not associated with a specific WebLogic domain but with a machine. You can use the same Node Manager process to control server instances in any WebLogic Server domain, as long as the server instances reside on the same machine as the Node Manager process.
For information about the commands that WLST can use while acting as a Node Manager client, see Node Manager Commands.
- Connect to an Administration Server, then use the Administration Server to start and stop servers in the domain. See Figure 4-2. Figure 4-2 Starting Servers in a Domain
In this case, WLST is a client of the Administration Server, and the Administration Server uses one or more Node Managers to start Managed Servers.
For information about the life cycle commands that WLST can use while acting as an Administration Server client, see Life Cycle Commands.
Using Node Manager to Start Servers on a Machine
WLST can connect to a Node Manager that is running on any machine and start one or more WebLogic Server instances on the machine. A domain's Administration Server does not need to be running for WLST and Node Manager to start a server instance using this technique.
To connect WLST to a Node Manager and start servers:
- Configure Node Manager to start servers.
See General Node Manager Configuration in the Node Manager Administrator's Guide.
- Start Node Manager.
Usually, as part of configuring Node Manager, you create a Windows service or a daemon that automatically starts Node Manager when the host computer starts. See Running Node Manager as a Service in the Node Manager Administrator's Guide.
If Node Manager is not already running, you can log on to the host computer and use WLST to start it:
c:\>java weblogic.WLST
wls:/offline> startNodeManager()For more information about startNodeManager, see startNodeManager.
- Start WLST.
java weblogic.WLST
- Connect WLST to a Node Manager by entering the nmConnect command.
wls:/offline>nmConnect('username','password','nmHost','nmPort','domainName','domainDir','nmType')
For example,
nmConnect('weblogic', 'weblogic', 'localhost', '5556', 'mydomain','c:/bea/user_projects/domains/mydomain','ssl')
Connecting to Node Manager ...
Successfully connected.
wls:/nm/mydomain>For detailed information about nmConnect command arguments, see nmConnect.
- Use the nmStart command to start a server.
wls:/nm/mydomain>nmStart('AdminServer')
starting server AdminServer
...
Server AdminServer started successfully
wls:/nm/mydomain>- Monitor the status of the Administration Server by entering the nmServerStatus command.
wls:/nm/mydomain>nmServerStatus('serverName')
RUNNING
wls:/nm/mydomain>- Stop the server by entering the nmKill command.
- wls:/nm/mydomain>nmKill('serverName')
Killing server AdminServer
Server AdminServer killed successfully
wls:/nm/mydomain>For more information about WLST Node Manager commands, see Node Manager Commands.
Using Node Manager to Start Managed Servers in a Domain or Cluster
To start Managed Servers and clusters using Node Manager:
- Configure Node Manager to start servers.
See General Node Manager Configuration in the Node Manager Administrator's Guide.
- Start Node Manager.
Usually, as part of configuring Node Manager, you create a Windows service or a daemon that automatically starts Node Manager when the host computer starts. See Running Node Manager as a Service in the Node Manager Administrator's Guide.
If Node Manager is not already running, you can log on to the host computer and use WLST to start it:
c:\>java weblogic.WLST
wls:/offline> startNodeManager()For more information about startNodeManager, see startNodeManager.
- Start an Administration Server.
- If WLST is not already running, invoke it. Then connect WLST to a running WebLogic Administration Server instance using the connect command.
c:\>java weblogic.WLST
wls:/(offline)> connect('username','password')
Connecting to weblogic server instance running at t3://localhost:7001 as username weblogic ...
Successfully connected to Admin Server 'myserver' 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>
For detailed information about connect command arguments, see connect.
- Do any of the following:
- To start a Managed Server, enter the following command:
start('managedServerName','Server')where managedServerName is the name of the server. For example,
start('managed1','Server')- To start a cluster, enter the following command:
start('clusterName', 'Cluster')where clusterName is the name of the cluster. For example:
start('mycluster', 'Cluster')For more information, see start.
Starting and Managing Servers Without Node Manager
The following sections describe starting and managing server state without using the Node Manager:
If you do not use Node Manager, WLST cannot start Managed Servers. For information on other techniques for starting and stopping server instances, see Starting and Stopping Servers in Managing Server Startup and Shutdown.
Starting an Administration Server Without Node Manager
To start an Administration Server without using Node Manager:
- If you have not already done so, use WLST to create a domain.
For more information, see Creating Domains Using WLST Offline.
- Open a shell (command prompt) on the computer on which you created the domain.
- Change to the directory in which you located the domain.
By default, this directory is BEA_HOME\user_projects\domains\domain_name, where BEA_HOME is the top-level installation directory of Oracle WebLogic products.
- Set up your environment by running one of the following scripts:
- bin\setDomainEnv.cmd (Windows)
- bin/setDomainEnv.sh (UNIX)
- Invoke WLST by entering: java weblogic.WLST
The WLST prompt appears.
wls:/(offline)>
- Use the WLST startServer command to start the Administration Server.
startServer([adminServerName], [domainName], [url], [username], [password],[domainDir], [block], [timeout], [serverLog], [systemProperties], [jvmArgs] [spaceAsJvmArgsDelimiter])
For detailed information about startServer command arguments, see startServer.
For example,
wls:offline/>startServer('AdminServer','mydomain','t3://localhost:7001','weblogic','weblogic','c:/bea/user_projects/domains/mydomain','true','60000','false')
After WLST starts a server instance, the server runs in a separate process from WLST; exiting WLST does not shut down the server.
Managing Server State Without Node Manager
WLST life cycle commands enable you to control the states through which a server instance transitions. See Life Cycle Commands. Oracle recommends that you enable and use the domain's administration port when you connect to servers and issue administrative commands. See Securing the WLST Connection.
The commands in Listing 4-1 explicitly move WebLogic Server through the following server states: RUNNING->ADMIN->RUNNING->SHUTDOWN.
Start WebLogic Server before running this script. See Invoking WLST. Listing 4-1 WLST Life Cycle Commands
connect("username","password","t3://localhost:8001")# First enable the Administration Port. This is not a requirement.
# After you enable the Administration Port in a domain, WebLogic Server
# persists the setting in its configuration files. You do not need to repeat
# the process in future WLST sessions.
edit()
startEdit()
cmo.setAdministrationPortEnabled(1)
activate(block="true")# check the state of the server
state("myserver")# now move the server from RUNNING state to ADMIN
suspend("myserver", block="true")# check the state
state("myserver")# now resume the server to RUNNING state
resume("myserver",block="true")# check the state
state("myserver")# now take a thread dump of the server
threadDump("./dumps/threadDumpAdminServer.txt")# finally shutdown the server
shutdown(block="true")