Friday, 28 March 2014

Weblogic Server : How to use encrypted username & password with weblogic.Admin command instead of providing hard coded values


How to use encrypted username & password with weblogic.Admin command instead of providing hard coded values

Run belo command to generate encrypted username & password

E:\Oracle\WLS1036\user_projects\domains\base_domain>java weblogic.Admin -username weblogic -password webl0gic -userconfigfile configfile -userkeyfile keyfile STOREUSERCONFIG
Creating the key file can reduce the security of your system if it is not kept in a secured location after it is created. Do you want to create the key file? y or n  y

( when prompted enter y )


Above command will create two files with name keyfile & configfile under your domain directory, now use both as below instead of providing direct hardcoded username & password 


E:\Oracle\WLS1036\user_projects\domains\base_domain>java weblogic.Admin -url localhost:7001 -userconfigfile E:\Oracle\WLS1036\user_projects\domains\base_domain\configfile -userkeyfile E:\Oracle\WLS1036\user_projects\domains\base_domain\keyfile GETSTATE

Current state of "AdminServer" : RUNNING




Weblogic WLST : Basics


Weblogic WLST : Basics of WLST ( Weblogic Scripting Tool )


First run setDomainEnv to set classpath

E:\Oracle\WLS1036\user_projects\domains\base_domain\bin>setDomainEnv.cmd

Now run below commands to connect with WLST prompt

E:\Oracle\WLS1036\user_projects\domains\base_domain>java weblogic.WLST
Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/WLST
Caused by: java.lang.ClassNotFoundException: weblogic.WLST
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: weblogic.WLST.  Program will exit.

if you get above error then use -cp with java with full weblogic.jar in path

E:\Oracle\WLS1036\user_projects\domains\base_domain>java -cp E:\Oracle\WLS1036\wlserver_10.3\server\lib\weblogic.jar weblogic.WLST

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline>

Now, at WLST prompt, use below command to connect with admin server

wls:/offline> connect('weblogic','webl0gic','t3://localhost:7001')
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'base_domain'.

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.

wls:/base_domain/serverConfig>

use below command to connect with node manager

wls:/offline> nmConnect('weblogic','webl0gic','localhost','5556','base_domain','E:/Oracle/WLS1036/user_projects/domains/base_domain','plain')

Connecting to Node Manager ...
Traceback (innermost last):
  File "<console>", line 1, in ?
  File "<iostream>", line 1408, in nmConnect
  File "<iostream>", line 1847, in raiseWLSTException
WLSTException: Error occured while performing nmConnect : Cannot connect to Node Manager. : Access to domain 'base_domain' for user 'weblogic' denie
Use dumpStack() to view the full stacktrace

if you get above error then


1. change node manager username and password as you have mentioned in nmConnect command from admin console => admin console > domain > security > under advance option ( NodeManager Username & NodeManager Password )

2. if still getting error, the update nm_password.properties under domain/config/nodemanager as below

username=weblogic
password=webl0gic

and restart nodemanager

wls:/offline> nmConnect('weblogic','webl0gic','localhost','5556','base_domain','E:/Oracle/WLS1036/user_projects/domains/base_domain','plain')
Connecting to Node Manager ...
Successfully Connected to Node Manager.
wls:/nm/base_domain>

To check status of server using node manager

wls:/nm/base_domain> nmServerStatus('MS1')

RUNNING

To start a server using node manager

wls:/nm/base_domain> nmStart('MS2')
Starting server MS2 ...
Successfully started server MS2 ...
wls:/nm/base_domain>

To disconnect fron node manager

wls:/nm/base_domain> nmDisconnect()
Successfully disconnected from Node Manager.

wls:/offline>

For further WST commands see below post

http://weblogicserveradministration.blogspot.in/2010/10/wlst-iii-online-and-offline-command.html

If you want to run few command via script then add all lines in a .py file in sequence and execute as below


java -cp E:\Oracle\WLS1036\wlserver_10.3\server\lib\weblogic.jar weblogic.WLST your_script.py

your_script.py as below to connect and start managed server MS1 with node manager

---------------------------------------------------------------------------------------------------------------------------------
nmConnect('weblogic','webl0gic','localhost','5556','base_domain','E:/Oracle/WLS1036/user_projects/domains/base_domain','plain')
nmStart('MS1')
nmServerStatus('MS1')
nmDisconnect()
--------------------------------------------------------------------------------------------------------------------------------





Sunday, 23 March 2014

Apache : What is reverse proxy, How it's work and Configuration


Apache : What is reverse proxy, How it's work and Configuration


Coming Soon............Stay Tune :)

Sunday, 16 March 2014

Apache : Troubleshooting Load Balancing, Status with mod_status and mod_info, Monitoring with WebLogicBridgeConfig


Apache : Troubleshooting Load Balancing, Status with mod_status and mod_info, Monitoring with WebLogicBridgeConfig


If you have knowledge of apache or any other web server like IIS, Iplanet etc and any application server like weblogic, websphere, jboss, tomcat etc, and worked or working in a support environment then you must have knowledge on web server and application server integration, and the concept of load balancing.

Most of the very common issue related with same we generally see is uneven load balancing of requests from web server to the application server. almost all of the organizations use a hardware load balancer ( like bigip, cisco ace etc ) either to divert the request to web server and then from web server to application server, or some organizations don't use web server and directly  send request to application server.

So, the basic architecture with hardware load balancer, web server and application server is -

Architecture 1
hardware load balancer => web server => application server ( with a single web server )


Architecture 2
hardware load balancer => web server => application ( more than one web server )



Architecture 3
hardware load balancer => application server ( without web server )



Architecture 4
hardware load balancer => application server ( with two hardware load balancers )



Based on above diagrams, you can imagine we can use n numbers of hardware load balancers, n number of web servers, and n number of application servers combinations to create a proper load balancing environment.

One thing I would like to clear you that there is no relation of cluster algorithms with the web ( http ) requests, means weblogic cluster don't  do the load balancing of http requests, for that you have to use either a web server or harware load balancer for load balancing the http requests.

Now,  the main issue we generally face is the load balancing from web server or hardware load balancer to application servers not working properly. ideal behavior is all nodes in the cluster should get equal number  ( or almost equal )  of requests.

 I am going to demonstrate you what could be possible causes of this, how we can troubleshoot it.

So, the first question is -

What could be the cause of uneven distributions of requests ?

Problem 1
you can define problem as, uneven load balancing of http requests due to uneven load balancing of http sessions.
Basically, proxy send requests to clustered nodes without session cookie, means every time request reach  to web server it divert to next new node on the cluster in round robin fashion, means each node in the cluster should get equal number of http sessions. if this does not happen, your any of the node or nodes in cluster will get more number of http sessions because of sticky session load balancing policy or you can say session affinity based load balancing.

what happened with sticky or session affinity load balancing is, when your http request connect with a server/node in a cluster, all subsequent requests for the same session send to the same server/node every time, that request create a session and maintain it in the request header, thus called uneven load balancing.
So, you can directly go ahead and disable the sticky load balancing / session affinity at hardware load balancer level.

Problem 2
Generally a proxy maintain a in-memory list of clustered nodes in General server List, which contain all the servers in good health at that of time, and proxy send requests to all nodes in round robin fashion. proxy general server list is almost the same as static servers defined in web server file, but sometime if there is some issues with any of the clustered node(s)/server(s) the proxy General Server List shrink to limited number of servers/nodes with good in health and this also cause unequal load balancing.


Troubleshooting - 

There are certain ways to troubleshoot this problems. below troubleshooting ways and steps are based on apache and weblogic configuration.

1. Enabling WebLogicBridgeConfig using DebugConfigInfo parameter at apache
2. Enabling server-status using mod_status module at apache

and with both above options, you have to enable Debug parameter also to enable the debug logging for apache.

Enabling WebLogicBridgeConfig using DebugConfigInfo parameter at apache

Below is my apache configuration
# Enable this with DebugConfigInfo to get detailed information
ExtendedStatus On
# Module to configure apache with weblogic
LoadModule weblogic_module modules/mod_wl_20.so
# configuration to access any of the web application deployed on weblogic
<Location />
SetHandler weblogic-handler
</Location>
# weblogic nodes configuration, with enable Debug and DebugConfigInfo
<IfModule mod_weblogic.c>
WebLogicCluster localhost:7002,localhost:7003
Debug ALL
DebugConfigInfo on
WLLogFile c:/temp/wlproxy.log
WLTempDir c:/temp


Enabling server-status using mod_status module at apache
# Enable server-status module and configuration to access server-status
</IfModule>
LoadModule status_module modules/mod_status.so
ExtendedStatus On
<Location /server-status>
   SetHandler server-status
      Order Deny,Allow
#   Deny from all
   Allow from localhost
   </Location>




Rest Coming Soon...............

Apache : Configuration with Weblogic Server, Load Balancing, Performance Tuning

Saturday, 15 March 2014

Weblogic Server : Custom Memory Heap Setting For Each Server


Weblogic Server : Custom Memory Heap Setting For Each Server

This is one of my favorite question which i frequently asked in lot's of interviews. We all know to change or alter memory heap size we have to chnage -Xms and -Xmx parameters either in setDomainEnv.sh or in startup script for managed servers startManagedServer.sh, but what would be case if I need to set different heap size for each managed servers? Yes, one way you most of the guys know is just create different startup script for each managed server and start server with the help of that, but most of the guys struggled a lot why changed heap is not reflecting even modified the startup scripts for all managed servers. so here are the reason and different ways which we can used to define different heap for different managed servers.

First, if you created separate startup files for each managed server then you have to make sure, inside each startup script, you should not be calling setDomainEnv.sh or commEnv.sh, otherwise your memory parameters will be override by the values existing in this script. So, make sure to define your memory heap parameters after any place where you are calling above scripts in your startup scripts.

Ok, Now here are different ways - 

1. For Admin Server 

Since, startWebLogic.sh is the script only used to start admin server, thus whatever the value you will update will reflect but only make sure you are updating new values after the place where you are calling, or i will add the values here in script


MEM_ARGS="-Xms<value>m  -Xmx<value>m"
export MEM_ARGS

2. For Managed Server(s)

You can have four ways to assign different memory arguments for managed servers

2.1 

Start your managed server as below 

startManagedWebLogic <Name_Of_Managed_Server> <Admin_URL> -Xms<value>m -Xmx<value>m

where <Name_Of_Managed_Server> is your managed server name.
<Admin_URL> is the Adminstration Server URL, for example http://localhost:7001
<value> in -Xms<value>m -Xmx<value>m, is the desired heap size, for example, -Xms512m -Xmx512m

2.2

Create custom scripts for each managed server and add memory heap parameters after you are calling setDomainEnv.sh, add as below 

After the JAVA_OPTIONS = "... {JAVA_OPTIONS}" line type:
JAVA_OPTIONS="${JAVA_OPTIONS} -Xms<value>m -Xmx<value>m"

2.3


If you are using the Node Manager then, From admin console, select the server, <Managed_Server> then configuration then Server Start then arguments, then add -Xms<value>m -Xmx<value>m under the arguments tab.


2.4

Directly edit the config.xml file and add argument as below

<server>
  <name>MS1</name>
  ...
  <server-start>
    <arguments>-Xms128m -Xmx128m</arguments>
  </server-start>
  ...
</server>

Ian s

Weblogic Server JDBC Connect String For Failover and Load Balancing

Weblogic Server Connect String For Failover and Load Balancing


There is a feature of JDBC ( not weblogic ) where you can use your single data source to load balance or failover the requests between different data source nodes ( for example different RAC nodes ), though it's good and easy to configure approach but have few limitations also.


A normal JDBC Connection String is like below 

jdbc:oracle:thin:@localhost:1521:XEDB


A Load-Balanced JDBC Connection String is like below 

jdbc:oracle:thin:@(description=(address_list=
(load_balance=on)
(failover=on)
(address=(protocol=tcp)(host=db1.localhst.com)(port=1521))
(address=(protocol=tcp)(host=db2.localhost.com)(port=1521)))
(connect_data=(service_name=rac_node1)))

A  Failover JDBC Connection String is like below 

jdbc:oracle:thin:@(description=(address_list=
(load_balance=off)
(failover=on)
(address=(protocol=tcp)(host=db1.localhost.com)(port=1521))
(address=(protocol=tcp)(host=db2.localhost.com)(port=1521)))
(connect_data=(service_name=rac_node2)))


Drawback would be - 


Failover would only occur at connect-time, that means during the automatic failover, weblogic will create a new data base connection to the other node instead of using the existing pool connection.

And second drawback is, Global XA transactions are not supported, because there is no guarantee that all of your database transaction involved in a a operation will be direct to the same RAC instance, that would lead some intermittent behavior.