Monday, September 4, 2017

The docker-compose for Oracle 12c XE

Oracle Database 12.1.0.2 Express Edition



After a while got time to explore the new learning in my way. Oracle 12.1.0.2 Express edition on docker container is my goal. In this post I am going to explain you how did I achieved this with different path of using docker-compose commands to bringing up the automated XE container. The regular choice is defined in GitHub and Docker hub it was mentioned to use docker pull and docker run commands to use.

Advantages of containerizing Oracle 12c XE

  • No need to download any software from OTN
  • No need to install - dockerfile will take care of it
  • No need to run dbca for Database cration - executed moment container boot time
  • No need to start LISTENER, STARTUP database because this container choosen is AUTOMATED [OK]


Lets search for the Oracle 12c XE

docker search oracle12c

Output of docker search result
Docker Oracle 12c XE search

The docker-compose for Oracle 12c XE Database


oracle12cxe:
 image: rodrigozc/oracle12c
 ports:
  - "1521:1521"
  - "8089:8080"
  - "2222:22"


docker-compose config
networks: {}
services:
  oracle12cxe:
    image: rodrigozc/oracle12c
    network_mode: bridge
    ports:
    - 1521:1521
    - 8089:8080
    - '2222:22'
version: '2.0'
volumes: {}

docker-compose up -d
Creating oraclexe_oracle12cxe_1

Now lets check the docker-compose wit running process list
 docker-compose ps
         Name                Command       State                                  Ports
-----------------------------------------------------------------------------------------------------------------------
oraclexe_oracle12cxe_1   /entrypoint.sh    Up      0.0.0.0:1521->1521/tcp, 0.0.0.0:2222->22/tcp, 0.0.0.0:8089->8080/tcp

SSH Connection with port 2222


Using PuTTY terminal you can connect to the container that is running Oracle 12c XE database in it.

Oracle 12.2.0.1 XE docker container SSH connection

check logs what is happening in the container when it was just started...

vagrant@docking ~/oracle_xe $ docker-compose logs oracle12cxe
Attaching to oraclexe_oracle12cxe_1
oracle12cxe_1  | SSH server started. ;)
oracle12cxe_1  | ls: cannot access /u01/app/oracle/oradata: No such file or directory
oracle12cxe_1  | Database not initialized. Initializing database.
oracle12cxe_1  | Starting tnslsnr
oracle12cxe_1  | Copying database files
oracle12cxe_1  | 1% complete
oracle12cxe_1  | 3% complete
oracle12cxe_1  | 11% complete
oracle12cxe_1  | 18% complete
oracle12cxe_1  | 37% complete
oracle12cxe_1  | Creating and starting Oracle instance
oracle12cxe_1  | 40% complete
oracle12cxe_1  | 45% complete
oracle12cxe_1  | 50% complete
oracle12cxe_1  | 55% complete
oracle12cxe_1  | 56% complete
oracle12cxe_1  | 60% complete
oracle12cxe_1  | 62% complete
oracle12cxe_1  | Completing Database Creation
oracle12cxe_1  | 66% complete
oracle12cxe_1  | 70% complete
oracle12cxe_1  | 73% complete
oracle12cxe_1  | 85% complete
oracle12cxe_1  | 96% complete
oracle12cxe_1  | 100% complete
oracle12cxe_1  | Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/xe/xe.log" for further details.
oracle12cxe_1  | Configuring Apex console

Here the log file shows that installation successful. And Now lets check the Expression Edition Enterprise manager console

http://192.168.33.100:8089/em

Oracle Enterprise Manager database express 12c Login page
Please enter the the login credentials as: sys/oracle select the check box as sysdba option. Because we want to do a DBA task now create user.

After login successful you will get the SYSDBA access.

Create User on Oracle 12c EM Console
Create User account as demouser 

Tablespaces for demouser

Assign privileges RESOURCE, CONNECT to demouser

Create User SQL statement processed succesfully


In the PuTTY terminal connect with oracle/welcome1 ssh credentials.
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/xe
export PATH=$ORACLE_HOME/bin:$PATH

To check Oracle Database running with process that have pmon word:
 ps -ef|grep pmon
You can check for the Oracle database configured and the Listener started with entrypoint.sh script.
lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 04-SEP-2017 19:16:36

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                04-SEP-2017 18:33:10
Uptime                    0 days 0 hr. 43 min. 26 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/38a4e2e216dd/listener/ale     rt/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=38a4e2e216dd)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=38a4e2e216dd)(PORT=8080))(Presentati     on=HTTP)(Session=RAW))
Services Summary...
Service "xe.oracle.docker" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
Service "xeXDB.oracle.docker" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully

Confirm the User creation

Using SQL*Plus you can test the connection to the demouser that created in the above section.

 sqlplus demouser/welcome1@localhost:1521/"xe.oracle.docker"

Output looks like this:


connection validation using SQL*Plus

References:

Git Hub link for Oracle 12c+ SSH 
Docker hub link of Rodrigozc

Monday, July 24, 2017

2. Writing Dockerfiles to install Java 8 and WebLogic 12c to create docker images

We have couple of options to create the docker images. In the last post we got the docker installed Linux environment available. Now in this post we will develop the Dockerfile such that it can create an image that can have Java JRE installed and WebLogic 12c installed.

Lets jump on the task where we will prepare, create the Dockerfile and build the image and run the container to check all done successful.

Prepare software installation


Remember that official images always preferable choice. When you search for docker images from public repository that is hub.docker.com. We might get huge list some of them are Automated some of them are not.Only one will be committed as Official image. Here selecting image is also a strategy, logic inside. So carefully proceed further.

We need to install Java Development Kit JDK latest version and WebLogic in silent mode installation.

Step 1: Copy installers to data folder this is my convention I've used
Here few Dockerfile commands

FROM - used to specify the base image
MAINTAINER - tell about author
RUN - executable commands separated by &&
USER - like su command in Linux is used for switch user
ENV - environment variables definitions predefined
ADD - share directories or files
WORKDIR - login is like cd in Linux you perform some of the commands there and then you can use one more time and perform
COPY - copy the files from host machine to container it is like scp
CMD - Execute command where you can give multiple commands in double quotes
ENTRYPOINT - when container started immediately this instruction will be executed


Now we are good to go for creating the Dockerfile as follows:


# WLS DOCKERFILES PROJECT
# --------------------------
# Pull base image
# ---------------
FROM dnraikes/oraclelinux-7:latest

# Maintainer
# ----------
MAINTAINER Pavan Devarakonda 

RUN mkdir -p /u01 /data && \
    chmod a+xr /u01 && \
    useradd -b /u01 -d /u01/oracle -m -s /bin/bash oracle && \
    chown oracle:oracle -R /u01 && \
    chown oracle:oracle -R /data

USER oracle

ENV PATH=/bin:$PATH

ADD ./data /data
ADD ./silent /u01/silent
ADD  wls_installer.sh /u01/wls_installer.sh

WORKDIR /u01
RUN /u01/wls_installer.sh

I'm just doing this experiment how much size this container would make that really matters.
Step 2: Copy silent folder containing wls_install.rsp, oraInst.loc with appropriate group and inventory location. Ref : Single hit installation of WebLogic 12c on Vagrant box

JDK, WebLogic Installation

Revisiting last blog post few changes made which will be help you to prepare the docker image while it creates image it will install JDK and WebLogic into the intermediate containers.

#!/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=/data
INSTAL_LOC=/u01/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...
WLS_INSTALLER=fmw_12.2.1.0.0_wls.jar
WLS_INSTALLER_PATH=/data

SILENT_DIR=/u01/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

Step 3: Run the docker build as follows:
#!/bin/bash
#

# ################## #
# BUILDING THE IMAGE #
# ################## #
echo "Building image '$IMAGE_NAME' ..."

IMAGE_NAME="wlsimg"
NOCACHE=true

BUILD_START=$(date '+%s')
docker build --force-rm=$NOCACHE --no-cache=$NOCACHE -t $IMAGE_NAME . || {
  echo "There was an error building the image."
  exit 1
}
BUILD_END=$(date '+%s')
BUILD_ELAPSED=`expr $BUILD_END - $BUILD_START`

echo ""

chmod u+x build.sh
./build.sh

After weblogic docker image build completed you can see the following lines at the end:
Successful execution of docker build

The docker image list looks as follows:

WebLogic docker image
Further experimenting on dockerization of WebLogic - Using containers will be posted soon.

Reference:

  1. GitHub link for Oracle-WebLogic docker build

Saturday, July 15, 2017

5. docker-compose for WebLogic cluster deployment

In the earlier post you have seen how to use docker-compose for WebLogic image build and run the container with new application deployment.

Prerequisites

Let me keep the list of prerequisite steps which you can follow my previous blog post or youtube video.

  1.  docker pull oraclelinux:7-slim  
  2. git clone https://github.com/oracle/docker-images.git 
  3. download server-jre1.8 latest version copy to OracleJava/dockerfiles build the image and make it as oracle/serverjre:8
  4. download weblogic 12.2.1.2.0 quick installer which is used for development, it is small in size. image name it as oracle/weblogic:12.2.1.2-developer 
  5.  create new docker images where 12212-domain:latest using WLST and shell script which are available in container scripts. 
  6. create new docker images named as 1221-appdeploy:latest where it uses 12212-domain as base images. 
  7. And also docker pull httpd:2.4 6. download the proxy plugin for 12.2.1.2 create the 1221-webtier:latest [apache with proxy plugin configured]

The power of docker-compose script

Now lets pick the following docker-compose.yml file where it will use two images the two images : 1221-appdeploy, 1221-webtier Using last session created admin container for create managedserver with port change
version: '2'

networks:
  &network wlsnet:
    driver: bridge

services:

  # Deploys the wlsServer with default hostname 'wlsadmin' used by scripts in 1221-domain.
  &adm adminserver:
    image: &i 1221-appdeploy
    container_name: wlsadmin
    ports:
    - "8001:7001"
    networks:
      - *network

  # Deploys a container running a Managed Server and a Node Manager to control MS from wlsServer
  managedserver:
    image: *i
    command: createServer.sh
    networks:
      - *network
    depends_on:
      - *adm

  # Deploys a container running only a node manager. to deploy a managed server here later, use wlsServer Web Console
  nodemanager:
    image: *i
    command: createMachine.sh
    networks:
      - *network
    depends_on:
      - *adm

 # WebTier for load balancing requests to cluster
  webtier:
    image: 1221-webtier
    networks:
      - *network
    ports:
    - "8800:80"
    environment:
      - WEBLOGIC_CLUSTER="managedserver:7001"
    links:
      - managedserver

################ END OF compose file ###############################

Next steps:

8. Validate the docker configuration syntaxt docker-compose config
9. If all good then proceed for the run the containers - wlsadmin, managedserver, nodemanager and webtier docker-compose up
10.  Check the containers logs with container names as argument docker-compose ps docker logs wlscluster_managedserver_1 -f
 11. Expansion of docker containers for clustered Weblogic domain. docker-compose scale managedserver=4


References:

Thursday, June 22, 2017

4.Learning docker-compose for WebLogic with examples

Learning docker-compose for WebLogic with examples

The docker-compose is one of the docker integration tool. it works based on yml or yaml file. The yml files are easy to read plain like English text. It is developed alternative to JSON files, both are used to store the key, value pairs and hierarchical structured data. To run docker-compose command in the current directory there should be  docker-compose.yml file must be exist.

Prerequisites for docker-compose

  • well awareness of docker
  • YML syntax
  • docker network

docker-compose build with Example


Dockerfile is used to build the docker image that should be present in the current directory.

Create docker-compose.yml file


Lets create the docker-compose.yml file for WebLogic Domain container which uses 1221-appdeploy image. The AdminServer port exposed as 7001 from the container and on left side host port opened with 7001. The container should run the command/shell script. here we can select startWebLogic.sh as starting shell script to be executed when container launched.

Here the docker Compose syntax is simple human readable. alternative to JSON. meta-data.
wls:
 image: 1221-appdeploy
 ports:
  - "7001:7001"
 command:
  - startWebLogic.sh

Now we are ready for Running the container with docker-compose command which will start the container and keep  it running state.

docker-compose up 

To run the docker container in the background we will use -d option

docker-compose up -d 


docker-compose for WebLogic appdeployment container
We have same number of commands as in docker for docker-compose. And it is more powerful than docker commands. because it can start multiple containers with single command.

How to check the WebLogic log files from docker host?

Docker container logs can be viewed from the docker host machine using the following command
  docker-compose logs --tail="all"

  docker-compose logs -f
   




How to get docker-compose process list?

We can get the list of process that are running on docker deamon.
docker-compose ps
docker-compose ps for WebLogic

How to bring down docker-compose containers?


To stop the container we can use stop option
docker-compose stop

To destroy and dispose you can use down option.
docker-compose down

It will stop and remove the container.

Destroying the container will loss all the changes in the last domain configuration. Better to have host volume shared or have a separate container to have WebLogic domains for backup.

Sunday, May 21, 2017

1. Learning dockerization for WebLogic on Oracle Linux in Vagrant

Writing this blog post after couple of executions experiments and research on docker. The basic requirement for docker is there must be a Linux/Unix based platform. Here I am creating that one on my Windows host machine, and the guest Ubuntu Trusty64 platform with the help of Vagrant and Oracle Virtualbox provider.

vagrant Ubuntu docker - Oracle Linux images

In this Article I am not dicuss about from the scratch What is docker etc. I'm not talking about Virtualization vs Containerization.
Create testnode1 folder on the Windows machine. I've created on F:\testnode1.

The Vagrantfile to launch Ubuntu Trusty64 Virtual machine is as follows:

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.define "test" do |testnode1|
 testnode1.vm.box = "williamyeh/ubuntu-trusty64-docker"
 testnode1.vm.hostname="testnode1.vybhava.com"
 testnode1.vm.network "private_network", ip: "192.168.33.102"
  end
  config.vm.synced_folder "F:/Softwares", "/u01/app/software"
  config.vm.provider "virtualbox" do |vb|
     vb.memory = "4096"
   end
 end

After Vagrant up looks like this

In the Trusty64 terminal the createuser.sh shell script will be executed first time. Next time onwards it will verify and shows message already executed.

Note that this vagrant box built-in with docker, and when you start the box it will automatically brings up the docker-engine.

How do I know docker installed?


Using docker info you will get to know about the docker version, status and information about daemon how much memory, CPU are allotted for it.

docker info
The docker info command execution


How do I check docker engine running?


Using regular Linux service command will tell about docker engine. Of-course docker info already tells the same in one of the line.

service docker status

Checking docker service status


Lets do dockerization

There are multiple docker commands which help you to create docker images, pull them from the global repository. Docker images will be used to generate docker containers. Here image is like blueprint and the container is like object of the blueprint.

docker search oraclelinux

docker search for oraclelinux image in public registry

Once you found your desired image then you can use pull command on docker engine then docker image will be visible.

docker pull oraclelinux7

docker pull oraclelinux-7
After pull successful your docker images stack will be updated to check use docker images command.

docker images

docker images list including oraclelinux-7
Running docker container
We can run the docker container from the pulled images, here we are interested on oraclelinux-7 image.


 docker run -i -t --name orawls --hostname orawls.vybhava.com dnraikes/oraclelinux-7:latest /bin/bash

Next post on Java WebLogic in docker image

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 
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!!!

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