Showing posts with label WEBLOGIC COMMON. Show all posts
Showing posts with label WEBLOGIC COMMON. Show all posts

Monday, February 13, 2012

Weblogic Server as Daemon Process

Script to start WebLogic domain server at  Machine Start in distributed environment .


I had a requirement to configure weblogic server to start at the server reboot on linux machine , i.e. to configure weblogic server as a daemon process. In my case the weblogic domain was distributed over two different physical machines .

Challenges :



  • In Weblogic Domain Admin Server should be started First.

  • After the Admin Server has come to RUNNING state, then we can start the Managed Server  of the local Machine and Remote Machine.


Steps :



  • Here I will mention the steps I followed to write the shell script to complete the above mentioned task. I will post the code snippet and the task they fulfill and in the end I will provide the complete


First task is to start the Weblogic Admin Server using the startWeblogic.sh file from $DOMAIN_HOME/bin dir.

My code snippet to check for the domain dir, then check for any nohup.out file existing or not and then finally start the server .
domain=/Middleware/user_projects/domains/BASE_DOMAIN
# Clear the nohup file that is existing
echo ${domain}/bin
cd ${domain}/bin
if [ `pwd` == ${domain}/bin ]
then
if [ -f nohup.out ]
then
rm -f nohup.out
fi
fi

# Start the Weblogic Admin Server.
echo " Starting Weblogic Admin Server "
nohup ./startWebLogic.sh &

 

Now we have to get the status of the Admin Server and wait till the Server comes in RUNNING State. For that I will use the weblogic.Admin GETSTAT command with below snippet .
CLASSPATH="/opt/Middleware1032/wlserver_10.3/server/lib/weblogic.jar${CLASSPATH}"
export CLASSPATH

status=`java weblogic.Admin -adminurl t3://host1.com:7231 -username weblogic -password weblogic123 GETSTATE AdminServer | awk '{print$6}'`

printf "Admin Server is Starting "

count=1
while [ "$status" != "RUNNING" ]
do
printf "."
status=`java weblogic.Admin -adminurl t3://host1.com:7231 -username weblogic -password weblogic123 GETSTATE AdminServer | awk '{print$6}'`
count=$count+1
if [ $count -gt 100 ];
then
echo " There is some problem with admin server "
exit 0
fi
done

After Admin Server has come to RUNNING state we will start the Managed Server of local machine.
if [ "$status" == "RUNNING" ];
then
echo "Admin Server is running "
echo "Starting Managed Server "
cd ${domain}/servers/MS1/bin
if [ `pwd` == ${domain}/servers/MS1/bin ]
then
if [ -f nohup.out ]
then
rm -f nohup.out
fi
fi

./startMS1.sh

echo " Managed Server is Starting "

echo " do : tail -f $pwd/nohup.out  to check the status of Server "

fi

Once Managed Server of local machine is started we will start the Managed Server of Remote Machine with below snippet.
# starting Managed Server on remote machine
#
MACHINE2=host2.com
if  ping -c 1 -w 10 $MACHINE2
then
echo "This machine is up and reachable"
echo " Checking MS2 server PID "

# Getting PID of MS2 on MACHINE2

PID=`ssh weblogic@host2.com \`\`ps -ef |grep -v grep |grep  weblogic.Name=MS2 | awk '{print\$2}'\`\``

echo $PID

if [ -z "$PID" ]
then
echo " MS2  Server not running "
echo " Starting MS2 Server "
ssh weblogic@host2.com '/flexcube/user_projects/domains/BASE_DOMAIN/servers/MS2/bin/startRelease1.sh ;/flexcube/user_projects/domains/BASE_DOMAIN/servers/MS2/bin/nohup.out'

else

#CLASSPATH="/oracle/app/Middleware1032/wlserver_10.3/server/lib/weblogic.jar${CLASSPATH}"
#export CLASSPATH

MS2_status=`java weblogic.Admin -adminurl t3://host2.com:7231 -username weblogic -password weblogic123 GETSTATE MS2 | awk '{print$6}'`

if [ "$MS2_status" = "RUNNING" ]
then
echo " MS2 is already Running "
echo " exiting from script"
exit 0
else
echo " MS2 PID=$PID exist and current state of server is $MS2_status"
fi

fi

fi

The complete script startBASE_DOMAIN.sh is available here :


One additional script has been used ,  startMS1.sh is available here :


${domain}/servers/MS1/bin .  The additional script can be found at below location.

Configuring the Above script in init.d directory.

In Linux : /etc/init.d

In AIX :   /etc/rc.d/init.d

Create a file weblogic.sh with the below contents :
#!/bin/sh
# Start the weblogic domains
su - weblogic -c "/opt /Middleware1032/wlserver_10.3/server/bin/startNodeManager.sh"
su - weblogic -c "/opt/user_projects/domains/scripts/startup/startBASE_DOMAIN.sh"

Now create soft link in /etc/rc.d/rc5.d with any name starting with S98 as given below:
Linux
ln –s  /etc/init.d/weblogic.sh S98weblogicstart

 AIX
ln –s /etc/rc.d/init.d/weblogic.sh S98weblogicstart

 
startBASE_DOMAIN.sh

#!/bin/sh
# To Start BASE_DOMAIN Domain while server start
# Written by Sandeep Singh
#
umask 037

domain=/flexcube/user_projects/domains/BASE_DOMAIN

# Clear the nohup file that is existing
echo ${domain}/bin
cd ${domain}/bin
if [ `pwd` == ${domain}/bin ]
then
if [ -f nohup.out ]
then
rm -f nohup.out
fi
fi

# Start the Weblogic Admin Server.
echo " Starting Weblogic Admin Server "
nohup ./startWebLogic.sh &

CLASSPATH="/opt/app/Middleware1032/wlserver_10.3/server/lib/weblogic.jar${CLASSPATH}"
export CLASSPATH

status=`java weblogic.Admin -adminurl t3://host1.com:7231 -username weblogic -password weblogic123 GETSTATE AdminServer | awk '{print$6}'`
printf "Admin Server is Starting "
count=1
while [ "$status" != "RUNNING" ]
do
printf "."
status=`java weblogic.Admin -adminurl t3://host1.com:7231 -username weblogic -password weblogic123 GETSTATE AdminServer | awk '{print$6}'`
count=$count+1
if [ $count -gt 40 ];
then
echo " There is some problem with admin server "
exit 0
fi
done
if [ "$status" == "RUNNING" ];
then
echo "Admin Server is running "
echo "Starting Managed Server "

cd ${domain}/servers/MS1/bin
if [ `pwd` == ${domain}/servers/MS1/bin ]
then
if [ -f nohup.out ]
then
rm -f nohup.out
fi
fi

./startMS1.sh
echo " Managed Server is Starting "
echo " do : tail -f $pwd/nohup.out  to check the status of Server "
fi

# Starting Managed Server on remote machine
#
MACHINE2=host2.com

if  ping -c 1 -w 10 $MACHINE2
then
echo "This machine is up and reachable"
echo " Checking MS2 server PID "

# Getting PID of MS2 on MACHINE2

PID=`ssh weblogic@host2.com \`\`ps -ef |grep -v grep |grep  weblogic.Name=MS2 | awk '{print\$2}'\`\``
echo $PID
if [ -z "$PID" ]
then
echo " MS2 Server not running "
echo " Starting MS2 Server "
ssh weblogic@host2.com '/flexcube/user_projects/domains/BASE_DOMAIN/servers/MS2/bin/startMS2.sh >/flexcube/user_projects/domains/BASE_DOMAIN/servers/MS2/bin/nohup.out &'
else
#CLASSPATH="/opt/app/Middleware1032/wlserver_10.3/server/lib/weblogic.jar${CLASSPATH}"
#export CLASSPATH
MS2_status=`java weblogic.Admin -adminurl t3://host1.com:7231 -username weblogic -password weblogic123 GETSTATE MS2 | awk '{print$6}'`

if [ "$MS2_status" = "RUNNING" ]
then
echo " MS2 is already Running "
echo " exiting from script"
exit 0
else
echo " MS2 PID=$PID exist and current state of server is $MS2_status"
fi
fi

fi

 

startMS1.sh



#!/bin/sh
#  Purpose : Starting the SOA SERVER1 of DOMAIN : BASE_DOMAIN
#
# WARNING: This file is created by the Configuration Wizard.
# Any changes to this script may be lost when adding extensions to this configuration.

export HOME=/flexcube/user_projects/domains/BASE_DOMAIN
export SR=MS1

nohup ${HOME}/bin/startManagedWebLogic.sh ${SR} http://host1.com:7231 &

 

 

Monday, January 30, 2012

Issue with NodeManager and Weblogic Server

Error :


<Jan 24, 2012 11:33:43 AM AST> <Error> <NodeManager> <BEA-300033> <Could not execute command "getVersion" on the node manager. Reason: "Access to domain 'Base_Domain' for user 'EZRXyZIP1P' denied".>

Debug Steps:


The default log level for node manager is : Info .
We need to set the log level to Finest.

Below are the available log level for Node Manager :

SEVERE             ----- (highest value)
WARNING
INFO                    ---- Default value .
CONFIG
FINE
FINER
FINEST             ----- (lowest value)

Then We will restart the Node Manager and check for the log file error message again.

Solution :


1 : Log on to the Admin Console of the domain for which we are getting the error ( http://hostname:port/console )

2 : Go to Domain Name (Base_Domain) in my case >>>>> Then to security >>>>

3 : Click on the Advance Option.

4 : Change the username and password values that you want to use with the node manager.

in my case : username is : weblogic

password is : weblogic123

5 : save the changes.

Then each remote host:

  • Navigate to the folder %DOMAINHOME%\config\nodemanager

  • Edit the file: nm_password.properties

  • Content should be set to:

  • username=weblogic

  • password=weblogic123

  • Save

  • Restart the Weblogic Node Manager


6 : Then go to the Base_Domain/servers/mannaged_server/data/nodemanager/ dir.

7 : open the boot.properties file and enter the below values :

username=weblogic

password= weblogic123

the same values as set on Admin Console.

8: Restart the Admin Server.

9 : Now run the nmEnroll() wlst command for all the machines that has the Managed server.

wlst>connect('username','password','t3://admin_host:admin_port')

online>>nmEnroll('Domain_dir_path','NodeManager_Home_Path')

online>>exit()

Now you can check the node manager status from Admin Console .

left panel >> Machines >> Machine1 >> Monitoring >>

The Status should be reachable.

If the above steps did not resolve the issue the you can still post you issue in the comments below and I can try to help .

 

 

 Error :


Feb 2, 2012 2:55:02 AM weblogic.nodemanager.server.NMServer main SEVERE: Fatal error in node manager server java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365) at java.net.ServerSocket.bind(ServerSocket.java:319) at java.net.ServerSocket.<init>(ServerSocket.java:185) at java.net.ServerSocket.<init>(ServerSocket.java:141) at weblogic.nodemanager.server.Listener.init(Listener.java:56) at weblogic.nodemanager.server.NMServer.start(NMServer.java:206) at weblogic.nodemanager.server.NMServer.main(NMServer.java:377) at weblogic.NodeManager.main(NodeManager.java:31)

Reason :


The error message : java.net.BindException: Address already in use at

Shows that the Port number used by the Node Manager process is being already  used by some other process .

Solution :


1 : First thing we need to check is whether Node Manager is already running on the machine :

For unix :

ps -ef | grep -v grep | grep -i weblogic.NodeManager

For windows :

netstat -a0 | findstr <NM_PORT_NO>

tasklist | findstr nodemanager

2 : If the process is not running already then, check which process is using the using the port assigned to node manager .

By default Weblogic Node Manager runs on port : 5556

So, to check which process is using this port use the below command .

For unix :

netstat -an | grep 5556

For Windows :

netstat -ao | findstr 5556

3 : If this port is already used by some other process then try to change the Node Manager Port number from file

%Middleware_Home%/wlserver_10.3/common/nodemanager/nodemanager.properties file :

ListenPort = XXXX

4 : Now try to start the Node manager from :

%Middleware_Home%/wlserver_10.3/server/bin/startNodemanager.sh or

%Middleware_Home%/wlserver_10.3/server/bin/startNodemanager.cmd

 

 Error :


NodeManager not Reachable: java.io.IOException: Invalid State File Format

Due to above error, Managed Servers cannot be started as the nodemanager is not reachable to Admin Console.

Stack trace from nodemanager.log file :



    

java.io.IOException: Invalid state file format. State file contents: at weblogic.nodemanager.common.StateInfo.load(StateInfo.java:135) at weblogic.nodemanager.server.ServerMonitor.loadStateInfo(ServerMonitor.java:475) at weblogic.nodemanager.server.ServerMonitor.isCleanupAfterCrashNeeded(ServerMonitor.java:139) at weblogic.nodemanager.server.ServerManager.recoverServer(ServerManager.java:255) at weblogic.nodemanager.server.DomainManager.initialize(DomainManager.java:103) at weblogic.nodemanager.server.DomainManager.(DomainManager.java:55) at weblogic.nodemanager.server.NMServer.getDomainManager(NMServer.java:257) at weblogic.nodemanager.server.Handler.handleDomain(Handler.java:224) at weblogic.nodemanager.server.Handler.handleCommand(Handler.java:108) at weblogic.nodemanager.server.Handler.run(Handler.java:70) at java.lang.Thread.run(Thread.java:619)


 

 

 Reason :


The state file of the managed server is in an invalid state.
Under each managed server directory, there is a NodeManager directory containing a state file <managed_server_name>.state. If this file is empty or corrupt, then the described errors occur.

For example, underE:\oracle\middleware\user_projects\domains\base_domain\servers\soa_server1\data\nodemanager, the soa_server1.state file is empty.
The major cause of the corruption of this file is unexpected shutdown of the Machine.

Solution :



  1. Stop the managed server if it is RUNNING.

  2. Stop the Admin Server.

  3. Stop Node Manager.

  4. Delete the following files:



E:\oracle\middleware\user_projects\domains\base_domain\servers\soa_server1\data\nodemanager\soa_server1.state
E:\oracle\middleware\user_projects\domains\base_domain\servers\soa_server1\data\nodemanager\soa_server1.lck
E:\oracle\middleware\user_projects\domains\base_domain\servers\soa_server1\data\nodemanager\soa_server1.pid


  1. Start Node Manager again.

  2. Start the Admin Server again.

  3. Start the managed server using the Admin Console.


 

Tuesday, January 10, 2012

Server

What is a Server?


In Java terms, there are some codes, application, modules that need a certain type of environment to get executed. The software that provides this environment is called as server.

A server can be classified as broadly into two categories:

Web Server:


A web server is the software or utility which takes http/https based request from browsers and generate html response which can be shown on web browsers. 

In Java technology, web servers are generally used to deploy html and jsp pages and for the business logic the request is forwarded to application servers.

e.g. of Web Servers : Apache Web Server , Iplanet/SunOne Web Server etc.

Application Server:


An application server is the software or utility used to deploy complex business logic modules. It provides other facilities to the deployed application such as transaction management , security management etc .

Most important use of the application server is to deploy EJB ( enterprise java beans ) which is used to create Distributed Enterprise Applications.

Java has specified some specification as J2EE-Specifications and all the application container has to follow this specification to become a J2EE compatible application server.

e.g. of application server : oracle weblogic server, IBM websphere server , Jboss server , glassfish server etc.

Difference between Application server and Web Server :



  1. The most basic difference is , web server is used to deploy html and jsp pages to fulfill client request whereas application server is used to deploy Enterprise Java Beans, Servlets and JSP's .

  2. Web Server is mainly used to generate the only request and response for the clients and for most of the business logic web server forwards the request to the application server. So web server is  mainly used for proxy-ing the client request to application server.


 

 

Sunday, January 8, 2012

Managed Weblogic Server

Weblogic Managed Servers:


In this post I will be providing some basic idea about the Weblogic Domain and its component called Managed Weblogic Server.

What is Weblogic Domain?


A domain is the basic administration unit for WebLogic Server instances. A domain consists of one or more WebLogic Server instances (and their associated resources such as JDBC resource or JMS resource) that can be managed with a single Administration Server.

A minimal domain can contain only one WebLogic Server instance, which functions both as an Administration Server, and as a Managed server. This instance is called as Weblogic Administration Server or Weblogic Admin Sever.

As it is the only instance present in domain so this Weblogic Admin Server can also be used as Managed Weblogic Server.

Below figure Fig.1 , shows a minimal Weblogic domain containing only one Admin Server.

Fig.1 Weblogic domain with Admin Server only.


 

Till now I hope, the concept of Weblogic Domain is clear.

As terms Weblogic Admin Server and Weblogic Managed Server has been used, let me explain each of them separately.

Weblogic Admin Server OR Weblogic Administration Server:


The minimum requirement for a Weblogic Domain to exist is that it must contain one Administration Server. This Weblogic Server Instance is basically used for the Administrative purpose of complete Weblogic domain.

This Admin Server can also be used for the purpose of deployment of applications along with Administrative purpose and in that case the Admin Server is acting as Managed Weblogic Server instance.

Managed Weblogic Server:


Any other server instance other than Administrative Server of a Weblogic domain is called as Managed Weblogic Server. Managed Servers host the components and associated resources that constitute the applications—for example, JSPs and EJBs.

Below figure Fig. 2 Shows A Weblogic Domain with 1 Admin Server and 1 Managed Server on a Single Machine.

Weblogic domain with Admin Server and one Managed Server.


Fig.2 Weblogic domain with Admin Server and one Managed Server.