4 Managing the Server Life Cycle

You can use the WebLogic Scripting Tool (WLST) to manage and monitor 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 Administering Server Startup and Shutdown for Oracle WebLogic Server.

For information on other techniques for starting and stopping server instances, see Starting and Stopping Servers in Administering Server Startup and Shutdown for Oracle WebLogic Server.

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 Node Manager Overview in Administering Node Manager for Oracle WebLogic Server.

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

Description of Figure 4-1 follows
Description of "Figure 4-1 Starting Servers on a Machine"

A Node Manager process may be associated with a specific WebLogic domain or it may be associated with a particular machine. If associated with a domain, you can use the Node Manager process only to control server instances in that domain. If associated with a machine, you can use the same Node Manager process to control server instances in any WebLogic 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 in Administering Node Manager for Oracle WebLogic Server. For information about Node Manager configuration, see Default Node Manager Configuration Administering Node Manager for Oracle WebLogic Server.

  • Connect to an Administration Server and then use the Administration Server to start and stop servers in the domain. See Figure 4-2.

Figure 4-2 Starting Servers in a WebLogic Domain

Description of Figure 4-2 follows
Description of "Figure 4-2 Starting Servers in a WebLogic 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 in WLST Command Reference for WebLogic Server.

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 WebLogic 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:

  1. Configure Node Manager to start servers.

    See Configuring Java Node Manager in Administering Node Manager for Oracle WebLogic Server.

  2. Start WLST.
  3. Start Node Manager.

    If Node Manager is not already running, use the startNodeManager script in either DOMAIN_HOME/bin or WL_HOME/server/bin to start it. See Starting Java-based Node Manager Using Scripts in Administering Node Manager for Oracle WebLogic Server.

  4. Connect WLST to a Node Manager by entering the nmConnect command.
    wls:/offline>nmConnect('username','password','nmHost','nmPort', 
    'domainName','domainDir','nmType')
    

    For example,

    nmConnect('adminusername', 'adminpassword', 'localhost', '5556',
    'mydomain','c:/bea/user_projects/domains/mydomain','SSL')
    Connecting to Node Manager ...
    Successfully connected to Node Manager.
    wls:/nm/mydomain>
    

    For detailed information about the nmConnect command arguments, see nmConnect in WLST Command Reference for WebLogic Server.

  5. Use the nmStart command to start a server.
    wls:/nm/mydomain>nmStart('AdminServer') 
    starting server AdminServer
    ...
    Server AdminServer started successfully
    wls:/nm/mydomain>
    
  6. Monitor the status of the Administration Server by entering the nmServerStatus command.
    wls:/nm/mydomain>nmServerStatus('serverName') 
    RUNNING 
    wls:/nm/mydomain>
    
  7. 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 in WLST Command Reference for WebLogic Server.

Using Node Manager to Start Managed Servers in a WebLogic Domain or Cluster

To start Managed Servers and clusters using Node Manager:

  1. Configure Node Manager to start servers.

    See Configuring Java Node Manager in Administering Node Manager for Oracle WebLogic Server.

  2. Start WLST.
  3. Start Node Manager.

    If Node Manager is not already running, use the startNodeManager script in either domain_home/bin or WL_HOME/server/bin to start it. For more information, see Starting Java-based Node Manager Using Scripts in Administering Node Manager for Oracle WebLogic Server.

  4. Start an Administration Server.
  5. Connect WLST to the Administration Server instance using the connect command.
    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 in WLST Command Reference for WebLogic Server.

  6. Do any of the following:
    • To start a Managed Server, enter the following command, where managedServerName is the name of the server.

      start('managedServerName','Server')

    • To start a cluster, enter the following command, where clusterName is the name of the cluster.

      start('clusterName','Cluster')

    See start in WLST Command Reference for WebLogic Server.

Starting and Managing Servers Without Node Manager

You can start and manage an Administration Server without 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 Administering Server Startup and Shutdown for Oracle WebLogic Server.

The following sections describe starting and managing server state without using the Node Manager:

Starting an Administration Server Without Node Manager

To start an Administration Server without using Node Manager:

  1. If you have not already done so, use WLST to create a WebLogic domain. See Creating WebLogic Domains Using WLST Offline.
  2. Open a shell (command prompt) on the computer on which you created the domain.
  3. Change to the directory in which you located the domain.
  4. Set up your environment by running one of the following scripts.
    • bin\setDomainEnv.cmd (Windows)

    • bin/setDomainEnv.sh (UNIX: Oracle recommends that you run this script from the Korn shell.)

    On Windows, you can use a shortcut on the Start menu to set your environment variables and invoke WLST (Tools > WebLogic Scripting Tool).

  5. Invoke WLST. See Invoking WLST.

    The WLST prompt appears.

    wls:/offline>
  6. Use the WLST startServer command to start the Administration Server.
    startServer([adminServerName], [domainName], [url], [adminusername], 
    [adminpassword],[domainDir], [block], [timeout], [serverLog], 
    [systemProperties], [jvmArgs] [spaceAsJvmArgsDelimiter])
    

    For detailed information about startServer command arguments, see startServer in WLST Command Reference for WebLogic Server.

    For example,

    wls:offline/>startServer('AdminServer','mydomain','t3://localhost:7001',
    'adminusername','adminpassword','c:/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 in Administering Node Manager for Oracle WebLogic Server. Oracle recommends that you enable and use the WebLogic domain's administration port when you connect to servers and issue administrative commands. See Securing the WLST Connection.

The commands in Example 4-1 explicitly move a server instance through the following server states: RUNNING->ADMIN->RUNNING->SHUTDOWN.

Start WebLogic Server before running this script.

Example 4-1 WLST Life Cycle Commands

# Specify the SSL arguments when starting WLST
export WLST_PROPERTIES="-Dweblogic.security.TrustKeyStore=DemoTrust,   -Dweblogic.security.SSL.ignoreHostnameVerification=true"

./wlst.sh

# Connect to the Administration Server
connect("username","password","t3://localhost:7001")

# 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")

# reconnect to the server
exit()
connect("username","password","t3://localhost:7001")

# 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")