Showing posts with label Solaris. Show all posts
Showing posts with label Solaris. Show all posts

Monday, March 24, 2014

RegEx for WebLogic Admin

Trick on grep


Normally every WebLogic user/Admin knows that "ps -ef|grep java" gives you the WebLogic servers process list in any UNIX or Linux environments. Most of the forums suggesting use "|grep -v" to exclude the "grep line". But, here I don't want to use one more pipe and grep -v option really makes expensive in CPU cycles. Searched for the optimistic solutions and finally found! Two choices using --exclude  and using regex.

The exclude options is not available on all UNIX systems. So I've chosen next option.

How do you avoid the grep line in the grep command output itself?
Here the trick is using the regular expression to workout this requirement. Use your searching pattern any one of the character in [] then it will automatically excludes the grep line from the output. actually it wouldn't get output itself!

bash-2.05$ ps -ef |grep jav[a]
weblogic   950   934  0   Feb 10 ?        0:06 /usr/local/bea/jdk142_11/bin/java -client -Xms32m -Xmx200m -Xverify
:none

Note here I have tried out this trick on Sun Solaris 9 machine. Write your experiments in the comment box, share it!

Wednesday, January 1, 2014

Setting up a best login profile on UNIX


Usually when you are working on building the platform for any application, you might be given UNIX (Solaris/Linux/HP-UX/AIX) boxes and new generation with Virtual boxes. which contains nothing you need to do many installations and configurations. To make your administrative task easy and simple we need to setup a fine tuned profile file. This profile file will be holding the multiple environment variables those are reusable when you log-on to UNIX Kernel  Here you can define shell functions or you can define simple single lined aliases that makes lengthy commands set to simple trimmed single letter or meaningful words.

What is user SHELL and  its profile association?


In your UNIX Kernel when a new user login will check the /etc/passwd file which shell is assigned by the super-user. It will look for the system profile and assign the environment values, then on top of it user profile can be loaded. Hence the variable is defined in system profile can be overridden by user profile. Example PATH environment variable that can be over written by user defined profiles most usual thing it is. So careful while defining such variables. It could behave differently for Solaris same line cannot work on Linux or on AIX box.

Why do we need this to be customize User profile?


Any Middleware admin may involve install and configuring the Apache or Oracle WebCenter Sites or spaces or SOA, Hadoop or Build and deployment platform may requires ANT or Gradle, Jenkins or Hudson setups. Every component that interacts with Middleware runs on the same UNIX Kernel need customized variables that can be referred from any directory or path, so we need them as global variables, this you can acquire by defining them as environment variables in SHELL profile. UNIX Operating system provides all shells associated with a  specific default system provided and a user profile script and that is in the hidden file which prefixed with dot(.) so it looks like .profile in your home directory. You can view them by ls -la command.

Where can I find this profile script?


Usually when you login to UNIX Kernel, you will be landing to a directory that is designated to your user HOME directory. Suppose you already working on some other path, you can simply use cd  or cd ~ and press enter the OS will takes to home directory. Alternatively you can use system defined environment variable by giving cd $HOME.



How do I know I am in which SHELL?


First you need to know about your user login SHELL(default). Every user can have different choice of having a shell. Once you have assigned user or role for WebLogic environment setup then  how do you know what SHELL it is? use the following:

$echo $SHELL
/bin/sh

How many SHELL do my env have?
To know this you could do little experiment on your prompt with the following commands

$ type bash
/usr/bin/bash


Then you can look in that directory all shell names ends with 'sh', list them with small regular expression trick on your ls command. The main trick here is using 'anchor' symbols, the $ symbol indicates ending of the word pattern, and you can use for avoiding the .sh files in that directory character classes can be negated with the [^] syntax.
[WLA@server~]$ cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh
...

[WLA@server~]$ ls /usr/bin | grep [^.]sh$
bash
csh
hash
jsh
ksh
pbksh
pbsh
pfcsh
pfksh
pfsh
remsh
rksh
rsh
ssh
tcsh
zsh
[WLA@server~]$ ls /usr/bin |grep [^.]sh$ |wc -l
cat /etc/shells

How to set bash as login SHELL?

I feel the Bourne Again Shell (bash) is best suitable login shell for WebLogic environment setup.
Sample .bashrc script which will be executed automatically when you hit 'bash' command at your Linux command prompt.
export JAVA_HOME=/u01/app/oracle/jdk1.8.0_121
export PATH=$JAVA_HOME/bin:$PATH
export MW_HOME=/u01/app/oracle/fmw122120
export WL_HOME=$MW_HOME/wlserver
alias wlst="$MW_HOME/oracle_common/common/bin/wlst.sh"

echo ===================================

Now your immediate question might be 'How do you know which shell is assigned to your user profile?' Here is the Trick for you!!

$ echo $SHELL
/bin/sh

The login shell will be assigned as per the common profile set by Solaris/Linux Administrator. That can be changed by passwd -e or passwd -r if you must have root access then only you can do editing the passwd file and update your desired shell there. Some times it is rejects you and shouts 'permission denied'. Just smile on it you can proceed with the following trick!! Using exec command, that will replaces the existing shell with new shell that you want.

export SHELL=/usr/bin/bash
exec $SHELL -l

Shell replacement ksh to bash with exec

What is a process?

process is an entity in execution. The process can be created by fork, exec system calls. the exec system call replaces current process. In the above also happens same for login shell. Example  If your default login shell is given as KSH(/bin/ksh), but in your .profile given exec command to replaces the shell with BASH(/bin/bash).


So, now I am ready with sample .bash_profile for WebLogic 11g for Solaris 10

Implementing the best practices all together, to make this most generic profile. 

#==============================================
# Sample .bash_profile or .bashrc or .profile for ksh
# Middleware Admin  on Solaris 10 operating environment
# Updated : October 8, 2010
#==============================================
clear

USERNAME=$LOGNAME
HOSTNAME=`hostname`
#---------- echo Welcome message ---------------------
echo
echo Welcome $USERNAME. You are on Server: $HOSTNAME !!!
export JAVA_HOME=$HOME/Oracle/Middleware/jdk160_18
#---------------WebLogic Specific ---------------------------------------
export MW_HOME=$HOME/Oracle/Middleware/
export WL_HOME=$MW_HOME/wlserver_10.3

export ORACLE_HOME=/opt/oracle/product/9.2.0
export LD_LIBRARY_PATH=$WL_HOME/server/native/solaris/sparc:$WL_HOME/server/lib/solaris/oci920_8:$ORACLE_HOME/lib32:$LD_LIBRARY_PATH
 
export THREADS_FLAG=native
export PATH=$PATH:.:$JAVA_HOME/bin:/usr/bin:/usr/ucb:/etc:$WL_HOME/bin:$ORACLE_HOME/bin:/usr/ccs/bin:/usr/share/lib:/sbin:/usr/sbin:/usr/local/bin:$WL_HOME/server/bin

export CLASSPATH=$WL_HOME/server/lib/weblogic.jar:$JAVA_HOME/jre/lib/rt.jar
#---------------- End of WebLogic specific ---------------------------------
export MANPATH=$MANPATH:/usr/share/man
export EDITOR=vi
export PS1="[\u@\h \w]\$ "
 
alias cls="clear"
alias sl=ls
alias cd..="cd .."
alias cd...="cd ../.."
alias gi="grep -i"
alias l="ls -al|grep '^d'"
alias lm="ls -al | more"
alias h=history
alias hm="history | more"
alias nu="who|wc -l"                # nu - number of users
alias np="ps -ef|wc -l"             # np - number of processes running
alias p="ps -ef"
alias help=man
alias path="echo $PATH"
##### End of the sample .bash_profile for smart WLA #################
#===== Published on http://wlatricksntips.blogspot.com =============#

Importance of DOT(.) in PATH
I just started using the above .bash_profile but, something missing in it... when I wish to start my WebLogic server from domain home I need to give dot and forward slash (./). This looks somewhat unusual, when I add a DOT( .) in PATH variable made everything normal and I can start my WebLogic instances with my customized script from the prompt.

Power of PATH
More power to your user shell with adding /usr/sbin most of the network, system relavent commands available to you at command prompt.

The changes I made for the PATH line adding JAVA_HOME/bin your latest Java binaries will be useful at command prompt such as jps, jstat, jmap very useful when you deal with heap dumps and memory issues, $WL_HOME/server/bin consists of most of the WebLogic related configuration and maintenance commands available to you, it is little trick you need adding this in Solaris and Linux because it uses L-R precedence on Solaris for Linux R-L use appropriately.

export PATH=$PATH:.:$JAVA_HOME/bin:/usr/bin:/usr/ucb:/etc:$WL_HOME/bin:$ORACLE_HOME/bin:/usr/ccs/bin:/usr/share/lib:/sbin:/usr/sbin:/usr/local/bin:$WL_HOME/server/bin

Java want CLASSPATH
When there is a need of running ANT or build scripts you need runtime that is rt.jar and tools.jar in CLASSPATH this very often.

If you are using JRockit instead of SunJava then you don't need the rt.jar or tools.jar files in CLASSPATH. Other than this we have WebLogic specific utility commands that can be run from any where if you add weblogic.jar into the CLASSPATH. You can run the following command line utilities:

  1. java weblogic.WLST
  2. java weblogic.Admin
  3. java weblogic.Deployer



Overcome Human Errors with Alias
Mistakes can be made by humans it is obvious thing. Mostly while working on UNIX environments while typing the command there could be mistype happens. Example very effective WebLogic troubleshooter in the pressure situations might mistype 'sl -l' instead of 'ls -l'. sometimes 'l s-lrt' these mistakes can be over come with proper identifying our typing styles :) define them as alias with correct command.

That looks pretty and easy to use. If you need any assistance write a comment or reach me on G+ or FB please don't shy!!  : )

Usage of umask

When your WebLogic server generating logs need common access to the other users who are just monitoring the system or auditing the system. Such users are not WebLogic admin user, even though they need to access your logs. For this privileges every WebLogic server logs folder you need to update using chmod command repeatedly. To resolve this best option is using umask.

Don't forget to write back your comments and queries.

Ubuntu profile setup in VM

Now a days Ubuntu became almost alternative for Windows OS with great UI features in a Linux flavors. In Ubuntu the default user shell is 'bash'. The order it will execute according to the system profile. The system contains bashrc. So you can place your environment variables int the .bashrc or else alternatively you can call the . ~/.bash_profile in the .bashrc
export JAVA_HOME=/usr/lib/jvm/java-7-oracle
export PATH=$PATH:$JAVA_HOME/bin
export WL_HOME=/home/pavanwla/Oracle/Middleware/Oracle_Home/wlserver
export CLASSPATH=$WL_HOME/server/lib/weblogic.jar:.

Please share your experiance with profile and without knowing about the profile. Lets have best profile for your WebLogic environments that you build. References
1. http://www.unixguide.net/unix/bash/A7.shtml
2. http://djcraven5.blogspot.com/2008/03/change-solaris-shell-to-bash.html
3. http://www.cyberciti.biz/faq/solaris-unix-change-default-shell/
4. http://www.ibm.com/developerworks/aix/library/au-speakingunix_commandline/?S_CMP=cn-a-aix&S_TACT=105AGX52
5. The umask command usage

Tuesday, August 13, 2013

Why long way for thread dump on UNIX/Linux machines? Easy Steps!

jps - Java process list : Java Utilitycommand 

I was looking for diagnostic ways with freely available tools from JDK then I found the great valuable command tool 'jps'. The jps command can be used with three options(l, v, m). it can work for any Java - JEE Servers such as WebLogic, WebSphere, JBoss, Tomcat. In other words, any app server that uses the latest JDK 5+ version (version 6, 7, 8 also supports). Let me walk-through those interesting options in Win and *nix platforms. Before you execute this command tool, make sure that JAVA_HOME\bin is in the PATH setting.
Java Command tool : jps options

jps Option : jps -l

this -l option will give the full Java package name that invoked the Java process.
C:\Users\pavanbsd>jps -l
9116 sun.tools.jps.Jps
8812 weblogic.Server
Filtering the weblogic instance with find command on jps will give you the desired outcome.
C:\Users\pavanbsd>jps -l |find "weblogic"
8812 weblogic.Server

jps -v

this -v option is most important for tracking WebLogic, this option gives you the JVM aguments used to invoke the JAVA process (weblogic.Server). Usually for our WebLogic what we set in the setDomainEnv.sh will appear with this option.
C:\Users\pavanbsd>jps -v |find "weblogic"
8812 Server -Xms256m -Xmx512m -XX:MaxPermSize=128m -Dweblogic.Name=adm_clstr_dom -Djava.security.policy=C:\Oracle\MIDDLE
~1\WLSERV~1.3\server\lib\weblogic.policy -Dweblogic.ProductionModeEnabled=true -da -Dplatform.home=C:\Oracle\MIDDLE~1\WL
SERV~1.3 -Dwls.home=C:\Oracle\MIDDLE~1\WLSERV~1.3\server -Dweblogic.home=C:\Oracle\MIDDLE~1\WLSERV~1.3\server -Dweblogic
.management.discover=true -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext
.dirs=C:\Oracle\MIDDLE~1\patch_wls1036\profiles\default\sysext_manifest_classpath

jps -m

this -m option will gives you the Java main() programs command line arguments that used by Java process.
 
C:\Users\pavanbsd>jps -m
8812 Server
8984 Jps -m

The problem of finding Java PIDs

Of course, you can kill the instance in the emergency in the same way this is quicker than regular ps command. Usually, WLA uses the following command for finding the WebLogic managed server process:
ps -fu username

Scanning that process list with your eyes for WebLogic start process, then its child process finally java process in that process list. the whole process looks hectic when there are many WebLogic instances running on the same machine. Sometimes killing wrong process makes nonsense/messy. To avoid such collisions in the decision of killing process best way is using 'jps'.

Try it and know about it then you can enjoy working with it...

Another problem area that will do pain for Middleware admins is that Find is the NodeManager is running or not on a machine (Win/*nix)? the best option I have simply types 'jps' it will give the desired result. Here I found the simple way for taking thread dump with JDK tools which work on the UNIX machine and also in Windows. Assuming that you WLA(WebLogic Admin) are aware of which WebLogic instance needs to take Thread-dump for analysis of an issue. The best option which I use that makes it very easy to do so is the java process in a UNIX box is :
$ jps -lv |grep WL_instancename

This will give you the process id and long view of JAVA_OPTIONS assigned to that instance. Pick that first number (Java PID) and use your regular kill -3 on it :)

The jps command as Troubleshooting helper

The jps command can be used to pipe out the PID for thread-dumps and memory/heap-dumps or Generation wise footprint with the following JDK commands utilities:

  • jstat 
  • jstack
  • jhat 
  • jdb
  • jmap
  • jinfo
  • jvisualvm
  • jconsole

Count WebLogic Servers using jps


Basically while working on Produciton environments, there would be WebLogic server bounce required while doing Application release or some patching happen on some of the middleware architecture components. Sometimes you may need to know how many WebLogic instances are running in that Unix machine or how many left for bounce. Simply you can use our free 'jps' command as shown below
 $jps |wc -l


If you wish to see only java process you can use simply jps command.
$jps


We can use for the WebLogic 9.x 10, 11g versions managed instances for thread dumps or terminating the process.

The same trick will work for all Oracle Fusion Middleware Infrastructure using services such as Oracle Analytics Server (OAS) domain, Oracle Data Integrator (ODI) domain, Oracle Business Intelligence Enterprise Edition (OBIEE), Oracle APEX domain, Oracle SOA Suite, Oracle Service Bus (OSB) domain, OUD, OIM and may more.

Note:
1. This command is available in JDK version 1.5 onwards only.
2. Careful while using long view it shows full details.

Tuesday, November 30, 2010

Script for Bouncing a WebLogic instance

In the last post I was made deeper research on getting the process id of all WebLogic instances with a script. After looking to that script, My asked me 'Why don't you try for a script for bouncing a WebLogic instance?'. I thought that's really good idea, this makes WebLogic Admin life more easier, which is very much need for every WebLogic Admin. Let me get all the clues before putting the logic into the script.






The bounce script will take the input as WebLogic instance name.
Then the script should do search for the corresponding Java Process id of given WebLogic instance.
That Java Process ID can be used for finding:
1. Thread dump
2. Domain directory
3. Shutdown instance (kill the process)


Above 1, 3 are commonly used commands but 2nd one required when situation like this, on the same machine if there exists multiple WebLogic domain instances then how to find the WebLogic instance started from? Here, I need to find the origin directory of startManagedWebLogic.sh used which gives the WebLogic domain directory. How to resolve this? The solution is pwdx command in Solaris gives you this directory path by passing process id to it.

This solution gives me to start the WebLogic instance which is residing in irrespective WebLogic domain. That's all I need to make the bounce script.

The bounce script goes like this
#==========================================================
# This script you can keep in common accessing PATH
# such as in $JAVA_HOME/bin
# For WebLogic instance take ThreadDump, Shutdown, and Start
#===========================================================
flag=0
if [ "$1" = "" ]; then
        echo "Usage : $0 [instance]"
        exit
else
        instance="$1"
        pid=`jps -v|grep $instance|awk '{print $1}'`
        echo 'pid ' $pid
        domainPath=` pwdx $pid |awk '{print $2}'`
 
        kill -3 $pid
        sleep 3
        kill -3 $pid
        sleep 3
        kill -3 $pid

 #Now shutting down the instance here
        kill -9 $pid

 #verifying the instance is existance if not wait
        while : 
        do 
                jps -v |grep $instance
                if [ $? -eq 1 ]; then
                        echo 'kill success'
                        flag=`expr $flag + 1`
                        break;
                else 
                        echo 'kill failed... sleeping 1 sec'
                        sleep 1
                fi 
        done 

 #Once kill is success then you can proceed for Start it
 # Here you can call startManagedWebLogic.sh script
        if [ $flag -gt 0 ]; then
                . ${domainPath}/startinstance.sh $instance
        fi
fi

Recently one of my blog ->pingbox user asked me about pwdx command, does it works on HP-UX? I thought I should update this post with proper references.
There is compatibility list given for pwdx command:
pwdx compatibility

Alternate solution is cwd for Linux.
Please suggest your ideas, Keep commenting

Sunday, September 12, 2010

X11 Forwarding in SSH for Solaris and Linux

You might be wonder what is fun in this blog looking for X11 forwarding on Solaris 5.10!! You might be excited to see the beauty of colorful Oracle Fusion Middleware WebLogic 11g installation window when you executable binaries (wls1033_solaris32.bin), You might wish to see Oracle WebLogic domain configuration Wizard (config.sh), Oracle WebLogic Domain Template builder(config_builder.sh), BEA Smart Update (bsu.sh) windows or your Oracle Database 11g while you work on a remote UNIX machines.

After spending few hours on the Internet found many blogs written on their experiences, few document on websites, which illustrated about SSH, X11 forwarding in UNIX. I understand that what I need to do? To achieve my objective X11 Forwarding using SSH window, I must have a X emulating software installed on my desktop. you guys have this on your desktop?? If not install Hummingbird Connectivity (Xming is alternative)

My experimenting environment is Solaris 10, Oracle WebLogic, SSH (You can use Putty also), Hummingbird Connectivity (Xming is alternative)

Applicable to:
This you can use for any Java AWT or Swing programs in any UNIX based Operating environment.
You might download free Hummingbird Software also providing evaluation version who want to test their environment.

Here I am sharing with smart guys WLA/DBA my version of brain storming on this. When I first-time tried to invoke X window command it rejected and told as shown below:

No X11 DISPLAY variable was set, but this program performed an operation which requires it.

I had updated DISPLAY variable as follows

$ export DISPLAY=localhost:11.0

My first experiment with normal UNIX user
When I executed bsu.sh script I got the following in Normal UNIX user:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class
sun.awt.X11GraphicsEnvironment
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
at sun.awt.X11.XToolkit.(XToolkit.java:89)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at java.awt.Toolkit$2.run(Toolkit.java:834)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)
at sun.swing.SwingUtilities2$AATextInfo.getAATextInfo(SwingUtilities2.java:126)
at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:1556)
at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:130)
at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1591)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:541)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:581)
at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1343)
at javax.swing.UIManager.initialize(UIManager.java:1432)
at javax.swing.UIManager.maybeInitialize(UIManager.java:1420)
at javax.swing.UIManager.getDefaults(UIManager.java:660)
at javax.swing.UIManager.put(UIManager.java:989)
at com.bea.plateng.common.ui.gui.GUIHelper.initPLAF(GUIHelper.java:69)
at com.bea.plateng.patch.gui.PatchGUIHelper.startGui(PatchGUIHelper.java:90)
at com.bea.plateng.patch.Patch.main(Patch.java:338)

My UNIX admin buddy told that dear, first try with xclock then go for other, then I thought Ohhh!! that's good idea, let me try that...

$ xclock
bash: xclock: command not found

Hmmmmmmm!!, what is this? Think, Think Think!!!, On a Solaris 5.10 you can find some of the commands in OpenSource folder, Let me try in that path this xclock on the following path.
/usr/openwin/bin/xclock

No luck buddy, same kind of error message as bsu.sh got above.

Now I realized and verified all those PATH, CLASSPATH are pointing to proper JAVA_HOME/bin, lib paths respectively, one of them is misconfigured reset to correct path.

One of Sun blog saying about Updating $Home/.ssh/config file as follows:

Host *
ForwardX11 yes
ForwardAgent no

After doing this I had ran the following:

$ ssh -X user@hostname

This is the command will activallte the X emulation on your UNIX machine with given SSH configuration. Actually it will refer to the default configuration /etc/.ssh/config but when you create new config file on your user home directory it will prefer to execute for your user settings. This command also updates .Xauthority file when you ssh -X command.

Verified every step again finally I got X window for xclock

Hey!! Cheerup on my face!!

Experiment 2: LDAP user logon with assume user name as 'pavanwla', switched to role 'wladmin'. I started trying on it for X11 forwarding. First Let me try, xclock on

-->

[wladmin@hostname~]$ /usr/openwin/bin/xclock
Error: Can't open display:

Ohh its same DISPLAY variable problem right? You remember it!!

[wladmin@hostname~]$ export DISPLAY=localhost:10.0
[wladmin@hostname~]$ echo $DISPLAY
localhost:10.0

Let me try now, what it will say...

[wladmin@hostname~]$ /usr/openwin/bin/xclock
X connection to localhost:10.0 broken (explicit kill or server shutdown)

Oh My Gash!!! what to do now????????????
After a while, I bugged again my buddy Mr. Unix Admin about this. He told that configurations, X emulating authoriy must match ldap user and role. Now my turn, first I tried to get xclock on ldap user, that confirms everything fine at ldap user level. This configuration, Xauthority I can use in role user too, then see what I did:

[wladmin@hostname~]$ scp pavanwla@hostname:/home/pavanwla/.ssh/config .ssh/
[wladmin@hostname~]$scp pavanwla@hostname:/home/pavanwla/.Xauthority .

Started ssh session with ssh -X command.

Finally, the climax came to end, xclock started. ahh!!
Reference:

https://cygwin.com/setup-x86_64.exe
http://sourceforge.net/projects/xming/files/Xming/6.9.0.31/Xming-6-9-0-31-setup.exe/download
http://download.oracle.com/docs/cd/E15051_01/common/smartupdate/guide/quickrefax.html

Friday, August 13, 2010

Best Practices for WebLogic Environment

Here I am jotting out few interesting Best practices for Oracle WebLogic environments, which I have experienced/encountered hurdles while preparing a WebLogic Domain. To Win this Running race you must overcome these hurdles, the best solutions is remembering all of them now I am sharing with you guys here:

1. Dedicated User and group
Oracle WebLogic installation on Solaris machine or Linux or a Windows machine, it is better to have a dedicated user and shared growup where you can install the Middleware components WebLogic, Coherence, WebCenter sites, Content Management etc. provide access to all  so that all other users need not to installing  for each new domain on the same machine.
  useradd [options] LOGIN

Some of important options are:

-d home directory
-s starting program (shell)
-p password
-g (primary group assigned to the users)
-G (Other groups the user belongs to)
-m (Create the user's home directory
My experiment:
useradd -g wladev -s /bin/bash -p xxxxxxxx -d /home/wladmin -m wladmin
Remember that, You can run above user creation command if you have root user access only. Double check the password working for the newly created user. Now a days Virtual Box users are becoming super user (root) just by sudo access. Switch to user (su - wladmin) will connect to the new user.
Change the user password from root user, using passwd wladmin command. On the root user it won't ask you previous password.

2. Using of sed for Migrations
When I worked for WebLogic 8.1 to WebLogic 9.2 migration for each instance wise configuring fresh properties updating took me around a week time for whole environment. Time changed and the requirements changed and this time WebLogic 11g migration from WebLogic 9.2 I have an idea to use stream editing option, and applied with proper regular expressions to finish my task. It worked for me perfectly it is awesome, whole updating done in half hour with small script that included sed in a for loop. I had experianced the fastness  with sed to change multiple lines search and replace in multiple files in the same machine

The following diagram will tells you how sed works on text patterns.
SED Script functionality

Learning SED scripting

for i in `ls instances|grep c`
do
cd $INST_HOME/$i/config
cp /oldinstance/$i/config/*.properties .
sed -e "s/$i-//g" \
      -e "s/$i\_//g" \
      -e "s/\_$i//g" \
      -e "s/-$i//g" \
      -e "s/wluser92/wluser11/g"  <  log4j.properties  >temp
mv temp log4j.properties


User per domain: If you are preparing a development environment then you can choose a user per domain it is the best way to avoid conflicts between developers code changes etc. Install new Oracle License and keep always a backup of old License.

3. Customizing your domain

AdminServer name, ListenAddress, ListenPort, Some times you might see errors saying that "Listen Port already in use", To avoiding port conflicts: Before assigning a port to your WebLogic instance better you check whether it is already in use or not? by using netstat command.
About Virtual IP issues.
i) WebLogic Server wise logs generation
WebLogic Server instance each one can generate separate server side STDOUT logs, STDERR logs as well as application logs. These logs must be collected in a separate mount point will make free for disk utilization memory problems. According to the application severity we can keep archiving the rotated logs on the disk. Most of the Admins, developers while doing troubleshooting for an issue they must revisit these logs and they must know from which server it was happening for this log4j provides more flexibility to digg/debug every Java package, class level, even method, line level too.

How to collect it?
To make this possible you need to enable your WebLogic server library path must pick the log4j-1.2.8.jar and the logging definitions in a separate file lets say it as log4j.properties file in the CLASSPATH.

Where to set?
Before weblogic.jar path or after? Oracle recommands application related jars and third-party jars must be set after weblogic.jar. So log4j.xx.jar must be in POST_CLASSPATH.

ii) Editing for all Domain Environments
a. JAVA_OPTIONS
b. USER_MEM_ARGS
c. JVM type
d. CLASSPATH (PRE/POST)
e. Native IO options
f. MuxerThread
g. SocketReaders

Changing JVM Hotspot Compiler

Editing common scripts impacts all the domains in that machine. If there is a need for the WebLogic server run with server JVM that will give more scope for In commEnv.sh script we are going to update .
Sample Example:
191    Sun)
192      JAVA_VM=-client
change to
191    Sun)
192      JAVA_VM=-server
d
4. Scalability for Domain
Adding servers to  or removing servers existing Cluster is nothing but scalability. While defining new Cluster identify proper multi-cast address suitable to your environment with multi-cast test. You must use Interface Address as the DNS/IP of the machine where the instance is configured in each server's Cluster tab. This will make you easy to run the clustered environment.

5. Effort saving means cost saving
While preparing your configuration keep focus on portable coding. I have been to many UNIX forums to find portable and flexible scripting. Here I am sharing for you. Efforts can be focused on the following things




Customized Stop All script for each domain 
Best option I found from stopManagedWebLogic.sh given by the Oracle. It is normal shell script it will invokes the Python script on the fly. I just replaced the 'Server' with 'Cluster' argument for shutdown WLST command and also called admin stop script in the bottom.


#!/bin/sh

DOMAIN_HOME="/home/domains/mydomain"

. ${DOMAIN_HOME}/bin/setDomainEnv.sh
ADMIN_URL="t3://my.adminhost.com:adminPort"

echo "wlsUserID ='username'" >>"shutdown.py" 
echo "wlsPassword = 'password'" >>"shutdown.py" 
echo "connect(${wlsuserID}, ${wlsPassword}, url='${ADMIN_URL}')" >>"shutdown.py" 
 
#=== fetching cluster list from the domain configuration repository =============
for cl in `grep -i clstr\<\/n ../config/config.xml|sed  's/.*\(.*\)<\/name>.*/\1/'
do
 echo "shutdown($cl','Cluster')" >>"shutdown.py" 
 echo "state($cl)">>"shutdown.py" 
done
echo "shutdown()" >>"shutdown.py" 
echo "exit()" >>"shutdown.py" 
 
echo "Stopping Weblogic Server..."
java -classpath ${FMWCONFIG_CLASSPATH} ${MEM_ARGS} ${JVM_D64} ${JAVA_OPTIONS} weblogic.WLST shutdown.py  2>&1 

echo "Done"

iv. Server Health checking script
Separate is a time, effort saving

6. Deployment Strategies
System resource deployments better you prepare your customized JDBC Data source configuration script using WLST. Avoid Start-up Classes configuration which will make dependable deployment, which leads you to not able to use side-by-side(SBS) deployment advantage.

7. WebLogic 9.x onward you have a flexibility to use Deployment plans for UAT, QA, Staging environments as same as production. This will reduce the problem of porting the code on one environment to other without any configuration changes.

8. OutOfMemoryError

Most of the production environments first hurdle is OOME, if it is occurring in your Web-tier environment then you can use JSP pre-compile.Prepare GC monitoring scripts

9. Now a days everywhere you can find Virtualization (SOLARIS ZONES), Cloud computing, Clustering (Database RAC), Grid concepts, Veritas Clustering in Disks/RAID etc. Have each topic in breif knowledge that could make you understand if anything goes wrong somewhere in the application environment you can easily figure it out.

10. Know about your production environment end to end how the data flows? Firewall, Load balancer software or hardware, proxy-plugin security aspects, Network connectivity, Net-backup locations etc.

Reference URL:
1. Best Virtual IP usage http://blogs.oracle.com/muralins/2007/08/ipmp_ip_multipath.html
http://www.eng.auburn.edu/~doug/howtos/multipathing.html
2. Linux Administration Commands http://www.faqs.org/docs/abs/HTML/system.html
3. WLST Configuration help http://wlstbyexamples.blogspot.com/
4. WebLogic Upgrade http://download-llnw.oracle.com/docs/cd/E13179_01/common/docs100/upgrade/comm_ref.html

Monday, August 9, 2010

Do you have alias in your profile??

Making mistake is human nature but, overcoming that mistake turning to desired outcome is very wise thing. You want to learn about that wise trick?


If yes follow me!!

In Unix platform there is a file called .profile (some Linux enviroments it is .bash_profile). Which executed automatically when you logon to your user, which inturn have the enviroment variables which are required to run your application on WebLogic. For WLA required to setup a standard .profile for his production enviroment that is for JAVA_HOME, WL_HOME are major some of the enviroments requires ORA_HOME in this file.

Defining JAVA_HOME, WL_HOME, etc is common thing for any WLA. But your my Smart WLA then you might applying a intersting UNIX command 'alias'. Most of the time we use 'ls' command for listing the files/folders. By mistake you might mistype as 'sl' instead of 'ls'. sometimes feeling hungry!! or thursty!! and typing command that may go wrong like 'cd..' or 'cd...'. Collect all these common mistypos and make use of 'alias' command then see!!

Though, You make mistake in typing it will give you desired command output. I like this command, since when I found it. This command makes magic, it is very interesting feature in UNIX. Just append to your .profile the following lines:
######WLA Smart idea for using alias #############################
alias cls=clear
alias sl=ls 
alias cd..="cd .."
alias cd...="cd ../.."
alias gi="grep -i"
alias l="ls -al"
alias lm="ls -al | more"
alias h=history
alias hm="history | more"

This is value added to your work, obviously it will reduce your time spending on working machine. Performance will be improved if you find more common mistakes in your enviroment and sortout with 'alias' the magical command, it will give you fruties results!!

Blurb about this blog

Blurb about this blog

Essential Middleware Administration takes in-depth look at the fundamental relationship between Middleware and Operating Environment such as Solaris or Linux, HP-UX. Scope of this blog is associated with beginner or an experienced Middleware Team members, Middleware developer, Middleware Architects, you will be able to apply any of these automation scripts which are takeaways, because they are generalized it is like ready to use. Most of the experimented scripts are implemented in production environments.
You have any ideas for Contributing to a Middleware Admin? mail to me wlatechtrainer@gmail.com
QK7QN6U9ZST6