Friday, October 26, 2012

kill a process id (pid)


How to kill a process in linux

when you open a file or it it is not opening or any trouble with its process then you can simple kill the process in linux
to see the current running process in linux
#ps -aux
it will show the process like this

to kill the process simple kill the pid ( process id)
#kill pid
means if would like to kill a process runing on 2049 means do like this
#kill  -9 2049
here it will kills the 2049 pid

Friday, October 12, 2012

How to copy files and folders remotely in ubuntu


How to copy files and folders remotely in ubuntu

To copy the files and folders in ubuntu or in redhat first of all intsall the ssh packages for remote terminal login

for ubuntu
#apt-get -y install openssh-server openssh-client

for redhat
#yum install openssh-server openssh-client

if you want to get the files or folder in ubuntu and redhat
#scp -r root@remoteip:/remotepath /localpath
here it will get the copy from other remote system

if you would like to send the local copy to other means
#scp -r /localpath root@remoteip:/remotepath
here it will send the copy of local file to the remote system   

Wednesday, October 10, 2012

High Availability of linux servers using HEARTBEAT package in ubuntu


High Availability of linux servers using HEARTBEAT package in ubuntu

heartbeat package is used for high availability for the linux servers, here by configure it the load can be balanced and if any server goes down the other will take up easily by configuring. Here we will show to configure heartbeat package in ubuntu.
To install heartbeat pacakage and also pacemaker
#apt-get -y install heartbeat pacemaker

here server1 ip address 192.168.1.111 and hostname is sunny (server name or node)
another server2 ip address 192.168.1.222 and hostname is venky(server name or node)

first of all we will install nginx in ubuntu in server1 and server2
root@sunny:~# apt-get install nginx
root@venky:~# apt-get install nginx

after this we will create a dummy website and configure it, remove this default files in both the servers
root@sunny:~#rm -rf /etc/nginx/sites-available/defautls
root@sunny:~#rm -rf /etc/nginx/sites-enable/defaults
root@sunny:~#vim /etc/nginx/sites-available/basic
server {
listen 192.168.1.111:80;
server_name sunny.example.com;
access_log /var/log/nginx/basic.access.log;
error_log /var/log/nginx/basic.error.log;
location / {
root /var/www/basic;
index index.html index.htm;
}
}

then save
after this create a directory
root@sunny:~#mkdir /var/www/basic
root@sunny:~#vim /etc/www/basic/index.html
sunnys site server1

then save
then create a simulink
root@sunny:~#cd /etc/nginx/sites-enable/
root@sunny:~#ln -s ../sites-available/basic

Then restart the service
root@sunny:~#/etc/init.d/nginx restart

then here we do same in the server2 but little changes

root@venky:~#vim /etc/nginx/sites-available/basic
server {
listen 192.168.1.222:80;
server_name sunny.example.com;
access_log /var/log/nginx/basic.access.log;
error_log /var/log/nginx/basic.error.log;
location / {
root /var/www/basic;
index index.html index.htm;
}
}

then save
after this create a directory
root@venky:~#mkdir /var/www/basic
root@venky:~#vim /etc/www/basic/index.html
sunnys site this is your site two server2

then save
then create a simulink
root@venky:~#cd /etc/nginx/sites-enable/
root@venky:~#ln -s ../sites-available/basic

Then restart the service
root@venky:~#/etc/init.d/nginx restart

from here we will configure heart beat
root@sunny~# vim /etc/ha.d/ha.cf
autojoin none
bcast eth0
warntime 3
deadtime 6
initdead 60
keepalive 1
node sunny
node venky
crm respawn

then save
here we copy the same in server2
root@sunny~# scp /etc/ha.d/ha.cf venky:/etc/ha.d
root@sunny~# ( echo -ne "auth 1\n1 sha1 "; \
dd if=/dev/urandom bs=512 count=1 | openssl md5 ) \
> /etc/ha.d/authkeys
root@sunny:~# chmod 0600 /etc/ha.d/authkeys
root@sunny:~# scp /etc/ha.d/authkeys venky:/etc/ha.d
root@sunny:~# ssh chmod 0600 venky:/etc/ha.d/authkeys

here we will restart the service in both the servers
root@sunny:~# /etc/init.d/heartbeat restart
root@sunny:~# ssh venky /etc/init.d/heartbeat restart
here both the cluster must me up and known by each other to see this we use crm tool
root@sunny:~# crm_mon -1 | grep Online
root@sunny:~# crm configure
crm(live)configure# primitive site_one_ip IPaddr params ip=192.168.1.111 cidr_netmask="255.255.255.0" nic="eth0"
crm(live)configure# primitive site_two_ip IPaddr params ip=192.168.1.222 cidr_netmask="255.255.255.0" nic="eth0"
crm(live)configure# commit
crm(live)configure# exit

root@sunny:~# crm configure show
node $id="1876vbiu-g98iuhgiu09-7hb0-9775" sunny.example.com
node $id="iho1ih24-4g2jjiofnufcv0-fe98sdkf7-1as sunny.example.com
primitive site_one_ip ocf:heartbeat:IPaddr \
params ip="192.168.1.111" cidr_netmask="255.255.255.0" nic="eth0"
primitive site_two_ip ocf:heartbeat:IPaddr \
params ip="192.168.1.222" cidr_netmask="255.255.255.0" nic="eth0"
root@sunny:~# crm configure
crm(live)configure# location site_one_ip_pref site_one_ip 100: sunny.example.com
crm(live)configure# location site_two_ip_pref site_two_ip 100: sunny.example.com
crm(live)configure# commit
crm(live)configure# exit

root@sunny:~# crm configure
crm(live)configure# monitor site_one_ip 40s:20s
crm(live)configure# monitor site_two_ip 40s:20s
crm(live)configure# commit
crm(live)configure# exit

after to check check from the other system like this in local
local system is some xyz with 192.168.1.49
in this edit the /etc/hosts file
root@xyz:#vim /etc/hosts
192.168.1.111 sunny.example.com sunny
192.168.1.222 sunny.example.com venky
then save

then serach for the website with sunny.example.com
it will show “sunnys server1”
then disconnect the net from server1
then serach for sunny.example.com here the page will be redirected to the second server
it will display “sunny this is your server2”

Thursday, October 4, 2012

dns configuration in ubuntu


DNS (Domain naming system);
In the world of internet a human cant memorize each and every ip address of the websites, so the ip address of the site is resloved by the name so that the humans can memorize easily. For this purpose the dns is used it will resolve the website with ipaddress and viceversa. How to configure dns in ubuntu is shown below
my dns server ipaddress is 192.168.1.35 with the hostname ubuntu111
other system connected in lan are 192.168.1.34 with hostname ubuntu100
and other with ipaddress 192.168.1.28 with hostname venky
here I will reslove a fully qualified domain I.e; ubuntu111.team.com
for this we have to give the static ip for the server

#vim /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.35
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1
broadcast 192.168.1.255
:wq!

Here also set hostname
#vim /etc/hostname
ubuntu111
:wq!

And also set hosts file
#vim /etc/hosts
192.168.1.35 ubuntu111.team.com ubuntu111
:wq!


then go to dns of your system
#vim /etc/reslov.conf
search team.com.
nameserver 192.168.1.35  #(it is the dns server ip address in which you are creating)#

Then install bind package
#apt-get install bind9 dnsutils

here we will edit two files /etc/bind/named.conf.options & /etc/bind/named.conf.local

#vim /etc/bind/named.conf.options

forwaders {
192.168.1.1; #(this is gateway of your router)
123.176.37.37; (this is the default of your dns server provided by internet seen in reslov.conf)
123.176.37.35;
8.8.8.8;
8.8.4.4;
};

save and quit

#vim /etc/bind/named.conf.local
zone "team.com"
{
type master;
file "/etc/bind/zones/team.com.db";
};
zone "1.168.192.in-addr.arpa"
{
type master;
file "/etc/bind/zones/rev.1.168.192.in-addr.arpa";
};

save and quit

here we will create a directory named zone in bind
#mkdir /etc/bind/zones
#vim /etc/bind/zones/team.com.db

#vim /etc/bind/zones/ rev.1.168.192.in-addr.arpa

then we will restart the bind service
#/etc/init.d/bind9 restart

to check the dns is working or not type
#dig ubuntu111.team.com

#nslookup ubuntu111.team.com
#nslookup ubuntu100.team.com
#nslookup venky.team.com
here he have created the dns server successfully

Thursday, September 20, 2012

REMOTE HOST IDENTIFICATION HAS CHANGED!


@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


do worry it can be fixed very simple just try out this command

#ssh-keygen -R (the remote ipaddress)
here it will now able to login to the remote using ssh

Saturday, September 15, 2012

How to create bootonly file for redhat 5,6


How to create bootonly file for redhat 5,6


here we will create a iso image file which has the only content from where to take the operating system through the network
How to create a boot only file in redhat, here shown below for rhel5, rhel6
first of all copy the isolinux folder from rhel6 dvd
keep the rhel6 dvd into the cd tray
then after

#cd /media/rhel6
#ls
here you can see all the dvd content, here you copy the isolinux folder at some of the location

#cp -rf /media/rhel6/isolinux /home/xyz/Desktop/
here it will copy the isolinux folder on to the desktop

#cd /home/xyz/Desktop
#chmod u+x isolinux/*
here it will give the execution permission for the isolinux folder

#mkisofs -o file.iso -b isolinux.bin -c boot.cat -no-emul-boot \-boot-load-size 4 -boot-info-table -R -J -v -T isolinux/

after this a file with name file.iso is created on the desktop
here the iso which is created is used like as a boot file, it will have the information of booting until from where to take the os
same procedure for the Rhel5
and copy this image into a cd to make as a bootonly cd

Network installation of redhat using nfs, ftp, http


Network installation of redhat using nfs, ftp, http

To create a network installation of redhat, you have to setup the ftp, nfs , http servers if want to setup click here
to setup network installation we should have to get the boot only image for this if you like to setup bootonly iso image clickhere
keep the boot only cd in the tray and make it boot
then it will be seen like this.











then give as follows 









to get the dump from the ftp server which has files in /var/ftp/pub










for http server give as below



for the nfs server give the url as 192.168.1.15
and path as /var/ftp/pub




















after this you will be able to install the linux in the system by using ftp nfs and http.