Friday, June 07, 2013

Oracle WebLogic 11g Creating an Windows Service: Thursday, June 6, 2013



First off, let me simply state that the fact that I have to create this script is an indication of a fundamental flow in Oracle's approach.  For an example of a piece of software that does it right look at LimeSurvey.  Perhaps Oracle has done butter in 12c, but I don't think so.



Setting Up a WebLogic Server Instance as a Windows Service
  • Script
    • sets values for server-specific variables
    • calls a WebLogic master script
Am I setting up a Manage Server to run from WebLogic 

    • add a Java class and modify master script so that the MS Management console will invode the class
Will do this after I get the script up and running.

Creating a Server-Specific Script
  • sets values for variables that identify the name of the server instance and other server-specific information
  • call the master script
    • WL_HOME\server\bin\installScv.cmd
    • master script invokes beasvc utility
      • to learn more about utility - WL_HOME\server\bin\beasvc -help
  • Example script
    • {this is not a complete example}
echo off  SETLOCAL  set DOMAIN_NAME=myWLSdomain  set USERDOMAIN_HOME=d:\Oracle\Middleware\user_projects\domains\myWLSdomain  set SERVER_NAME=myWLSserver  set PRODUCTION_MODE=true  set  JAVA_OPTIONS=-Dweblogic.Stdout="d:\Oracle\Middleware\user_projects\domains\myWLSdomain\  stdout.txt" -Dweblogic.Stderr="d:\Oracle\Middleware\user_projects\domains\myWLSdomain\  stderr.txt"  set ADMIN_URL=http://adminserver:7501  set MEM_ARGS=-Xms40m -Xmx250m  call "d:\Oracle\Middleware\wlserver_10.3\server\bin\installSvc.cmd"  ENDLOCAL

These values are being set in the following files:
  • WL_HOME\user_projects\domains\<domain>\bin\startManagedWebLogic.cmd
    • DOMAIN_NAME=myWLSdomain
  • E:\Oracle\Middleware\user_projects\domains\<domain>\init-info\
    • USERDOMAIN_HOME=
The 'root' directory for the Administration server is the same as USERDOMAIN_HOME and contain the domain's configuration file.
  • What is the domain's configuration file name?
And is called 'config.xml'

OK, with this knowledge do I no know where the text file is to be stored?

I think part of the documentation is not correct.  The 'Administration Server's root directory doesn't contain the configuration file, it contains the configuration directory.

I think I want the production mode set to false for now so that it runs in development mode.

The text files needs a '.cmd' extension

The above script is only partial.

Example Java Class that Shuts Down a Server Instance
  • This basically logs into the server and tells it to shutdown.
  • Class is ServerStopper
  • Shutdown all 
They are not giving me enough information.
  • Where does this file go?
  • How is it called?
I have to go to another page to try to piece this together.

OK, let's read though the instructions again.

Setting Up a WebLogic Server Instance as a Windows Service
  • Microsoft Management console (MMC)
    • Where you start, stop and configure Windows services.
  • For every server setup as a Windows service, WebLogic Server creates a key in the Windows Registry
    • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
    • information in key used to invoke the 'weblogic.Server main class
  • MMC cannot be configured to use Node Manager to start Managed Servers
  • Node Manager's monitoring and automatic restart features cannot be used if Windows service is used to start the WebLogic Server
Setting Up a Windows Service: Main Steps
  • Create a script that sets values of server-specific variables and than calls a WebLogic Server master script
  • Are we installing Managed Server as a Windows service?
There are a lot of servers being talk about and one server can be called by more than one name.
  • Servers
    • WebLogic Server
    • Managed Server
    • Administration Server
      • Some of the naming seems to indicated this is the same as WebLogic Server
  • Do we have a Managed Server?  How do I tell if we are running a Managed Server?
    • Is is started in the WebLogic Server master script?
  • Create Java class to shutdown the service.
What is the service called?  How do i find it in the MMC?
  • I need to redirect the standard out and standard error so it can be read.
  • The Java class for graceful shutdown need to be added to the WebLogic Server master script so that the WebLogic server instance can invoke it.
  • Run the server-specific script
    • I believe this is the script that sets the server-specific variables and calls the WebLogic Server master script.
  • server-specific script
    • AdminServerWebLogicMMCService.cmd
  • located in the Administration Server's root directory
    • Where is this directory located?
      • The absolute pathname of the Administration Server's root directory is contain in the user domain home script variable (USERDOMAIN_HOME).
      • d:\Oracle\Middleware\user_projects\domains\myWLSdomain  
      • <Drive>:\Oracle\Middleware\user_projects\domains\<WLS domain>
      • WebLogic Server (WLS)
  • The following commands are required to start the script:
    • SETLOCAL  
      • What does this command do?
      • http://ss64.com/nt/setlocal.html
        • controls the visibility of environment variables
        • causes script to inherit all current variables from the master environment/session
        • ENDLOCAL  restore the variable to the state when SETLOCAL was called.
    • set DOMAIN_NAME=domain-name  
      • The name of the WebLogic Server domain
      • domain-name is <my domain>
    • set USERDOMAIN_HOME=absolute-pathname  
      • The absolute pathame of the Administration Server's root directory.
      • This is a bit confusing to me because the name seems to the path  to the WLS domain name; however, the name of the server is AdminServer.  Is the administration server the WebLogic server?  Can there be more that one WebLogic server running at a time?
    • set SERVER_NAME=server-name  
      • This name in both the incomplete example script and in my install is 'AdminServer'.
        • Where did is set this?
        • Can there be more than one of these types of servers?
  • The following command are optional.  However, I don't see how that can be 'optional' in normal circumstances where you have a server you that you must log into which seems to be the default install.
    • set WLS_USER=username

    • set WLS_PW=password  
      •   This user name and password are set in the install and by default the user name is 'weblogic'.  I don't think there is a default password.
      • These login credentials are encrypted and stored in the Windows registry.  However, they are is simple text in the server specific script.
    • set PRODUCTION_MODE=[true]  
      • Should leave this off while getting the script running so I have more debug info.
    • set JAVA_OPTIONS=java-options  
      • I believe that I use the one from the example as long as I update the path.
    • set JAVA_VM=-JVM-mode  
      • I believe that I can omit this and let Java use its default
    • set MEM_ARGS=[-XmsNumberm] [-XmxNumberm]  
      • Use the values from the example
    • I think I can leave out the connection retries, ip address and port number
  • The following command are required to end the script
    • call "WL_HOME\server\bin\installSvc.cmd"  
      • I need to put the complete path name
    • ENDLOCAL  
      • causes the environment variables to be restore to there state when SETLOCAL was called.
Ok, now that I have the script written, how do I test it?

Configuring a Connection to the Administration Server
  • Managed Server as a window service
  • location of the domain's Administration Server
  • Managed Server contacts the Administration Server to get configuration data.
  • Administration Server is not a service.
    • I thought that this is what I was the service I am creating.

Configuring Managed Server Connections to the Administration Server
  • How do I start the Administration Server in a shell or command line?
  • Starting and Stopping Servers
  • There are two conditions that I have to do this
    • starting a Managed Server
    • invoking the java weblogic.Server  command directly
  • I am not doing either of those, so I should be off the hook
It seems like the Admin Server and the WebLogic Server are two different things.

Verifying the Setup
  • veirfy that I have successfully set up a WebLogic server as a Windows service
    • Open a command window and set the path variable to server bin
      • set PATH=WL_HOME\server\bin;%PATH%  
    • Navigate to the directory immediately above you domain directory.
      • MW_HOME\user_domains\mydomain  to MW_HOME\user_domains  
    • Execute the beasvc command
      • beasvc -debug "yourServiceName  
How do I determine the service name?

Looking for the beasvc command in script.

Didn't find.

Searching the web brings me back to the above pages.

I am going to assume that it is the name of the server in the SERVER_NAME variable in the server specific script.

How does the above command verify anything?



No comments: