Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Sunday, May 13, 2018

Learning 1. Minikube Kubernetes Cluster Running in the Oracle VirtualBox

My learning Kubernetes Cluster is an essential skill for SRE DevOps Engineers on any Cloud platforms. My learning capability keep growing with this daily dose!! :) I like the statement given in one of the author -Kubernetes is like captain of ship where multiple container clusters carried in the huge ship. This is a first step that will help you to enter into world of Kubernetes cluster technologies. Kubernetes is also known as k8s, this is quite young technology in the DevOps stack. Here we have two options to work-out on Learning Kubernetes:
  1. Kubernetes installing in master-slave in multiple nodes
  2. Minikube running a locally single node
The first option will be used in real-time production environments, and the other is used for learning purposes. Here I've selected the second option for running WebLogic on Minikube.


Benefits of Kubernetes cluster

There are many benefits but in brief for WebLogic  

  • Kubernetes is the core component in Cloud Native Engineering platforms
  • It Will be extensively used in aws, azur and BMC (Spartacus)
  • Ready to plug in real time web applications for easy deploy and scale
Running WebLogic server on Minikube Kubernetes cluster

In this article, I will be discussing 
  1. How to prepare the VirtualBox for Minikube?
  2. Installation of Docker CE in Ubuntu
  3. Installation of Minikube in Ubuntu
  4. Deploy the minikube kubernetes dashboard
  5. Running WebLogic container in a pod

Prerequisites for Minikube in Ubuntu Virtual Box               

Install the VirtualBox if it was not latest and try to launch the new Ubuntu virtual disk image. I preferred to use Ubuntu 16.04 Xenial or Ubuntu 17.10 Artful are best suites for this experiment. Select the virtual disk from  uncompressed folder. Assigned the 4Gig Ram and 2 CPUs to the VirtualBox. Start the Ubuntu 16.04 VirtualBox image, after login osboxes user. Install the Guest Additions then try to configure shared folder where you wish to store the software that shares between host machine with a guest machine. Enable the shared clipboard -> bidirectional, and also drag and drop -> bidirectional.

1. Enter into a terminal use sudo -i to switch to the root user, update the apt package index with:

 apt-get update 

2. Install packages to allow apt to use a repository over HTTPS:
 
apt-get install \
                                apt-transport-https \
                                ca-certificates \
                                curl \
                                software-properties-common

3. Add Docker’s official GPG key:
 
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 

4. Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

 apt-key fingerprint 0EBFCD88
docker fingerprint validation in Ubuntu

Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well. To add the edge or test repository, add the word edge or test (or both) after the word stable in the commands below. 5. Adding repositories for the latest stable version

 add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) \
stable"

Note: Starting with Docker 17.06, stable releases are also pushed to the edge and test repositories. 6. Update the apt package index.

 apt-get update

7.Install the latest version of Docker CE, or go to the next step to install a specific version:

 apt-get install docker-ce 

8. login through root check below command if running or not:
                docker version
                docker info                
 

Install minikube 

Minikube is recommended for development environments or to experience the Kubernetes in a quick way in a local VM/Laptop. Docker swarm is also a similar orchestration tool as Kubernetes. Kubernetes is open-source. Kubernetes is also supports non-docker containers such as rocket containers.

1. Firstly, download minukube and kubectl

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

Now kubectl download and move to /usr/local/bin
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && cp kubectl /usr/local/bin 

2. Set the MINIKUBE Env Variables
                export MINIKUBE_WANTUPDATENOTIFICATION=false
                export MINIKUBE_WANTREPORTERRORPROMPT=false
                export MINIKUBE_HOME=$HOME
                export CHANGE_MINIKUBE_NONE_USER=true
                mkdir $HOME/.kube || true
                touch $HOME/.kube/config
                export KUBECONFIG=$HOME/.kube/config

3. Lets start the Minikube with the none driver there are multiple drivers available. Each driver works according the platform where your host machine running. So using for this experiment vm-driver=none is best suitable because it is a Virtualization of Containerization.

minikube start --vm-driver=none

We can use kubectl commands which are able to interact with Minikube cluster. If you get any issue related to certs. The fix will be simply stop the minikube and start it.

Understanding kubernetes Head Node


 Minikube internally runs Kubernetes Head node or some other says that Master node, the whole control will be operated from this node only, which contains all components:

  1. etcd
  2. scheduler
  3. controller
  4. apiserver
  5. addons-manager
All the component required for Head node we can see in the namespace list:
kubectl get po --all-namespaces

Head node work with the set of namespaces

Kubelet is a Kubernetes Node agent which will be always running and monitoring all the components. If anything goes down it will brings up that component service automatically.

The etcd is capable to store the key, values which are used in the Kubernetes cluster. It is developed and inspired from coreos.

Every Kubernetes master will have scheduler, that is actually used to triggered as per the start time value, by default it will be 0.

Kuberneretes master have controller which internally talks to docker environment and a kubelet. Kubelet is like running an agent for Kubernetes master.The internal communication will be using RSA certs.

The apiserver in the master will be serving the client requests and they will be routed to the available Nodes. A Node may have multiple pods of same category.

Think Differently

Using minikube dashboard to deploy WebLogic Console application where many thousands of examples are there to tell hello-world app but say think differently web application that is WebLogic administration console as app to deploy as service and name it as wls-app.

Minikube Kubernetes will be providing us a nice UI dashboard to show the workload on the cluster. What all the status of pods, services, and also allows use to create and manage the deployments etc.

Let's start the dashboard

minikube dashboard

when you run the above command it will try to launch the browser and start the dashboard
Minikube dashboard

Finally stopping the minikube
minikube stop
Stopping local Kubernetes cluster...
Machine stopped.

Next post 


Learning 2: MiniKube Kubernetes Cluster WebLogic Application deployment

Hoping you like this experiment trick. please share this with your techie friends, share your comments.

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

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

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