Sunday, March 25, 2012

Check Nodemanager status using simple Shell script

Hi, 


Here I like to explain about, checking the node manager status using a simple shell script.

Function of this shell script:
           If you execute this shell script, it will check whether Node Manager is running or not on your machine, using WLST, we can do the same using "ps" command, but we are trying to use the WLST commands.

Shell script will call a python script (checkNM.py), it will call WLST and try to connect with Node manager and it will check the status.

You can customize this script by updating the following variables, 
1. weblogic home.
2. Nodemanager IP
3. Nodemanager Port
4. Domain name
5.Domain full path

WLST command to connect with NM:
nmConnect(CONSOLE_USER_NAME, CONSOLE_PASSWORD, NODE_MANAGER_IP, NODE_MANAGER_PORT, DOMAIN_NAME,FULL_PATH_FOR_DOMAIN,'plain') 

To call WLST and execute a python script:
sh ${WL_HOME}/common/bin/wlst.sh ${PYTHON_FILE_NAME}

shell script used to start Node manger:
startNodeManager.sh 

Solaris command used to get the last command status - $?

Shell Script to start Node Manager process:

#!/bin/sh


#***************************************************************
# This script is used to check your server status and node manager status using WLST
# It sets the following variables:
#
# WL_HOME    - The root directory of your WebLogic installation
# PYTHON_FILE_NAME - WLST file name to get server status
#****************************************************************




BEA_HOME="/opt/weblogic-10.3.3"
WL_HOME="${BEA_HOME}/weblogic103"
PYTHON_FILE_NAME="checkNM.py"
NODE_MANAGER_HOME="/ dir0/ dir1/ dir2/nodemanager"
NM_STARTUP_FILE="startNodeManager.sh"


sh ${WL_HOME}/common/bin/wlst.sh ${PYTHON_FILE_NAME}
if [ $? -eq 2 ]         # Test exit status of "cmp" command.
then
  echo "Node manager is not running"
  ls -lrt ${NODE_MANAGER_HOME}/${NM_STARTUP_FILE}
  value=$?
  if [ value -eq 2 ]
then 
echo ${NM_STARTUP_FILE} " File not found in "  ${NODE_MANAGER_HOME}  
  elif [ value -eq 0 ]
then
echo "NM  Home found and starting Node Manager "
nohup ${NODE_MANAGER_HOME}/${NM_STARTUP_FILE} &
if [ $? -eq 0 ]
then
ps -ef | grep weblogic.NodeManager | grep -v grep
if [ $? -eq 0 ]
then
echo "Node manager started properlly"
else
echo "Node manager not started"
fi


else
echo "Not able to start Node Manager"
fi
  else
echo "Some other error - " value
  fi  
else  
  echo "Process completed"
fi


-----------------------------------------------------------------


Python script - checkNM.py:


CONSOLE_USER_NAME="weblogic"
CONSOLE_PASSWORD="weblogic11"
NODE_MANAGER_IP="192.168.1.40"
NODE_MANAGER_PORT="5301"
DOMAIN_NAME=" domainName"
FULL_PATH_FOR_DOMAIN=" / dir0/ dir1/ dir2/domainName"
import sys
try:
nmConnect(CONSOLE_USER_NAME, CONSOLE_PASSWORD, NODE_MANAGER_IP, NODE_MANAGER_PORT, DOMAIN_NAME,FULL_PATH_FOR_DOMAIN,'plain')
connected = 1
except:
    print('Could not connect to the NodeManager.')
NODE_1="ManageServer1"
NODE_2=" ManageServer12"

if connected==1:
server = NODE_1
serverStatus=nmServerStatus(server)
try:
if serverStatus=='RUNNING':
server = NODE_2
serverStatus=nmServerStatus(server)
if serverStatus=='RUNNING':
print('All servers were running - '+server+' -'+serverStatus)
else:
print(server+' - '+serverStatus)
elif serverStatus=='SHUTDOWN':
print(server+' - '+serverStatus)
elif serverStatus=='STARTING':
print('Server startup has been initiated by another process.')
else:
print(server+' - '+serverStatus)
except:
print('Error restarting.')
nmDisconnect()
exit()
else:
exit(exitcode=2)
----------------------------------------------------------------- 

Please try yourself and let me know if you have any questions


Tuesday, December 28, 2010

Overview of Proxy server

What is proxy server ?

Proxy server is a component, it will redirect all the request to your main server which is more scalable and durable. Here main server is weblogic. Proxy server is any third party server.








Why we need to use proxy server ? in which situation we need this ?

Proxy server is used between the client and server as an intermediate server, like, it will hide the main server details or its details.

To understand proxy server, we need some practical example,

Assume, we are running a pizza shop, it should run for 24 hours, our shop dns name is rampwaq.com , now you registered with this domain name and your IP address is 10.11.94.06 with this IP address and 7001 port weblogic server is running, rampwaq_pizza enterprise web application (ear file) running on weblogic.

Now users are accessing the application using the following url,

http://rampwaq.com:7001/jsp/home.jsp

Initially some 100 users are accessing this application, its working fine and our pizza was good, the number of clients are increasing to 10,000 now we are getting out of memory error, we need to increase the RAM size to handle our clients, the management decided to buy new hardware with extended memory and with different IP address or due to some firewall settings we are changing the IP address.

Now the IP addresss is 11.11.11.11, it should mapped with DNS server for the domain name, its again a separate task for the management to mapping the IP Address with DNS name.

Now rampwaq.com management is reporting to weblogic we are getting this problem (like changing the IP address and mapping it with DNS name), now weblogic is coming with a solution called Proxy server.

Proxy server is a third party “apache http server”, DNS name, rampwaq.com is mapped with the IP address of “Apache Http Server” IP Address not with weblogic server IP Address.

http://rampwaq.com is mapped with (100.100.100.100)

The probability for “weblogic machine going down” is high compare to apache server machine, we can say “nil for apache server machine” because apache server is not doing anything other than just redirecting the request to weblogic server.

The structure is like this,










Today weblogic is running on 11.11.11.11 or 12.12.12.12, if we change to some other IP address also, it wont affect clients directly or indirectly, because they will contact only proxy server, the only place we need to change the IP Address of weblogic is “Proxy server” specifically in configuration file of the apache server (httpd.conf)

Now we will see how the proxy is happening from apache server to weblogic.

Apache server will redirect the request from client to weblogic based on some condition,

It is classified in two types,

1. proxy by path

2. proxy by MIME type

Now may be you will get this question, why we need these conditions?

Assume, our clients using our site to get the menu of pizzas and its price, if they choose any one type of pizza, then they will register their contact details and the pizza will be delivered to them.

There are 2 tasks for our site:

1. Display the menu with price

2. Register user info and map the pizza which they want

For the first task we need only, HTML pages, so its not necessary to go to weblogic server to display these html pages.

For the second task we need JSP and the JSP’s are calling some EJBs and its configured with data source JNDI.

Note: If you feel, for your application, EJB is not required and its not an enterprise application then you can use web server (like, Tomcat) no need to choose weblogic. (no need for proxy)

Ok, come again to the first task, like there are some HTML pages which we need to display, so it will be deployed on apache server itself and its not necessary to deploy it in weblogic.

Now we need proxy by MIME or Path,

Client request will be answered by your proxy server,

If client is looking for only html pages – now you can use proxy by MIME type

If client is looking for JSP pages then it will be redirected to weblogic

“By Path” method also doing the same, here servlet name will taken into account, from our url (http://rampwaq.com:7001/jsp/home.jsp),

Client request will be redirected to weblogic if folder name (or servlet name) is HTML then it will answered by apache server else if folder name is JSP it will answered by weblogic.

These configuration changes will be done in the httpd.conf file of apache http server, like thise,


IfModule mod_weblogic.c
 WebLogicHost myweblogic.server.com
WebLogicPort 7001
MatchExpression *.jsp
MatchExpression *.xyz
    IfModule

Here we are using “Proxy by MIME“ method, only JSP and XYZ files request is redirect to weblogic and weblogic server information is mentioned, the above configuration for “Non clustered environment”

For clustered environment,

  IfModule mod_weblogic.c
 WebLogicCluster w1s1.com:7001,w1s2.com:7001,w1s3.com:7001
 MatchExpression *.jsp
 MatchExpression *.xyz
 IfModule

How proxy server used for Load sharing?

We can say html pages contains some part of load your web application and it was deployed on proxy server, so proxy server is sharing the load of weblogic.

The following questions will be answered in next post,

How proxy server used for Load Balancing?

How Proxy server used for “Fail over”?

What is Keep-alive and “Keep-alive timeout”?

Sunday, December 26, 2010

Collect Thread dump on windows


Step 1: Prepare a command to get Thread dump

java weblogic.Admin -url t3://localhost:7001 –username weblogic –password weblogic THREAD_DUMP

localhost - IP address of admin server

7001 - port number of admin server

Step 2: Open a command prompt and execute the above command

if you get ClassNotFoundException, it means the classpath is not properly set to call the java class weblogic.Admin,

Step 3: Set classpath to call weblogic.Admin

To set the classpath you can use -classpath variable and set the required JAR files or you can do the following,

Go to your weblogic domain and execute SetDomainEnv.cmd (for 9.2) or SetEnv.cmd (for 8.1) on the same command prompt.

Now the command prompt is ready to call the Java class weblogic.Admin and you can see the Threads details on the console (command prompt) of the weblogic server.

if you want to see the Thread dump on a file, you need to customize your startup script and redirect your logs to a file,

Step 4: Customize the weblogic startup script to redirect the logs

Commnad to start your weblogic server

%JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -Dweblogic.Name=%SERVER_NAME% -Dweblogic.ProductionModeEnabled=%PRODUCTION_MODE% -Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" weblogic.Server >> console.log


Step 5:
You can see the thread dumps on weblogic console itself from 9.1 version,
If you using a weblogic 9.1, you can navigate to Server > Monitoring > Threads



Step 6: Get the output on the console




If you install your weblogic 8.1 as a service on windows machine then you can use beasvc to get thread dump, but its old procedure, now a days, thread dumps are available on console itself on weblogic 9.1 and 10.3

Please post your comments if you need more clarification.

Wednesday, December 22, 2010

Useful solaris command to view server availability

As you know,

ps -ef|grep java

it will provide you the following output,

admin 6412 15489 0 15:21:29 ? 92:18 /opt/weblogic-9.2.3/jdk150_12/bin/java -client -Xmx512m -XX:MaxPermSize=256m -c

we can not able to see the full java command which is used to start weblogic server, like server name and memory otpions, location of the server and classpath.

To get these information, you can use the following command,

$/usr/ucb/ps -auxww
This command will display all process in the solaris machine with whole java command including classpath, server options, java options, memroy settings.

from this you can search the process id of weblogic server by its server name ,
$/usr/ucb/ps -auxww|grep serverName

It will display only your weblogic server parameters from the all process.

In a solaris machine if multi java process running, then this command will help you to get your server paramerters by simple search options.


Saturday, December 18, 2010

Customize your weblogic server


We knew that, the following lines will start a weblogic server, here we can see how we can customize the settings for weblogic. Here setMyEnv.sh is a file will set the values for your weblogic server, it’s a text file which we can create.

#Start WebLogic server
. "./setMyEnv.sh"
echo Starting server...
nohup "${JAVA_HOME}/bin/java" ${JAVA_VM} ${MEM_ARGS} -cp ${CLASSPATH} ${JAVA_OPTIONS} -Dweblogic.Name=${SERVER_NAME} -Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} -Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" weblogic.Server 1>>logs/weblogic-console.log 2>&1 &

some points about server startup script

. "./setEnv.sh" – first setEnv.sh file will be executed and the variables will be set then the remaining lines will be executed.


Normally the setMyEnv.sh will call commonEnv.sh of weblogic, the following variables will be set in setMyEnv.sh file,


${JAVA_VM} – It will provide the Java vendor, whether it is Java hot spot or JRockit
${MEM_ARGS} – It will provide the value for initial and maximum memory setting for your weblogic server, the value depends on your hardware and java vendor
${CLASSPATH} – It will provide the classpath Jar files which are required to run your application, here you can add your Library files.
${JAVA_OPTIONS} – There are some pre-defined options which you can pass to weblogic server


-Dweblogic.Domain=${WLS_DOMAINS}
Here you can specify the domain name


-Dweblogic.security.anonymousUserName=guest
User guest can enter into console of the weblogic for read operation

-Dweblogic.allow.lookup.weblogic.jndi=everyone

Any one can look up any JNDI name if they have initial context.

- Dweblogic.allow.lookup.weblogic.jndi.weblogic.management.home
=everyone

Any one can look up JNDI names for Management of weblogic server, like monitoring purpose


Configuration for SSL:
-Djavax.net.ssl.trustStore=${MY_APP_HOME}/ssl/MyAppTrustStore.jks


Here you can specify the certificates for ssl, automatically weblogic will create a keystore and ssl certificates configuration on the weblogic console.

The same way we can specify for keystore also.
-Djavax.net.ssl.keyStore=${ MY_APP_HOME }/ssl/MyAppKeyStore.jks


Configuration for JMS Bridge:
-Dweblogic.debug.DebugMessagingBridgeStartup=true


For Memory arguments:
MEM_ARGS="-Xmx512m -XX:MaxPermSize=512m"

For all weblog.Server options please refer the following site,
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/admin_ref/weblogicServer.html#wp1008628

License issue in weblogic

We migrated our application from old machine to new machine after that we got an issue, some users not able to access the application and they are getting a error message as
“web page not authenticated to display” and they got error code as 403.

We got the following log message in server log

#### DynamicListenThread[Default] <> <> <> <> <1292597967156> Connection rejected, the server license allows connections from only 5 unique IP addresses.

First we thought, its related to application license and we sent this to application team, but they told, its not their issue.

In the log message there is no application related information and there is a error code

We got the error code description from the following site,
http://download.oracle.com/docs/cd/E13222_01/wls/docs90/messages/Server.html


But we didn’t get any clue, why we are getting this issue. Then we tried to look into the license file of the weblogic.

In the license file, its clearly mentioned that, servlet session for only 5 units.

component="Servlet Session"
cpus="unvalued"
expiration="never"
ip="any"
licensee="BEA Evaluation Customer"
serial="616351266349-2030864056716"
sessions="unlimited"
type="SDK"
units="5"
signature="MCwCFE7tDgaAw2zNpvoMIn0MqtUoBjk2AhR3TgeRWbb6sQWvRgrh8rCZyfG0Qg=="
/>

Root cause of the issue is weblogic license file.







We have updated the license file with the old weblogic installation.


component="Servlet Session"
cpus="unvalued"
expiration="never"
ip="any"
licensee="Customer"
serial="454493271161-2646859048"
sessions="unlimited"
signature="MC0CFLx94IvLftg7XVEvQIUeAjR0VFg3fR3XSQhT7Opi47Hgig="
type="RTK"
units="unlimited"
/>

Last time we have installed the demo version instead of rela product version.

We have upated the license file with the product version, issue resolved.

Wednesday, December 15, 2010

License for weblogic

After the acquision of weblogic from BEA, Oracle changed the license files too, oracle removed the Expiration Date for the license, after they removed the whole license file,

but license file will be useful to understand, what are the components, are used in weblogic, like,

whether this production contains the Clustered JMS or not ?,
and what is the version of EJB (1.0, 2.0, 2.1)is supporting ?

based on this, we can understand about product details. so it seems, oracle removed the license file, but oracle having a single license file,in their support site,

to list the components of weblogic server for all version...

to get your components list or license file, please use this URL,
http://www.oracle.com/us/support/licensecodes/bea/index.html

Followers