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

Thursday, October 3, 2019

Docker Swarm Setup - Mithun technologies +91-9980923226


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

                                                        Docker Swarm Setup
                                                       ================

Rerequisites:
============

3 - Ubuntu Servers
     1 - Master
    2 - Workers
   
Steps:
======
         
1) Install Docker Community Edition in all the 3 Servers.
   And add user(ubuntu) to docker group.
                
   # Below command works for most of the Linux flavors except Redhat Linux
   sudo curl -fsSL get.docker.com | /bin/bash
  
   # Add Current User to docker group.
   sudo usermod -aG docker ${USER}
  
2) Open below ports in AWS Security Groups.
      
    TCP port 2377 for cluster management communications
    TCP and UDP port 7946 for communication among nodes
    UDP port 4789 for overlay network traffic.
   
    If you are planning on creating an overlay network with encryption     (--opt encrypted), you will  also need     to ensure ip protocol 50 (ESP) traffic is allowed.
     
3) Execute below command to initiate docker swarm manager in one system.
  
   # Initialize docker swarm cluster.
   docker swarm init
  
   # Get worker token
   docker swarm join-token worker
  
   # Get manager token to add another node as secondary manager
   docker swarm join-token manager
  
4) Add workers machines to cluster.
   #Execute join token(worker token from manager) in all worker machines.
  
  
5) Display docker cluster nodes in manager machine.

   docker node ls
  
6) Deploy Sample Docker Application in docker swarm cluster.

    docker service create --name webserver --replicas 2 -p 80:80 httpd     
  

Monday, September 30, 2019

SonarQube Server Integration with Jenkins Mithun Technologies - +919980923226



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

Pre Requisite:

SonarQuber Server
Jenkins Server

Step 1) Install "SonarQube Scanner"  plugin in Jenkins as follow.

 
Step 2) Integrate SonarQube server with Jenkins  as follows.


Manage Jenkins ---> Configure System ---> SonarQube servers



Generate the SonarQube server authentication token 
 
Login into SonarQube with Admin user.
Default Credentials:
User: admin
Password: admin

Click on Administration tab.




Click on Tokens





Step3) Execute the SonarQube report for Maven Java Project.

Select the job , to which we need to run the sonarqube report, click on configure, in Post-build Actions options, click on Add post-build action --> Select the SonarQube report for Maven project.






Monday, September 16, 2019

Install Ansible in AWS EC2 Redhat Server - Mithun Technologoes +91-9980923226

 

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

1) Create RedHat 3 Servers (1-AnsibleServer , 2- Host Machines for demo) in AWS.
 

2) Login As a root user and create ansible user and provide sudo access in all Servers.

    2.1) Create the user ansible and set the password on all hosts:
           sudo useradd ansible
           sudo passwd ansible
     
    2.2) Make the necessary entry in sudoers file /etc/sudoersfor ansible        
           user for password-less sudo access:
          
           visudo

           ansible ALL=(ALL) NOPASSWD: ALL

       

    2.3) Make the necessary changes  in sshd_config file /etc/ssh/sshd_config    
           to enable password based authentication.

         Un comment PasswordAuthentication yes
         and comment  PasswordAuthentication no.
         And save the file .

            vi /etc/ssh/sshd_config

     2.4)    Then restart sshd service.
                sudo service sshd restart

=============================================================================
               Install Ansible in Red hat (Ansible Server)
=============================================================================

1)     SSH to Redhat System & Switch to ansible user
       sudo su - ansible
      
2)     Install python
       sudo yum install python3 -y
      
3)    Update python alaternatives
       sudo alternatives --set python /usr/bin/python3
      
4)    Verify Python Version
         python --version
 
5)    Install ansible using Yum 
sudo yum -y install ansible
      
6)    Verify Ansible version
       ansible --version
       
=============================================================================
               Generate SSH Key, Copy SSH Key(Ansible Server)
=============================================================================

1)    Now generate SSH key in Ansible Server

sudo su - ansible

ssh-keygen

2)    Copy it to Host  servers as ansible user: 

  Repeat below command by updating HOST IP for all the  HOST Servers. 

          ssh-copy-id ansible@<HostIP>

 

Update Host Inventory in Ansible Server to add host servers’ details.

1)    Add Host Server details

 

vi  /etc/ansible/hosts

 

# Connect using username and password

192.168.1.105 ansible_user=ansible ansible_password=password

 

# Connect using username and pem(Make Sure Have pem file at given path)

172.31.35.23 ansible_user=ec2-user ansible_ssh_private_key_file=~/aws.pem

 

# If ssh keys are copied

172.31.35.23

 

2)    Use ping module to test Ansible and after successful run you can see the below output. 

 

          ansible all -m ping

            172.31.35.23 | SUCCESS => {

            "changed": false,

             "ping": "pong"

             }

 

3)    Install sshpass in Ansible server if you get below error .

 

"to use the 'ssh' connection type with passwords, you must install the sshpass program

$ sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/sshpass-1.06-2.el7.x86_64.rpm

PUSH/PULL Docker Image form Private Repository (Nexus) - Mithun Technologies +91-9980923226

PUSH/PULL Docker Image form Private Repository (Nexus)


Pre-Requisities:
Server 1: Ubuntu                                         Server 2: Ubuntu
Install the below softwares in Server1          Install the below softwares in Server2
Java 8                                                              Docker

Docker

Jenkins

Maven/Gradle
Server 1:
1   We are going to build our project using maven/gradle
2   Through docker file we are going to create an docker image for that project
  We are going to push the docker image to Nexus (docker hosted) repo
Server 2:
We are going to pull the docker image form Nexus (docker hosted) repo
2   Create a container using the docker image
Nexus Repository (docker hosted,proxy) Creation:
docker hosted:   
1) Login to your Nexus repository.
2) Create docker hosted


 Here give a name to the repo (dock-hosted), then we are going to assign a port to this docker hosted repo. Through this port we are going to access this repo. (Note: you should not give 8081 because it is already assigned to Nexus Repo, so use different port number)

In this case I have assigned 8083 for this repo.

3) Keep the remaining settings as it is and create repository




 Note: Open 8083 in AWS Security Groups.
Ubuntu Configuration : Server 1 & 2
Do these steps in both the servers in order to push and pull docker images from Nexus Repo.
1.     Login as root user
2.     Go to /etc/docker
            cd /etc/docker
3.     Then create a file called daemon.json
vi /etc/docker/daemon.json
4.     Write these script in daemon.json

{
  "insecure-registries": [ "13.234.21.143:8083" ]
}

(Here we are allowing our docker daemon to access the Nexus Hosted Repo)
5.     Save the file
6.     Restart docker service using below command.
            systemctl restart docker

 
Server 1: Login,Build & Push
1 Login to Nexus repo
docker login –u admin –p password 13.234.21.143:8083
(or)
docker login 13.234.21.143:8083



Build an image using below command.
docker build –t 13.234.21.143:8083/image1 .
           
(here while building an docker image we will use ip address with port for the docked hosted repo instead of username in hub.docker.com)


 
3 Push docker image to Nexus Repo



Server 2: Pull image/Run container
1.     Login to Nexus

2   Pull docker image

 
Build a container
docker run –d –p 8090:8080 –p 9990:9990 - -name wildfly 13.234.21.143:8083/image1
(I am using wildfly to deploy)     

   








    

 

Ansible Installation in Amazon Linux - Mithun Technologies - 9980923226

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