Friday, April 13, 2012

How to Force Shutdown WebLogic Managed Server

WebLogic Server (WLS) provides several ways to start and stop server instances[1]. The method that you choose depends on whether you prefer using the Administration Console or a command-line interface, and on whether you are using Node Manager to manage the server's life cycle.

In this article, we will show you how to force shutdown WLS Managed Server from the command-line. This may come in handy when your WLS Managed Servers have stuck threads and will take you minutes to connect to it using the Console. Also, you don't care about dropping any user sessions. For example, in our case, we are just running some performance benchmarks.

stopManagedWebLogic.sh

You can stop WLS Managed Server using stopManagedWebLogic.sh script provided in your domain:
  • <domain_path>/bin
Note that the environment we demonstrate here is in Linux.  The syntax of the command is:
  • DOMAIN_NAME/bin/stopManagedWebLogic.sh managed_server_name admin_url username password
For example, we use:
  • ./stopManagedWebLogic.sh CRMDemo_server1 t3://<machine_name>:7001 weblogic weblogic1
However, the default setting is not FORCE SHUTDOWN as shown in the following output line:

Shutting down the server CRMDemo_server1 with force=false while connected to AdminServer ...

stopWebLogic.sh

stopManagedWebLogic.sh actually invokes stopWebLogic.sh indirectly as shown here:

 ${DOMAIN_HOME}/bin/stopWebLogic.sh $1 $2

To make it shutdown forcibly, you need to modify the following line in the stopWebLogic.sh from:
  • echo "shutdown('${SERVER_NAME}','Server', ignoreSessions='true')" >>"shutdown.py"
to
  • echo "shutdown('${SERVER_NAME}','Server', ignoreSessions='true', force='true')" >>"shutdown.py"
Note that WLST shutdown command[2] is used to do the work in the script.

Sample Output

After changing the script file, we re-execute the command and here is the sample output:
Stopping Weblogic Server...

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://<machine_name>:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'xxxx'.

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.

Shutting down the server CRMDemo_server1 with force=true while connected to AdminServer ...
......................................................
Exiting WebLogic Scripting Tool.

Done
Stopping Derby Server...

Stopping Admin Server

Because our change was done in stopWebLogic.sh, if you want to shutdown Admin Server, it also becomes FORCE SHUTDOWN as shown below:

$ ./stopWebLogic.sh
Stopping Weblogic Server...
Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Please enter your username :weblogic
Please enter your password :
Connecting to t3://<server_name>:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'atgdomain'.

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.

Shutting down the server AdminServer with force=true while connected to AdminServer ...
WLST lost connection to the WebLogic Server that you were
connected to, this may happen if the server was shutdown or
partitioned. You will have to re-connect to the server once the
server is available.
Disconnected from weblogic server: AdminServer
Disconnected from weblogic server:


Exiting WebLogic Scripting Tool.

Done
Stopping Derby Server...

Conclusion

Be warned that:
  • If you force shutdown server instances, the server immediately stops all processing. Therefore, any pending session data may be lost. 
  • Each WebLogic Server instance runs in its own JVM. If you are unable to shut down a server instance using the methods described, you can use an operating system command to kill the JVM.  However, if you kill the JVM for an Administration Server while the server is writing to the config.xml file, you can corrupt the config.xml file.

References

  1. Oracle® Fusion Middleware Managing Server Startup and Shutdown for Oracle WebLogic Server 11g Release 1 (10.3.4)
  2. WLST Command and Variable Reference
  3. Starting and Stopping Fusion Applications the Right Way (Oracle A-Team)
  4. Oracle WebLogic Server on Docker Containers (white paper)
  5. WebLogic on Docker (GitHub)
    • Sample Docker configurations to facilitate installation, configuration, and environment setup for DevOps users. This project includes quick start dockerfiles and samples for both WebLogic 12.1.3 and 12.2.1 based on Oracle Linux and Oracle JDK 8 (Server).

4 comments:

E.T said...

Thanks, very much.

It's really help me.

David&Monica said...

Thanks, very helpful and direct.

-David M

Kiran V said...

Thanks so much.

Blogger said...

DreamHost is one of the best hosting company for any hosting services you need.