Showing posts with label JDK 8 automatic installation. Show all posts
Showing posts with label JDK 8 automatic installation. Show all posts

Friday, September 9, 2022

Single click installation of WebLogic 14c|12c in Linux

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 situation but only few of them who have "AUTOMATION IN MINDS" could attempt to resolve this with a nicely blended Shell script.

Here I would like to target two types of installations with two different Shell 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

YOu can use the same logic in WebLogic 14c the latest version as well.
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 
wls.cfg
JDK_INSTALLER=jdk-8u*-linux-x64.tar.gz
JDK_INSTALLER_PATH=/u01/app/software/jdk
INSTAL_LOC=/u01/app/oracle
WLS_INSTALLER=fmw_12.*_wls.jar
WLS_INSTALLER_PATH=/u01/app/software/FMW_wls
SILENT_DIR=/u01/app/software/silent

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

. wls.cfg
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 .

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, April 25, 2018

Ansible automation for WebLogic - Part1 Java Installation

Ansible is a task execution engine. Ansible is designed to work on multiple machines to execute the batch of simple task to scale. Ansible is written in Python language, it uses Python 2.6 above is supported platform as requirement.

No Agents required!

Ansible is simple language that is started as opensource and later it is acquired by Red Hat. The core communication happens with SSH. SSH widely available trusted in all UNIX and Linux systems. Ansible can be run any system as it doesn't relay on central machine.
Ansible automation for Java and WebLogic 12c 

Here my experiment goes with two Ubuntu 14 Trusty Tahr machine. In one machine Ansible will be installed and other machine is used as target node, in real-time scenario the target list can be many hundreds and this has been proven by NASA and other Ansible implements. Using Ansible lots of organizations get into structured and role based automation implementations successful.

For Redhat flavors


The actions that need to executed in remote host machine are called TASK. playbooks are executable batches which are ymal files. Plays are having one or more tasks.   Playbooks can be collections of tasks. Plays are executed top to bottom when it parse the playbook. to work with playbook we must define inventory which we define hosts file.

Defining Inventory in hosts file
This can be placed in user home directory or common location /etc/ansible/hosts. The inventory will be defined with groups such as webapps, appservers, dbservers etc. As we are going to work on WebLogic application server we will define it as appservers group in the host inventory.

Host Inventory defining for ansible

There are many alternative options that shown in the above picture to define the host inventory. We can make grouped and un-grouped host list. Mostly grouped inventory is having more options to define the host list. we can include the list with IP address list or you can use hostnames list as well. While grouping we need to think about the task execution procedure.

Lets create a simple one our WebLogic servers host IP into the appservers as a group the file.could be stored in the $HOME path with the content as follows:

vi hosts
[appservers]
192.168.33.100
192.168.33.102


Setting up Ansible to run with SSH


ssh-keygen -t rsa -b 4096 -C "My ansible key"

ssh-keygen for vagrant user

copy the ssh key

ssh-copy-id -i ~/.ssh/id_rsa.pub vagrant@192.168.33.102



now regular Unix level command try to connect with ssh this should not prompt for password
ssh vagrant@192.168.33.10
ssh connection validation for ansible
eval $(ssh-agent)


ssh-add

lets confirm now with ansible all ssh connections are good to go for ansible play.

ansible -i ~/hosts -m ping all

ansible hosts ping all


Create your first yaml file for ansible play

The playbook is developed with yaml coding to set up couple of plays. Each play contain multiple task, which will tell the Ansible engine.

Ansible Playbook structure


Each task can be developed with module which is a part of core module and we can also create custom modules if required. There 700+ modules are freely available in opensource ansible. Here I am going to use the unarchive core module which requires src, dest values and this sample playbook have only have single play that will install Java that is unarchive the tar.gz file that is availabe in the specified shared location mentioned as src. If you don't have shared drive then ansile should use copy module and then use this task.

vagrant@docking ~/wls_auto $ cat java_install.yml
- hosts: appservers
  remote_user: vagrant
  tasks:
   - name: Unpack archive
     unarchive:
        src: /u01/app/software/jdk/jdk-8u172-linux-x64.tar.gz
        dest: /home/vagrant
        remote_src: yes


Please correct if indentation looks wrong

The execution is as follows:



We will be sharing the part 2 which will be install the WebLogic in the remote machine.

Please let me know you have any new thoughts on automation with Ansible code. This post is beginning.

References:

How to install and configure Ansible on Ubuntu?
Unarchive module sample
How to solve “Permissions 0777 for ‘~/.ssh/id_rsa’ are too open.” ?



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