Wednesday, June 8, 2016

Weblogic 12c: start and stop script for starting weblogic admin and managed server

As in my previous blog post I share the concept of starting and stopping nodemanager. In this blog post I am going to show you how you can start and stop weblogic admin server and managed server using admin server connection.

Start scripts for admin server and managed server

Well the basic logic to start admin and managed server is as:

  • Start the admin server using ./startWeblogic.sh script stored at the domain directory.
  • check for the admin server status is running or not by using same way as did for nodemanager in this post. But here we check for the string "RUNNING"
  • After admin started we invoke to start all the managed server cluster (all the server in a cluster will automatically start).
Here is the script:


rm -rf  *_Server.out AdminServer.out

tfile="AdminServer.out"

cd $DOMAIN_HOME
nohup ./startWebLogic.sh > AdminServer.out &

AdminStatus="STOP"

while [ "$AdminStatus" = "STOP" ]; do
                echo $tfile

                count=$(cat $tfile | grep "RUNNING" | wc -l)

echo "The value of count is ${count}"

                if [[ "$count" -gt 0 ]]; then
                        echo "AdminServer Started..."
AdminStatus="RUNNING"
nohup $WEBLOGIC_HOME/common/bin/wlst.sh startOSB.sh > OSB_Server.out &
                        nohup $WEBLOGIC_HOME/common/bin/wlst.sh startSOA.sh > SOA_Server.out &
                        nohup $WEBLOGIC_HOME/common/bin/wlst.sh startWSM.sh > WSM_Server.out &

                        rm -f $tfile
                        exit 0
                else
                    echo "Waiting For AdminServer To Start..."
                        
                fi
        sleep 5s
        done


echo "Please check ${tfile} log file for more issues"
exit 1 

In the above scripts I am calling three more scripts which are used to start the managed server cluster.

startOSB.sh

Content of the script is as follow:

connect('weblogic', 'welcome1', 't3://adminhostname:port')

start('bpm_osb_cluster','Cluster')

disconnect()

startSOA.sh

Content of the script is as follow:

connect('weblogic', 'Oracle123', 't3://adminhostname:port')

start('bpm_soa_cluster','Cluster')

disconnect()

startWSM.sh

Content of the script is as follow:

connect('weblogic', 'Oracle123', 't3://adminhostname:port')

start('bpm_wsm_cluster','Cluster')

disconnect()

Note: you can start the server instead of start cluster, refer this documentation 

Stop scripts for admin and managed server

For stopping managed server scripts first connect to the nodemanager and use the nmkill() method to kill the managed server

nmConnect('weblogic', 'Oracle123', 'prdbpmn01.ebsafrica.com', '5556', 'BPMDomain', '/u02/oracle/config/domains/BPMDomain','ssl')

nmKill('wls_wsm1')
nmKill('wls_osb1')
nmKill('wls_soa1')

nmDisconnect()

exit()

so you have to kill each server because there is no such method available to stop the cluster.

After that stop the admin server using this script.

nohup sh /u01/oracle/config/domains/BPMDomain/bin/stopWebLogic.sh &

Weblogic 12c: start and stop script for nodemanager

Recently I was working on the automated script to start and stop the nodemanager, AdminServer and all managed server (ESS, SOA, OSB, WSM) in a domain. So in this post I am going to share my work, it may be possible that these scripts may not be suited for your environment but yes It must give you a basic idea of how to start and stop nodemanager automatically.

Start scripts for nodemanager

Well the basic logic that I used to start the nodemanager is

  • check if nodemanager is running or not
  • start the nodemanager and take the output in a temporary file.
  • while the nodemanager is starting keep looking for the string "socket listener started on port" in a temporary file. 
  • if the matching string is found that means node manager is started and exit().
rm -rf nodemanage.*

tfile="nodemanage.$$.out"
status= ps -eaf | grep "weblogic.NodeManager" | grep -v grep| wc -l
date=date
echo $status
echo "Node Manager Directory: " $1

if [[ "$status" -eq 0 ]]; then
echo  $date " :Starting Weblogic NodeManager..."
echo $1
nohup $1 > $tfile 2>&1 &

else
echo  $date " :NodeManager is already RUNNING.."
fi

if [ "$?" != 0 ]; then
echo "Command Failed To Execute Properly"
exit 1;
fi

export a=0;
while [ $a -lt 10 ]; do
echo $tfile

count=$(cat $tfile | grep "socket listener started on port" | wc -l)

echo "The value of count is ${count}"                 

if [[ "$count" -gt 0 ]]; then
echo "NodeManager Started..."
rm -f $tfile
exit 0
else
echo "Waiting For NodeManager To Start..."
echo $a
((a++))
fi
sleep 5s
done
echo "Please check ${tfile} log file for more issues"
exit 1

Save the above script in .sh file e.g. startNode.sh. Now to run this script you have to pass the location of the nodemanager i.e.

nohup ./StartNode.sh $DOMAIN_HOME/bin/startNodeManager.sh > nodemanage.out &


Stop script for nodemanager

To stop the nodemanager find the process id of nodemanager instance and kill that process id, here is the script below:

node1=$(ps -ef | grep weblogic.nodemanager | grep config=/u01 | awk '{printf $2}')

kill -9 $node1

Save the above code in the .sh file e.g. stopNode.sh and execute the script as below:

nohup sh StopNode.sh &


In the next post I am going to share the start and stop script for weblogic AdminServer and Managed server.

Thursday, June 2, 2016

Change default /tmp path to other alternate tmp path for middleware installation

Some times when you install middleware component like oracle soa, weblogic etc. then it requires some temp space to extract content and install on the location but there may be case your /tmp directory is full or not having write permissin etc. (in my case there was no space in the tmp directory) you middleware installation stops in between.

Solution:

you can create a new directory as tmp only in some other location (/home/oracle/tmp) and map to the symbolic link of the directory /tmp (previously created).

Command : ln {source} {link}

i.e. ln -s /home/oracle/tml /tmp


Friday, May 13, 2016

Linux: SSH login without password

I was writing the custom shell scripts for starting and stopping the remote server and these scripts required to executed on the remote server itself using ssh. Now but everytime you run ssh command it ask for the password to avoid that I use the public key authentication without the pass phrase (well you should always use the pass phrase from the security perspective).

Steps to configure public key authentication

  • Create ssh public and private keys, i.e. run the command ssh-keygen -t rsa
  • Do not give the pass phrase if you do not want to enter password every time you do the ssh.
  • Add Keys to the server by using the command ssh-copy-id username@hostname
  • Enter the password for first time.
  • now connect the machine using ssh, you will directly connected to the machine without passing the password.

Wednesday, May 11, 2016

OER 12c: Configure oracle enterprise repository to browse and upload file from local system

I was working on the oracle enterprise repository 12.1.3, and trying to upload an asset in oer from my local machine. But in the submit asset window its only showing the file location url i.e. add a file by reference


Steps to configure file upload option

  • Open oer console i.e. http://<host>:<port>/oer in browser, login with admin user.
  • Go to Admin tab -> System Settings -> search for property cmee.server.paths.upload

  • set the location value to upload the file in submission upload directory i.e. /tmp/upload, as shown below

  • Save the setting and go to asset tab and try to create new asset. This time file upload option is visible.



Deployment Failed: XML-24500: (Error) Can not build schema 'http://www.springframework.org/schema/util' located at 'http://www.springframework.org/schema/util/spring-util.xsd'.

Today I was deploying soa composite for oracle enterprise repository on soa server and getting the following exception:

Deploying on partition "default" of "/Domain_base_domain/base_domain/AdminServer" ...
Deploying on "/Domain_base_domain/base_domain/AdminServer" failed!
There was an error deploying the composite on AdminServer: Deployment Failed: Error occurred during deployment of component: TimedEventClass to service engine: implementation.spring for composite: OERWorkflows: SCA Engine deployment failure.: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from URL [oramds:/deployed-composites/default/OERWorkflows_rev1.0/TimedEventClass.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 834; <Line 10 Column 834>: XML-24500: (Error) Can not build schema 'http://www.springframework.org/schema/tool' located at 'http://www.springframework.org/schema/tool/spring-tool-2.5.xsd'.


Cause

This problem comes in oracle product version 12.1.3.0.0 and on windows-7 64 bit system. It occurs due to the parameter -Doracle.xml.schema\Ignore_Duplicate_components=true has back slash in setDomainEnv.cmd file.

Solution

  1. Go to <DOMAIN_HOME>/bin/setDomainEnv.cmd
  2. Change -Doracle.xml.schema\Ignore_Duplicate_components=true to -Doracle.xml.schema/Ignore_Duplicate_components=true i.e. change back slash to forward slash.
  3. Restart the server.
Reference: check the oracle support document Doc ID 2092104.1

Saturday, March 19, 2016

Oracle API Gateway: How to rename ftp file name in OAG

I was working on a requirement in which I have to read a txt file from ftp directory and uploaded to the another ftp server, but the uploaded file name should be appended with the DateTime i,e suppose the file name is code_confuse_sheet.txt and then after uploading the name should change to code_confuse_sheet_20160319.txt
In this blog post I am going to show you how you can rename your ftp file name.

Note: I am not going to show end to end OAG policy and configuration, will show the code snippet and how to use it in your OAG policies.

Steps to rename ftp file name:

When you create FTP Poller listener then it reads the file from the ftp location and pass the file name in attribute ${ftp.file.name}
  • First step is to save the file name in local attribute say ftpfilename. This you can done by using Set Attribute Filter as shown below

  • After that alter the value of this attribute i.e. ftpfilename. This can be done by using Scripting Language Filter and configure as below

importPackage(Packages.com.vordel.trace);
importPackage(Packages.java.lang);
function invoke(msg)         {          
var file = msg.get("ftpfilename");
java.lang.System.out.println("Filename is " + file);
var splitstr =  file.substring(0,file.indexOf("."));
java.lang.System.out.println("Filename is after split " + splitstr);
var newFile = splitstr +"_20160319" + ".txt" ;
Trace.debug(file);
Trace.debug("End of scripting");
java.lang.System.out.println(file);
java.lang.System.out.println("New File Name " +newFile );
java.lang.System.out.println("End of scripting");
msg.put("ftp.file.name",newFile );
return true;

         }
Note: here I have hard coded the value of date just to show how you can add new string, you just change according to your usecase.
  • Use the file upload filter to upload the file and pass the name of the file as ${ftp.file.name}

  • Deploy and test the configurations.