Weblogic Admin and Managed servers as a Windows service

0 0
Read Time:7 Minute, 2 Second

When running a Weblogic server and its managed servers I have heard at multiple projects that there is a need of automatic startup of these server processes. There is not default an options to create a windows service when installing Weblogic and for example SOA Suite. The one option that is available is to create a windows service for the node manager.

This small guide will show how to create a windows service for the Weblogic AdminServer, the node manager and the Managed server and setting up the evironment settings. For creating the Windows services a tool called NSSM (the Non-Sucking Service Manager) is used.

Weblogic as a windows service
Weblogic as a windows service

Scroll to: Change DomainEnv script | AdminServer start script | Windows Service | Node manager | Managed Servers | Delayed Start

Change SOADomainEnv script

First we are going to change the setSOADomain.env script. The reason for this is we want to be in control about the memory settings of the JVM just like we can with the node manager. The node manager uses the settings which can be configured via the Weblogic console, but when starting a managed server with the OS start script it won’t pick those up. We want to be in control by setting the environment variable USER_MEM_ARGS in advance.

This script can be found on the following location: {ORACLE_HOME}\middleware\user_projects\domains\{WL_DOMAIN}\bin.

Change following piece of code from:

...
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
  set USER_MEM_ARGS=%PORT_MEM_ARGS%
) else (
  set USER_MEM_ARGS=%DEFAULT_MEM_ARGS%
)
...

To:

...
if "%USER_MEM_ARGS%"=="" (
  if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    set USER_MEM_ARGS=%PORT_MEM_ARGS%
  ) else (
    set USER_MEM_ARGS=%DEFAULT_MEM_ARGS%
  )
)
...

Prepare AdminServer start script

For starting the AdminServer we create a new batch script, i.g. service_AdminServer.cmd, with the following content:

set USER_MEM_ARGS=-Xms256m -Xmx640m -XX:PermSize=256m -XX:MaxPermSize=512m
call C:\oracle\middleware\user_projects\domains\soadomain\bin\startWebLogic.cmd

This script sets the USER_MEM_ARGS to override the default settings of the weblogic AdminServer. It sets the min & max Heap space and PermSize and calls the startWeblogic script (value depends environment).

This script is also placed in: {ORACLE_HOME}\middleware\user_projects\domains\{WL_DOMAIN}\bin

Create AdminServer as Windows service

The AdminServer start script, service_AdminServer.cmd, can now be registered as a windows service. For this we use a tool called NSSM. Which stands for the Non-Sucking Service Manager. This program can be downloaded from: http://nssm.cc/.
It can be run by starting it via the command-line.

Usage: nssm {option} [args]

To show service installation GUI:
  nssm install [{servicname}]

To install a service without confirmation:
  nssm install {servicename} {app} [{args}]

To show service removal GUI:
  nssm remove [{servicname}]

To remove a service without confirmation:
  nssm remove {servicname} confirm

example gui: nssm install "Oracle soadomain AdminServer"
example cmd: nssm install "Oracle soadomain AdminServer" "D:\oracle\middleware\user_projects\domains\soadomain\bin\service_AdminServer.cmd"
Install Weblogic Server as Windows Service (NSSM)
Install Weblogic Server as Windows Service (NSSM)

The created Windows service name is in this example Oracle soadomain AdminServer.

When running the Weblogic Adming server in production mode, the boot.properties need to know the username and password of the weblogic server. More info about that further down this page.

When the Windows service is stopped, only that weblogic server (Java process) is killed. Other weblogic servers need to be stopped using the Weblogic console, or using the process explorer, but a better solution is to create a Windows service per Weblogic (managed) server and stop all services.

Node Manager as a service

When only running the Weblogic Admin server as a windows service, then the Node Manager can be used to start the managed servers using the Weblogic console. De Node Manager can be started using the startup script {ORACLE_HOME}\Middleware\wlserver_10.3\server\bin\startNodeManager.cmd, but since we want to use Windows services for the entire environment the node manager can be installed as a windows service by running the included script {ORACLE_HOME}\Middleware\wlserver_10.3\server\bin\installNodeMgrSvc.cmd.

The created Windows service name is something like Oracle Weblogic nodeManager (C_oracle_middleware_wlserver_10_3).

When using Windows services you can still use the Node Manager to stop/start/restart a Managed server. When using the Node Manager to do more complicated configurations when starting the Managed server then I would only recommend to start the Weblogic Admin server as a Windows service. Edwin Biemond wrote a blog about starting Managed services in the background using the Node Manager.

Managed Servers as services

Managed services can be started using the Weblogic console when the Node Manager is running, but because we want to start the Managed servers when the machine is rebooted, we need to create one new Windows service per Weblogic Managed server.

Prepare boot.properties

If a Manager server is started using the Weblogic console then the username and password is passed, by the Node Manager, to the startup script of the Managed server. When starting the Managed server using a Windows service it need to be done in another way. It is possible to pass them by using environment variables i.g the WLS_USER and WLS_PW variable, but it is much cleaner to do this using the boot.properties file.

The boot.properties file includes a encoded username and password. Create a file named boot.properties in the folder {domain}\servers\AdminServer\security. It is possible that the file already exists.

C:\Oracle\Middleware\user_projects\domains\soadomain\servers\AdminServer\security

If the directory does not exist then it needs to be created. The file needs to include two properties.

username={AES}n+VikQNyvcBQOhxZA7uIQQZYQxEpJ0p6dKYcFpVQzaY=
password={AES}5pfuhmLQInk+NGdcQSIYzIl32JGvD329pT5xaa6o35g= 

Or in case the properties are encoded with a 3DES encryption:

username={3DES}fBq5uqh14+VrMAAwJLq5Cg==
password={3DES}fBq5uqh14+VrMAAwJLq5Cg== 

The encoded values can be created in the following way.

  • Start a command prompt.
  • Navigate to the bin folder of the domain.
    cd \oracle\middleware\user_projects\domains\soadomain\bin
  • Setup the environment by using: setDomainEnv.cmd.
  • Generate the code using: java weblogic.security.Encrypt {tekst}.
    java weblogic.security.Encrypt weblogic

    Repeat this fot the password.

The boot.properties file needs to be copied to the security directory of the Managed Servers. If the security directory does not exist then it needs to be created.

Prepare soa_server1 start script

Just like the AdminServer per Managed Server there should be a startup script that the Windows service will call. For example there is a SOA Suite server installed as soa_server1. For this server we create a script called service_soa_server1.cmd with the following content:

set USER_MEM_ARGS=-Xms1024m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m
call D:\oracle\middleware\user_projects\domains\soadomain\bin\startManagedWebLogic.cmd soa_server1

This script should be placed in: {ORACLE_HOME}\middleware\user_projects\domains\{WL_DOMAIN}\bin.

Use NSSM to create a Windows service that uses the startup script for that Managed Service.

nssm install "Oracle soadomain soa_server1" "D:\oracle\middleware\user_projects\domains\soadomain\bin\service_soa_server1.cmd"

The created Windows service is now created with the name Oracle soadomain soa_server1.

Prepare osb_server1 start script

For example there is also a Oracle service bus installed as osb_server1. For this server we create a script called service_osb_server1.cmd with the following content:

call D:\oracle\middleware\user_projects\domains\soadomain\bin\startManagedWebLogic.cmd osb_server1

This script should be placed in: {ORACLE_HOME}\middleware\user_projects\domains\{WL_DOMAIN}\bin.

Use NSSM to create a Windows service that uses the startup script for that Managed Service.

nssm install "Oracle soadomain osb_server1" "D:\oracle\middleware\user_projects\domains\soadomain\bin\service_osb_server1.cmd"

The created Windows service is now created with the name Oracle soadomain osb_server1.

Delayed Start of a Windows service

Since Windows Server 2008 (Windows 7) there a new startup type for services called Automatic (Delayed Start). Services that uses this startup type are started after all Automatic services are started. Choose this startup type for the Managed Services.

When starting these services, de thread priority is set to the lowest priority level. All other action on the system will get precedence at startup before starting the delayed start services.

 


About Post Author

Robert van Molken

Robert designs and develops application integration solutions both on-premises and in the cloud. Traditionally the solutions where based on the Oracle Middleware Stack, but lately he advises solutions that use a more cloud-native or hybrid approach. Besides application integration development he is an advocate on Blockchain, IoT and Microservices. Robert is heavily involved in the developer community.He is an international speaker at conferences (CodeOne, TeqNation, Open World), author of two books, blogger, and participates in tech related Podcasts. For this effort Robert was awarded Oracle ACE Associate in 2015, Oracle ACE in 2016, and Developer Champion in 2017 (which was renewed from 2018 to Oracle Groundbreaker Ambassador).
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

3 thoughts on “Weblogic Admin and Managed servers as a Windows service

  1. Superb yaar i had followed You snippet its working fine in WIN env

    Can i have the same in AIX Env

Comments are closed.

Next Post

OTN Yathra 2013: Verkenning van de IT-sector in India

Lucas Jellema heeft voor Computable zijn ervaringen van de twee weken durende conferentie tour, Yathra 2013, samengebundeld. In het verslag ‘Verkenning van de IT-sector in India’ wordt ingegaan op de verwachtingen, vooroordelen, het algemene beeld en op de ontwikkelingen van de IT in India en schetst een beeld over de […]
%d bloggers like this: