Sunday, January 12, 2020

How to Install, Configure, and Deploy NGINX on a Kubernetes Cluster with Ubuntu

 What is Kubernetes?

Kubernetes is an open-source container management system that is based on Google Borg. It can be configured to provide highly available, horizontally auto scaling, automated deployments.

This guide shows you how to manually set up a Kubernetes cluster on a ubuntu with a Dashboard



Master node System requirement -
4GBRAM, 2CPU, Ubuntu 18.04 VM/Physical node

On Master Node:-


First install docker and Enable docker to auto start during reboot :
# sudo apt install docker.io
# docker --version
# sudo systemctl enable docker


Install curl and Download the gpg key for kubernetes installation and add to ubuntu :
#  sudo apt install curl
# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add


Now add the Google's kubernetes repository:
# sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"


Install kubeadm and disable the swap :
# sudo apt-get install kubeadm
# kubeadm version
# sudo swapoff -a

Create this file (daemon.json) and add the below contents to it


# vi /etc/docker/daemon.json

{

     "exec-opts": ["native.cgroupdriver=systemd"]

}



Then

# sudo systemctl daemon-reload
# sudo systemctl restart docker
# sudo systemctl restart kubelet

Set the Master node hostname :
# sudo hostnamectl set-hostname master-node   


Advertise your Master node as API server and specify the POD network
# sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.1.36

You will have the below output after running this command:


################### OUTPUT ########################


Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

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

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.1.36:6443 --token 120q6i.2276fcfwddizp1jm \
    --discovery-token-ca-cert-hash sha256:7eb84ab94d85234179c298c392dae2d681831358d960a5d43fc562220668a811

PLS NOTE :
------------------

The joining token generated is valid only for 24hours. In case the 24 hours exceed we need to generate the new token using the command "sudo kubeadm token create"



################### OUTPUT ########################


To start using your cluster, you need to run the following as a regular user:
# mkdir -p $HOME/.kube
# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# sudo chown $(id -u):$(id -g) $HOME/.kube/config


To list/See the nodes in your cluster
# kubectl get nodes    >>>>>>> This will list the nodes in your cluster, Now this will list only the MASTER Node


Now deploy the network for pod communications with flannel networking, You can select Calico networking also her I have used Flannel :
# sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml


Once the flannel network is deployed , we can verify the flannel interface for the  ip address assigned
# sudo  ip a show flannel.1


====================================
Now deploy the kubernetes dashoard :
====================================

I have used V2 Dashboard V1 having some bugs.

# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml   - V1 Dashboard

# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml    - New Dashboard

Then Run this :
# sudo kubectl proxy --address=0.0.0.0


Kubernetes dashboard URL in browser :
I have used V2 Url :

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/.   - Old Dashboard

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/.    -New Dashboard



To properly login to the kubernetes dashboard we need to creat a service account and assign the proper role :
# kubectl create serviceaccount dashboard -n default
# kubectl create clusterrolebinding dashboard-admin -n default --clusterrole=cluster-admin --serviceaccount=default:dashboard


Now generate the login key with this command :
# kubectl get secret $(kubectl get serviceaccount dashboard -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode

Then paste the tocken on the web link and click sign-in

#########################################
 MANSTER NODE CONFIG DONE
#########################################

Worker node System requirement -
4GBRAM, 1CPU, Ubuntu 18.04 VM/Physical node


On Slave/Worker node :

First install docker and Enable docker to auto start during reboot :
# sudo apt install docker.io
# docker --version
# sudo systemctl enable docker


Install curl and Download the gpg key for kubernetes installation and add to ubuntu :
#  sudo apt install curl
# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add


Now add the Google's kubernetes repository:
# sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"


Install kubeadm and disable the swap :
# sudo apt-get install kubeadm
# kubeadm version
# sudo swapoff -a

Set the Master node hostname :
# sudo hostnamectl set-hostname Worker-node1    - Set the hostname


Then run the below command as a ROOT user :

kubeadm join 192.168.1.36:6443 --token 120q6i.2276fcfwddizp1jm \
    --discovery-token-ca-cert-hash sha256:7eb84ab94d85234179c298c392dae2d681831358d960a5d43fc562220668a811

" The joining token generated is valid only for 24hours. In case the 24 hours exceed we need to generate the new token using the command :
# sudo kubeadm token create"


To list/See the nodes and the PODS in your cluster
#  sudo kubectl get nodes           >>>>> Now you can see the Worker node also
#  sudo kubectl get pods --all-namespaces



This is one node cluster So I have added only one node, you can add multiple node in your cluster


###########################
WORKER NODE CONFIG DONE
###########################

Now the deployment part

I am deploying nginx via Dashboard :


Open the Master node dashboard > Click the + logo > Create from form > Give a App name "Vipin Demo" > give container image name :nginx" >

Select service as External > Specify the source and traget ports > Then DEPLOY


############# ##################


Connecting to the Dashboard Remotely

If you need to access the Dashboard remotely, you can use SSH tunneling to do port forwarding from your localhost to the node running the kubectl proxy service. The easiest option is to use SSH tunneling to forward a port on your local system to the port configured for the kubectl proxy service on the node that you want to access. This method retains some security as the HTTP connection is encrypted by virtue of the SSH tunnel and authentication is handled by your SSH configuration. For example, on your local system run:

# ssh -L 8001:127.0.0.1:8001 192.168.1.36

Substitute 192.168.1.36 with the IP address of the host where the kubectl proxy service is running. When the SSH connection is established, you can open a browser on your localhost and navigate to:

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/.


You should see the Dashboard log in screen for the remote Kubernetes cluster. Use the same token information to authenticate as if you were connecting to the Dashboard locally.



#############  THANKS ###############


Sunday, August 28, 2016

Script to check the remote network port status with Nmap

Scan the remote network IP and port with Nmap :








Save this as a XYZ.sh and  Run from your terminal.

#!/bin/bash
## Created By Vipin Chereekandy ##
## chereekandy@gmail.com ##
echo "Please enter the DESTINATION IP: "
read dip
echo "Please enter the DESTINATION PORT: "
read port

sudo nmap -Pn $dip -p $port

## END ##

This script will prompt you to enter the DESTINATION IP and PORT, you can enter those details and see the output


*********************

Wednesday, January 6, 2016

Installing Git on CentOS 6, and Migrating/Converting SVN (Subversion) repositories to GIT


  • GIT Installation step by step -





Git is an open source, distributed version control system (VCS). It’s commonly used for source code 
management (SCM).

Step 1:- Installing git package
# yum update
# yum install git
# git --version

Step 2:- Configuration 
To prevent any commit errors, it’s a good idea to setup your user for git. We’ll setup the user vipin with the
e-mail address vipin@example.com.
# git config --global user.name "vipin"
# git config --global user.email "vipin@example.com"

Step 3:- Verifying the confogiration

To verify the configuration please run the below commands
# cd
# cat .gitconfig
# git config –list

Installation part is completed here. Now we can migrate all SVN repositories to git.
 






  • Migrating/Converting SVN (Subversion) repositories to GIT -

Before getting there, you need to have availablethe git-svn command. For most distributions, the package 
is also called git-svn. This is a tool that allows you to convert Subversion repositories to Git and also allows 
you to push changes back to the Subversion repository. This could be useful for someone who has to deal 
with a project's Subversion repository but prefers to use Git. For most distributions, the package name is 
called git-svn.

Step 1:- Installing git-svn package

# yum install git-svn

Step 2:- Creating authors.txt file
Now create an authors.txt file. This file will map the names of Subversion committers to Git authors, resulting
in a correct history of the imported Subversion repository.For projects with a small number of committers, this
is quite easy.For larger projects with a lot of committers, this may take some time. The syntax of the file 
would be: user = Xyz Abc <user@example.com>
# cd
# mkdir git
# cd git
# vi authors.txt
vipin = vipin chereekandy <vipin@example.com>
 
:wq!

Step 3:- Creating one more git directory 
Now create one more git directory, so that the migrated SVN repos will be available in this directory.

# cd /
# mkdir git

Step 3:- Clone the Subversion repository.
The final step is to clone the Subversion repository, which creates a local Git repository based on it.
# git svn clone --stdlayout --authors-file=authors.txt http://192.168.1.X/testrepo /git/testrepo
                                                               ***** Thanks *****



Thursday, April 9, 2015

Subversion 1.8 Installation in Centos-6.X Step By Step






How to install Basic SVN and Mod SVN (1.8) in Centsos-6.X with Viewvc integration

Steps to Create Basic SVN (1.8) :


Step 1 :

To install SVN 1.8 Firstly we need to configure yum repository in our system. Create a new repo file /etc/yum.repos.d/wandisco-svn.repo and add following content as per your operating system version.

# vi /etc/yum.repos.d/wandisco-svn.repo

  [WandiscoSVN]
  name=Wandisco SVN Repo
  baseurl=http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/$basearch/
  enabled=1
  gpgcheck=0


 :wq!

# yum clean all
# yum install subversion subversion-python

# svn --version


Step 2 :  Creating the Repo

# mkdir /svn
# svnadmin create /svn/testrepo


Step 3 : Create user (svn) and Giving ownership for the created Repo

# useradd svn -s /sbin/nologin
# chown -R svn /svn/testrepo/


Step 4 : Deleting/Renaming the default passwd file from Conf folder

# cd /svn/testrepo/conf
# mv  passwd passwd.old 

(from newly create repo , inside conf directory)


Step 5 : Now Create a soft link to the passwd file which present in location at /svn/testrepo/conf  with a command -

# vi /svn/passwd  (just create a blank file)
# ln -s /svn/passwd /svn/testrepo/conf/passwd


Step 6 : Edit the svnserve.conf and change like this

# vi  /svn/testrepo/conf/svnserve.conf

Anon_access=none
Auth_access=write
Password-db=passwd

:wq!


Step 7 : Now start the svnserve demon


# /usr/bin/svnserve -d -r /svn

Put this code in rc.local so that the svnserve demon will run after the system restart also.


Step 8 : Now create the initial directories

# svn mkdir file:///svn/testrepo/{trunk,tags,branches} -m "initial directories"


Step 9 : Create a username and password to checkout SVN repo

# vi /svn/passwd

 vipin = yourpassword

:wq!


Step 10 : Your Basic SVN server is ready, Now just checkout and see

# svn co svn://192.168.1.X/testrepo/ /mnt/






Steps to Create MOD SVN (1.8) :

Note : In this example I am setting up the mod svn in the same server itself. 
So please follow the above 9 steps.


The benefit of Mod_svn is you can access all repo data over browser with the login credentials provided by the administrator, it is easier to browse, without any client svn package, Mod SVN subversion is moderated and managed by apache , so password file and ownership by default goes to apache user or you have to change ownership for the repo to apache before to us.

Step 1: Install the Packages.

# yum install  –y mod_dav_svn httpd


Step 2: Now Edit /etc/httpd/conf.d/subversion.conf file like this.

# Make sure you uncomment the following if they are commented out
LoadModuledav_svn_module     modules/mod_dav_svn.so
LoadModuleauthz_svn_module   modules/mod_authz_svn.so

# Add the following to allow a basic authentication and point Apache to where the actual repository resides


# vi /etc/httpd/conf.d/subversion.conf


<Location /testrepo>
  DAV svn
  SVNPath /svn/testrepo
  AuthType Basic
  AuthName "SVN Repo"
  AuthUserFile /svn/mod-auth/svn.passwd
  Require valid-user
</Location>

:wq!


Step 3 : change ownership from root to apache

# chown -R apache.apache /svn/testrepo/


Step 4 : Create htpassword file from command

# mkdir /svn/mod-auth
# htpasswd -cm /svn/mod-auth/svn.passwd vipin

    Now enter the password

Note : If you want to add multiple user, please run the code like this :
# htpasswd -cm /svn/mod-auth/svn.passwd user1
# htpasswd -m /svn/mod-auth/svn.passwd user2


Step 5 : Restart the apache service.

# service httpd restart
# chkconfig httpd on


Your Mod SVN is ready. Now open the browser and type :

http://192.168.1.X/testrepo






Steps to Install & Configure ViewVC (1.1.10) :



Step 1: Download ViewVC stable release 1.1.10
You can download using wget command on CentOS server as below.

# cd /tmp
# wget http://viewvc.tigris.org/files/documents/3330/48879/viewvc-1.1.10.tar.gz

Step 2 : Extract and unzip the viewvc-1.1.10.tar.gz using below command.

# tar xvfz viewvc-1.1.10.tar.gz

Step 3 : Go to viewvc-1.1.10 directory and start the installation

# cd viewvc-1.1.10
# ./viewvc-install


Step 4 : Now Edit viewvc.conf file

# vi /usr/local/viewvc-1.1.10/viewvc.conf

(Uncomment line 151 and define the subversion root repositories )

root_parents = /svn : svn,


:wq!

Note : Here /svn is your repo path.

 
Step 5 : Edit the apache web server config file as below


# vi /etc/httpd/conf/httpd.conf

Add the below two lines under ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" Stanza

ScriptAlias /viewvc /usr/local/viewvc-1.1.10/bin/cgi/viewvc.cgi
ScriptAlias /query /usr/local/viewvc-1.1.10/bin/cgi/query.cgi

:wq!



Step 6 : Restart all the services

# service httpd restart
# chkconfig httpd on
# setenforce 0
# service iptables stop 



Now open the browser and type :   http://192.168.1.X/viewvc





***** Thanks *****





Tuesday, March 24, 2015

Creating The Repository - TortoiseSVN






Here the steps to create a Repository on an existing SVN Server :



Step 1 :  Creating the Repo

# svnadmin create testrepo


Step 2 : Giving ownership for the created Repo

# chown -R svn /svn/testrepo/


Step 3 : Deleting the default passwd file from Conf folder

# mv  -r passwd passwd.old 

(from newly create repo , inside conf directory)


Step 4 : Now Create a soft link to the passwd file which present in location at /svn/testrepo/conf  with a command -

# ln –s /svn/passwd /svn/testrepo/conf/passwd


Step 5 : Edit the svnserve.conf and change like this

# vi  /svn/testrepo/conf/svnserve.conf

Anon_access=none
Auth_access=write
Password-db=passwd

:wq!

# service xinetd restart


Step 6 : Now create the initial directories

# svn mkdir file:///svn/testrepo/{trunk,tags,branches} -m "initial directories"


Step 6 : Now just checkout and see

# svn co svn://testrepo.abc.com/testrepo/ /mnt/test


***** Thanks *****





Install GTK+ And Firefox On Amazon Linux X86-64






 To Install GTK+ and Firefox on Amazon Linux please follow the below steps :
 
Step 1 :

# yum update all

Step 2 :

Run the below script :



#!/bin/bash
# GTK+ and Firefox for Amazon Linux
# Written by Vipin Chereekandy


# chmod 755 ./gtk-firefox.sh
# sudo ./gtk-firefox.sh


TARGET=/usr/local

function init()
{
export installroot=$TARGET/src
export workpath=$TARGET

yum --assumeyes install make libjpeg-devel libpng-devel \
libtiff-devel gcc libffi-devel gettext-devel libmpc-devel \
libstdc++46-devel xauth gcc-c++ libtool libX11-devel \
libXext-devel libXinerama-devel libXi-devel libxml2-devel \
libXrender-devel libXrandr-devel libXt dbus-glib \
libXdamage libXcomposite
mkdir -p $workpath
mkdir -p $installroot
cd $installroot
PKG_CONFIG_PATH="$workpath/lib/pkgconfig"
PATH=$workpath/bin:$PATH
export PKG_CONFIG_PATH PATH

bash -c "
cat << EOF > /etc/ld.so.conf.d/firefox.conf
$workpath/lib
$workpath/firefox
EOF
ldconfig
"
}

function finish()
{
cd $workpath
wget -r --no-parent --reject "index.html*" -nH --cut-dirs=7 http://download.cdn.mozilla.net/pub/mozilla.org/firefox/releases/latest/linux-x86_64/en-US/
tar xvf firefox*
cd bin
ln -s ../firefox/firefox
ldconfig
}

function install()
{
wget $1
FILE=`basename $1`
if [ ${FILE: -3} == ".xz" ]
then tar xvfJ $FILE
else tar xvf $FILE
fi
SHORT=${FILE:0:4}*
cd $SHORT
./configure --prefix=$workpath
make
make install
ldconfig
cd ..
}

init
install ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz
install http://download.savannah.gnu.org/releases/freetype/freetype-2.4.9.tar.gz
install http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.9.0.tar.gz
install http://ftp.gnome.org/pub/gnome/sources/glib/2.32/glib-2.32.3.tar.xz
install http://cairographics.org/releases/pixman-0.26.0.tar.gz
install http://cairographics.org/releases/cairo-1.12.2.tar.xz
install http://ftp.gnome.org/pub/gnome/sources/pango/1.30/pango-1.30.0.tar.xz
install http://ftp.gnome.org/pub/gnome/sources/atk/2.4/atk-2.4.0.tar.xz
install http://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/2.26/gdk-pixbuf-2.26.1.tar.xz
install http://ftp.gnome.org/pub/gnome/sources/gtk+/2.24/gtk+-2.24.10.tar.xz
finish


# adds the /usr/local/bin to your path by updating your .bashrc file.
cat << EOF >> ~/.bashrc
PATH=/usr/local/bin:\$PATH
export PATH
EOF

***** Thanks *****



Wednesday, February 11, 2015

SSH X11-Forwarding Step By Step in Centos-6.x






How to do SSH X11-Forwarding :-


In order to run an application on one CentOS 6 system and have it display on another system there are a couple of prerequisites. Firstly, the system on which the application is to be displayed must be running an X server. If the system is a Mac OS X, UNIX or Linux based system with a desktop environment running then this is no problem. If the system is running Windows, however, then you must install an X server on it before you can display applications from a remote system. A number of commercial and free Windows based X servers are available for this purpose and a web search should provide you with a list of options.
Secondly, the system on which the application is being run (as opposed to the system which the application is to be displayed) must be configured to allow SSH access.

From Server :

Before you start  confirm the below packages are installed in your server. Run this command

Step :1

# rpm -qa xorg-x11-xauth openssh 

This will give a output like this :

xorg-x11-xauth-1.0.2-7.1.el6.x86_64
openssh-5.3p1-104.el6_6.1.x86_64


Step :2

Edit  /etc/ssh/ssh_config file and change ForwardX11 no to ForwardX11 yes

# Vi /etc/ssh/ssh_config

 ForwardX11 yes

:wq!

# service sshd restart
# setenforce 0
# service iptables stop







From Client :

The first step in remotely displaying an application is to move to the system where the application is to be displayed. At this system, ssh into the remote system so that you have a command prompt. This can be achieved using the ssh command. When using the ssh command we need to use the -X flag to tell ssh that we plan to tunnel X traffic through the connection:

# ssh -X user@hostname

In the above example user is the user name to use to log into the remote system and host-name is the host-name or IP address of the remote system. Enter your password at the login prompt. Once logged in, run the following command to see the DISPLAY setting:

# echo $DISPLAY

The command should output something similar to the following:

localhost:10.0

To display an application, simply run it from the command prompt. For example:

# gedit

When run, the above command should run the gedit tool on the remote system, but display the output on the local system.



***** Thanks *****

Wednesday, February 4, 2015

How to install VLC Player on CentOS-6.4






Solution To install VLC Player on CentOS 6.X


Open the terminal and follow the below steps :-

# cd /etc/yum.repos.d/

# wget http://pkgrepo.linuxtech.net/el6/release/linuxtech.repo

# yum install vlc



To Run VLC Player as "root" user in CentOS Please follow the below steps also :



1) Install "hexedit" utility in linux using yum. The command is,

# yum install hexedit


2) After successful installation, open "/usr/bin/vlc" using hexeditor as given below.

# hexedit /usr/bin/vlc


3) Now, Press "TAB" key

4) Now, Press "Ctrl + S" key to search ASCII string.

5) In the given search box, type "geteuid"

6) Then replace it with "getppid" by just typing "getppid"

6) Now, Press "Ctrl + X" to save the file.

Finally, your VLC player is ready to run as "root" user.


***** Thanks *****

How to install Skype-4.3.0.37 on CentOS-6.4







Step 1 :
To install Skype on Centos first enable EPEL repo. Steps to enable EPEL Repository on CentOS:


# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

# rpm -ivh epel-release-6-8.noarch.rpm

Step 2 :
Then install the dependency packages for skype 

Note : Is better to run a yum update before the dependency installation.


# yum install libXv*
# yum install libXv.so.1
# yum install libXss.so.1
# yum install qt 
# yum install libQtDBus.so.4
# yum install libQtWebKit.so.4


Step 3 :
Now download and extract Skype source

# cd /usr/src
# wget http://www.skype.com/go/getskype-linux-dynamic
# tar -xjvf skype-4.3.0.37.tar.bz2

# mv skype-4.3.0.37 skype
# cd skype
# ./skype






Step 4 :
After the installation Export the GTK path in ~/.bash_profile 

# vi ~/.bash_profile

export PATH
export GTK2_RC_FILES="/etc/gtk-2.0/gtkrc"

:wq!


 Step 5 :
 Then run
# source ~/.bash_profile 


Now you can open Skype from your terminal
# skype


***** Thanks *****

Tuesday, January 27, 2015

How to create a rsync auto backup script with email notification







Step 1 :- First enable a password less SSH to the remote server from you backup PC

Step 2 :- Then copy and paste the below code in to a text file and save as a .sh file


#!/bin/bash
PATH=/bin:/usr/bin:/sbin:/usr/sbin

#### Mail server Data Backup ####
#### Created by Vipin Chereekandy ####
#### chereekandy@gmail.com ####

## Below command will sync the data with the Backup server ###
rsync -avgr -e ssh --delete root@192.168.1.1:/home/data /secondary_bkp/mailserver/.

## Below command will send you an email notification ##
if [ $? != "0" ]
  then
   echo Mail server data Backup is failure|mail -s "Mail server Backup Failure" yourid@example.com
  else
   echo Mail server data Backup is successful|mail -s "Mail server Backup Successful" yourid@example.com
 fi

### End of the script ##


Note : Replace IP address, mail ID and directory path with your own Server base.


Step 3 :- Set a cronjob to run this script



**** Thanks ****





Friday, January 23, 2015

How to Check the Network Bandwidth between two network by using Iperf

Check your Network Bandwidth with Iperf






What is Iperf ?


Iperf is a tool to measure maximum TCP bandwidth, allowing the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss.

For this we needs 2 machine, Client(Sender) and Server(Receiver).

Here :-
Node 1 - 192.168.1.1 (Server)
Node 2 - 192.168.2.1 (Client)



From Node 1- (192.168.1.1) :-

Install iperf package
yum -y install iperf

Run the server service from Node 1 (192.168.1.1)
# iperf -s



From Node 2- (192.168.2.1) :-


Install iperf package
yum -y install iperf



Execute the below command from Node 2 (192.168.2.1), This will print the bandwidth.

# iperf -c 192.168.1.1 -fM -m -i5 -t25


Here the output :-

------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 0.02 MByte (default)
------------------------------------------------------------
[  3] local 192.168.2.1 port 41773 connected with 192.168.1.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 5.0 sec  3.25 MBytes  0.65 MBytes/sec
[  3]  5.0-10.0 sec  2.75 MBytes  0.55 MBytes/sec
[  3] 10.0-15.0 sec  3.00 MBytes  0.60 MBytes/sec
[  3] 15.0-20.0 sec  2.88 MBytes  0.57 MBytes/sec
[  3] 20.0-25.0 sec  3.00 MBytes  0.60 MBytes/sec
[  3]  0.0-25.3 sec  15.0 MBytes  0.59 MBytes/sec
[  3] MSS size 1376 bytes (MTU 1416 bytes, unknown interface)


For more detail execute this command :
# man iperf



Thank You
****



Wednesday, January 14, 2015

How to Remove NIC bonding in LINUX CentOS



Steps to Remove NIC bonding in LINUX CentOS



# ifconfig bond0 down

# echo "-eth0" > /sys/class/net/bond0/bonding/slaves
# echo "-eth1" > /sys/class/net/bond0/bonding/slaves
# echo "-bond0" > /sys/class/net/bonding_masters

# rmmod bonding

# service network restart



***********

Wednesday, December 24, 2014

Yum local Server configuraion in Redhat linux

How to configure a YUM local server :

Step 1 : Copy the Server folder from redhat CD to the system

# mount /dev/cdrom /mnt
# mkdir /backup
# cp -ruv /mnt/Server /backup/.


Step 2 : Install the vsftpd package from CD

# cd /backup/Server
# rpm -ivh vsftpd*
# service vsftpd restart

Step 3 : Move all the RPM packages from /backup To /var/ftp/pub fro accessing the rpm's via FTP

# mv /backup/Server


Friday, December 19, 2014

How to Install Roundcube Webmail on Linux/CentOs







Server Requirements:-

    * Apache webserver
    * PHP Version 5.2.1 or greater
    * MySQL, PostgreSQL, SQLite or MSSQL database
    * An IMAP server which supports IMAP4 rev1
    * An SMTP server (recommended) or PHP configured for mail delivery

    * OS - CentOs


Installation Procedure:

     Download the latest stable version of RoundCube web mail from http://www.roundcube.net and copy it to your web server.

Link : http://liquidtelecom.dl.sourceforge.net/project/roundcubemail/roundcubemail/0.8.5/


1) Roundcube Webmail installation:

Login to your Apache server host through shell (putty)
Un tar roundcubemail-0.3.1.tar.gz in the web root directory


# tar -xvzf roundcubemail-0.3.1.tar.gz -C /var/www/html/
# cd /var/www/html
# mv roundcubemail-0.3.1/ roundcubemail
# cd roundcubemail/


RoundCube needs to save some temp files and it also writes logs. Therefore make sure that the following directories (temp,logs) are writable by the web server user


#chown -R apache.apache logs temp



Configuration:

2) Mysql configuration:

Login to your mysql server through shell (or webmin) and Create a database for your webmail (You can use the same server for both Apache and MySQL)

Example: db name - roundcubedb, username - roundcubeuser , password - roundcubepwd (your choice)


#mysql -u root -p ( enter the mysql root password)
mysql> create database 
roundcubedb;
mysql> grant all privileges on 
roundcubedb.* to roundcubeuser@localhost identified by 'roundcubepwd';
mysql> FLUSH PRIVILEGES;
mysql> exit


Above commands will create a database roundcubedb with the required permissions.
If you are ruining Apache and mysql in different servers, you have to grand privilege for roundcubeuser@apacheserverip.
Now import the table layout


#mysql roundcubedb < SQL/mysql.initial.sql  -u root -p
(enter the root password or mysql server)
Create the config file from samples


#cd config/
#cp db.inc.php.dist db.inc.php
#cp main.inc.php.dist main.inc.php



Edit Database Configuration File:

Edit the db.inc.php file and replace the below lines with your database access details

#vim db.inc.php
$rcmail_config['db_dsnw'] = 'mysql://roundcubeuser:roundcubepwd@localhost/roundcubedb';



3) Apache Server Configuration:

DNS Configuration:
Add dns entry for your support website ( webmail.example.com to 192.168.1.X (replace with your ip) )
If you don't have dns server already running, you can use the ip directly

Edit Apache Config:


edit /etc/httpd/conf/httpd.conf and add the following configurations
< VirtualHost 192.168.1.3:* >
DocumentRoot /var/www/html/roundcubemail
ServerName webmail.example.com
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
    < Directory "/var/www/html/roundcubemail"  >
        DirectoryIndex index.php
    < /Directory >
Options ExecCGI
< /VirtualHost >


If you don't have DNS server you can skip the above step

and add alias for this mail directory

#vim /etc/httpd/conf/httpd.conf


Alias /webmail "/var/www/html/roundcubemail"

Restart apache server


Other wise add the roundcubemail document path here : 
#vim /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html/roundcubemail"
:wq!

#service httpd restart


4) Installer config:

Edit main.inc.php file and enable the installer and check all the required modules are present, php config, etc

# vim main.inc.php
$rcmail_config['enable_installer'] = true;


Now you can Point your browser to http://url-to-roundcube/installer/ (http://192.168.1.X/webmail/installer).





After checking this installer script you can disable  the installer 

#vim main.inc.php
$rcmail_config['enable_installer'] = false;


Now you can start using your webmail through browse 
your webmail url http://webmail.example.com  or ip (from remote computer)
If no dns server configured , use alias http://192.168.1.X/webmail ( from local host http://localhost/webmail)


Here you can enter your username, password, mail server details and start browsing your mails 


You can start using the webmail with the above configuration itself. Below I have mentioned optional configurations. 

A) Customizing the Configuration


IMAP server configuration:
By default the login screen provides a text box where you need to enter the IMAP host which you want to connect to. If you dont want your users to enter the mailserver details, you can hide this by setting one fixed IMAP host address
#vim main.inc.php
$rcmail_config['default_host'] = 'yourmailserverip';
$rcmail_config['smtp_server'] = 'yourmailserverip';

If you want to add multiple servers
$rcmail_config['default_host'] = array(
  'mail.example.com' => 'Default Server',
  'webmail.example.com' => 'Webmail Server',
  'ssl://mail.example.com:993' => 'Secure Webmail Server'


Deleted messages:

Some mail clients just mark messages as deleted and finally remove them when leaving the application. RoundCube by default move messages to the Trash folder when hitting the delete button. However this behavior can be changed by unsetting the 'trash_mbox' property and enabling 'flag_for_deletion'. Your configuration could look like this:
$rcmail_config['trash_mbox'] = '';
$rcmail_config['flag_for_deletion'] = true;
$rcmail_config['skip_deleted'] = false;

Messages will now be marked as deleted which can be reverted again. To finally remove them, the user needs to click "Compact" below the folder list. 


B) Other Configurations:

PostgreSQL:
To use RoundCube with PostgreSQL support you have to follow these
simple steps, which have to be done as the postgres system user (or
which ever is the database superuser):
$ createuser roundcube
$ createdb -O roundcube -E UNICODE roundcubemail
$ psql roundcubemail
roundcubemail =# ALTER USER roundcube WITH PASSWORD 'the_new_password';
roundcubemail =# \c - roundcube
roundcubemail => \i SQL/postgres.initial.sql

All this has been tested with PostgreSQL 8.x and 7.4.x. Older
versions don't have a -O option for the createdb, so if you are
using that version you'll have to change ownership of the DB later. - See more at: http://linuxadmin.melberi.com/2010/07/roundcube-webmail-installation.html#sthash.OSwI7aYe.dpuf


*******************

Thursday, December 18, 2014

How do I edit a log message that I already committed in Subversion


Edit a log message that I already committed in Subversion on Linux :

You can use svn proedit command to edit the logs, But sometimes it will give an error like this : 
"svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found"
So the solution is Set SVN_EDITOR Environment Variable To Vim.
Here the command to export the path :
# export SVN_EDITOR=vim
To permanently set this environment variable put the below line in your ~/.bash_profile file.
# export SVN_EDITOR=vim
Now you can edit the SVN log :
# svn propedit -r N --revprop svn:log URL
                         OR
# svn propset -r N --revprop svn:log "new log message" URL
Here N will be the Rev no
URL is your SVN path
When you run this propedit command, and just in case you see this message
"DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existen"
Its because Subversion doesn't allow you to modify log messages because they are unversioned and will be lost permanently.
Go to the hooks directory on your Subversion server (replace ~/svn/reponame with the directory of your repository)
# cd ~/svn/reponame/hooks
Remove the extension
# mv pre-revprop-change.tmpl pre-revprop-change
Make it executable (cannot do chmod +x!)
#chmod 755 pre-revprop-change

Now edit, it will work..!
**************