lunedì 24 ottobre 2016

WebLogic Cluster & Load Balancer: Example with WebLogic Plug-In on Apache HTTP Server


I have used on Windows 10 x64 :
I assume that you have already Installed and Configured a Cluster (Traditional or Dynamic) on WLS.

In my examples I have created a Dynamic Cluster with 2 Managed Server (Maximum of 8) and the 2 Active Managed Server are:
FabryManaged-1: fmarini-it.it.oracle.com:7101
FabryManaged-2: fmarini-it.it.oracle.com:7102

It is recommended to enable the WLS settings "WebLogic Plugin Enabled":
http://www.ateam-oracle.com/wls-plugin-enabled/

Install now Apache Http Server:
it is very simple, on windows you must only unzip the file.

Now unzip the content of the file WLSPlugin12.2.1.1.0-Apache2.2-Apache2.4-Win64-12.2.1.1.0.zip inside a folder.

I have installed Apache in  d:\Apache24 and I have unzipped the plugin in the folder d:\Apache24\WLS-PLUGIN\


This is the content extracted from WLSPlugin12.2.1.1.0-Apache2.2-Apache2.4-Win64-12.2.1.1.0.zip:


I have created a startApache.cmd file where I have added d:\Apache24\WLS-PLUGIN\lib\ to the PATH envinroment variable:



Now we must modify the httpd.conf that is in the folder: d:\Apache24\conf:
- We must add the WebLogic plugin
- We must add the information of the WebLogic Cluster:

LoadModule weblogic_module d:\Apache24\WLS-PLUGIN\lib\mod_wl_24.so  
 <IfModule weblogic_module>  
   <Location />  
    SetHandler    weblogic-handler  
    WebLogicCluster fmarini-it.it.oracle.com:7101,fmarini-it.it.oracle.com:7102  
   </Location>  
 </IfModule>  


Now start everything, WebLogic Admin, your Cluster and Apache, deploy something on the cluster and test it, in my example I have deployed MyApp.war on a Dynamic cluster that is composed by 2 managed server (and 8 as max), and I can test MyApp pointing directly to each one of the Managed Server:

http://fmarini-it.it.oracle.com:7101/MyApp
http://fmarini-it.it.oracle.com:7102/MyApp

To test if the Apache & the Weblogic PlugIn are correctly configured, you can try to call your deployed App pointing directly on Apache: (In my test I have started everything on a single machine):

http://localhost/MyApp

You must remember that in httpd.conf file you have only defined 2 Managed Server that at he moment are part of the Dynamic Cluster.

Those 2 Managed are defined "Cluster Master" and they are responsible to create/maintain & update the Dynamic Server List that WebLogic send to the WebLogic PlugIn:

DynamicServerList (default ON)
WebLogicCluster is only a starting point for the dynamic server list that the server and plug-in maintain
This server list is dynamically updated for every request
If set to OFF:
The plug-in only uses the static list specified with the WebLogicCluster parameter
If one or more servers in the static list fails, the plug-in could waste time trying to connect to a dead server, resulting in decreased performance.
If you add a new server to the cluster, the plug-in cannot proxy requests to the new server unless you redefine this parameter. WebLogic Server automatically adds new servers to the dynamic server list when they become part of the cluster.

Important Points:
  • WLS sends the dynamic server list as a part of a response to the proxy (example Apache) NOT to the client
  • Only the cluster master would send the list after collecting the details which servers are up and read to servers client request, NOT each servers sends the list.
  • If you Shutdown or Create and Start new Managed Server (also not defined in WebLogicCluster parameter of the httpd.conf file) the oldest Active Managed Server is always the Cluster Master
Try to put DebugConfigInfo  On (Disable It on Production Environment) inside the httpd.conf file, like this:

<IfModule weblogic_module>  
   <Location />  
    SetHandler    weblogic-handler  
    WebLogicCluster fmarini-it.it.oracle.com:7101,fmarini-it.it.oracle.com:7102  
    DebugConfigInfo On  
   </Location>  
 </IfModule>  

Now try to call your Application adding in the URL this parameter:
?__WebLogicBridgeConfig

In my case, if I call:
http://localhost/MyApp?__WebLogicBridgeConfig

I receive this output in the Browser:

WebLogic Server Plugin version 12.2.1.1.0, <WLSPLUGINS_12.2.1.1.0_WINDOWS.X64_160606.1942>
Query String: '?__WebLogicBridgeConfig'
WebLogic Cluster List:
  1. Host: '192.168.56.1' Port: 7101 SecurePort: 0 *Primary*
WLRetryAfterDroppedConnection: 'ALL'
WLRetryOnTimeout: 'NONE'
    General Server List:
    1. Host: '192.168.56.1' Port: 7101 SecurePort: 0 Status: OK
    2. Host: '192.168.56.1' Port: 7102 SecurePort: 0 Status: OK
    ConnectRetrySecs: '2'
    ConnectTimeoutSecs: '10'
    WLCookieName: JSESSIONID
    DebugConfigInfo: 'ON'
    DefaultFileName: ''
    DisableCookie2Server: OFF
    DynamicServerList: 'ON'
    ErrorPage: ''
    FileCaching: ON
    Idempotent: ON
    KeepAliveEnabled: ON
    KeepAliveSecs: 20
    MaxPostSize: 0
    MaxSkipTime: '10'
    PathPrepend: ''
    PathTrim: ''
    QueryFromRequest: OFF
    WLForwardUriUnparsed: OFF
    WLAllowDoubleEscapedURI: OFF
    SecureProxy: 'OFF'
    StatPath: 'false'
    WLDNSRefreshInterval: '0'
    WLIOTimeoutSecs(old name is HungServerRecoverSecs): '300'
    WLSocketTimeoutSecs: '2'
    WLProxySSL: OFF
    WLProxyPassThrough: OFF
    WLProxySSLPassThrough: OFF
    WLServerInitiatedFailover: ON
    WLMaxWebSocketClients: 32

    Runtime statistics:


    • requests: 7
    • successful requests: 6
    • Exception objects created: 7
    • Exception Objects deleted: 14
    • URL Objects created: 5
    • URL Objects deleted: 4
    • connections recycled: 0
    • UNKNOWN_ERROR_CODE exceptions: 0
    • CONNECTION_REFUSED exceptions: 7
    • CONNECTION_TIMEOUT exceptions: 0
    • READ_ERROR_FROM_CLIENT exceptions: 0
    • READ_ERROR_FROM_SERVER exceptions: 0
    • READ_ERROR_FROM_FILE exceptions: 0
    • WRITE_ERROR_TO_CLIENT exceptions: 0
    • WRITE_ERROR_TO_SERVER exceptions: 0
    • WRITE_ERROR_TO_FILE exceptions: 0
    • READ_TIMEOUT exceptions: 0
    • WRITE_TIMEOUT exceptions: 0
    • UNKNOWN_HOST exceptions: 0
    • NO_RESOURCES exceptions: 0
    • PROTOCOL_ERROR exceptions: 0
    • CONFIG_ERROR exceptions: 0
    • FAILOVER_REQUIRED exceptions: 0
    • POST_TIMEOUT exceptions: 0
    • REQUEST_ENTITY_TOO_LARGE exceptions: 0
    • HALF_OPEN_SOCKET_RETRY exceptions: 0
    • BAD_REQUEST_FROM_CLIENT exceptions: 0
    • UNKNOWN_ERROR_CODE exceptions: 0
    ---------------------------------------------------------------------------------------------------------------------

    If you are using Apache 2.4 on Windows NT follow this suggestion:

    Nessun commento:

    Posta un commento