Friday, February 17, 2012

Starting Managed Servers without an Administration Server using Node Manager and WLST

Weblogic 12c


 

The steps for starting the Managed  Server without AdminServer using WLST and Node Manager are as follows :

i)  Setting up your environment.

Add WebLogic Server classes to the CLASSPATH environment variable and WL_HOME\server\bin to the PATH environment variable.  OR

You can use a  C:\Oracle\Middleware\wlserver_12.1\server\bin\setWLSEnv.cmd  script to set both variables.



 

ii)  Start WLST Session using command : java weblogic.WLST



iii)  Start Node Manager using command :

                         startNodeManager(verbose='true', NodeManagerHome='C:\\Oracle\\Middleware\\wlserver_12.1\\common\\nodemanager', ListenPort='5556', ListenAddress='localhost')





iv) Connect WLST to a Node Manager by entering the nmConnect command.

nmConnect('weblogic', 'weblogic123', 'localhost', '5556', 'base_domain' , 'C:\\Oracle\\Middleware\\user_projects\\domains\\base_domain' , 'ssl')



note: Node Manager security relies on a one-way SSL connection between the client and server.If you are establishing a command line connection to the Java Node Manager using the WebLogic Server Scripting Tool (WLST) nmConnect command, you provide the Node Manager user name and password(here weblogic and weblogic123 respectively). Node Manager verifies the username and password against the domain's nm_password.properties file.Node Manager credentials are located on the Security>General>Advanced Options of Console page.Administration Console users do not need to explicitly provide credentials to connect to Node Manager—the Node Manager user name and password are available in the domain configuration and are provided automatically.

v) Starts the managed server in the current domain using Node Manager. : nmStart('Server-0')



 

 

 Related Common Issues :


 

If you are trying to automate the environment using Node Manager and WLST .

And you are trying to Start the Admin Server and all the Managed Server using WLST only.

And the Managed servers are to be started for the first time using WLST and Node Manager then you may encounter the below error :

 






There are 1 nested errors:

weblogic.management.ManagementException: Booting as admin server, but servername, soa_server1, does not match the admin server name, AdminServer
at weblogic.management.provider.internal.RuntimeAccessService.start(RuntimeAccessService.java:67)
at weblogic.t3.srvr.ServerServicesManager.startService(ServerServicesManager.java:461)
at weblogic.t3.srvr.ServerServicesManager.startInStandbyState(ServerServicesManager.java:166)
at weblogic.t3.srvr.T3Srvr.initializeStandby(T3Srvr.java:879)
at weblogic.t3.srvr.T3Srvr.startup(T3Srvr.java:566)
at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:467)
at weblogic.Server.main(Server.java:71)


Cause :


The reason for the above error is that when the Managed Server are to be started for the first time using the Node Manager and WLST,  the boot.properties file ( at %domain_home%/servers/ManagedServer/security/) and startup.properties file ( %domain_home%/servers/ManagedServer/data/NodeManager/) should be already present.

Solution :


To generate the boot.properties file , and startup.properties file use the below WLST command :

 nmGenBootStartupProps('ms1') 


 

 

 

 

Starting the Managed Server Using Node Manager and WLST

Weblogic 12c


 

The steps for starting the Managed  Server  using WLST and Node Manager are as follows :

i)  Setting up your environment.

Add WebLogic Server classes to the CLASSPATH environment variable and WL_HOME\server\bin to the PATH environment variable.  OR

You can use a  C:\Oracle\Middleware\wlserver_12.1\server\bin\setWLSEnv.cmd  script to set both variables.



 

ii)  Start WLST Session using command : java weblogic.WLST



iii)  Start Node Manager using command :

                         startNodeManager(verbose='true', NodeManagerHome='C:\\Oracle\\Middleware\\wlserver_12.1\\common\\nodemanager', ListenPort='5556', ListenAddress='localhost')





iv) Connect WLST to a Node Manager by entering the nmConnect command.

nmConnect('weblogic', 'weblogic123', 'localhost', '5556', 'base_domain' , 'C:\\Oracle\\Middleware\\user_projects\\domains\\base_domain' , 'ssl')



note: Node Manager security relies on a one-way SSL connection between the client and server.If you are establishing a command line connection to the Java Node Manager using the WebLogic Server Scripting Tool (WLST) nmConnect command, you provide the Node Manager user name and password(here weblogic and weblogic123 respectively). Node Manager verifies the username and password against the domain's nm_password.properties file.Node Manager credentials are located on the Security>General>Advanced Options of Console page.Administration Console users do not need to explicitly provide credentials to connect to Node Manager—the Node Manager user name and password are available in the domain configuration and are provided automatically.

 

v) Use the nmStart command to start a server.
nmStart('AdminServer')



Monitor the status of the Administration Server by entering the nmServerStatus command.
nmServerStatus('AdminServer')

vi) Connect WLST to a running WebLogic Administration Server instance using the connect command.
connect('weblogic','weblogic123')



vii) To start a Managed Server or cluster, enter the following command:
start('Server-0','Server')
         start('mycluster', 'Cluster')



viii) Stop the server by entering the nmKill command.
nmKill('Server-0')



 

ix) Stop the AdminServer by entering the nmKill command.
nmKill('AdminServer')



  x) Disconnect the node manager :     nmDisconnect()   and   Exit the WLST:     exit()



note:  To find node manager process :
For windows
netstat -ao| findstr 5556
TCP    ajit:5556              ajit:0                 LISTENING       1900

here : PID - 1900.

For Linux/unix :

netstat -an | grep -v grep | grep weblogic.NodeManager

 

 

Starting the Administration Server Using Node Manager and WLST

Weblogic 12c


The steps for starting an Administration Server using WLST and Node Manager are :

 

i)  Setting up your environment.

Add WebLogic Server classes to the CLASSPATH environment variable and WL_HOME\server\bin to the PATH environment variable.  OR

You can use a  C:\Oracle\Middleware\wlserver_12.1\server\bin\setWLSEnv.cmd  script to set both variables.



 

ii)  Start WLST Session using command : java weblogic.WLST



iii)  Start Node Manager using command :

                         startNodeManager(verbose='true', NodeManagerHome='C:\\Oracle\\Middleware\\wlserver_12.1\\common\\nodemanager', ListenPort='5556', ListenAddress='localhost')





iv) Connect WLST to a Node Manager by entering the nmConnect command.

nmConnect('weblogic', 'weblogic123', 'localhost', '5556', 'base_domain' , 'C:\\Oracle\\Middleware\\user_projects\\domains\\base_domain' , 'ssl')



note: Node Manager security relies on a one-way SSL connection between the client and server.If you are establishing a command line connection to the Java Node Manager using the WebLogic Server Scripting Tool (WLST) nmConnect command, you provide the Node Manager user name and password(here weblogic and weblogic123 respectively). Node Manager verifies the username and password against the domain's nm_password.properties file.Node Manager credentials are located on the Security>General>Advanced Options of Console page.Administration Console users do not need to explicitly provide credentials to connect to Node Manager—the Node Manager user name and password are available in the domain configuration and are provided automatically.

 

v) Use the nmStart command to start a server.
nmStart('AdminServer')



Monitor the status of the Administration Server by entering the nmServerStatus command.
nmServerStatus('AdminServer')

vi) Connect WLST to a running WebLogic Administration Server instance using the connect command.
connect('weblogic','weblogic123')



vii) Stop the AdminServer by entering the nmKill command.
nmKill('AdminServer')



viii) Disconnect the node manager :     nmDisconnect()   and   Exit the WLST:     exit()

Start a Managed Server using Node Manager through the Administration Console

 

Before you start  make sure that your  environment meets the following Prerequisites:

 

i) Start Node Manager using command prompt

C:\Oracle\Middleware\wlserver_12.1\server\bin>startNodeManager.cmd localhost 5556



ii) Navigate to Domain Structure in Oracle Weblogic Server 12c  console  and click  Servers. And then click on control tab in the right pane i.e  Summary of Servers.



 

iii) Select managed server need to start and click on start tab.



iv) A request has been sent to the node manager to start the server. See Snap below



 

Monday, February 13, 2012

Weblogic Server Release Version

Now days there is lot of confusion regarding the WebLogic Server Release versions available.

I will post here the the version details for the WebLogic Server 11g .

The new Naming convention for the WebLogic Server 11g is : WebLogic Server 11g Release [1-2] Patch Set [1-3]

WebLogic Server 12c    ------------------------------12.1.1.0
WebLogic Server 11gR2  ----------------------------10.3.5.0
WebLogic Server 11gR1 Patch Set 3 ---------------10.3.4.0
WebLogic Server 11gR1 Patch Set2 ----------------10.3.3.0
WebLogic Server 11gR1 Patch Set1 ----------------10.3.2.0
WebLogic Server 11g   -------------------------------10.3.1.0



To get the WebLogic Server Version Installed , you can use anyone of the below steps :

1 : Check the registry.xml   present at location : %MIDDLEWARE_HOME%

2 : For Windows ,  command prompt execute setWLSEnv.cmd to set the environment and then execute the on the same command prompt java weblogic.version -verbose.
%Middleware_Home%/wl_server/server/bin/setWLSEnv.cmd
java weblogic.version -verbose

 

3 : For Linux :

source %Middleware_Home%/wl_server/server/bin/setWLSEnv.sh

java weblogic.version -verbose

 

 

 

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 &