Tuesday, July 3, 2012

what are the Best Practices for WebLogic Environment?

1. Dedicated Users per installation
Oracle WebLogic installation on Solaris machine or Linux or a Windows machine better to have a dedicated user where you can install the WebLogic components. provide access to all other users so that no need of reinstalling required for each new domain on the same machine.

  1. useradd [options] LOGIN  
  3. Some of important options are:  
  5. -d home directory  
  6. -s starting program (shell)  
  7. -p password  
  8. -g (primary group assigned to the users)  
  9. -G (Other groups the user belongs to)  
  10. -m (Create the user's home directory  

  1. useradd -g wladev -G wladmin -s /bin/bash -p xxxxxxxx -d /home/user -m user  
Remember that, You can run this command if you have root user access only

2. Using of sed
When I worked for WebLogic 9.2 migration for each instance wise configuring fresh properties updating took me around a week time for whole environment. This time WebLogic 11g migration I have an idea to use stream editing option, and apply proper regular expressions to finish my task. It worked for me awesome, whole updating done in half hour with small script that included sed in a for loop. I had to change multiple lines search and replace in multiple files in the same machine, so I took the above said trick it worked and saved my time.

  1. for i in `ls instances|grep c`  
  2. do  
  3. cd $INST_HOME/$i/config  
  4. cp /oldinstance/$i/config/*.properties .  
  5. sed -e "s/$i-//g" \  
  6.       -e "s/$i\_//g" \  
  7.       -e "s/\_$i//g" \  
  8.       -e "s/-$i//g" \  
  9.       -e "s/wluser92/wluser11/g"  <  >temp  
  10. mv temp  

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 logs as well as application logs. Most of the developers while troubleshooting an issue 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 file.

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

ii) Editing for all Domain Environments
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 script we are going to update .
Sample Example:

  1. 191    Sun)  
  2. 192      JAVA_VM=-client  
  3. change to  
  4. 191    Sun)  
  5. 192      JAVA_VM=-server  
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

i. Customized start script for admin server,
ii. Customized start script for managed server
The following start script save it as "" assuming that you might need few instance specific properties need to refer in script.

  1. INSTANCE=$1  
  2. export INSTANCE  
  3. SOURCE=$(cd -P -- "$(dirname -- "$0")" && pwd -P)  
  5. nohup $SOURCE/ $INSTANCE >$INST_HOME/$INSTANCE/logs/$INSTANCE.out 2>&1 &  
  6. echo tail -f $INST_HOME/$INSTANCE/logs/$INSTANCE.out  

Here $INST_HOME is defined in the user profile script.

These customized start scripts for admin server and managed servers. In the script make a copy of the last server instance log to instance.out_bkp. Some times due to some panic situations servers might crashed, after monitoring you found that it happen so restarting server should not loss that lost logs. If you maintain the backup of logs file automatically before starting the instance, then you are saved with that backup log file for further analysis about that crash.

Here in the above script, Most of the UNIX environments your script could use "nohup" that means no hung up when the remote machine is accessed with ssh/Putty.
If you create this script in development/QA environment same script can be used for production because keeping it more portable with SDIR (source directory path).

iii. Customized Stop All script for each domain 
Best option I found from 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.

  1. #!/bin/sh  
  3. DOMAIN_HOME="/home/domains/mydomain"  
  5. . ${DOMAIN_HOME}/bin/  
  6. ADMIN_URL="t3://"  
  8. echo "wlsUserID ='username'" >>""   
  9. echo "wlsPassword = 'password'" >>""   
  10. echo "connect(${wlsuserID}, ${wlsPassword}, url='${ADMIN_URL}')" >>""   
  12. #=== fetching cluster list from the domain configuration repository =============  
  13. for cl in `grep -i clstr\&lt;\/n ../config/config.xml|sed  's/.*<name>\(.*\)&lt;\/name&gt;.*/\1/'  
  14. do  
  15.  echo "shutdown($cl','Cluster')" &gt;&gt;""   
  16.  echo "state($cl)"&gt;&gt;""   
  17. done  
  18. echo "shutdown()" &gt;&gt;""   
  19. echo "exit()" &gt;&gt;""   
  21. echo "Stopping Weblogic Server..."  
  22. java -classpath ${FMWCONFIG_CLASSPATH} ${MEM_ARGS} ${JVM_D64} ${JAVA_OPTIONS} weblogic.WLST  2&gt;&1   
  24. echo "Done"  
  25. </name>  

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 onwards 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.

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.

No comments:

Post a Comment