Monday 24 December 2012

Configuration of LINUX Gateway Machine


Check two network devices attach properly or not.

Follow the steps to configure the Linux machine(CentOS, Fedora) gateway.


i )  Check the Device eth0, eth1 are available on the machine by running command.

   [root@Xhost ]# ifconfig 

It will display eth0 and eth1 two network card details (ip, mac and etc).



ii)  Configure eth0 as the Public Network ip address. (/etc/sysconfig/networking-scripts/ifconfig-eth0)


# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
IPADDR=xx.xx.xx.xx  # IP ADDRESS of Public Network
NETMASK=255.255.255.0 # Provided by the ISP
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
GATEWAY=xx.xx.xx.1 # Provided by the ISP





iii)  Configure  eth1 as the Private Network ip address (/etc/sysconfig/networking-scripts/ifconfig-eth1)


# cat ifcfg-eth1

BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth1
NETMASK=255.255.0.0 # Specify based on your requirement
IPADDR=192.168.0.1 # Gateway of the LAN
NETWORK=192.168.0.0 # Optional
USERCTL=no
IPV6INIT=no
PEERDNS=yes
ONBOOT=yes




iv) Check each eth0 and eth1 separte like.


 [root@Xhost ]# service network restart
:
:
 [root@Xhost ]# ifconfig eth1 down
 [root@Xhost ]# ping  xx.xx.xx.xx  # Ping any public ip
:
:
if it works fine. other wise check the configuration of eth1

simmillarly for eth1


 [root@Xhost ]# service network restart
:
:
 [root@Xhost ]# ifconfig eth0 down
 [root@Xhost ]# ping  192.168.0.xx  # Ping any private ip
:
:


if both working means continue this fifth step




V)  Host Configuration (Optional)

# cat /etc/hosts
127.0.0.1 nat localhost.localdomain localhost




vi)  Gateway Configuration

# cat /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=nat
GATEWAY=xx.xx.xx.1 # Internet Gateway, provided by the ISP




Vii)  DNS Configuration

# cat /etc/resolv.conf

nameserver xx.xx.xx.xx # Primary DNS Server provided by ISP
nameserver xx.xx.xx.xx # Secondary DNS Server provided by ISP



viii) NAT with iptables:

[root@Xhost ]# iptables -F  # Flush iptables 
[root@Xhost ]# iptables -t nat -F # Flush nat table
[root@Xhost ]# iptables -t mangle -F # Flush mangle table

setup forwarding rule in the iptables

[root@Xhost ]# iptables -t nat -A PREROUTING -o eth0 -j MASQUERADE
[root@Xhost ]# iptables -A FORWARDING -i eth1 -j ACCEPT


iX) Enabling the Kernel ip forwarding

Check kernel ip forwading enable or not

[root@Xhost ]# sysctl -a | grep  net.ipv4.ip_forward
net.ipv4.ip_forward = 0

if 0 is there set it to 1 by

[root@Xhost ]# echo 1 > /proc/sys/net/ipv4/ip_forward

and edit to make the change permanent

[root@Xhost ]#vi /etc/sysctl.conf

net.ipv4.ip_forward=1 # modify this 0 to 1



X) Apply configurations

[root@Xhost ]# service iptables save
[root@Xhost ]# service iptables restart
[root@Xhost ]#  chkconfig --list iptables  # on 3,5 runlevel






Finally Gateway is setuped ..

Now we need to test this gateway from any client system(private network).
login into client system.

ping 192.168.0.1;
ping  xx.xx.xx.xx # Any public IP

Read More

Friday 21 December 2012

Guide to Install VServer in Fedora and Install MYPLC in VServer

This Guide will explain how to install Vserver in Fedora and then How to Install MyPLC in Vserver

Step 1 : Install Fedora 12 without GUI (do not Install Any X11 packages Because in GUI mode vserver not Installing Properly)

Option 1 :
Download Fedora Net Install ISO and Install while Installing Choose Minimal as Installation Option  Because It is Not Going to Install Any GUI Component.
Download Link for Fedora 12 Net Install ISO 

Option 2:
Download Fedora 12 DVD and while Installing Choose Minimal as Installation Option Because It is Not Going to Install Any GUI Component, And Coustamize packages and remove all GUI packages and Multimedia Packages and all Applications which contain GUI.
Download Link for Fedora 12 DVD

Goto Step 2 If you Installed Fedora With Out GUI

Step 2:
Stop SELINUX
Check this http://linux-problem-solver.blogspot.in/2012/09/disabling-selinux-in-fedora.html 

Step 3:
Stop IPTable ( Firewall )
Check this http://linux-problem-solver.blogspot.in/2012/09/disable-or-turnoff-iptables-firewall-in.html 

Step 4:
If you did not restart system after step2, step3 then restart your System now.

Step 5:
Add Vserver repo
[root@xyz~]# cd /etc/yum.repos.d/
[root@xyz yum.repos.d]# vim vserver.repo

#Add Only One based on 32 bit or 64 bit

#for 32 bit Fedora
#Add Following Lines to vserever.repo 
[vserver]
name=Linux-VServer related packages for Fedora $releasever - $basearch
baseurl=http://build.onelab.eu/vserver/f12/i686
gpgcheck=0
#gpgkey=http://build.onelab.eu/conf/keys/RPM-ONELAB-GPG-KEY




#for 64 bit Fedora
#Add Following Lines to vserever.repo 
[vserver]
name=Linux-VServer related packages for Fedora $releasever - $basearch
baseurl=http://build.onelab.eu/vserver/f12/x86_64/
gpgcheck=0
#gpgkey=http://build.onelab.eu/conf/keys/RPM-ONELAB-GPG-KEY

Step 6:
Add this Line : exclude=kernel* util-vserver* yum in fedora.repo the location is before 
[fedora-debuginfo] line Like below
[root@xyz~]# cd /etc/yum.repos.d/
[root@xyz yum.repos.d]# vim fedora.repo
[fedora]
...
...
...
exclude=kernel* util-vserver* yum

[fedora-debuginfo]
...
...

Step 7:
Add this Line : exclude=kernel* util-vserver* yum in fedora-update.repo the location is before 
[fedora-debuginfo] line Like below
[root@xyz~]# cd /etc/yum.repos.d/
[root@xyz yum.repos.d]# vim fedora.repo
[fedora]
...
...
...
exclude=kernel* util-vserver* yum

[fedora-debuginfo]
...
...

Step 8:
yum install kernel 
It will Install Kernel like kernel-2.6.32.11-162.vs2.3.0.36.29.4.fc12.i686 [this kernel will support Vserver with out any Problem)

step 9:
Open Grub file and set timeout to 10 seconds or any value And Default to 0 because it 
will select latest installed kernal as default kernel
[root@xyz~]# vi /etc/grub.conf
.....
.....
default=0
timeout=10
....
....

Restart So System will boot into Newly Installed Kernel
Check which kernel is selected by typing uname -a in terminal
[root@xyz~]# uname -a
Linux center.cmmacs.ernet.in 2.6.32.11-162.vs2.3.0.36.29.4.fc12.i686 #1 SMP Thu Dec 2 19:34:22 CET 2010 i686 i686 i386 GNU/Linux

Step 10:
Install kernel-firmware version which is related to our installed kernel
For 32 bit
[root@xyz~]# rpm -U --force http://build.onelab.eu/vserver/f12/i686/kernel-firmware-2.6.32.11-162.vs2.3.0.36.29.4.fc12.i686.rpm
for 64 bit
[root@xyz~]# rpm -U --force http://build.onelab.eu/vserver/f12/x86_64/kernel-firmware-2.6.32.11-162.vs2.3.0.36.29.4.fc12.x86_64.rpm

Step 11:
Install yum which support chroot
[root@xyz~]# rpm -qa | grep yum
yum-utils-1.1.26-1.fc12.noarch
yum-3.2.28-5.fc12.noarch
yum-metadata-parser-1.1.2-14.fc12.i686
#Remove yum
[root@xyz~]# rpm -e --nodeps yum-3.2.28-5.fc12.noarch
Success, Now

For 32 bit
[root@xyz~]# rpm -ivh http://build.onelab.eu/vserver/f12/i686/yum-3.2.25-2chroot.noarch.rpm
For 64 bit
[root@xyz~]# rpm -ivh http://build.onelab.eu/vserver/f12/x86_64/yum-3.2.25-2chroot.noarch.rpm

Step 11:
Install Necessary Packages
[root@xyz~]# yum install util-vserver util-vserver-build
[root@xyz~]# yum install subversion
[root@xyz~]# yum install httpd
[root@xyz~]# yum install createrepo
[root@xyz~]# yum install qemu
[root@xyz~]# yum install bridge-utils
[root@xyz~]# yum install emacs
[root@xyz~]# yum install ntp

Step 12:
Download Necessary Files to Setup Vserver Properly
[root@xyz~]# cd
[root@xyz~]# svn co http://svn.planet-lab.org/svn/build/trunk svn-build
If SVN showning unknown host error set proxy for SVN like below
[root@xyz~]# vi /etc/subversion/servers
Edit the file Like below
[Global]
http-proxy-host=my.proxy.com
http-proxy-port=3128

Step 13:
Copy Distribution files to /etc/vservers/.distributions
[root@xyz~]#  cd 
[root@xyz~]# cd svn-build
[root@xyz  svn-build]#  cd mirroring
[root@xyz  mirroring]# cp -r * /etc/vservers/.distributions

Step 14:
Initializing Vserver Distributions 
[root@xyz  mirroring]# sh mirror.sh -a
[root@xyz  mirroring]# sh mirror.sh init

Step 15: Verifying the setup
Going to install Fedora 12 in Vserver
Go to /etc/vservers/.distributions
[root@xyz~]# cd /etc/vservers/.distributions
[root@xyz .distributions]# ls
centos5  f10  f12  f13  f7  f8  fc1  fc2  fc3  fc4  fc5  fc6  rh9  suse91
[root@xyz .distributions]# cd f12
[root@xyz f12]# cd yum.repos.d/
[root@xyz yum.repos.d]# ls
building.repo  building.repo.in
IF building.repo not there then
[root@xyz yum.repos.d]# cp building.repo.in building.repo

Step 16: Adding MYPLC repository to Vserver repository
Going to install MyPLC in Vserver of Fedora 12
[root@xyz~]# cd /etc/vservers/.distributions/f12/yum.repos.d
#Note to create vserver Successfully we need to change gpgcheck=1 to gpgcheck=0 in .repo file
[root@xyz yum.repos.d]# vim building.repo
[fedora]
name=Fedora 12 - $basearch
baseurl=http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/releases/12/Everything/$basearch/os/
enabled=1
metadata_expire=7d
gpgcheck=0
gpgkey=http://mirror.onelab.eu/keys/RPM-GPG-KEY-fedora-12-primary

[updates]
name=Fedora 12 - $basearch - Updates
baseurl=http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/updates/12/$basearch/
enabled=1
metadata_expire=7d
gpgcheck=0
gpgkey=http://mirror.onelab.eu/keys/RPM-GPG-KEY-fedora-12-primary

Add MYPLC Repository location in building.repo file

[root@xyz yum.repos.d]# vim building.repo
[fedora]
...
...
...
#For 32 bit
[myplc]
name= MyPLC
baseurl=http://build.onelab.eu/5.0/rc32/onelab--5.0-rc32-f12-32/RPMS/
enabled=1
gpgcheck=0

#For 64 bit
[myplc]
name= MyPLC
baseurl=http://build.onelab.eu/5.0/rc32/onelab--5.0-rc32-f12-64/RPMS/  
enabled=1
gpgcheck=0
         
Step 17:
Some times while creating Vserver we get error /proc/uptime can not be accessed
to Avoid this before creating Vserver Start vprocunhide script
[root@xyz~]# cd /etc/init.d/
[root@xyz init.d]# ./vprocunhide start

Step 18:
Create Vserver
[root@xyz svn-build]# cd ~/svn-build

For 32 bit System

[root@xyz svn-build]# ./vtest-init-vserver.sh -f f12 -d onelab -p linux32 vtest32 http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/releases/12/Everything/i386/os/Packages/ -- --interface eth0:138.96.255.221 --hostname vnode01.inria.fr &> vtest32.log&


For 64 bit System

[root@xyz svn-build]# ./vtest-init-vserver.sh -f f12 -d onelab -p linux64 vtest64 http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/releases/12/Everything/x86_64/os/Packages/ -- --interface eth0:138.96.255.221 --hostname vnode01.inria.fr &> vtest64.log&

Check RPM packages location connecting or not other wise change location, currently 
http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/releases/12/Everything/i386/os/Packages/ link is working properly

Step 19:
Start Vserver and Install MYPLC
[root@xyz~]# vserver vtest32 start
[root@xyz~]# vserver vtest32 enter
[vtest32 ] /# yum install plc
Install myplc
[vtest32 ] /# yum install myplc
make myplc start at system startup 
[vtest32 ] /# chkconfig plc on
Start MYPLC if you done all steps correctly then you will see text like below
[vtest32 ] /# service plc start
PLC: Generating network files:                             [  OK  ]
PLC: Generating SSL certificates for: PLC: WWW: PLC: API: P[  OK  ]:
PLC: Generating GPG keys:                                  [  OK  ]
PLC: Generating SSH keys:                                  [  OK  ]
PLC: Starting web server: PLC: Setting PHP timezone to GMT:[  OK  ]
PLC: Starting PostgreSQL server:                           [  OK  ]
PLC: Configuring the API:                                  [  OK  ]
PLC: Bootstrapping the database: PLC:  - 101-up-leases.sql (dbdumped): PLC:  - 102-up-isvalid.sql (dbdumped): PLC:  - 103-up-extensions.sql (dbdumped): PLC:  - 104-up-noderole.sql (dbdumped): PLC:  - 105-up-timespent.sq[  OK  ]ped):
PLC: Starting DNS server: PLC: Configuring resolv.conf:    [  OK  ]
PLC: Creating BootCD variants:                             [  OK  ]
PLC: Rebuilding Boot CD:                                   [  OK  ]
                                                           [  OK  ]
PLC: Signing and indexing node packages:                   [  OK  ]


MyPLC Installation Completed



























Read More

Tuesday 18 December 2012

Uninstall or Remove Any Application or Package in Fedora


Hi I already installed yum-3.2.28-5.fc12.noarch package now i want to remove that package and
Install lower version yum-3.2.25-2chroot.noarch


[root@server1]#rpm -Uvh yum-3.2.25-2chroot.noarch.rpm 
Preparing...                ########################################### [100%]
package yum-3.2.28-5.fc12.noarch (which is newer than yum-3.2.25-2chroot.noarch) is already installed


1 st time Fail
[root@server1]#yum remove yum

Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package yum.noarch 0:3.2.28-5.fc12 set to be erased
--> Processing Dependency: yum >= 3.2.24 for package: yum-utils-1.1.26-1.fc12.noarch
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.26-1.fc12 set to be erased
--> Finished Dependency Resolution
Error: Trying to remove "yum", which is protected
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

2 nd time Success
[root@server1]#rpm -qa | grep yum

yum-utils-1.1.26-1.fc12.noarch
yum-3.2.28-5.fc12.noarch
yum-metadata-parser-1.1.2-14.fc12.i686
Note the package need to remove

[root@server1]#rpm -e yum-3.2.28-5.fc12.noarch
error: Failed dependencies:
yum >= 3.2.24 is needed by (installed) yum-utils-1.1.26-1.fc12.noarch

For me no need to remove dependence packages So

[root@server1]#rpm -e --nodeps yum-3.2.28-5.fc12.noarch
Success, Now
[root@server1]#rpm -ivh yum-3.2.25-2chroot.noarch.rpm Preparing...                ########################################### [100%]
   1:yum                    ########################################### [100%]



Read More

Thursday 13 December 2012

Find Size of table and Size of Index in MySQL Command Prompt

To find Size of table in MySQL command prompt use below command

mysql > SELECT table_name AS "Table", round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "database_name" AND table_name = "table_name";


To find Size of  Index of a table in MySQL command prompt use below command

mysql > SELECT table_name AS "Table", round(((index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "database_name" AND table_name = "table_name";
Read More

Thursday 6 December 2012

Add new Line while Appending two files in Linux

If two files containing following content
file1:
1
2
file2:
3
4

After append : cat file2>>file1 
output in file1:
1
23
4

to Add new Line while Appending two files
Command : sed -i -e '$a\' file2 | cat file2 >> file1

From Above
sed -i -e '$a\' file2
This adds \n at the end of the file only if it doesn't already end in a newline. So if you run it twice it will not add another newline.

Read More
Here We Write The Problems we face at different situations and Solutions to those problems.