Thursday, March 30, 2017

Single click installation of WebLogic 12c in a Vagrant Box

Current IT Trending towards devOps automation in every Software product development. I am also part of  this devOps culture. I had a thought that, How much I can leverage my regular task by making simple shell script for Installation task.

As every Oracle WebLogic system administrator would pass through this only few of them could attempt to resolve this with automation script.

Here I would like to target two installations with two different scripts:

  1. Fusion Middleware 12.2.1.2.0 WebLogic Server installation
  2. Fusion Middleware 12.2.1.2.0 Infrastructure installation


Objective of this script is to get single hit would do multiple tasks such as:

  • JAVA installation
  • setting the JAVA_HOME in shell profile
  • using Java run the WebLogic installer in silent mode


Assumptions:

  • Downloaded Software will be stored in common shared location. 
  • Installation of software such as JDK, WebLogic will be same mount point and directory structure
  • Linux Operating System user have bash shell!   
Knowledge base:


Auto Install pre-requisite for Application - Script 

#!/bin/bash
# This script will be installing JDK
# installing WebLogic in silent mode
#
#- Info 
#-    Author   : Pavan Devarakonda
#-    Date     : 30-March-2017
##############################################3

JDK_INSTALLER=jdk-8u121-linux-x64.tar.gz
JDK_INSTALLER_PATH=/u01/app/software/jdk
INSTAL_LOC=/u01/app/oracle

echo "installing JDK ${JDK_INSTALLER}"
cd $INSTAL_LOC
tar -zxvf $JDK_INSTALLER_PATH/$JDK_INSTALLER

ls -l
echo confirm JDK installation
cd $INSTAL_LOC/jdk*

JAVA_HOME=`pwd`
echo "export JAVA_HOME=$JAVA_HOME">>$HOME/.bashrc
echo "export PATH=$JAVA_HOME/bin:$PATH">>$HOME/.bashrc

. $HOME/.bashrc

echo "Check for java version"
java -version

echo Installing WebLogic now...
echo .

WLS_INSTALLER=fmw_12.2.1.0.0_wls.jar
WLS_INSTALLER_PATH=/u01/app/software/FMW_wls

SILENT_DIR=/u01/app/software/silent

java -jar $WLS_INSTALLER_PATH/$WLS_INSTALLER -silent -invPtrLoc $SILENT_DIR/oraInst.loc -responseFile $SILENT_DIR/wls_install.rsp

echo "WebLogic $WLS_INSTALLER installed successfully...."
echo .
echo setting MW_HOME ...
MW_HOME=`grep ORACLE_HOME $SILENT_DIR/wls_install.rsp |cut -d'=' -f2`
echo "export MW_HOME=$MW_HOME">>$HOME/.bashrc
echo "export WL_HOME=$MW_HOME/wlserver">>$HOME/.bashrc
echo "alias wlst=$MW_HOME/oracle_common/common/bin/wlst.sh">>$HOME/.bashrc
. $HOME/.bashrc
echo "Use wlst command to test everything working..."

Oracle Fusion Middleware Infrastructure installation Shell Script

Here the script is little bit improved the installer normally coming as zip file which can be uncompressed by script and also silent file will be using
INSTALL_TYPE=Fusion Middleware Infrastructure With Examples
Now the script for Infrastructure will be look like this.
#!/bin/bash
# This script will be installing JDK
# installing WebLogic in silent mode
#
JDK_INSTALLER=jdk-8u121-linux-x64.tar.gz
JDK_INSTALLER_PATH=/u01/app/software/jdk
INSTAL_LOC=/u01/app/oracle

echo "installing JDK ${JDK_INSTALLER}"
cd $INSTAL_LOC
tar -zxvf $JDK_INSTALLER_PATH/$JDK_INSTALLER

ls -l
echo confirm JDK installation
cd $INSTAL_LOC/jdk*

JAVA_HOME=`pwd`
echo "export JAVA_HOME=$JAVA_HOME">>$HOME/.bashrc
echo "export PATH=$JAVA_HOME/bin:$PATH">>$HOME/.bashrc

. $HOME/.bashrc

echo "Check for java version"
java -version

echo Installing WebLogic now...
echo .

WLS_INSTALLER=fmw_12.2.1.2.0_infrastructure_Disk1_1of1.zip
WLS_INSTALLER_PATH=/u01/app/software/FMW_wls
cd $WLS_INSTALLER_PATH
unzip $WLS_INSTALLER_PATH/$WLS_INSTALLER

INFRA_JAR=fmw_12.2.1.2.0_infrastructure.jar

SILENT_DIR=/u01/app/software/silent

java -jar $WLS_INSTALLER_PATH/$INFRA_JAR -silent -invPtrLoc $SILENT_DIR/oraInst.loc -responseFile $SILENT_DIR/fmw12.2.1_infra_install.rsp

echo "FMW Infrastructure $WLS_INSTALLER installed successfully...."
echo .
echo setting MW_HOME ...
MW_HOME=`grep ORACLE_HOME $SILENT_DIR/$SILENT_DIR/fmw12.2.1_infra_install.rsp |cut -d'=' -f2`
echo "export MW_HOME=$MW_HOME">>$HOME/.bashrc
echo "export WL_HOME=$MW_HOME/wlserver">>$HOME/.bashrc
echo "alias wlst=$MW_HOME/oracle_common/common/bin/wlst.sh">>$HOME/.bashrc
. $HOME/.bashrc
echo "Use wlst command to test everything working..."


Note: If you are running other than Linux platform you can use ksh shell .profile.

keep in touch with your comment and suggestions for improve more effective way.

cheers!!!

Wednesday, July 15, 2015

Windows command line Tricks for Better, Faster Administration

Windows CMD commands for life made easy for WebLogic, OFMW, WebSphere, Tomcat, JBoss Administrators.

Windows shortcuts will shave our time more. Especially working on Windows 8.1 is more complex than previous so I pulled out some of the important commands which will make your life easy.
Some of them are collected from the daily works in OFMW administrator.

Linux like commands in Windows
Mapping of SHELL command with CMD commands

How to set the proxy in CMD?


You need to run the following command in the CMD to set the proxy.
set HTTP_PROXY=http://your_proxy:your_port
set HTTPS_PROXY=https://your_proxy:your_port

How to add a IP, DNS to your Windows hosts file?

The Linux OS maintains /etc/hosts and it can be editable only by root user. Whereas, in Windows OS same file is available at c:\windows\system32\drivers\etc\hosts. This will be same for Windows 7 and Windows 8.1. You could also check in the hot Windows 10. Hence the command to edit this :
start notepad c:\windows\system32\drivers\etc\hosts
You can also use WindowKey + R and paste:
notepad c:\windows\system32\drivers\etc\hosts 
in the Open text box and click on 'Ok' button.

How do I open Environment Variables Windows   from command prompt?

When you work for installing OFMW product installation on Windows system you might setting the PATH, WL_HOME, CLASSPATH, JAVA_HOME in the environment variables to work more efficiently from the command prompt instead of setting in the command prompt. If you set these variables in the User defined environment variables we must open a fresh cmd prompt.

I've Windows 8.1 system on command prompt executed the following command
rundll32 sysdm.cpl,EditEnvironmentVariables

You could also run in the Run window :
 

Where is Java installed in Windows (which/where commands like in Linux)?

You can find the path where Java is installed using the following dir command with search option applied on java.exe file:

C:>dir /b /s java.exe

How to find WebLogic server PID with Port in Windows?


On Windows platform you can use netstat command with -n -a -o options which works same as in Linux platforms. Filter of the process id list can be done with ^| (cap followed by pipe).  Then you can use it for terminating by taskkill command.

FOR /F "tokens=4 delims= " %P IN ('netstat -a -n -o ^| findstr :7001') DO ^
@ECHO TaskKill /PID %P /f /t

In batch scripts you can use %%P if it is command line you can only use %P. If your system is Windows 7 then you need tokens=5. Above command only that matches :7001 port mapped pid with message taskkill command option. You can kill by copy paste out of them which are really matches to weblogic running process or you directly remove the @echo and execute, if that above command give accurate process list. Note: Double check the process list.

How to find the Free Available Memory from CMD as in Linux free -m?


In Windows about Total, Free, Virtual Memory info we can get from systeminfo, it is a command that will output system information, We can filter out Mem string using findstr
D:\>systeminfo |findstr Mem
Total Physical Memory:     16,294 MB
Available Physical Memory: 12,798 MB
Virtual Memory: Max Size:  20,390 MB
Virtual Memory: Available: 15,792 MB
Virtual Memory: In Use:    4,598 MB


Killing NodeManager in Windows using Taskkill command


In the Windows we can do this task from the task manager. Here I can get the PID of NodeManager using jps command.
It is Linux kill/pkill like command is taskkill for Windows. You need to know the options how to use it for terminating the process. You could get the help by typing the
 taskkill /? 

Sample taskkill example for killing NodeManager process.
C:\>jps
6312 NodeManager
2524 WLST
10376 Jps

C:\>taskkill /pid  6312 /f /t
SUCCESS: The process with PID 6312 (child process of PID 2524) has been terminated.

I use this whenever I want to force an immediate reboot:
shutdown -t 0 -r -f

For a more friendly "give them some time" [GRACEFUL SHUTDOWN] option, you can use option with time interval like this:
shutdown -t 30 -r
As you can see in the comments, the -f is implied by the timeout.

Here's how to do the shutdown functions via a batch file:
·        shutdown -r — restarts
·        shutdown -s — shutsdown
·        shutdown -l — logoff
·        shutdown -t xx — where xx is number of seconds to wait till shutdown/restart/logoff
·        shutdown -i — gives you a dialog box to fill in what function you want to use
·        shutdown -a — aborts the previous shutdown command....very handy!
·         
Additional options:
·        -f — force the selected action
·         -m -- option for remote shutdown:
shutdown -r -f -m \\machinename
Note that:

  • The -r parameter causes a reboot (which is usually what you want on a remote machine, since physically starting it might be difficult).
  • The -f parameter option forces the reboot.
  • You must have appropriate privileges to shut down the remote machine, of course.
What is the CMD line continuation character?
A. The caret (^) symbol is the cmd.exe line-continuation character that allows you to continue a command on multiple lines

Java silent mode installation in Command line in Windows


This would be typical requirement where you could do the automation for your Window box installations of your OFMW produtcts. Where JDK is pre-requisites for all products. Hence lets know this awesome trick JDK installation from command :


c:\OFMW\jdk-7u79-windows-x64.exe /s /v /qn  ADDLOCAL=ToolsFeature INSTALLDIR=C:\Java /L C:\jdk.log





The above command will install the JDK at give INSTALLDIR here it is C:\Java. Normally JDK installer will run a wizard and ask questions in GUI, when you use /qn it will off the UI for installer.

where this also include the installation of tools.jar, locale features also installed with ADDLOCAL option.


Note: The INSTALLDIR cannot be overridden, if one time JDK installed you cannot install in other path. You need to uninstall from control panel.

RDP

Remote Desktop starting from CMD
You can run with ‘mstsc’ command utility
start mstsc

Run Services

·        Type "start services.msc" to open services Window

Windows Tools

Daily works sometimes we need boost up our work with using external tools that won’t be available with Windows OS. Here I’ve collected some of the useful links for everyone.

ProcessExplorer

This works like Linux utility ‘top’ command gives us the clear sorted process related info. You could kill a process or manage them to avoid issues.

bareTail

tail command like tool with effective UI for Windows.

Gow

GNU on Windows people who are more habituated with Linux/Unix platforms feel uncomfortable to work on Windows CMD. Here is a alternative. After downloading this update your environment variable PATH with this will give Linux commands outputs from C++ compiled code.

Everything

Microsoft search sometimes makes us stuck, no worries we have Everything’’  search tool helps you to find faster way for searching files.

TCPView

To see the TCP ports in use on a Windows
https://download.sysinternals.com/files/TCPView.zip



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