Tuesday, July 28, 2020

ShellScript Examples - Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 


File Name: userCreation.sh

##############################################################################################
#Purpose : This Script is to create a user and add it to devops group and set the  password.
#Author: Mithun Reddy Lacchannagari
#Date Created : June 24th 2010
##############################################################################################

clear
echo "Please enter the user name for the account you want to create!"
read userName
echo "The name you entered is: "  $userName
/usr/sbin/useradd   $userName
/usr/sbin/usermod -G devops $userName
echo ".......User is created..........."
echo ".......Now Set the password for  ....... $userName"
passwd $userName
---------------------------------------------------------------------------------------------------------------------------
File Name: createUser.sh

##############################################################################################
#Purpose : This Script is to create a user , set the  password add it into sudoers file.
#Author: Mithun Reddy Lacchannagari
#Date Created : June 24th 2010
##############################################################################################


#!/usr/bin/env bash

if [ $# -ne 1 ]
then
  echo "Usage: $0  username"
  exit
else
  USERNAME=$1
fi

# creating user
/usr/sbin/useradd $USERNAME
passwd $USERNAME

echo "User has created successfully.."
echo "Providing sudo access.."

# Giving sudo access
sed -i "/NOPASSWD/a\\$USERNAME ALL=(ALL)       NOPASSWD: ALL" /etc/sudoers

echo "Sudo access provided successfully.."




Wednesday, July 15, 2020

Grafana Installation - Linux RHEl - 8 - Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Grafana Installation

#Login as a root user
sudo su -

#Create file called grafana.repo in /etc/yum.repos.d directory and add the below content.
vi /etc/yum.repos.d/grafana.repo

[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

#Install the grafana.
yum install grafana -y

#Enable the grafana-server service.
systemctl daemon-reload

systemctl enable grafana-server

#Start the grafana-server service.
systemctl start grafana-server

#Check  the grafana-server service status.
service grafana-server status


Troubleshooting
---------------------
Unable to access Grafana URL?
----------------------------------------
https:<<IP Address>>:3000/

Deafult Credentails
User Name: admin
Password:  admin

a)make sure port 3000 is opened in security groups in AWS ec2 instance.

Docker Commands - Mitun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Docker Commands

docker info: It will give status of weather docker is running or not  and also It will display the detailed information about docker engine. 

docker version: Show the Docker version information.

docker images (OR) docker image ls : List all images that are locally stored with the Docker engine.

docker run <<Docker Image>> : It will run the docker image.

Example: docker run hello-world: This command will download the hello-world image, if it is not already present, and run the hello-world as a container.

docker images <<Image Name>>: It will display the information about image.

docker images -q: It will display only the images IDs.

docker rmi << Image ID/Image Name>> (OR) docker image rm << Image ID/Image Name>>: It will delete an image from the local image store.
Example: docker rmi nginx

docker rmi $(docker images -q) (OR) docker rmi -f $(docker images -q) : It will remove all the images from docker engine.

docker run --name “hello-world-container” helloworld: Start the hello-world image with “hello- world-container” container name. 

docker create “hello-world-cont” helloworld : It will create a container called “hello-world-cont” from the image hello-world and it won’t start the container.

docker ps (OR) docker container ls: Lists running containers
(It will not display the stopped containers)

docker ps –a (OR) docker container ls --all (OR) docker container -a: Lists all containers (It will display the stopped containers along with running containers.)
                                                    
docker start <Container name|id>: It will start the container.

docker start webserver: It will start the webserver.

docker stop <container name|id> (OR) docker container stop <container name|id>: It will stop the docker container.

docker stop webserver: It will stop the container called webserver.

docker pause CID/CNAME: It will pause the container.

docker unpause CID/CNAME: It will unpause the container.

Docker Container status are, created, restarting, running, removing, paused, exited, or dead

docker ps -a --filter "name=mithun16thjune": It will display all the containers with name mithun16thjune name.

docker ps -a --filter 'exited=0' :

docker ps --filter status=running: It will display the all the running state containers.

docker ps --filter status=paused: It will display the all the paused state containers.

docker logs <container name>: It will display the logs for that container.

docker logs --tail 100 <<Container Name>>: Print the last 100 lines of a container’s logs.

docker top <<Container ID>>: This will shows the top processes in within in a container.

docker reanme <<Container Old Name>> <<Container New Name>>: It will rename the conatiner.

docker rm -f <<Container Name>>: It will remove the container.

docker rm -f webserver: It will stop and remove the running container with a single command.

docker stop $(docker ps -a -q): It will stop all the containers.

docker rm -f $(docker ps -aq): Delete all running and stopped containers.

docker kill <<CID/C Name>>: It will kill the container.

docker container prune: It will delete all stopped containers.

docker search <<Image Name>>: It will search all of the publicly available images on Docker
Hub(https://hub.docker.com).

docker pull <<Image Name>: Pull an image from Docker Hub

docker inspect <<CID>> : It will give information for container.

docker attach <<CID>> : It will connect to running container.

docker exec <<CID>> : Run a linux command in a running container.

docker stats <<CID>> : It will display a live stream of container resource usage statics.

docker network ls: List the networks.

docker network create mithuntechnologies : It will create the network with name called as mithuntechnologies.

docker network inspect bridge: Display detailed information on one or more networks.

docker network connect: Connect a container to a network.

docker network prune: Remove all unused networks.

docker run -it -v /Users/mithunreddyl/Desktop/dockervolumes:/mithuntechnoVol1 ubuntu : Create a container with volume mithuntechnoVol1.


docker run -it -v /Users/mithunreddyl/Desktop/dockervolumes:/mithuntechnoVol1:ro --name ubuntucontainer16 ubuntu : Create the Read only Volume.


docker run -it --volumes-from ubuntucontainer16 --name ubuntucontainer1604 ubuntu:16.04:
Create a container ubuntucontainer1604 that uses the same volumes as ubuntucontainer16

Can I mount same volume to multiple docker containers?
Ans) Yes you can add same location as a volume to many docker containers.

docker login: To sign into the Docker Hub.

docker logout: To logout from the Docker Hub. If no server is specified, then the default is used.


Saturday, July 11, 2020

Package Management in Linux (RHEL) using yum (Yellowdog Updater, Modified) - Mithun Technologies - +91-9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 

The package management is a method of installing,updating,removing software on the system.

In RedHat Linux Distribution we can use yum command for installing, updating and removing the software.

Note: yum command need to execute as a root user or with sudo access.

Install a Package with YUM

To install a package any, use below command syntax.

Syntax: yum install <<package name>>
Example: yum install tree

The above command will ask confirmation before installing any package on your system. If you want to install packages automatically without asking any confirmation, use option -y as shown in below example.

Syntax: yum install <<package name>> -y
Example: yum install vim -y
We can install multiple packages with separated by space for each package name as follows.

#yum install zip unzip tar -y

Updating a Package using YUM
Using yum command we can update the package as follows.

Syntax: yum update <<package name>> -y
Example: yum update tree -y

UN-Install /Remove a Package using YUM
Using yum command we can uninstall the package as follows.

Syntax: yum remove <<package name>> -y
Example: yum remove tree -y

Get Information of a Package using YUM
Using yum command we can get the package information as follows.

Syntax: yum info <<package name>>
Example: yum info tree

List all Available Packages using YUM

To display all the package which are available in yum repository, use the below command.

#yum list

List all Installed Packages using YUM

To display all the package which are installed in Linux server, use the below command.

#yum list installed

Check for Available Updates using Yum

To find how many of installed packages on your system have updates available, to check use the following command.

#yum check-update

Update System using Yum

To keep your system up-to-date with all package updates, run the following command. It will install all latest patches and security updates to your system.

#yum update

List all available Group Packages

In Linux, number of packages are bundled to particular group. Instead of installing individual packages with yum, you can install particular group that will install all the related packages that belongs to the group. For example to list all the available groups, just issue following command.

#yum grouplist

Install a Group Packages

To install a particular package group, we use option  groupinstall as follows.

#yum groupinstall 'Development Tools'

To know how many packages are available in particular group, execute the below command.

#yum groupinfo 'Development Tools': Here Development Tools is a group name.

Update a Group Packages

To update any existing installed group packages, just run the following command as shown below.

#yum groupupdate 'Development Tools'

Remove a Group Packages

To delete or remove any existing installed group from the system, just use below command.

#yum groupremove 'Development Tools'



Tuesday, June 23, 2020

Crontab in Linux - Mithun Technologies - +91-9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Crontab
 

To allow or deny access to specific users, crontab uses the files /etc/cron.allow and /etc/cron.deny. Based on the existence of /etc/cron.allow and /etc/cron.deny files, crontab decides whom to give access to cron in following order.

  1. If cron.allow exists – only the users listed in the file cron.allow will get an access to crontab.
  2. If cron.allow does not exist – all users except the users listed into cron.deny can use crontab
  3. If neither of the file exists – only the root can use crontab
  4. If a user is listed in both cron.allow and cron.deny – that user can use crontab.
crontab -l : To display the cron jobs.
crontab -e : To edit the cron table.

crontab -r : To remove the crontable without confirmation.
crontab -ir: To remove the crontable with confirmation.

To list,schedule or remove cron job for the particular user, use below commands.
#crontab -l -u mithun
#crontab -e -u mithun
#crontab -ir -u mithun

Crontab Format

# Minute   Hour    Day of Month          Month               Day of Week        Command /Script
# (0-59)    (0-23)        (1-31)            (1-12 or Jan-Dec)   (0-6 or Sun-Sat)    /usr/bin/find


Run the cron job every minute.
*/1 * * * *

Run the cron job every 10 minutes.

*/10 * * * *

Wednesday, May 13, 2020

Kubernetes setup in AWS using KOPS - Mithun Technologies - +91-9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Kubernetes Cluster setup in AWS using KOPS

1) Create Ubuntu EC2 instance

2) Install AWSCLI

 sudo apt update -y
 sudo curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip
 sudo apt install unzip python -y
 sudo unzip awscli-bundle.zip
 #sudo apt-get install unzip - if you dont have unzip in your system
 sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
 
 
3) Install kops on ubuntu instance:

     #Install wget if not installed
     sudo apt install wget -y
     sudo wget https://github.com/kubernetes/kops/releases/download/v1.16.1/kops-linux-amd64
     sudo chmod +x kops-linux-amd64
     sudo mv kops-linux-amd64 /usr/local/bin/kops
 
4) Install kubectl

 sudo curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl

 sudo chmod +x ./kubectl
 sudo mv ./kubectl /usr/local/bin/kubectl

5) Create an IAM role from Consloe or CLI with below Policies.

    AmazonEC2FullAccess
    AmazonS3FullAccess
    IAMFullAccess
    AmazonVPCFullAccess


Then Attach IAM role to ubuntu server from Console Select KOPS Server --> Actions --> Instance Settings --> Attach/Replace IAM Role --> Select the role which
You Created. --> Save.



6) create an S3 bucket Execute below commond in KOPS Server use unique bucket name if you get bucket name exists error.

    aws s3 mb s3://<bucketname>
   
    ex:
    # S3 bucket name should be unique across AWS
    aws s3 mb s3://balajimtbatch18.k8s.local
    
    Expose environment variable:

    # Add env variables in bashrc
    vi .bashrc
   
    # Give Unique Name And S3 Bucket which you created.
    export NAME=balajimtbatch18.k8s.local
    export KOPS_STATE_STORE=s3://balajimtbatch18.k8s.local
 
    source .bashrc
   
7) Create sshkeys before creating cluster

    ssh-keygen
 

8)Create kubernetes cluster definitions on S3 bucket

    kops create cluster --zones ap-south-1a --networking weave --master-size t2.medium --master-count 1 --node-size t2.micro --node-count=2 ${NAME}
   
   
    kops create secret --name ${NAME} sshpublickey admin -i ~/.ssh/id_rsa.pub

9) Create kubernetes cluser

     kops update cluster ${NAME} --yes

10) Validate your cluster(KOPS will take some time to create cluster ,Execute below commond after 3 or 4 mins)

       kops validate cluster
 
11) To list nodes

      kubectl get nodes
 
 
 
To Delete Cluster

   kops delete cluster --name=${NAME} --state=${KOPS_STATE_STORE} --yes 
  
====================================================================================================


IF you wan to SSH to Kubernates Master or Nodes Created by KOPS. You can SSH From KOPS_Server

ssh  admin@<IPOrDNS>
it above command  is not working
then execute
ssh -i ~/.ssh/id_rsa admin@<IPOrDNS>
 

Mongo DB Commands - Mithun Technologies - +91 99809 23226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 


mongod --version: It will gives the MongoDB Server version.

mongo -version: It will gives the MongoDB Shell version.
Mongo Shell is the command line client.

To login into mongo db just type mongo command.

db.createCollection("students"): It will create a collection called students.


db.students.insertOne( {
    name: "Mithun",
    age: 07,
    status: "A"
 } )



Friday, March 13, 2020

Tomcat Installation - Linux - Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Tomcat Installation

#Login as a root user
sudo su -

yum install wget unzip -y

cd /opt
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.86/bin/apache-tomcat-9.0.86.zip
unzip apache-tomcat-9.0.86.zip
cd /opt/apache-tomcat-9.0.86
chmod u+x *.sh

ln -s /opt/apache-tomcat-9.0.86/bin/startup.sh /usr/bin/startTomcat
ln -s /opt/apache-tomcat-9.0.86/bin/shutdown.sh /usr/bin/stopTomcat
#ps -fax | grep tomcat
#netstat -tunlap
#vi /opt/apache-tomcat-9.0.65/webapps/manager/META-INF/context.xml
#Comment the below lines
#<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
# allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->
startTomcat
#stopTomcat
 
#Create a user
#vi /opt/apache-tomcat-9.0.44/conf/tomcat-users.xml

Troubleshooting
--------------------

tomcat server is not starting?

a)Check the catalina.out file which is available  in conf dir.
b)check java is installed or not using java -version command.

Unable to access Tomcat server URL in browser?

a)make sure port 8080 is opened in security groups - AWS ec2 instance.

Thursday, March 12, 2020

DevOps Videos URLs - Mithun Technologies - 9980923226



Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/
Linux Videos
-------------
https://www.youtube.com/playlist?list=PLUltco2RCw43vhoBxQl90UaMfMqEY6FwN

Shell Script Videos
-------------------
https://www.youtube.com/playlist?list=PLUltco2RCw42wrkxcsqGyi-5-FqRIgKdR

Gi and GitHub Videos
--------------------
https://www.youtube.com/playlist?list=PLUltco2RCw41G__vPuebVkj9hF1o2fH6z

Java Videos
-----------
https://www.youtube.com/playlist?list=PLUltco2RCw400e4VSlfONdXfqkoJifCjd

Maven Videos
------------
https://www.youtube.com/playlist?list=PLUltco2RCw41kFVAT9tEiet60xdkYKJUT

Tomcat Videos
-------------
https://www.youtube.com/playlist?list=PLUltco2RCw43d1kbZiCbKB2v35nvs4DIr


SonarQube Server Videos
-----------------------
https://www.youtube.com/playlist?list=PLUltco2RCw43iSpp9B-sOtHuBQInkmnYA

Nexus Videos
------------
https://www.youtube.com/playlist?list=PLUltco2RCw42HGb3_KjqnJFi6HBD7Kxea


Jenkins Videos
--------------
https://www.youtube.com/playlist?list=PLUltco2RCw411cVNkBki1ZGjIM1X01h4D


Docker and Docker Swarm Videos
-------------------------------
https://www.youtube.com/playlist?list=PLUltco2RCw416lg-Pzaks4nSL_6L_fEjc


Kubernetes Videos
-----------------
https://www.youtube.com/playlist?list=PLUltco2RCw411cVNkBki1ZGjIM1X01h4D


Ansible Videos
--------------
https://www.youtube.com/playlist?list=PLUltco2RCw43Gd2hClMPx7d0I6YaPRS0O


Terraform Videos
----------------
https://www.youtube.com/playlist?list=PLUltco2RCw42eV5Kumvqh8pZGpmFvcXfZ

Packer Videos
-------------
https://www.youtube.com/playlist?list=PLUltco2RCw41kmkmr13XflG5edNoUGZBo


Mongo DB Videos
---------------
https://www.youtube.com/playlist?list=PLUltco2RCw40MEt_qD3itOxCcs_YdzL0H


Nagios Videos
-------------
https://www.youtube.com/playlist?list=PLUltco2RCw42GG7B27-1m5ku2WsPS8hhn

EC2 Instance Creation by using Terraform - Mithun Technologies - +91-9980923226



Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/

provider "aws" {
  region = "ap-south-1"
  access_key = "AIA4UQE3BUQ6GQ3BAEO"
  secret_key = "5LAzj2tYFxf1NNvmvz0Z1UASoEzDZHlc6R5wHF"
}

resource "aws_instance" "AWSServer" {
  ami = "ami-0a74bfeb190bd404f"
  instance_type = "t2.micro"
  key_name = "mithuntechnologies"
  security_groups = ["launch-wizard-1"]
  tags = {
   Name = "Terrafrom Server"
  }
}

Wednesday, March 4, 2020

Vault Installation - Linux Server- Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Packer Installation 
#Login as a root user in ec2 instance
sudo su -

#You will need to upgrade your system and packages
yum update -y

#Install wget and unzip packages
yum install wget unzip vim -y


#Go to /opt dir
cd /opt

#Download the Vault software.
https://www.vaultproject.io/downloads/

wget https://releases.hashicorp.com/vault/1.3.2/vault_1.3.2_linux_amd64.zip

#Extract the terraform software.
unzip vault_1.3.2_linux_amd64.zip -d /usr/local/bin/

#Check the version

vault -v (OR) vault --version

#Help

vault  -help
 

Tuesday, February 25, 2020

Java Installation - Linux - Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Java Installation  in RHEL
#Login as a root user
sudo su -


#Install JRE 1.8
yum install java-1.8.0-openjdk -y
java -version 
#Install JDK 1.8 
yum install java-1.8.0-openjdk-devel -y

javac -version 
#Install JRE 11  
yum install java-11-openjdk -y
java -version 
#Install JDK 11
yum install java-11-openjdk-devel -y
javac -version  

                                                          Java Installation  in Ubuntu
##Login as a root user
sudo su -
       

Monday, February 24, 2020

Packer Installation - Linux Server- Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Packer Installation 
#Login as a root user in ec2 instance
sudo su -

#You will need to upgrade your system and packages
yum update -y

#Install wget and unzip packages
yum install wget unzip vim -y


#Go to /opt dir
cd /opt

#Download the Packer software.
https://packer.io/downloads.html 

wget  https://releases.hashicorp.com/packer/1.5.4/packer_1.5.4_linux_amd64.zip

#Extract the terraform software.
unzip packer_1.5.4_linux_amd64.zip -d /usr/local/bin/

#Check the version

packer -v (OR) packer --version

#Help

packer -help

Saturday, February 22, 2020

Steps to create password less ssh between two AWS EC2 instances - Mithun Technologues - +91-9980923226

Steps to create password less ssh between two AWS EC2 instances - Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Steps to create password less ssh between two AWS EC2 instances

Pre Requisites

  2 Linux Servers
     Redhat Linux Server - A
     IP:       13.233.128.180
     User:     ec2-user
     Password: ********
   
     Redhat Linux Server - B
     IP:       13.127.64.6
     User:     ec2-user
     Password: ********

Step  1

Generate the ssh key using below command in Redhat Linux Server - A

ssh-keygey
~/.ssh/
id_rsa
id_rsa.pub

Step 2
Copy the public key from Redhat Linux Server - A to Redhat Linux Server - B as follows.

ssh-copy-id ec-user@Redhat Linux Server - B HostName/IP Address


Step 3
Test the configurations as follows.

ssh ec2-user@Redhat Linux Server - B HostName/IP Address

It should not ask the password and It will successfully connected to Redhat Linux Server - B from Redhat Linux Server - A




  

Thursday, February 20, 2020

Terraform Installation - Linux Server- Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Terraform Installation 
#Login as a root user in ec2 instance
sudo su -

#You will need to upgrade your system and packages
yum update -y

#Install wget and unzip packages
yum install wget unzip vim -y

#Download the terraform software.
#Use https://www.terraform.io/downloads.html to download the terraform software.

wget https://releases.hashicorp.com/terraform/1.3.3/terraform_1.3.3_linux_amd64.zip

#Extract the terraform software.
unzip terraform_1.3.3_linux_amd64.zip -d /usr/local/bin/

#Check the version
terraform -v (OR) terraform version

#Help
terraform -help

Wednesday, February 19, 2020

Mongo DB Installation - Linux - Mithun Technologies - 9980923226



Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Mongo DB Installation 
#Login as a root user
sudo su -

#Configure the package management system (yum).
#Create a file /etc/yum.repos.d/mongodb-org-4.2.repo


vi /etc/yum.repos.d/mongodb-enterprise-4.2.repo

#add below lines in /etc/yum.repos.d/mongodb-org-4.2.repo file

[mongodb-enterprise-4.2]
name=MongoDB Enterprise Repository
baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/4.2/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc

#Install the mongodb
yum install -y mongodb-enterprise

#Enable the mongod service
systemctl enable mongod
#Start  the mongod service
systemctl start mongod
#Check the mongo db version
mongo --version

#Connect to mongo db
mongo
#Create a user

use admin
 
db.createUser(
  {
    user: "mithuntechnologies",
    pwd: "passw0rd",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

#Enable authentication

vi /etc/mongod.conf

security:
    authorization: "enabled"
   
#Restart the mongod service as follows.

service mongod restart

# Connect to Mongo DB from any client
mongo mongod:IPAddress:27017


Tuesday, February 11, 2020

Install Git in AWS - EC2 Instance - Mithun Technologies - +91 - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/
##Login as a root user
sudo su -

##Change dir to /opt
cd /opt
##The below command will download and install all required development libraries to your system.

yum groupinstall "Development Tools" -y

yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel curl-devel -y
yum install wget tar -y

##Open below URL and select the specific version and right click on that and click on Copy Link ##Address, then execute the wget command.
##https://github.com/git/git/releases

wget https://github.com/git/git/archive/v2.18.0.tar.gz -O git-bash.tar.gz
tar -zxf git-bash.tar.gz

cd git-2.18.0
make configure
./configure --prefix=/usr/local
##make install command will copy the built program, and its libraries and documentation, to the correct locations.
make install

git --version

git config --global user.name "Mithun Technologies"
git config --global user.email "devopstrainingblr@gmail.com"
git config --list


Sunday, January 19, 2020

Install Apache HTTP Server in Linux Redhat Server - Mithun Technologies - 9980923226



Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/
Install Apache HTTP Server Installation 
 Login as root user and execute the below command for install http server.

yum install httpd -y

Enable the service as follows.

systemctl enable httpd.service

Start the HTTP server as follows.

systemctl start httpd.service

Important Points
  1.  httpd.conf file is the configuration file for Apache HTTP server, which is available in /etc/httpd/conf directory.
  2. Logs will be available in /etc/httpd/logs directory.

Thursday, January 16, 2020

Install Docker in Linux Server - Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/
 
In Ubuntu Server
----------------------
Method-1
=======

Step 1: Update all Software Repositories using below command.

#sudo apt-get update

Step 2: Install a Docker using below command

#sudo apt install docker.io -y

Step 3: Enable and start the docker service as follows.

#sudo systemctl enable docker
#sudo systemctl start docker

Step 4: Check the  docker version

#docker --version

# You will get permison denied error as regular user dosn't have permisions to execute docker commands, add ubuntu user to docker group.

#sudo usermod -aG docker $USER
     or 
#sudo usermod -aG docker ubuntu

# Exit From Current SSH Terminal & SSH(Login) again .Then execute
docker ps

To Un Install a docker
-----------------------------

Use below command to un-install docker
#apt-get remove docker docker-engine docker.io -y
----------------------------------------------------------------------------------------------------------------------------
Method -2
========
Step 1: Update all Software Repositories using below command.
#apt-get update


Step 2: Install Docker using below command
#curl -fsSL get.docker.com | /bin/bash


Step 3: Check all the versions.
#apt-cache madison docker-ce


Step 4: If we want to install the specific version use the below command.
apt-get install docker-ce=<VERSION>

Step 5: If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

#usermod -aG docker  <<YourUser>>
============================================================================

 In Amazon Linux
-----------------------

sudo yum update -y       
sudo yum install docker -y
sudo service docker start

Add Regural user to dockergroup
sudo usermod -aG docker  <username>

ex:
sudo usermod -aG docker ec2-user

Once you add user to group exit from the server and login again.
# Get docker information
docker info

#Install Docker in Linux (Works for most of linux flavors).
sudo curl -fsSL get.docker.com | /bin/bash

Docker Home Directory/Working Dir:
/var/lib/docker

============================================================================
Install Docker on AWS RHEL  (Offcially No Support)
----------------------------------------------------------------------

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install docker-ce-3:18.09.1-3.el7 -y
sudo systemctl enable docker
sudo systemctl start docker

sudo docker info

# Check docker is installed or not
docker info

# You will get permison denied error as regular user dosn't have permisions to execute docker commands, add user to docker group.

sudo usermod -aG docker $USER
or
sudo usermod -aG docker ec2-user

# Exit From Current SSH Terminal & SSH(Login) again .Then execute
docker ps




Sunday, January 5, 2020

Jenkins Docker Swarm Integration - Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 





Jenkins Docker Swarm Integration
=========================

1) CI/CD Pipeline Scrit to build and deploy single service in docker swarm


2) CI/CD Pipeline Scrit to build and deploy multiple services using docker stack(Compose File) in docker swarm


Pre Requisite:
==========

1) Docker Swarm Cluster
  
   https://www.youtube.com/watch?v=cuNW5Qwd-D4
  
2)  Setup CI/CD (Jenkins) Server   

=========Install Java, Jenkins, Docker in Ubuntu==============

sudo apt update -y

sudo apt install openjdk-8-jdk -y

wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update -y
sudo apt-get install jenkins -y

sudo systemctl status jenkins

sudo curl -fsSL get.docker.com | /bin/bash

# Add jenkins user to docker group
sudo usermod -aG docker jenkins
# Restart jenkins to reflect docker permisions
sudo systemctl restart jenkins

# Use below commands if you want to switch to jenkins user.
sudo -i -u jenkins
sudo su -s /bin/bash jenkins

##Plugins Used
sshAgent

Monday, November 18, 2019

Kubernetes Setup Using Kubeadm In AWS EC2 Ubuntu Servers - Mithun Technologies - +91-9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 

Agenda: Kubernetes Setup Using Kubeadm In AWS EC2 Ubuntu Servers
=======================================================


Prerequisite:
==========


3 - Ubuntu Serves

1 - Manager  (4GB RAM , 2 Core) t2.medium

2 - Workers  (1 GB, 1 Core)     t2.micro


Note: Open Required Ports In AWS Security Groups. For now we will open All trafic.

==========COMMON FOR MASTER & SLAVES START ====

# First, login as ‘root’ user because the following set of commands need to be executed with ‘sudo’ permissions.

sudo su -

# Install Required packages and apt keys.

apt-get update -y
apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update -y



#Turn Off Swap Space

swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

# Install And Enable Docker

apt install docker.io -y
usermod -aG docker ubuntu
systemctl restart docker
systemctl enable docker.service


#Install kubeadm, Kubelet And Kubectl

apt-get install -y kubelet kubeadm kubectl kubernetes-cni

# Enable and start kubelet service

systemctl daemon-reload
systemctl start kubelet
systemctl enable kubelet.service

==========COMMON FOR MASTER & SLAVES END=====



===========In Master Node Start====================
# Steps Only For Kubernetes Master

# Switch to the root user.

sudo su -

# Initialize Kubernates master by executing below commond.

kubeadm init

#exit root user & exeucte as normal user

exit

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config


# To verify, if kubectl is working or not, run the following command.

kubectl get pods -o wide --all-namespaces

#You will notice from the previous command, that all the pods are running except one: ‘kube-dns’. For resolving this we will install a # pod network. To install the weave pod network, run the following command:

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

kubectl get nodes

kubectl get pods --all-namespaces


# Get token

kubeadm token create --print-join-command

=========In Master Node End====================


Add Worker Machines to Kubernates Master
=========================================

Copy kubeadm join token from and execute in Worker Nodes to join to cluster



kubectl commonds has to be executed in master machine.

Check Nodes
=============

kubectl get nodes


Deploy Sample Application
==========================

kubectl run nginx-demo --image=nginx --port=80

kubectl expose deployment nginx-demo --port=80 --type=NodePort


Get Node Port details
=====================
kubectl get services

Saturday, October 26, 2019

Jenkins installation in Linux Server - Mithun Technologies - +91-9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 

Login as a root user
sudo su -

Install Jenkins

cd /opt/

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

yum install jenkins -y

Enable and start the jenkins service

systemctl enable jenkins

systemctl start jenkins








Wednesday, October 23, 2019

Install Maven Build Tool in Linux Server - Mithun Technologies - +919980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/

Install Maven Build Tool in Linux Server/ Set Class path for Maven Build Tool in Linux Server
-------------------------------------------------------------------------------------------------------------------------

Pre Requisite Software
-----------------------------
Java (JDK) is the Pre - Requisite Software for Maven.

javac -version

Install Maven
------------------

Step1) Login as a root user and change the directory to /opt/

sudo su -
cd /opt/
yum install wget unzip -y

Step2) Download the Maven Software

wget https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.zip
unzip apache-maven-3.9.5-bin.zip

Step3) Set the class path/Environmental Variable

For Specific User
----------------------
vi ~/.bash_profile

export M2_HOME=/opt/apache-maven-3.9.5

export PATH=$PATH:$M2_HOME/bin

source ~/.bash_profile

For All Users
---------------------- 
vi /etc/profile
export M2_HOME=/apache-maven-3.9.5
export PATH=$PATH:$M2_HOME/bin

source /etc/profile

Step4) Check the Maven version

mvn -version


Tuesday, October 22, 2019

AWS Password Login - Configuration - Mithun Technologies +91-9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 



Enable a password login instead of pem file when logging into EC2 Instance using SSH
================================================================


Procedure to Enable the password login
---------------------------------------------------

Step 1) First login into ec2 instance with pem file, then switch to root user.
ssh -i "mithuntechnologies.pem" ec2-user@ec2-52-66-196-244.ap-south-1.compute.amazonaws.com

sudo su - (OR) sudo -i

Step 2) Set a password for ec2-user as follows.
       
passwd ec2-user
       
Step 3) Update the PasswordAuthentication parameter in the /etc/ssh/sshd_config file as follows.
       
vi /etc/ssh/sshd_config
       
PasswordAuthentication yes

Step 4) Restart the sshd service as follows.

service sshd restart


Nexus Server Installation in Linux - Mithun Technologies - +91-9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 

Login as a root user
sudo su -
cd /opt
yum install tar wget -y
wget http://download.sonatype.com/nexus/3/nexus-3.15.2-01-unix.tar.gz
tar -zxvf nexus-3.15.2-01-unix.tar.gz
mv /opt/nexus-3.15.2-01 /opt/nexus

#As a good security practice, Nexus is not advised to run nexus service as a root user, so create a new user called nexus and grant sudo access to manage nexus services as follows.
 

useradd nexus

#Give the sudo access to nexus user

visudo
nexus ALL=(ALL) NOPASSWD: ALL

#Change the owner and group permissions to /opt/nexus and /opt/sonatype-work directories.

chown -R nexus:nexus /opt/nexus
chown -R nexus:nexus /opt/sonatype-work
chmod -R 775 /opt/nexus
chmod -R 775 /opt/sonatype-work

#Open /opt/nexus/bin/nexus.rc file and  uncomment run_as_user parameter and set as nexus user.

vi /opt/nexus/bin/nexus.rc
run_as_user="nexus"

#Create nexus as a service

ln -s /opt/nexus/bin/nexus /etc/init.d/nexus

#Switch as a nexus user and start the nexus service as follows.

sudo su - nexus

#Enable the nexus services
sudo systemctl enable nexus

#Start the nexus service
sudo systemctl start nexus

#Access the Nexus server from Laptop/Desktop browser.
 
http://IPAddess/Hostname:8081/

#Default Credentials
User Name:
Password:

Troubleshooting
---------------------

nexus service is not starting?

a)make sure need to change the ownership and group to /opt/nexus and /opt/sonatype-work directories and permissions (775) for nexus user.
b)make sure you are trying to start nexus service with nexus user.
c)check java is installed or not using java -version command.
d) check the nexus.log file which is availabe in  /opt/sonatype-work/nexus3/log  directory.

Unable to access nexus URL?
-------------------------------------

a)make sure port 8081 is opened in security groups in AWS ec2 instance.

Configuration of NFS Server - Mithun Technologies - +91-9980923226

   Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/

                                                          Configuration of NFS Server

Step 1: Install NFS Kernel Server
Before installing the NFS Kernel server, we need to update our system’s repository index with that of the Internet through the following apt command as sudo:

$ sudo apt-get update

The above command lets us install the latest available version of a software through the Ubuntu repositories.

Now, run the following command in order to install the NFS Kernel Server on your system:

$ sudo apt install nfs-kernel-server


Step 2: Create the Export Directory

sudo mkdir -p /mnt/share/

# As we want all clients to access the directory, we will remove restrictive permissions.
sudo chown nobody:nogroup /mnt/share/
sudo chmod 777 /mnt/share/

Step 3: Assign server access to client(s) through NFS export file

sudo vi /etc/exports


#/mnt/share/ <clientIP or Clients CIDR>(rw,sync,no_subtree_check,no_root_squash)
 #Ex:
/mnt/share/ *(rw,sync,no_subtree_check,no_root_squash)


Step 4: Export the shared directory

$ sudo exportfs -a


sudo systemctl restart nfs-kernel-server

Step 5: Open firewall for the client (s) PORT 2049


Configuring the Client Machine


Step 1: Install NFS Common
Before installing the NFS Common application, we need to update our system’s repository index with that of the Internet through the following apt command as sudo:

$ sudo apt-get update


$ sudo apt-get install nfs-common


# Test if we can mount nfs path with client systems folder.

Step 2: Create a mount point for the NFS host’s shared folder

sudo mkdir -p /mnt/sharedfolder_client

Step 3: Mount the shared directory on the client

sudo mount serverIP:/mnt/share/ /mnt/mountfolder_client

Thursday, October 17, 2019

Install Maven Build Tool in MAC - Mithun Technologies - +919980923226


             Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com
                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 

Install Maven Build Tool in MAC Book / Set Class path for Maven Build Tool in MAC Book
---------------------------------------------------------------------------------------------------------------------

Pre Requisite Software
-----------------------------
Java is the Pre Requisite Software for Maven.

java -version


Install Maven
------------------

Download the Maven Software using below url.
https://maven.apache.org/download.cgi

Set the class path/Environmental Variable
vi ~/.bash_profile

export M2_HOME=/Users/mithunreddy/MithunTechnologies/Softwares/Running/apache-maven-3.6.2

export PATH=$PATH:$M2_HOME/bin

source ~/.bash_profile

Check the Maven version

mvn -version

Ansible Installation in Amazon Linux - Mithun Technologies - 9980923226

  Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com                                                 ...