Sunday, November 29, 2015

WLS: Change JVM (JDK/JRockit) - Linux

Following post will help you to upgrade/change the JDK used by an Oracle WebLogic Server to a newer version.
  • Upgrade JDK:
  1. Make sure new JDK version is certified with Weblogic version and other products installed in the same domain.
  2. Install New JDK.
  3. Shutdown Weblogic domain
  4. Modify all occurrences of the original JDK directory path value with the new JDK directory path value for the files listed below.

  5. Note 1: Take backup of below mentioned files before change.
    Note 2: Following command will help you find list of files referring to JAVA_HOME
    find . -type f -name "*.sh" -exec grep -il JAVA_HOME {} \;

    11g:
    ----
    • MW_HOME/wlserver_10.3/common/bin/commEnv.sh
    • MW_HOME/wlserver_10.3/common/nodemanager/nodemanager.properties
    • MW_HOME/utils/bsu/bsu.sh
    • MW_HOME/utils/quickstart/quickstart.sh
    • MW_HOME/utils/uninstall/uninstall.sh
    • MW_HOME/wlserver_10.3/.product.properties
    • DOMAIN_HOME/user_projects/domains/<mydomain>/bin/setDomainEnv.sh

    12c:
    ----
    • MW_HOME/install/envVars.properties
    • MW_HOME/oracle_common/common/bin/commEnv.sh
    • MW_HOME/oracle_common/common/bin/setHomeDirs.sh
    • MW_HOME/oui/bin/compareInventory.sh
    • MW_HOME/oui/bin/install.sh
    • MW_HOME/oui/bin/viewInventory.sh
    • MW_HOME/wlserver/.product.properties
    • DOMAIN_HOME/bin/setDomainEnv.sh
    • DOMAIN_HOME/nodemanager/nodemanager.properties

  6. Clear cache and tmp folders resides in each server folder.

  7. Note: Incase Weblogic version is 10.3.6 and the targetJDK version is JAVA 7 (version 1.7.0_x),following jar files needs to be copied manually from $MW_HOME/modules to the directory $JAVA_HOME/jre/lib/endorsed

    • javax.annotation_1.0.0.0_1-0.jar
    • javax.xml.bind_2.1.1.jar
    • javax.xml.ws_2.1.1.jar

  8. Startup Weblogic domain

  9. Simple way: You can install new JDK and rename new JDK folder name to old JDK name to skip JAVA_HOME path update in all the files mentioned in step 4.
  • Change JRockit to JDK and Vice-versa:
    Refer below steps along with above mentioned JDK upgrade steps.
  1. Refer below 2 steps and update following two files as needed:
    • setDomainEnv.sh
    • commEnv.sh
  2. If you are changing from JRockit  to JDK:
  3. JAVA_HOME="/usr/bin/jdk1.6.0_31"
    JAVA_VENDOR="Sun"
    export JAVA_HOME
    export JAVA_VENDOR
  4. If you are changing from JDK  to JRockit:
  5. JAVA_HOME="/usr/bin/jrockit_28.1"
    JAVA_VENDOR="Oracle"
    export JAVA_HOME
    export JAVA_VENDOR

Refer to Oracle Security Alerts page to get latest patch updates.

Thursday, November 12, 2015

WLS: Configure Watch and Notification

Following post will help you to setup monitoring about the state of your system and send notification to selected recipients.

To set up your notification alerts you will need to cover these main steps:

1. Configure New Mail Session
2. Configure New Diagnostic Module
3. Configure New Collected Metrics
4. Configure New Notification
5. Configure New Watch rule

In the below example, we will set up alerts on the state of the Weblogic Managed Server to get an alert when a server is in the RUNNING state.

1. Configure Mail Session:
    Note: Mail sessions facilitate the process of using the JavaMail APIs, which provide applications and other J2EE modules with access to Internet Message Access Protocol (IMAP)- and Simple Mail Transfer Protocol (SMTP)-capable mail servers on your network or the Internet.

  • Go to Services -> Mail Sessions and click "New" to create a new Mail Session
  • Provide Name, JNDI Name and JavaMail Properties as follow:

Name – WLSMailAlert
JNDI Name – WLSMailAlert

JavaMail Properties:
mail.debug="true"
mail.transport.protocol=smtp
mail.smtp.user=admin
mail.smpt.password=password
mail.smtp.port=25
mail.smtp.from="admin@abc.com"
mail.smtp.host=smtp.abc.com
  • Click Next and Target the mail session to a server(s) and click finish. This is needed to expose the mail session on the servers JNDI tree.


2. Configure New Diagnostic Module
    Note: Most of the times Weblogic will have Diagnostic Module (Module-FMWDFW) configured and targeted to all servers. Below steps will help you if its not exists.
  • Go to Diagnostics -> Diagnostics Modules and click "New" to create a new diagnostics module.
  • Provide a Name and Description.

          Name – WLDMServerState
          Description – WLDF module to monitor server state

  • Select the newly created module and select "Targets" tab. Select required server(s) as Target and Save.



3. Configure New Collected Metrics
    Note: This metric is collected at a configurable interval, by default 300000ms i.e 300 sec(5 mins).  It means recipients will be notified for every 5 mins.
  • Select the newly created module "WLDMServerState" and select "Collected Metrics" tab. Click New.
  • Select "ServerRuntime" and click "Next"
  • Select "weblogic.management.runtime.ServerRuntimeMBean" from the drop down and click "Next"
  • From the list of collected attributes select "State" and shuffle it to the "Chosen" category. Click "Next"
  • From the instances list, select the required servers and shuffle to the "Chosen" category. Click "Finish"



4. Configure New Notification

  • Select the newly created module "WLDMServerState" and go to "Watches and Notifications" tab  --> "Notification" sub-tab
  • Click "New" to create a new Notification
  • Select "SMTP (E-Mail)"for Type and click "Next"
  • Provide a name – WLSServerStateAlert and Select "Enable Notification" check box. Click "Next"
  • Configure the following properties for the "SMTP Properties" page

           Mail Session Name – select "WLSMailAlert" (Created in step 1)
           E-Mail Recipients – admin@abc.com

  • Click "Finish"



5. Configure New Watch rule

  • Select the newly created module "WLDMServerState" and go to "Watches and Notifications" tab  --> "Watches" sub-tab
  • Click "New" to create a new Watch. Provide the name and select the type as "Collected Metrics". Also make sure the watch is enabled.

           Name – ServerStateWatch

  • Click "Next". Click "Add Expressions"
  • Select "ServerRuntime" and click “Next”
  • Select "weblogic.management.runtime.ServerRuntimeMBean" from the dropdown and click "Next"
  • Select the instance for the appropriate server from the list for "Instance" dropdown and click "Next"
  • Select "State" from "Message Attribute", Operator as "=", and Value as "RUNNING"
  • Click "Finish" to go back to "Create Watch" page
  • Rule value will be similar to (${ServerRuntime//[weblogic.management.runtime.ServerRuntimeMBean]com.bea:Name=adf_server1,Type=ServerRuntime//State} = 'RUNNING')
  • Click "Next" in "Create Watch" page. Select "Use an automatic reset alarm" and click "Next". (Set the "Automatic reset period" reduce mail alerts)
  • From the list of available notifications select "WLSMailAlert" and shuffle it to the "Chosen" category. Click "Finish"



Note: This Watch will be triggered every time the server state is RUNNING. And notification will be sent based on the Collected Metric’s sampling period i.e. 5 mins.

Note: Check Domain log file to find alerts related to configured watch.
Sample Domain Log:
####<Nov 11, 2015 11:03:16 PM CST> <Notice> <Diagnostics> <hostxxx.abc.com> <adf_server1> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <f50689c08d6d3474:5aefc86b:150f9d35d8e:-8000-0000000000000800> <1447304596087> <BEA-320068> <Watch 'ServerStateWatch' with severity 'Notice' on server 'adf_server1' has triggered at Nov 11, 2015 11:03:16 PM CST. Notification details:
WatchRuleType: Harvester
WatchRule: (${ServerRuntime//[weblogic.management.runtime.ServerRuntimeMBean]com.bea:Name=adf_server1,Type=ServerRuntime//State} = 'RUNNING')
WatchData: com.bea:Name=adf_server1,Type=ServerRuntime//State = RUNNING
WatchAlarmType: AutomaticReset
WatchAlarmResetPeriod: 60000

Sample Notification: