Monday, September 25, 2023

1) Search and replace text script  -- script name replace.sh


#!/bin/bash
# script to search and replace text and take backup file
if [ $# != 3 ] ; then
echo "Input error : syntax replace < search path> <search string> < replace string>
exit 1
elif [ ! -e $1 ] ; then
echo "Given Path $1 doesnt exist"
exit 1
else
find $1 -type f -iname *.log -exec sed -i-$(date +%d-%m-%y) "s/$2/$3/g" {} \;
exit 0
fi

2) Execution outcome 



Tuesday, May 12, 2020

Ubuntu 20.4 manual ip config

1) cat /etc/netplan/00-installer-config.yaml 
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s3:
      dhcp4: no
      addresses: [192.168.0.200/24]
      gateway4: 192.168.0.1  
      nameservers:
              addresses: [8.8.8.8,8.8.4.4]
  version: 2
2) netplan apply

3) ip a

Saturday, October 19, 2019

ocp 3.9 origin installation on centos 7

1) install required packages 

yum install -y wget git  nano net-tools docker-1.13.1 bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct openssl-devel httpd-tools NetworkManager python-cryptography python-devel python-passlib java-1.8.0-openjdk-headless "@Development Tools";

2) Add ansible repo for 2.6 version 

[ansible]
name = Ansible Repo
baseurl = https://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/
enabled = 1
gpgcheck =  0

3) update centos 7

yum update -y

4) start and enable docker 

systemctl start docker && systemctl enable docker && systemctl status docker

5) install ansible 2.6 required for ocp 3.9 ansible playbook 

yum -y install ansible-2.6* pyOpenSSL

6) clone ansible repository 

git clone https://github.com/openshift/openshift-ansible.git -b release-3.9

7) create ssh key and copy to target system 

ssh-keygen
ssh-copy-id   master infra worker

7) edit inventory ini for 1 master 1 worker and 1 infra node without LB


8) Run playbooks

ansible-playbook -i inv.ini playbooks/prepare.yml
ansible-playbook -i inv.ini playbooks/deploy_cluster.yml

Wednesday, February 14, 2018

Linux command line proxy / docker proxy configuraiton

Linux command line proxy configuration 

 If your system  placed in the restricted network and it  require to connect Internet through proxy server then you need to setup proxy server configuration by exporting http_proxy  or https_proxy linux environment value.

syntax :

export http_proxy=http://username:password@proxyserver:proxyport

export https_proxy=https://username:password@proxyserver:proxyport

example:

export http_proxy=http://kamal:kamal@myproxy.mynetwork.com:8080

export https_proxy=http://kamal:kamal@myproxy.mynetwork.com:8443

if you want to revert http_proxy config then simply type  $unset http_proxy from linux command prompt .

Docker proxy configuration

Same way you need to setup proxy configuration for docker too so that you can download / search / push / pull docker images from public docker registry.

by default docker wont take proxy config from environment variable you need to config by creating http-proxy.config file in the docker service directory.

1) Create a directory path and config file as a root user ( remember your user need to be a member of docker group or you must be a root user to perform this docker config by default directory and configuration file doesn't exist  )

# mkdir -p /etc/systemd/system/docker.service.d

vi /etc/systemd/system/docker.service.d/http-proxy.conf    or      #vi /etc/systemd/system/docker.service.d/https-proxy.conf

2) Edit docker proxy  config file
  
#vi /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTP_PROXY=http://kamal:durai@proxy.myserver.com:8080"

3)Reload systems daemon configurations

 #systemctl daemon-reload

4) Restart docker service
  #systemctl restart docker
  
5) Verify docker proxy config
  #systemctl show --property=Environment docker    

6) Search docker images from docker registry 

#docker search nginx 

now you can see number of  nginx docker iamges from varies registry   

Thursday, July 13, 2017

Ansible installation yum based

Ansible:-

 Ansible is a push method config management tool, Relay on ssh protocol and Python is required on master and other nodes,support windows too through winRM module.

Installation :

1) ansible package is available in EPEL repository so EPEL is required.
2)yum -y install ansible
3)boto module installation for aws modules support
4)pip install boto ; pip upgrade boto

Verification:
#ansible --version

user creation and access path creation 

Ansible master node public key needs to copy all the nodes and ansible user sudo access must create.

master node :
 #useradd ansible;passwd ansible;su - ansible;ssh-keygen ;ssh-copy-id -i id_pub ansible@node1
   visudo ; ansible ALL=(ALL)  NOPASSWD
node1:
 #useradd ansible;passwd ansible;su - ansible

Tuesday, December 8, 2015

Docker installation and proxy settings from docker site (Cent OS)

I - Installation :-

1)Adding docker yum repository to your local machine.

#vi  /etc/yum.repos.d/docker.repo

[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
#Proxy config -- optional
#proxy=http://192.168.1.1:80
#proxy_username=domainname\username
#proxy_password=password

2)Install docker throught yum

#yum install docker-engine

3)start & check status of docker service using systemctl

#systemctl start docker.service
#systemctl status  docker.service

II - Docker Proxy configuration for  docker image :- 

1)create a directory for docker service

#mkdir /etc/systemd/system/docker.service.d

2)Add proxy settings in config file

#vi /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="http_proxy=http://domainname\username:password@192.168.1.1:80"

3)Reload docker config and restart docker service

  # systemctl daemon-reload
  # systemctl show docker --property Environment
  # systemctl restart docker

4)Check docker service and pull ubuntu image

  #docker run hello-world
  #docker run -it ubuntu bash

5)check docker version
 
  #docker info

Monday, October 26, 2015

Raspberry PI static IP setup - Wireless wlan0


1)Edit network card and add ip / broadcast / gateway address

pi@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.33
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.254
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

pi@raspberrypi ~ $

2) Add wifi router name & password

pi@raspberrypi ~ $ sudo cat  /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="hubname"
        psk="password"
        key_mgmt=WPA-PSK
}
pi@raspberrypi ~ $

3)View your ip


pi@raspberrypi ~ $ ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr
          inet addr:192.168.1.33  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:915 errors:0 dropped:148 overruns:0 frame:0
          TX packets:329 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:202526 (197.7 KiB)  TX bytes:49840 (48.6 KiB)

pi@raspberrypi ~ $

simple google search can fetch lots of results  but this post is for my reference :) ,Today My Raspberry PI2 DAY :)




Wednesday, April 8, 2015

Tomcat startup script - Tomcat V6/7/8 - Linux

Tomcat startup script :-

Script based  Tomcat lifecycle management is good in Production and test environment,Befor starting  Tomcat server we have to export Tomcat variables in system level

most common varialbes are :-

1)CATALINA_BASE     - Tomcat installation location
2)CATALINA_HOME   - Tomcat instance location if you are running multible instance in same machine .
3)CATALINA_OPTS    - Server scope java options  eg time zone ,language support etc
4)CATALINA_OUT      - Catalina.out file location - jvm output will be store in this file
5)CATALINA_PID        - Tomcat server process id file
6)JAVA_HOME             - Java home
7)JAVA_OPTS              - Java options - JVM options , heapsize ,minimum & maximum memor size , tunning parameters

Sample  bash script which is used to start  owcs 11g  hosted tomcat instance .

startup.sh

#!/bin/sh

FW_UID=11112

if [[ $EUID -ne $FW_UID ]]; then
  echo "This script must be run as  tomcat user"  1>&2
  exit 1
else

CATALINA_OUT=/owcs/logs/dev/editorial/catalina.out
CATALINA_BASE=/owcs/dev/editorial/cs_tomcat
CATALINA_HOME=/owcs/apache-tomcat-6.0.37
CATALINA_PID=/owcs/pids/dev_editorial_pid
JAVA_HOME=/owcs/jdk1.6.0_45
CLASSPATH=$CATALINA_HOME/lib/ojdbc6.jar:$CATALINA_BASE/cs_tomcat/webapps/cs/WEB-INF/lib/MSXML.jar:/owcs/dev/owcs-editorial/bin:$JAVA_HOME/lib/tools.jar
JAVA_OPTS="-Xms2048m -Xmx2048m -Xss512k -Xloggc:/owcs/logs/dev/editorial/verbosegc.$$ -XX:PermSize=512m -XX:MaxPermSize=650m -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Duser.timezone=Europe/London -Dcom.sun.management.jmxremote -Dfile.encoding=UTF-8 -Dcs.useJavaURLDecoder=false -Dcs.useEhcache=true -Dnet.sf.ehcache.enableShutdownHook=true -DenableErrorPropagation=true -Djava.library.path=/owcs/dev/owcs-editorial/bin -Djava.awt.headless=true"

export CATALINA_OUT CATALINA_BASE CATALINE_HOME CATALINA_PID JAVA_HOME JAVA_OPTS CLASSPATH

case $1 in
'start')
        exec "$CATALINA_HOME"/bin/catalina.sh start "$@"
        ;;

'stop')
        exec "$CATALINA_HOME"/bin/catalina.sh stop -force "$@"
        ;;

*)
        echo "usage: $0 {start|stop}"
        rval=1
        ;;
esac
fi

Reference :-

http://tomcat.apache.org/tomcat-6.0-doc/index.html

Monday, April 6, 2015

Yum based Docker installation (Redhat EL 6.6 )

Yum based Docker installation :-

Requirements :

1)Redhat linux 6.5 or above
2) EPEL Repository

Procedure :-

1) Download EPEL 6 - 64 bit repository 

#rpm -ivh  http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
#yum update
#yum repolist

2) Install docker-io through yum 

#yum -y install docker-io

3) Disable selinux 

#SELINUX=disabled in  /etc/selinux/config file and reboot system

4) Start and enable docker daemon 

#service docker start
#chkconfig docker on
#service docker status

6) Check docker installation - 250 MB download from internet depends on your download speed

# docker run -i -t fedora /bin/bash

Unable to find image 'fedora:latest' locally
fedora:latest: The image you are pulling has been verified

511136ea3c5a: Pull complete
00a0c78eeb6d: Pull complete
834629358fe2: Pull complete
Status: Downloaded newer image for fedora:latest


Reference :-

1) http://docs.docker.com/installation/rhel/

Monday, June 9, 2014

JRockit 1.6 64 bit installation on Redhat Linux 6 64 bit .

In production systems we use JRockit jvm for weblogic application server .

1)Copy bin format jrockit 1.6 installer into your linux box /opt directory .
     scp jrockit-jdk1.6.0_37-R28.2.5-4.1.0-linux-x64.bin root@localhost:/opt 

2)Add execute file permission into installer.
   #chmod +x  jrockit-jdk1.6.0_37-R28.2.5-4.1.0-linux-x64.bin

3)Execute jrokit 1.6 installer .
   #./jrockit-jdk1.6.0_37-R28.2.5-4.1.0-linux-x64.bin
  Follow the wizard  if you want to change installation location you can specify directory location during the installation .

eg: 

<------------------------- Oracle JRockit Installer - Oracle JRockit JDK R28.2.5 for Java SE 6 with JRMC 4.1 ------------------------>

Choose Product Installation Directory:
--------------------------------------

    "Product Installation Directory" = [Enter new value or use default "/root/jrockit-jdk1.6.0_37-R28.2.5-4.1.0"]

     Enter new Product Installation Directory OR [Exit][Previous][Next]> /opt/jrockit1.6.0_37

4)Once installation completed then check jrockit installed directory 
    eg 
      # ll /opt/jrockit1.6.0_37
       total 260
      drwxr-xr-x. 2 root root   4096 Sep 27  2012 bin
      drwxr-xr-x. 3 root root   4096 Sep 24  2012 include
      drwxr-xr-x. 3 root root   4096 Jun  9 14:02 inventory
      drwxr-xr-x. 4 root root   4096 Jun  9 14:02 jre
      drwxr-xr-x. 2 root root   4096 Sep 24  2012 lib
      drwxr-xr-x. 6 root root   4096 Jun  9 14:02 missioncontrol
      -rw-r--r--. 1 root root 239443 Sep 27  2012 THIRDPARTYLICENSEREADME.txt

     


   

Thursday, November 14, 2013

Remote Display using ssh - xterm issue

When you try to access remote system display through ssh you may get below error .

$ xterm
xterm Xt error: Can't open display: 
xterm:  DISPLAY is not set
CHECKING REMOTE DISPLAY CONFIGURATION 

$ echo $DISPLAY

CHANGE BELOW VALUES IN THE FILE 

$ VI /etc/ssh/sshd_config 
X11Forwarding yes
X11DisplayOffset 10
RESTART THE SSHD SERVICE
#service sshd restart 
CONNECT REMOTE SERVER 
#ssh -X root@remoteserver.com
TEST X SERVER DISPLAY
#xterm

Monday, September 30, 2013

Linux Simple NFS Sharing (Redhat/Centos/etc..)

This procedures for  simple nfs sharing

Server Side : (192.168.0.1)

1) Install nfs package (nfs,nfs utils,rpcbind are packages are required )
    #yum install nfs*

2) Export nfs sharing folders
    #vi /etc/exports
 
  eg : /nfs folder export to all network with read and write access
               # cat  /etc/exports
                      /nfs *(rw)
3)start the nfs services (nfs using rpcbind port number 2049)

#service rpcbind start
#service nfs start
#chkconfig rpcbind on
#chkconfig nfs on

4)exporting the  shares

   #exportfs -av
 
5)verifying  exports

  #showmount -e localhost
 
Client Side : (192.168.0.2)
  mounting NFS sharing  to local machine 
 
1)create mount directory
   #mkdir /nfs
 
2)installing nfs packages

   #yum install nfs*
 
3)staring the nfs service (first we need to start rpcbind as nfs using rpcbind port number 2049)

   #service rpcbind start
   #service nfs start
   #chkconfig rpcbind on
   #chkconfig nfs on

4)mounting nfs share

  #mount -t nfs 192.168.0.1:/nfs  /nfs

5)check the mount points

  #mount  
  

WLST access using key files


1) connect the server and store the user credentials as a key file

             connect("weblogic","Webl0gic","t3://192.168.1.10")
             storeUserConfig('/opt/oracle/user.config','/opt/oracle/user.key')

2) example to  connect the server  using key files

connect(userConfigFile='/opt/oracle/user.config',userKeyFile='/opt/oracle/user.key',url='t3://192.168.1.10')

Sunday, September 22, 2013

Apache Tips

Some of my Apache works

1)fix for apache error 'Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using sso.linux.com for ServerName'

add below properties in /etc/httpd/conf/httpd.conf file


ServerName localhost

2)Disable default html index file
  

comment out all the lines in /etc/httpd/conf.d/welcome.conf


3) Directory Listening using virtual host and alias  example





NameVirtualHost *:808

Alias /logs  "/test"

<VirtualHost *:808>

<Directory /test>
    Options Indexes FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>
</VirtualHost>


4)Apache Reverse proxy Configuration example
 <VirtualHost *:8446>
  SSLEngine On
  SSLCertificateFile /home/apache/ssl_certs/server.crt
  SSLCertificateKeyFile /home/apache/ssl_certs/server.key
  ProxyPass    /app01/    http://10.0.1.1:808/logs/
  ProxyPassReverse     /app01/    http://10.0.1.1:808/logs/
  ProxyPass    /app02/    http://10.0.1.2:808/logs/
  ProxyPassReverse     /app02/    http://10.0.1.2:808/logs/
</VirtualHost>

5) Apache 2.4 virtual host directory sharing config for ansible
 
http://localhost:81/opt/repo  should work fine for file sharing  

 Listen 81
<VirtualHost *:81>
DocumentRoot "/"
<Directory "/opt/repo">
    Options Indexes MultiViews FollowSymlinks
    AllowOverride None
    Require all granted
</Directory>
<Directory "/foo">
    Options Indexes MultiViews FollowSymlinks
    AllowOverride None
    Require all granted
</Directory>
</VirtualHost>
 

Weblogic Application deployment using maven plugin

1)create a "weblogic" maven plug-in

 i) change webloigc library directory

      #cd MW_HOME/wlserver_10.3/server/lib/

 ii)create a plug-in using wljarbuilder

      #java -jar wljarbuilder.jar -profile weblogic-maven-plugin

 iii)now you can see the weblogic maven plugin file "weblogic-maven-plugin.jar"

2)weblogic plugin  configuration and installaion in to maven ".m2" repository

    i)extract pom file from weblogic plug-in

      #jar xvf weblogic-maven-plugin.jar META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml
  
   ii)copy the pom file from extract location to local location .
    
      #cp META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml .

   iii)add "com.oracle.weblogic" in pluginGroups to the maven settings.xml as follow
  
            <pluginGroups>
                  <pluginGroup>com.oracle.weblogic</pluginGroup>
             </pluginGroups>

  iV)change the weblogic-maven-plugin.jar pom.xml file as follows
         <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
          http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.oracle.weblogic</groupId>
        <artifactId>weblogic-maven-plugin</artifactId>
        <packaging>maven-plugin</packaging>
        <version>10.3.4</version>
        <name>Maven Mojo Archetype</name>
        <url>http://maven.apache.org</url>
        <dependencies>
           <dependency>
               <groupId>org.apache.maven</groupId>
               <artifactId>maven-plugin-api</artifactId>
               <version>2.0</version>
           </dependency>
        </dependencies>
        <build>
        <plugins>
          <plugin>
          <artifactId>maven-plugin-plugin</artifactId>
          <version>2.3</version>
           <configuration>
             <goalPrefix>weblogic</goalPrefix>
           </configuration>
          </plugin>
        </plugins>
        </build>
        </project>
   v) install weblogic-maven-plugin file and pom file .
  
       #mvn install:install-file -Dfile=weblogic-maven-plugin.jar -DpomFile=pom.xml  

3)verify weblogic plug-in

   i)execute below file will show weblogic help
    
     #mvn weblogic:listapps


4)sample maven for undeploy , deploy and list the applications in cluster

<?xml version="1.0" encoding="windows-1252" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <groupId>application</groupId>
  <artifactId>applicationEar</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>ear</packaging>
 
  <dependencies>
    <dependency>
          <groupId>application</groupId>
          <artifactId>applicationViewController</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <type>war</type>
    </dependency>
  </dependencies>
 
  <build>
    <resources>
          <resource>
            <directory>../.adf</directory>
            <includes>
              <include>**/*</include>
            </includes>
            <targetPath>adf</targetPath>
          </resource>
          <resource>
            <directory>../src/META-INF</directory>
            <includes>
              <include>**/*</include>
            </includes>
            <targetPath>META-INF</targetPath>
          </resource>
     </resources>
    <plugins>
        <plugin>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
              <finalName>application</finalName>
              <earSourceDirectory>${project.build.directory}/classes</earSourceDirectory>
              <archive>
                <addMavenDescriptor>false</addMavenDescriptor>
              </archive>
              <modules>
                <webModule>
                  <groupId>application</groupId>
                  <artifactId>applicationViewController</artifactId>
                  <contextRoot>application</contextRoot>
                </webModule>
              </modules>
              <defaultLibBundleDir>lib</defaultLibBundleDir>
            </configuration>
          </plugin>
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>10.3.6.0</version>
<configuration>
<adminurl>t3://10.0.1.40:7001</adminurl>
<user>wldeployer</user>
<password>wldeployer123</password>
<upload>true</upload>
<target>vfccare</target>
<verbose>true</verbose>
<source>${project.build.directory}/application.ear</source>
<stage>true</stage>
<name>application</name>
<failonerror>false</failonerror>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>undeploy</goal>
<goal>deploy</goal>
<goal>list-apps</goal>
</goals>
</execution>
</executions>
</plugin>

    </plugins>
   
  </build>
 
  <parent>
    <groupId>application</groupId>
    <artifactId>application</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
 
</project>

Tuesday, August 6, 2013

Key Less linux root login using moba - Xterm


MobaXterm is powerful ssh client for linux and it's better then putty !!!

1) download and install mobaxterm personal edition  from website http://mobaxterm.mobatek.net/

2)log into linux box as a root .

3)generate private / public ssh key without passphrace

   #ssh-keygen -t rsa

  below three files will create under .ssh directory

   /root/.ssh/
                id_rsa   - private key
                id_rsa.pub - public key
                known_hosts - know host file

4)copy the public key to  login as a root user

 #ssh-copy-id -i /root/.ssh/id_rsa.pub root@master.linux.com

the above command will create authorized_keys file under /root/.ssh/ folder to authenticate key less ssh login

5)copy the private key in to your local windows machine

  eg : -

[root@master .ssh]# cat id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEoQIBAAKCAQEA9vrrNhbh9qjagzn+s88C4Jlpp1H2ABZ+h2ExN3uvRAi0mHd7
Jgm+T1ank9Tr2H6DwEDoSyAIckaVtroJnA66vYbG8qvHjaRuQzH+a/voL6647xXX
TirmlPexiVE8kGmRu04nVy9rmgvbWcLXwVXX3LNjECh3ejmTUFTPAb0Uu5UkemxN
37ixedJ3YKPQ5P5WydWautlnrjPrZKwY0bk2qPyZp8ZiL8CKTZge+CIoSV3td6++
FRAwxYV3yZFa7u8wrNRkgyW/3sS154KCPgaEJ8m1khu9BwemWYX+uhxGyhSZMRus
Qn5oZOJFj5zhc7q7AX2X36wYj3015teC/gfdWwIBIwKCAQEAok0eOXzAYEMTQEqu
sKybfaakg+VnJKERUaZE6fIxWJgBpgVfjgZnHjGhUoSa+/td5Lzwa+HZqi5iYiJ7
V+xsFiVeKnDiOIH/ULpz/dFssZ60CtPWoRTgqwkrhh9w8S9uZSS6xEO7vQB6M6vs
3iJ36M2nf6WQV6ItmzBqxqDTHC2EVq5YIvX8g1u9kPjfO2W10alA6PWCva7BtlSB
9u0YPH8ZDNW9jjM4URtAZeYvpDrHc7KftGr5jmBVWWQ4km+5wFBs9YDrxDn+UyNc
yX2kn01VebyqpHGnpwMyhlBzqRfNHWgxZqLJTP/ABvbf2cKdwdZ+ksNENHM7YL+2
ALZbOwKBgQD9tst2mxPSAM9VYgU4XFicXB1RZoF60zSIqXOlOX5g5ZqmzjujeSSw
EdFUxMiXbPzdzexRI9Uh4CWY5HrcIBJEKi62tynIpKBNBA5N99tSP/Ntnkr6n1So
l3WnszpH/WzBasPli/nQdpW2QCVFLxKfpIFPK8bIV219vqoyLohVcwKBgQD5NJeI
zKj7CimdWalxWsgrUA/FKX4l5t8w0kiMbmK8AyYapJ6H/5vScnDMYKI9O4IMq8ne
FlV84DFzRsvl8AZiioRV5xZj7iUzyR0AHq7IFs/nRbGoeJa72izdnqpZ7LtGmZfU
lMSG/rEdLpvCD4sVCX46LZrHCaMmJaVoXxweeQKBgBW/NgLaF6RJNlfGkruwJNoz
x/+ps1OrtAu2wMUE7ZNG4V7BOE/XLwfHA1Boo3qxkgRiG5HtIOWlf5DDIHlEk9n0
/LCTW1pXQPCok4MGncU4rnccMk//B0GmlQ5f0cuoAgHzNVzRe9AKKhbvjiqAYK6Z
EmXfLkuvuO2FXwudlqg9AoGAHHsKAQFyZdVGlaPY2cE7cqoQbk3ih/0g0mEs3Nlq
XqFGLu4+AOoDLf5zSo6zdLZYAXK3/B/PQXi1Mb7yuzFf0L9flMnz7inYXbCVmZ0b
ShE8VPIFrNqU4kTR7XE4Ckbw1N5afrHqkxXLGUcnvmgtJvnFSHo9kxcLVNEaN9Ba
/CsCgYA3xCp5THCtBLpEphP1oIixIYdERHpHOLdL+rQM5LUtvAZ02pHj0GfBaRtQ
i5Rs2wbigmbY2dZJotWY/WZRXQvUgsiyyhzPthw8JI7ZuNQsHBMFmhRXZJ7xHb4v
hPPRpP/XuhKVxqWiROcBnRDt8vK+Bh47jFWDZViO7N/n70RllQ==
-----END RSA PRIVATE KEY-----
[root@master .ssh]#

6)open new session in mofa-xterm in windows and do  below six steps for key less authentication

   i) create a .ssh directory in home folder
          #mkdir ~/.ssh
   2) create a private authantication key file in .pem file format
          #vi ~/.ssh/master.pem
   3) copy the above step 5 private key from Begin line to end line in to ~/.ssh/master.pem

   4) just verify the key file
           #cat  ~/.ssh/master.pem
             -----BEGIN RSA PRIVATE KEY-----
MIIEoQIBAAKCAQEA9vrrNhbh9qjagzn+s88C4Jlpp1H2ABZ+h2ExN3uvRAi0mHd7
Jgm+T1ank9Tr2H6DwEDoSyAIckaVtroJnA66vYbG8qvHjaRuQzH+a/voL6647xXX
TirmlPexiVE8kGmRu04nVy9rmgvbWcLXwVXX3LNjECh3ejmTUFTPAb0Uu5UkemxN
37ixedJ3YKPQ5P5WydWautlnrjPrZKwY0bk2qPyZp8ZiL8CKTZge+CIoSV3td6++
FRAwxYV3yZFa7u8wrNRkgyW/3sS154KCPgaEJ8m1khu9BwemWYX+uhxGyhSZMRus
Qn5oZOJFj5zhc7q7AX2X36wYj3015teC/gfdWwIBIwKCAQEAok0eOXzAYEMTQEqu
sKybfaakg+VnJKERUaZE6fIxWJgBpgVfjgZnHjGhUoSa+/td5Lzwa+HZqi5iYiJ7
V+xsFiVeKnDiOIH/ULpz/dFssZ60CtPWoRTgqwkrhh9w8S9uZSS6xEO7vQB6M6vs
3iJ36M2nf6WQV6ItmzBqxqDTHC2EVq5YIvX8g1u9kPjfO2W10alA6PWCva7BtlSB
9u0YPH8ZDNW9jjM4URtAZeYvpDrHc7KftGr5jmBVWWQ4km+5wFBs9YDrxDn+UyNc
yX2kn01VebyqpHGnpwMyhlBzqRfNHWgxZqLJTP/ABvbf2cKdwdZ+ksNENHM7YL+2
ALZbOwKBgQD9tst2mxPSAM9VYgU4XFicXB1RZoF60zSIqXOlOX5g5ZqmzjujeSSw
EdFUxMiXbPzdzexRI9Uh4CWY5HrcIBJEKi62tynIpKBNBA5N99tSP/Ntnkr6n1So
l3WnszpH/WzBasPli/nQdpW2QCVFLxKfpIFPK8bIV219vqoyLohVcwKBgQD5NJeI
zKj7CimdWalxWsgrUA/FKX4l5t8w0kiMbmK8AyYapJ6H/5vScnDMYKI9O4IMq8ne
FlV84DFzRsvl8AZiioRV5xZj7iUzyR0AHq7IFs/nRbGoeJa72izdnqpZ7LtGmZfU
lMSG/rEdLpvCD4sVCX46LZrHCaMmJaVoXxweeQKBgBW/NgLaF6RJNlfGkruwJNoz
x/+ps1OrtAu2wMUE7ZNG4V7BOE/XLwfHA1Boo3qxkgRiG5HtIOWlf5DDIHlEk9n0
/LCTW1pXQPCok4MGncU4rnccMk//B0GmlQ5f0cuoAgHzNVzRe9AKKhbvjiqAYK6Z
EmXfLkuvuO2FXwudlqg9AoGAHHsKAQFyZdVGlaPY2cE7cqoQbk3ih/0g0mEs3Nlq
XqFGLu4+AOoDLf5zSo6zdLZYAXK3/B/PQXi1Mb7yuzFf0L9flMnz7inYXbCVmZ0b
ShE8VPIFrNqU4kTR7XE4Ckbw1N5afrHqkxXLGUcnvmgtJvnFSHo9kxcLVNEaN9Ba
/CsCgYA3xCp5THCtBLpEphP1oIixIYdERHpHOLdL+rQM5LUtvAZ02pHj0GfBaRtQ
i5Rs2wbigmbY2dZJotWY/WZRXQvUgsiyyhzPthw8JI7ZuNQsHBMFmhRXZJ7xHb4v
hPPRpP/XuhKVxqWiROcBnRDt8vK+Bh47jFWDZViO7N/n70RllQ==
-----END RSA PRIVATE KEY-----

  5)change the file permission read and write only for user

     #chmod 600 ~/.ssh/master.pem

  6) create a login config file for ssh

     #vi ~/.ssh/config
     
      host master
      hostname 192.168.0.30
      user root
      IdentityFile ~/.ssh/master.pem

7)run below command it will take  to your linux box (192.168.0.30) without any key

    #ssh master

Tuesday, July 30, 2013

Weblogic Admin server startup service script

1) create a file in this path   /opt/init.d/wlsdomains

2)copy the below script
#!/bin/bash
#
# Weblogic Admin Server Startup Script
#
# chkconfig: 345 94 06
# description: Weblogic
# processname: Java

# Source function library
. /etc/rc.d/init.d/functions

WLS_HOME=/opt/apps/wls/Oracle/Middleware/
WLS_USER=wlsadmin
DOMAIN_HOME=/opt/apps/wls/domains
DOMAIN=test
#set the return value of the script to 0, which means no error.
RETVAL=0

prog="WebLogic Admin Server"
PIDFILE=$DOMAIN_HOME/$DOMAIN/wls_pid

function pidfile()
{
    PID=`cat $PIDFILE`
    echo "PID=$PID"
}

start() {
echo -n $"Starting $prog: "
nohup su - $WLS_USER -c $DOMAIN_HOME/$DOMAIN/startWebLogic.sh  > /tmp/$DOMAIN.log &
echo $! > $PIDFILE
echo "Starting $prog: $DOMAIN.... OK"
}

stop() {
echo -n $"Stopping $prog: "
nohup su - $WLS_USER -c $DOMAIN_HOME/$DOMAIN/bin/stopWebLogic.sh > /tmp/$DOMAIN.log &
echo "Shutting down $prog: $DOMAIN... OK"
rm -rf $PIDFILE
}

restart() {
  stop
  sleep 10
  start
}

reload() {
        restart
}

case "$1" in
start)
        start
pidfile
        ;;
stop)
pidfile
stop
        ;;
reload)
        reload
        ;;
restart)
        restart
        ;;
status)
#STATUS=`ps -ef | grep java | grep weblogic | wc -l`
PID=`cat $PIDFILE`
if `ps -p $PID > /dev/null`; then
             echo "$prog: $DOMAIN is running, PID=$PID ok."
        else
             echo "$prog: $DOMAIN is not running ..."
        fi
;;
*)

echo $"Usage: $prog {start|stop|status|restart|reload}"
esac

exit 1

3) chang the file permission
  #chmod  +x /etc/init.d/wlsdomains

4) add in to service 
  #cd /etc/init.d
  #chconfig --add wlsdomains
  #chkconfig wlsdomains on
  #service wlsdomains start

Nodemanager linux Init script

1) create a file 'nodemanager'
   vi /etc/init.d/nodemanager
2)copy the below script in to that file
#!/bin/bash
#
# Weblogic Nodemanager Startup Script
#
# chkconfig: 345 95 05
# description: Weblogic Node Manager
# processname: Nodemgr

# Source function library
. /etc/rc.d/init.d/functions

WLS_HOME=/opt/apps/wls/Oracle/Middleware
DOMAIN_HOME=/opt/apps/wls/domains
WLS_USER=wlsadmin
#set the return value of the script to 0, which means no error.
RETVAL=0
PROCESS_STRING="^.*$WLS_HOME/.*weblogic.NodeManager.*"
prog="WebLogic Nodemanager"
NODEMANAGER_PIDFILE=$WLS_HOME/wlserver_10.3/common/nodemanager/nodemanager_pid

function pidfile()
{
    PID=`cat $NODEMANAGER_PIDFILE`
    echo "PID=$PID"
}

start() {
echo -n $"Starting $prog: "
nohup su - $WLS_USER -c $WLS_HOME/wlserver_10.3/server/bin/startNodeManager.sh > /tmp/nodemanager.log &
echo $! > $NODEMANAGER_PIDFILE
echo "Starting $prog.... OK"
}

stop() {
echo -n $"Stopping $prog: "
OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
if [ "$OLDPID" != "" ]; then
/bin/kill -TERM $OLDPID
else
echo " $prog is already shutdown..."
fi
rm -rf $NODEMANAGER_PIDFILE
}

restart() {
  stop
  sleep 10
  start
}

reload() {
        restart
}

case "$1" in
start)
        start
pidfile
        ;;
stop)
pidfile
stop
        ;;
reload)
        reload
        ;;
restart)
        restart
        ;;
status)
OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
if [ "$OLDPID" != "" ]; then
/bin/echo "$prog is running (pid: $OLDPID)"
else
/bin/echo "$prog is not running"
fi
RETVAL=$?
;;

*)

echo $"Usage: $prog {start|stop|status|restart|reload}"
esac

exit 1

3) change the file permission
   #chmod +x /etc/init.d/nodemanager
4) add in to service
  #chkconfig --add /etc/init.d/nodemanager
5) enable the service 
  #chkconfig nodemanager on
6) start the nodemanager
   #service nodemanager start
7)status of nodemanager
  #service nodemanager status 
8)stop the nodemanager 
  #service nodemanager stop

Tuesday, March 12, 2013

Generating Weblogic server JVM report on HTML format using wlst script



Generating JVM report on HTML format using wlst script .

This wlst script source got it from google search and modified .

jvm_status.py


import os
import sys
import datetime
username='weblogic'
password='webl0gic'
ipaddr=os.environ["HOSTNAME"]
url='t3://'+ipaddr+':7001'
lmtime =str(datetime.datetime.now())
fo = open("jvm.html", "wb+")
fo.write('<html><body bgcolor="lightblue"><center><h3>Weblogic server  &quot;'+ipaddr.upper()+'&quot; Status Updated At :'+lmtime+'</h3>')
fo.write('<table border="1" style="border:1px ;width:80%;border-collapse:collapse;">')
# This module is for retrieve the JVM statistics

def monitorJVM():
     connect('weblogic', 'webl0gic',url)
     serverNames = getRunningServerNames()
     for name in serverNames:
      try:
       cd("/Servers/"+name.getName()+"/ServerStart/"+name.getName())
       jvm = str(cmo.getArguments())
       cpath = str(cmo.getClassPath())
       fo.write('<tr align="center"><h2><td>Server Name: '+ name.getName() + '</td></h2></tr>')
       fo.write('<tr align="center"><td>JVM ARGUMENTS</td></tr>')
       fo.write('<td> '+jvm+' </td>')
       fo.write('<tr align="center"><td>CLASS PATH</td></tr>')
       fo.write('<tr><td> '+cpath+' </td></tr>')
      except WLSTException,e:
       pass
# This module for managed Servers list
def getRunningServerNames():
     config()
     return cmo.getServers()

if __name__== "main":
     monitorJVM()
     fo.write('</table></html>')
     disconnect()




Weblogic patching using off line updater



Weblogic  patching  using off line updater  - linux 64 bit

1) copy patch to weblogic cache directory  (/apps/oracle/wls11g/utils/bsu/cache_dir)
           cp *.jar /apps/oracle/wls11g/utils/bsu/cache_dir/
           cp *.xml /apps/oracle/wls11g/utils/bsu/cache_dir/

2) Check the patch status on current system

           cd /apps/oracle/wls11g/utils/bsu/
           sh bsu.sh  -prod_dir=/apps/oracle/wls11g/wlserver_10.3 -patch_download_dir=/apps/oracle/wls11g/utils/bsu/cache_dir/ -status=downloaded -view -verbose

3) Install the patch
             cd /apps/oracle/wls11g/utils/bsu/
             ./bsu.sh -patch_download_dir=/apps/oracle/wls11g/utils/bsu/cache_dir/ -   prod_dir=/apps/oracle/wls11g/wlserver_10.3/ -patchlist=9ZW7 -install -verbose

4)Verify the current patch

cd /apps/oracle/wls11g/utils/bsu/;
sh bsu.sh -prod_dir=/apps/oracle/wls11g/wlserver_10.3 -status=applied -view -verbose


sample script .

killall java
killall -9 java
sleep 1
cd /apps/oracle/wls11g/utils/bsu/

./bsu.sh -patch_download_dir=/apps/oracle/patch/p10076424/  -prod_dir=/apps/oracle/wls11g/wlserver_10.3/ -patchlist=VJPE -install -verbose;

./bsu.sh -patch_download_dir=/apps/oracle/patch/p10166432/  -prod_dir=/apps/oracle/wls11g/wlserver_10.3/ -patchlist=H3QP -install -verbose;

./bsu.sh -patch_download_dir=/apps/oracle/patch/p10276172/  -prod_dir=/apps/oracle/wls11g/wlserver_10.3/ -patchlist=8IWX -install -verbose;

./bsu.sh -patch_download_dir=/apps/oracle/patch/p9324911/  -prod_dir=/apps/oracle/wls11g/wlserver_10.3/ -patchlist=Y3IR -install -verbose;

./bsu.sh -patch_download_dir=/apps/oracle/patch/p9412909/  -prod_dir=/apps/oracle/wls11g/wlserver_10.3/ -patchlist=R4P6 -install -verbose;