4 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" inManaging Server Startup and Shutdown for Oracle WebLogic Server.

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 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 the Node Manager Administrator's Guide 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 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 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 WebLogic Scripting Tool Command Reference.

  • 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 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 WebLogic Scripting Tool Command Reference.

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 "General Node Manager Configuration" in the Node Manager Administrator's Guide for Oracle WebLogic Server.

  2. 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 for Oracle WebLogic Server.

    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" in WebLogic Scripting Tool Command Reference.

  3. Start WLST.

    java weblogic.WLST
    
  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('weblogic', 'welcome1', '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" in WebLogic Scripting Tool Command Reference.

  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 WebLogic Scripting Tool Command Reference.

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 "General Node Manager Configuration" in the Node Manager Administrator's Guide for Oracle WebLogic Server.

  2. 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 for Oracle WebLogic Server

    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" in WebLogic Scripting Tool Command Reference.

  3. Start an Administration Server.

  4. 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" in WebLogic Scripting Tool Command Reference.

  5. 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" in WebLogic Scripting Tool Command Reference.

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 for Oracle WebLogic Server.

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.

    For more information, see Chapter 3, "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.

    By default, this directory is MW_HOME\user_projects\domains\domain_name, where MW_HOME is the top-level installation directory of Oracle WebLogic products.

  4. Set up your environment by running one of the following scripts:

    • bin\setDomainEnv.cmd (Windows)

    • bin/setDomainEnv.sh (UNIX)

    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 by entering: java weblogic.WLST

    The WLST prompt appears.

    wls:/(offline)>
    
  6. 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" in WebLogic Scripting Tool Command Reference.

    For example,

    wls:offline/>startServer('AdminServer','mydomain','t3://localhost:7001',
    'weblogic','welcome1','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" in WebLogic Scripting Tool Command Reference. 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 WebLogic Server through the following server states: RUNNING->ADMIN->RUNNING->SHUTDOWN.

Start WebLogic Server before running this script. See Invoking WLST.

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