Saturday, October 22, 2011

Linux JDK Installation

Installation:
Once the file is copied on the Linux server (example: /usr/java).
JDK Installation Steps on Linux Operating System:
1. Change the file permission as follows.
chmod a+x jdk-xx-xxx.bin
                        
2. Run the bin file to start the installation.
./jdk-xx-xxx.bin
Unpacking...
Checksumming...
Extracting...
...
...

                        
A directory will be created under "/usr/java" with the JDK version name, which will consists of all the jdk files.
3. You can export the Java home to create it as an environment variable.
export JAVA_HOME=/usr/java/jdk1.6.x_xx
export PATH=$JAVA_HOME/bin:$PATH
                        
4. you can verify the JDK version installed on your system by issuing the following command.
which java
                        
Output:
/usr/java/jdk1.6.x_xx/bin/java
                        
java -version
                        
Output:
java version "1.6.x_xx"
Java(TM) SE Runtime Environment (build 1.6.x_xx-bxx)
Java HotSpot(TM) 32-Bit Server VM (build 11.0-bxx, mixed mode)
                        
5. Installation Completed

How to install java jdk

Installation Setup

1 ) Please visit sun java website to download any java jdk version you like.
http://java.sun.com/javase/downloads/index.jsp

2 ) Click download, select Linux platform, language and accept license and continue.

3 ) Select “Linux RPM in self-extracting file” and download jdk_filename-rpm.bin file (jdk-6u6-linux-i586-rpm.bin).

4 ) After downloaded, changed to the directory where you saved the file.

5 ) login to root user or su to root or sudo, and issue ‘chmod +x jdk_filename.-rpm.bin’ to make it executable.
chmod +x jdk_filename.bin
 
6 ) Execute it
./jdk_filename-rpm.bin
 
7 ) Press space bar , repeat until system prompt to enter yes or no, type y and enter to continue.

8 ) This will output a .rpm file in same directory

9 ) Issue ‘rpm -i jdk_filename.rpm’, this will install all jdk files on linux system /usr/java/jdk-version/
rpm -i jdk_filename.rpm
 
10 ) Create symbol links to make it execute anywhere
ln -s /usr/java/jdk1.6.0/bin/java /usr/bin/java
 ln -s /usr/java/jdk1.6.0/bin/javac /usr/bin/javac
 
11 ) type java -version, DONE !!

Post-Installation Setup

Set JAVA_HOME into environment variable

Copy following statement and append to /etc/profile or .bashrc file, make system set JAVA_HOME into system environment variable.
export JAVA_HOME="/usr/java/jdk1.6.0;"

Thursday, October 6, 2011

HeartBeat and build HA (High Availability) cluster environment

This example sets 2 systems as cluster servers. The environment of 2 systems are like below.
They have 2 NICs.
(1) www1.server-linux.info[eth0:192.168.0.21] [eth1:10.0.0.21]
(2) www2.server-linux.info[eth0:192.168.0.22] [eth1:10.0.0.22]

The package Heartbeat:-List of RPM files to download . e.g
1) heartbeat-2.1.3-3.el5.centos.i386.rpm
2) heartbeat-pils-2.1.3-3.el5.centos.i386.rpm
3) heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm


[1]Install HeartBeat first. It's necessary to do this on both systems.

[root@www1 ~]# yum -y install heartbeat

[root@www1 ~]# yum -y install heartbeat
 
# run again becaus of errors

[root@www1 ~]# vi /etc/ha.d/authkey

# create certificates
auth 1
1 crc

[root@www1 ~]# chmod 600 /etc/ha.d/authkeys
 
[2]Config for a server of (1)
 
[root@www1 ~]# vi /etc/ha.d/ha.cf

crm on
# debug log
debugfile /var/log/ha-debug
# log file
logfile /var/log/ha-log
# the way of output to syslog
logfacility local0
# keepalive
keepalive 2
# deadtime
deadtime 30
# deadping
deadping 40
# warntime
warntime 10
# initdead
initdead 60
# port
udpport 694
# interface and IP address of another Host
ucast eth1 10.0.0.22
# auto failback
auto_failback on|off
# node name (the name of "uname -n")
node www1.server-linux.info
node www2.server-linux.info
respawn root /usr/lib/heartbeat/pingd -m 100 -d 5s -a default_ping_set
 
[3]Config for a server of (2). The different point is only the section of ucast.
 
[root@www1 ~]# vi /etc/ha.d/ha.cf

crm on
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
deadping 40
warntime 10
initdead 60
udpport 694
# interface and IP address of another Hostucast eth1 10.0.0.21
auto_failback on
node www1.server-linux.info
node www2.server-linux.info
respawn root /usr/lib/heartbeat/pingd -m 100 -d 5s -a default_ping_set
[4]Start HeartBeat on both server
 
[root@www1 ~]# /etc/rc.d/init.d/heartbeat start
Starting High-Availability services:
[  OK  ]

[root@www1 ~]# chkconfig heartbeat on
[5] Run crm_mon on both server, then if following result is shown, it's OK, heartbeat running normally. These are Basical configuration of HeartBeat.

[root@www1 ~]# crm_mon -i 3

Defaulting to one-shot mode
You need to have curses available at compile time to enable console mode

============
Last updated: Sun Jun 15 05:04:34 2008
Current DC: www2.server-linux.info (f8719a77-70b4-4e5f-851b-dafa7d65d3a2)
2 Nodes configured.
0 Resources configured.
============

Node: www2.server-linux.info (f8719a77-70b4-4e5f-851b-dafa7d65d3a2): online
Node: www1.server-linux.info (2bbd6408-ec01-4b8c-bb8e-207237af3a99): online

Install DRBD(Distributed Replicated Block Device) and set Disk mirroring

This example based on my environment below. I used hda6 that is empty partition for this config.
(1) www.server-linux.info[192.168.0.18]
(2) www2.server-linux.info[192.168.0.21]

Install and configure DRBD on both Host. Configure the same settings on them. For installing, Specify "kmod-drbd", the DRBD is also installed.The package that you need is e.g :-

1) drbd82-8.2.6-1.el5.centos.i386.rpm
2) kmod-drbd82-8.2.6-2.i686.rpm

[root@www ~]# yum -y install kmod-drbd-xen
[root@www ~]# vi /etc/drbd.conf
resource r0 {
# Specify A or B or C
protocol C;

syncer {
# band width
rate 300M;
}

disk {
on-io-error detach;
}

on www.server-linux.info {
# DRBD device
device /dev/drbd0;
# phisical device

disk /dev/hda6;

# IP address:port

address 192.168.0.18:7788;

meta-disk internal;

}

on www2.server-linux.info {

device /dev/drbd0;

disk /dev/hda6;

address 192.168.0.21:7788;

meta-disk internal;

}

}

[root@www ~]# modprobe drbd
# load module
[root@www ~]# lsmod | grep drbd
drbd      185096   0
# just loaded
[root@www ~]# dd if=/dev/zero of=/dev/hda6 bs=1M count=128
128+0 records in
128+0 records out
134217728 bytes (134 MB) copied, 2.39478 seconds, 56.0 MB/s
[root@www ~]#
drbdadm create-md r0
 
# create meta-data

v08 Magic number not found
v07 Magic number not found
v07 Magic number not found
v08 Magic number not found
Writing meta data...
initialising activity log
NOT initialized bitmap
New drbd meta data block sucessfully created.
--== Creating metadata ==--

As with nodes we count the total number of devices mirrored by DRBD at
at http://usage.drbd.org.

The counter works completely anonymous. A random number gets created for
this device, and that randomer number and the devices size will be sent.

http://usage.drbd.org/cgi-bin/insert_usage.pl?nu=5112098206248082396&ru=12990301505065341479&rs=1073741824
Enter 'no' to opt out, or just press [return] to continue:
success
[root@www ~]# /etc/rc.d/init.d/drbd start
[root@www ~]# cat /proc/drbd
# show status

version: 8.0.11 (api:86/proto:86)
GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b build by buildsvn@c5-i386-build, 2008-03-09 10:26:43
  0: cs:Connected st:Secondary/Secondary ds:Inconsistent/Inconsistent C r---
 
ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 
resync: used:0/31 hits:0 misses:0 starving:0 dirty:0 changed:0 
act_log: used:0/127 hits:0 misses:0 starving:0 dirty:0 changed:0
[2]Make a Host you set primary first. Then mirroring is started
[root@www ~]# drbdsetup /dev/drbd0 primary -o #make it primary
drbd0: Forced to consider local data as UpToDate!
[root@www ~]# cat  /proc/drbd

version: 8.0.11 (api:86/proto:86)
GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b build by buildsvn@c5-i386-build, 2008-03-09 10:26:43
0: cs:SyncSource st:Primary/Secondary ds:UpToDate/Inconsistent C r---  # changed
      ns:77968 nr:0 dw:0 dr:85524 al:0 bm:4 lo:111 pe:259 ua:1999 ap:0 
      [>...................] sync'ed: 7.5% (971572/1048508)K
      finish: 0:00:37 speed: 25,644 (25,644) K/sec
      resync: used:2/31 hits:40719 misses:6 starving:0 dirty:0 changed:6
      act_log: used:0/127 hits:0 misses:0 starving:0 dirty:0 changed:0

[root@www ~]# mkfs -t ext3 /dev/drbd0

[root@www ~]# mkdir /mnt/drbd

[root@www ~]# mount /dev/drbd0 /mnt/drbd

[root@www ~]# touch /mnt/drbd/test.txt # make test file

[root@www ~]# ll /mnt/drbd

total 16
drwx------ 2 root root 16384 May 11 02:18 lost+found
-rw-r--r-- 1 root root 0 May 11 02:22 test.txt
[3] If you'd like to mount DRBD device on secondary Host, unmount DRBD device on primary Host first and make primary Host secondary first. Next make secondary Host primary and mount DRBD devicet
########### on primary host ###########

[root@www ~]# umount  /mnt/drbd
[root@www ~]# drbdadm secondary r0 # make it secondary

########### on secondary host ###########

[root@www2 ~]# drbdadm primary r0 # make it primary
[root@www2 ~]# mkdir /mnt/drbd
[root@www2 ~]# mount /dev/drbd0 /mnt/drbd
[root@www2 ~]# ll /mnt/drbd
total 16
drwx------ 2 root root 16384 May 11 02:18 lost+found
-rw-r--r-- 1 root root 0 May 11 02:22 test.txt  


[4] Resolve the issue (split brain) been happen in  currently whereby drbd response status showing unknown status. to recover a split brain status in drbd here is the following steps need to be taken:-


under Slave drbd run the following command :-
#drbdadm disconnect all
# drbdadm -- --discard-my-data connect all

Primary drbd
# drbd connect all
# service drbd start

Wednesday, July 27, 2011

Linux Creating or Adding New Network Alias To a Network Card (NIC)

Linux Creating or Adding New Network Alias To a Network Card (NIC)

Q. I would like to create alias for my network card (NIC).
How do I setup 2 IP address on One NIC?
How do I add alias under Centos / Fedora / Debian / Ubuntu Linux?

A. Linux allows you to add additional network address using alias feature.
Please note that all additional network IP address must be in same subnet.
For example if your eth0 using 192.168.1.5 IP address then alias must be setup using 192.168.1.0/24 subnet.

fconfig command line

You can use ifconfig command to configure a network interface and alias. For example:
  • eth0 NIC IP 192.168.1.5
  • eth0:0 first NIC alias: 192.168.1.6
To setup eth0:0 alias type the following command as the root user:
# ifconfig eth0:0 192.168.1.6 up

Verify alias is up and running using following command:
# ifconfig -a
# ping 192.168.1.6

However, if you reboot the system you will lost all your alias. To make it permanent you need to add it network configuration file.

Debian / Ubuntu Linux Instructions

You can configure the additional IP addresses automatically at boot with another iface statement in /etc/network/interfaces:
# vi /etc/network/interfaces

Append text as follows:
auto eth0:1
iface eth0:1 inet static
name Ethernet alias LAN card
address 192.168.1.7
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
 
Save and close the file. Restart the network:
# /etc/init.d/networking restart


Red Hat / RHEL / CentOS / Fedora Linux Instructions

Copy etc/sysconfig/network-scripts/ifcfg-eth0 file as /etc/sysconfig/network-scripts/ifcfg-eth0:0
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0

Open file /etc/sysconfig/network-scripts/ifcfg-eth0:0 using vi text editor:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0:0

Find entry that read as follows:
DEVICE=eth0 

Replace with:
DEVICE=eth0:0

Find entry that read as follows:
IPADDR=xxx.xxx.xxx.xxx
 
Replace it with your actual IP address:
IPADDR=192.168.1.7
 
At the end your file should like as follows:
DEVICE=eth0:0
IPADDR=192.168.1.7
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
NAME=eth0:0
 
Open file /etc/sysconfig/network-scripts/ifcfg-eth0 and make sure file does not have a GATEWAY= entry:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Find the entry that read as follows:
GATEWAY=your-ip
 
Remove or comment it out by prefixing # (hash) :
# GATEWAY=192.168.1.254
 
Save the file. Add the GATEWAY= to your /etc/sysconfig/network:
# vi /etc/sysconfig/network
 
Append or modify GATEWAY entry:
GATEWAY=192.168.1.254
 
Save the file. Reboot the system or run the following command:
# ifup eth0:0
OR
# service network restart

Red Hat / CentOS / Fedora Multiple IP address range

You can assign multiple ip address range as follows to eth0:
vi /etc/sysconfig/network-scripts/ifcfg-eth0-range0

Append following code from 202.54.112.120 to 202.54.112.140:
IPADDR_START=202.54.112.120
IPADDR_END=202.54.112.140
CLONENUM_START=0
NETMASK=255.255.255.0 
Save and close the file.

 ====================================

Network IP aliasing:
Assign more than one IP address to one ethernet card:
ifconfig eth0   XXX.XXX.XXX.XXX netmask 255.255.255.0 broadcast XXX.XXX.XXX.255
ifconfig eth0:0 192.168.10.12   netmask 255.255.255.0 broadcast 192.168.10.255
ifconfig eth0:1 192.168.10.14   netmask 255.255.255.0 broadcast 192.168.10.255
 
route add -host XXX.XXX.XXX.XXX dev eth0
route add -host 192.168.10.12 dev eth0
route add -host 192.168.10.14 dev eth0
In this example 0 and 1 are aliases in addition to the regular eth0. The result of the ifconfig command:
eth0      Link encap:Ethernet  HWaddr 00:10:4C:25:7A:3F  
          inet addr:XXX.XXX.XXX.XXX  Bcast:XXX.XXX.XXX.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14218 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1362 errors:0 dropped:0 overruns:0 carrier:0
          collisions:1 txqueuelen:100 
          Interrupt:5 Base address:0xe400 

eth0:0    Link encap:Ethernet  HWaddr 00:10:4C:25:7A:3F  
          inet addr:192.168.10.12  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:5 Base address:0xe400 

eth0:1    Link encap:Ethernet  HWaddr 00:10:4C:25:7A:3F  
          inet addr:192.168.10.14  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:5 Base address:0xe400 
Config file: /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
BROADCAST=192.168.10.255
IPADDR=192.168.10.12
NETMASK=255.255.255.0
NETWORK=192.168.10.0
ONBOOT=yes
Aliases can also be shut down independently. i.e.: ifdown eth0:0 The option during kernel compile is: CONFIG_IP_ALIAS=y (Enabled by default in Redhat)       

Linux bond or team multiple network interfaces (NIC) into single interface

Linux bond or team multiple network interfaces (NIC) into single interface


Finally today I had implemented NIC bounding (bind both NIC so that it works as a single device). We have two Dell servers that need setup with Intel Dual Gig NIC. My idea is to improve performance by pumping out more data from both NIC without using any other method.

This box act as heavy duty ftp server. Each night I need to transfer over 200GB data from this box to another box. Therefore, the network would be setup is two servers on a switch using dual network cards.
I am using Red Hat enterprise Linux

Linux allows binding multiple network interfaces into a single channel/NIC using special kernel module called bonding. According to official bonding documentation, "The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical "bonded" interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services.
Additionally, link integrity monitoring may be performed."Setting up bounding is easy with RHEL

Step #1: Create a bond0 configuration file

Red Hat Linux stores network configuration in /etc/sysconfig/network-scripts/ directory.
First, you need to create bond0 config file:

# vi /etc/sysconfig/network-scripts/ifcfg-bond0

Append following lines to it:
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

Replace above IP address with your actual IP address. Save file and exit to shell prompt.


Step #2: Modify eth0 and eth1 config files:

Open both configuration using vi text editor and make sure file read as follows for eth0 interface
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Modify/append directive as follows:
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none


Open eth1 configuration file using vi text editor:#
 vi /etc/sysconfig/network-scripts/ifcfg-eth1

Make sure file read as follows for eth1 interface:
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Save file and exit to shell prompt.


Step # 3: Load bond driver/module

Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. You need to modify kernel modules configuration file:
# vi /etc/modprobe.conf

Append following two lines:
alias bond0 bonding
options bond0 mode=balance-alb miimon=100


Save file and exit to shell prompt. You can learn more about all bounding options in kernel source documentation file (click here to read file online).


Step # 4: Test configuration

First, load the bonding module:
# modprobe bonding

Restart networking service in order to bring up bond0 interface:
# service network restart

Verify everything is working:
# less /proc/net/bonding/bond0

Output:
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:59

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:63
 
List all interfaces:
# ifconfig

Output:

bond0     Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
 UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
 RX packets:2804 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1879 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:250825 (244.9 KiB)  TX bytes:244683 (238.9 KiB)

eth0      Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:2809 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1390 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:251161 (245.2 KiB)  TX bytes:180289 (176.0 KiB)
 Interrupt:11 Base address:0x1400

eth1      Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:4 errors:0 dropped:0 overruns:0 frame:0
 TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:258 (258.0 b)  TX bytes:66516 (64.9 KiB)
 Interrupt:10 Base address:0x1480

Monday, July 25, 2011

Howto Red hat enterprise Linux 5 configure the network card

Howto Red hat enterprise Linux 5 configure the network card


Q. I’ve installed Red Hat enterprise Linux 5 and now added one more LAN card (NIC).
How do I configure the network card from the command line? I can see 2nd my network card detected while booting the IBM server.

A. Red hat Linux provides following tools to make changes to Network configuration such as add new card, assign IP address, change DNS server etc.

[a] GUI tool (X Windows required) - system-config-network
[b] Command line text based GUI tool (No X Windows required) - system-config-network
[c] Edit configuration files stored in /etc/sysconfig/network-scripts/ directory.

Following instructions are compatible with
(1) Cent OS Linux
(2) Fedora Core Linux
(3) Red Hat Enterprise Linux (RHEL) 3/4/5

Method # 1: GUI tool system-config-network

Type the following command at shell prompt (open x terminal):
$ system-config-network &
Red hat enterprise Linux 5 configure the network card - system-config-network

You will see Window as above. Now select your Ethernet card (eth0 or eth1) and click on Edit button. You can now setup IP address, netmask, default gateway and other properties.
setup IP address, netmask, default gateway and other properties

You can obtain IP address using DHCP or setup manually. Once IP address assigned, click on Ok button to save the changes. You can activate card by clicking on Activate button.

Method # 2: Command line tool system-config-network-tui

If you don’t have X windows GUI installed type the following command at shell prompt:
# system-config-network-tui &
Command line tool system-config-network-tui

(click to enlarge image)
You will see text based GUI as above. Select your Ethernet card (eth0 or eth1) and hit [Enter] or [F12] special key.
Cent OS, Fedora Core, RHEL configure the network card - system-config-network-tui
(click to enlarge image)
You can obtain IP address using DHCP or setup manually. Once IP address assigned, click on Ok button to save the changes


Method #3: Edit configuration files stored in /etc/sysconfig/network-scripts/

You can configure network card by editing text files stored in /etc/sysconfig/network-scripts/ directory.
First change directory to /etc/sysconfig/network-scripts/:
# cd /etc/sysconfig/network-scripts/
You need to edit / create files as follows:
  • /etc/sysconfig/network-scripts/ifcfg-eth0 : First Ethernet card configuration file
  • /etc/sysconfig/network-scripts/ifcfg-eth1 : Second Ethernet card configuration file
To edit/create first NIC file, type command:
# vi ifcfg-eth0
Append/modify as follows:

# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:30:48:56:A6:2E
IPADDR=10.10.29.66
NETMASK=255.255.255.192
ONBOOT=yes


 
Save and close the file. Define default gateway (router IP) and hostname in /etc/sysconfig//network file:
# vi /etc/sysconfig/network

Append/modify configuration as follows:
NETWORKING=yes
HOSTNAME=www1.nixcraft.in
GATEWAY=10.10.29.65

Save and close the file. Restart networking:
# /etc/init.d/network restart

Make sure you have correct DNS server defined in /etc/resolv.conf file:
# vi /etc/resolv.conf

Setup DNS Server as follows:
nameserver 10.0.80.11
nameserver 10.0.80.12
nameserver 202.67.222.222


Save and close the file. Now you can ping the gateway/other hosts:
$ ping 10.0.80.12

Output:
PING 10.0.80.12 (10.0.80.12) 56(84) bytes of data.
64 bytes from 10.0.80.12: icmp_seq=1 ttl=251 time=0.972 ms
64 bytes from 10.0.80.12: icmp_seq=2 ttl=251 time=1.11 ms
 
You can also check for Internet connectivity with nslookup or host command:
$ nslookup cyberciti.biz

Output:
Server:         10.0.80.11
Address:        10.0.80.11#53

Non-authoritative answer:
Name:   cyberciti.biz
Address: 75.126.43.232
You can also use host command:
$ host nixcraft.in

Output:
nixcraft.in has address 75.126.43.232
nixcraft.in mail is handled by 10 mail.nixcraft.in.

Wednesday, July 13, 2011

Step-By-Step Configuration of NAT with iptables

Requirements:

CPU - PII or more
OS - Any Linux distribution
Software - Iptables
Network Interface Cards: 2
Here is my considerations:
Replace xx.xx.xx.xx with your WAN IP
Replace yy.yy.yy.yy with your LAN IP
(i.e. 192.168.0.0/16, 172.16.0.0/12,  10.0.0.0/8 as suggested by Mr. tzs)
WAN = eth0 with public IP xx.xx.xx.xx
LAN = eth1 with private IP yy.yy.yy.yy/ 255.255.0.0

 

Step by Step Procedure

Step #1. Add 2 Network cards to the Linux box
Step #2. Verify the Network cards, Wether they installed properly or not
ls /etc/sysconfig/network-scripts/ifcfg-eth* | wc -l
    ( The output should be "2")
Step #3. Configure eth0 for Internet with a Public ( IP External network or Internet)
cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
BROADCAST=xx.xx.xx.255    # Optional Entry
HWADDR=00:50:BA:88:72:D4    # Optional Entry
IPADDR=xx.xx.xx.xx
NETMASK=255.255.255.0    # Provided by the ISP
NETWORK=xx.xx.xx.0       # Optional
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
GATEWAY=xx.xx.xx.1    # Provided by the ISP

Step #4. Configure eth1 for LAN with a Private IP (Internal private network)
cat /etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO=none
PEERDNS=yes
HWADDR=00:50:8B:CF:9C:05    # Optional
TYPE=Ethernet
IPV6INIT=no
DEVICE=eth1
NETMASK=255.255.0.0        # Specify based on your requirement
BROADCAST=""
IPADDR=192.168.2.1        # Gateway of the LAN
NETWORK=192.168.0.0        # Optional
USERCTL=no
ONBOOT=yes

Step #5. Host Configuration    (Optional)
cat /etc/hosts
    127.0.0.1       nat localhost.localdomain   localhost
Step #6. Gateway Configuration
cat /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=nat
    GATEWAY=xx.xx.xx.1    # Internet Gateway, provided by the ISP

Step #7. DNS Configuration
cat /etc/resolv.conf
    nameserver 203.145.184.13      # Primary DNS Server provided by the ISP
    nameserver 202.56.250.5        # Secondary DNS Server provided by the ISP

Step #8. NAT configuration with IP Tables
    # Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.
iptables --flush            # Flush all the rules in filter and nat tables
iptables --table nat --flush
iptables --delete-chain
# Delete all chains that are not in default filter and nat table
iptables --table nat --delete-chain
# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT
# Enables packet forwarding by kernel
echo 1 > /proc/sys/net/ipv4/ip_forward
 #Apply the configuration
service iptables restart
Step #9. Testing
 # Ping the Gateway of the network from client system
ping 192.168.2.1
Try it on your client systems
ping google.com

 Configuring PCs on the network (Clients)

•    All PC's on the private office network should set their "gateway" to be the local private network IP address of the Linux gateway computer.
•    The DNS should be set to that of the ISP on the internet.
Windows '95, 2000, XP,  Configuration:

•    Select "Start" + Settings" + "Control Panel"
•    Select the "Network" icon
•    Select the tab "Configuration" and double click the component "TCP/IP" for the ethernet card. (NOT the TCP/IP -> Dial-Up Adapter)
•    Select the tabs:
o    "Gateway": Use the internal network IP address of the Linux box. (192.168.2.1)
o    "DNS Configuration": Use the IP addresses of the ISP Domain Name Servers. (Actual internet IP address)
o    "IP Address": The IP address (192.168.XXX.XXX - static) and netmask (typically 255.255.0.0 for a small local office network) of the PC can also be set here.

Thursday, July 7, 2011

Adding Microsoft Office Document Image Writer Printer back after being removed.

Solution 1.
Type the following into a command prompt window: (unsure if you have to be admin or not)
cscript c:\windows\system32\prnmngr.vbs -a -p "Microsoft Office Document Image Writer" -m "Microsoft Office Document Image Writer Driver" -r "Microsoft Document Imaging Writer Port:"

Solution 2. (Not mine, borrowed from somewhere else.)
1. Close all running applications. If you have any Office application
running, the driver will not be installed properly.
2. Go to the "Control Panel" and "Add or Remove Programs".
3. Click on"Microsoft Office 2003" and then click on "Change".
4. Check "Add or Remove Features" and click "Next".
5. On the bottom of the page check "Choose advanced customization of
applications." and click "Next".
6. Under Microsoft Office click on the + sign in front of "Office
Tools"
7. Locate "Microsoft Office Document Imaging", click the icon and
select "Not Available".
8. Click on "Update". This will uninstall the MODI driver.

9. Repeat steps 1 to 6 to go back to the same location you were before.

10. Locate the object "Microsoft Office Document Imaging", click the
icon and select "Run from My Computer".
11. Click on "Update".

Use the Remote Shutdown Tool to Shutdown, Restart, or Logoff a Local or Networked Computer on Windows OS

This guide shows you how to use the shutdown command and its various switches to shutdown, restart, or logoff local or networked computers from the command prompt, dialog window, or batch file.

What can the shutdown command do?
The shutdown command can be use via the command prompt, the remote shutdown dialog window, or in a batch file.  You can logoff, shutdown, or restart a computer with this tool.  You can even set the shutdown tool to perform a task at a certain time on certain days and to many computers at one time using a batch file.
This is a good tool to easily shutdown or restart lots of computers on a network at one time.  It can also be handy for helpdesk technicians when fixing remote computers.

Shutdown Command via Dialog Window
Typing commands in a DOS window is not what most computer users want to fool with so I’m going to start by showing you how to use the dialog window to use the shutdown tool.
To open the dialog window click start, click run, type cmd and press enter.  A black DOS looking window will open.  Type shutdown -i and press enter.  A window similar to the one below will popup.




Under computers type the network name of the computer you want to shutdown, restart, or logoff.  In this example I will use \\yourcomputer.  You can use your computer’s name to try the commands on your computer if you like.

If you don’t know a computers name right click my computer, select properties, select the computer name tab.  Your computer name is listed next to full computer name.
To send these commands to other computers across your network you need to have administrative privileges on those computers.  An easy way to see if you have administrative privileges on a networked computer is to try browsing to it.  Click start, click run, type \\yourcomputer (replace yourcomputer with your computer’s name of course) and press enter.  If you are able to access the computer you will be able to send shutdown commands to it.  If you get asked for a password or it denies access you don’t have administrative privileges and you won’t be able to send shutdown commands to that computer.
In this example I’m going to shutdown computer \\yourcomputer on my network.  Before it shuts down it’s going to show a message for 20 seconds.

The first thing you need to do is add which computer you want to shutdown.  Click add and type your computer name in the add computers box.


You can send the command to multiple computers by pressing enter after the name of each computer and typing the name of the next computer on the next line.  Each computer needs to be on its own line.
Click OK when you are finished adding the computer(s) you want to send the command to.
Under what do you want these computers to do: tell it to shutdown, restart, or logoff.

If you want a box to popup on the computer(s) you are sending the command to that lets them know the computer is about to shutdown, restart, or logoff in X many seconds leave warn users of the action checked off.  If you want to change how many seconds to countdown before performing the action you can change that next to seconds.

You can tell a user on the computer you are about to perform the action on why you are performing that action by typing your message in under comment.

Click OK to send the command to the computer(s).


If you get an error when sending the command it will look like the one below.

Shutdown Command via Command Prompt
The shutdown command becomes more flexible and automated when used from the command prompt.  To run the shutdown command from the command prompt, go to start, run, type cmd, and press enter.  In the black box (the command prompt) type shutdown and the switches you want to use with the shutdown command.  You have to use at east one switch for the shutdown command to work.

The Switches
The shutdown command has a few options called switches.  You can always see them by typing shutdown -? in the command prompt if you forget any of them.
-i: Display GUI interface, must be the first option
-l: Log off (cannot be used with -m option)
-s: Shutdown the computer
-r: Shutdown and restart the computer
-a: Abort a system shutdown
-m \\computername: Remote computer to shutdown/restart/abort
-t xx: Set timeout for shutdown to xx seconds
-c “comment”: Shutdown comment (maximum of 127 characters)
-f: Forces running applications to close without warning
-d [u][p]:xx:yy:

The reason code for the shutdown u is the user code p is a planned shutdown code xx is the major reason code (positive integer less than 256) yy is the minor reason code (positive integer less than 65536)

Please note: I’ve noticed using a switch with a – sign doesn’t work sometimes. If you are having trouble try using a / in place of – in your switches.

Examples
shutdown –m \\computername –r –f 
This command will restart the computer named computername and force any programs that might still be running to stop.

shutdown –m \\computername –r –f –c “I’m restarting your computer. 

Please save your work now.” –t 120 
This command will restart the computer named computername, force any programs that might still be running to stop, give to user on that computer a message, and countdown 120 seconds before it restarts.

shutdown –m \\computername –a 
This command will abort a previous shutdown command that is in progress.

Using a Batch File
You can create a file that performs the shutdown command on many computers at one time.
In this example I’m going to create a batch file that will use the shutdown command to shut down 3 computers on my home network before I go to bed.

Open notepad and type the shutdown command to shut down a computer for each computer on the network.  Make sure each shutdown command is on its own line.  An example of what should be typed in notepad is below.
shutdown –m \\computer1 –s
shutdown –m \\computer2 –s
shutdown –m \\computer3 -s


Now I’ll save it as a batch file by going to file, save as, change save as type to all files, give the file a name ending with .bat.  I named mine shutdown.bat.  Pick the location to save the batch file in and save it.
When you run the batch file it’ll shutdown computer1, 2, and 3 for you.

You can use any combination of shutdown commands in a batch file.  I just used the one above as an example

Tuesday, July 5, 2011

Linux CentOS - LAMP (Apache, PHP and MySQL in Linux) Server for CentOS/RHEL

INTRODUCTION

This tutorial shows a quick way of installing a LAMP server (Linux + Apache + MySQL + PHP/Perl together commonly known as LAMP Server) with some additionally repositories (for updated PHP, MySQL packages and phpMyAdmin) on CentOS/RHEL server systems.


Install the extra repositories

The first step requires downloading some RPM files that contain the additional YUM repository definitions.

Centos 5.x

wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
sudo rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

Centos 6.x

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm


Update CentOS
yum update

YUM PRIORITIES

The Yum Priorities plugin can be used to enforce ordered protection of repositories, by associating priorities to repositories. Visit the Yum Priorities CentOS Wiki for more information.

Install Yum Priorities
yum install yum-priorities

Configure Yum Priorities
1. Open the Yum Priorities configuration file with your favourite text editor
vi /etc/yum/pluginconf.d/priorities.conf
- Ensure the following lines exist
[main]
enabled=1
- Save and close the file

2. Open the CentOS base repository configuration file
vi /etc/yum.repos.d/CentOS-Base.repo
 

- Add the following text to the end of the Base, Updates, Addons, and Extras repository entries (A repository entry is specified with the repository name placed between [example], i.e. the base repository entry is specified with [base])
priority=1 - 
Enable (change the enable value 0 to 1) and add the following text to the end of the CentOSPlus repository entry
priority=2

EPEL RPOSITORY

Extra Packages for Enterprise Linux (EPEL) is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages that complement the Fedora-based Red Hat Enterprise Linux (RHEL) and its compatible spinoffs such as CentOS or Scientific Linux. Visit the Fedora EPEL Wiki for more information.

Install EPEL Repository
- Download the latest EPEL repository
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

- Run the rpm install command
rpm -Uvh epel-release-5*.rpm

Open the EPEL repository file
/etc/yum.repos.d/epel.repo

- Set priority for the EPEL repository
Add priority=3 to the end of the [epel] section



REMI REPOSITORY

 

The Remi repository is a repository containing updated PHP and MySQL packages and is maintained by Remi. See the Remi Documentation for more information.

Install Remi Repository
1. Download the latest Remi repository
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm


2. Run the rpm install command
rpm -Uvh remi-release-5*.rpm


Configure Remi Repository
1. Open the Remi repository file
vi /etc/yum.repos.d/remi.repo


2. Enable the Remi Repository
Change enabled=0 to enabled=1

3. Set priority for the Remi Repository
Add priority=3 to the end of the [remi] section

Exclude PHP and MySQL packages from the CentOS base repositories
1. Open the CentOS base repository configuration file
vi /etc/yum.repos.d/CentOS-Base.repo


2. Append the following text to all repositories
exclude=*php* *mysql* *phpmyadmin*

APACHE SERVER

Apache HTTP Server is an open-source HTTP server for modern operating systems including UNIX and Windows NT. For more information on Apache HTTP Server, you can visit their website at httpd.apache.org.

Install Apache
yum install httpd

NOTE: The Apache server is installed with our VPS packages with CentOS by default so you may skip this step.

Set the apache service to start on boot
chkconfig httpd on

or type ntsysv for GUI tool

PHP

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. For more information on PHP, visit their website at http://www.php.net/.

Install PHP
yum install php

Restart Apache to load php
/etc/init.d/httpd restart


Test If PHP Is Working Or Not:

1. Create a file named info.php
vi /var/www/html/info.php 

with the following text:
<?php
  phpinfo();
?>

Then point your browser to http://ipaddress/info.php.
NOTE: It is NOT recommended to expose the info PHP file to public view.
That's it! You should see a PHP configuration file displaying all kind of paths and installed modules.

MYSQL

MySQL is a Relational Database Management System (RDBMS) that runs as a server providing multi-user access to a number of databases. For more information on MySQL, you can visit their website at www.mysql.com.

Install MySQL Database Server
yum install mysql-server mysql php-mysql

1. Set the MySQL service to start on boot
chkconfig mysqld on or type ntsysv for GUI tool
 
2. Start the MySQL service
/etc/init.d/mysqld start

3. Log into MySQL
mysql -u root

4. Set the root user password for all local domains (otherwise anybody can access your MySQL database!)
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new-password');
SET PASSWORD FOR 'root'@'localhost.localdomain' = PASSWORD('new-password');
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('new-password');

5. Drop the Any user
DROP USER ''@'localhost';
DROP USER ''@'localhost.localdomain';

6. Exit MySQL
exit

Alternatively you can run a script to improve the security of your MySQL installation. This is recommended for all MySQL servers in production use!
mysql_secure_installation

PHPMYADMIN

phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the Web. Visit the phpMyAdmin website for more information.

Install phpMyAdmin
yum install phpmyadmin

NOTE: You might encounter the following errors while configuring phpMyAdmin
Forbidden
You don't have permission to access /phpmyadmin/ on this server.


To fix:
Edit the /etc/httpd/conf.d/phpMyAdmin.conf file and uncomment the line deny from all
vi /etc/httpd/conf.d/phpMyAdmin.conf
<Directory "/usr/share/phpmyadmin">
  Order Deny,Allow
  # Deny from all
  Allow from 127.0.0.1
</Directory>

NOTE: The location of the phpMyAdmin configuration file is /etc/phpMyAdmin/config.inc.php

Restart the Apache Server
/etc/init.d/httpd restart
 
Test:
1. Visit http://ipaddress/phpmyadmin in your web browser. You should be prompted for authentication
2. Enter the system root username and password and click OK
3. You should now be presented with the phpMyAdmin home page


Monday, July 4, 2011

Upgrading CentOS 5.5 to CentOS 5.6

Before upgrading CentOS 5.5 to 5.6 it cannot be stressed enough how important it is to make a backup of your system before you do this. Actions listed in this post are written with the assumption that they will be executed by the root user running the bash or any other modern shell.Clean All Packages
# yum clean all
The following command will get a list of packages that are going to be updated.
# yum list updates
Lets begin upgrading CentOS 5.5 to 5.6
# yum update
Finally reboot the server for Kernel changes to take effect
# reboot
Verify that CentOS 5.6 is working:
# cat /etc/redhat-release
CentOS release 5.6 (Final)
Or:
# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.6 (Final)
Release: 5.6
Codename: Final
Or:
# rpm -q centos-release
centos-release-5-6.el5.centos.1

Sunday, July 3, 2011

Get Information About Your BIOS / Server Hardware From a Shell Without Opening Chassis ( BIOS Decoder )

biosdecode is a command line utility to parses the BIOS memory and prints information about all structures (or entry points) it knows of. You can find out more information about your hardware such as:
=> IPMI Device
=> Type of memory and speed
=> Chassis Information
=> Temperature Probe
=> Cooling Device
=> Electrical Current Probe
=> Processor and Memory Information
=> Serial numbers
=> BIOS version
=> PCI / PCIe Slots and Speed
=> Much more

biosdecode parses the BIOS memory and prints the following information about all structures :
=> SMBIOS (System Management BIOS)
=> DMI (Desktop Management Interface, a legacy version of SMBIOS)
=> SYSID
=> PNP (Plug and Play)
=> ACPI (Advanced Configuration and Power Interface)
=> BIOS32 (BIOS32 Service Directory)
=> PIR (PCI IRQ Routing)
=> 32OS (BIOS32 Extension, Compaq-specific)
=> VPD (Vital Product Data, IBM-specific)
=> FJKEYINF (Application Panel, Fujitsu-specific)
In this tip you will learn about decoding BIOS data (dumping a computer's DMI ) and getting all information about computer hardware without rebooting the server.

More about the DMI tables

The DMI table doesn’t only describe what the system is currently made of, it also can report the possible evolutions such as the fastest supported CPU or the maximal amount of memory supported.

dmidecode - Read biosdecode data in a human-readable format

Data provided by biosdecode is not in a human-readable format. You need to use dmidecode command for dumping a computer’s DMI (SMBIOS) table contents on screen. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware.

Task: Display information about IPMI Device

# dmidecode --type 38
Output:
# dmidecode 2.7
SMBIOS 2.4 present.

Handle 0x0029, DMI type 38, 18 bytes.
IPMI Device Information
        Interface Type: KCS (Keyboard Control Style)
        Specification Version: 2.0
        I2C Slave Address: 0x10
        NV Storage Device: Not Present
        Base Address: 0x0000000000000CA2 (I/O)
        Register Spacing: Successive Byte Boundaries

Task: Display information about PCI / PCIe Slots

# dmidecode --type 9
# dmidecode 2.7
SMBIOS 2.4 present.

Handle 0x000E, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIX#1-133MHz
        Type: 64-bit PCI-X
        Current Usage: Available
        Length: Long
        ID: 1
        Characteristics:
                3.3 V is provided

Handle 0x000F, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIX#2-100MHz
        Type: 64-bit PCI-X
        Current Usage: Available
        Length: Long
        ID: 2
        Characteristics:
                3.3 V is provided

Handle 0x0010, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIE#3-x8
        Type: Other
        Current Usage: Available
        Length: Other
        Characteristics:
                3.3 V is provided

Handle 0x0011, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIE#4-x8
        Type: Other
        Current Usage: Available
        Length: Other
        Characteristics:
                3.3 V is provided

Handle 0x0012, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIE#5-x8
        Type: Other
        Current Usage: Available
        Length: Other
        Characteristics:
                3.3 V is provided

Task: Find out Information about BIOS

# dmidecode --type 0
Output:
# dmidecode 2.7
SMBIOS 2.4 present.
Handle 0x0000, DMI type 0, 24 bytes.
BIOS Information
        Vendor: Phoenix Technologies LTD
        Version: 6.00
        Release Date: 01/26/2007
        Address: 0xE56C0
        Runtime Size: 108864 bytes
        ROM Size: 1024 kB
        Characteristics:
                PCI is supported
                PNP is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                ESCD support is available
                Boot from CD is supported
                Selectable boot is supported
                EDD is supported
                3.5"/2.88 MB floppy services are supported (int 13h)
                ACPI is supported
                USB legacy is supported
                LS-120 boot is supported
                ATAPI Zip drive boot is supported
                BIOS boot specification is supported
                Targeted content distribution is supported

Understanding BIOS keywords

dmidecode --type {KEYWORD / Number }
You need to pass dmidecode following keywords:
  • bios
  • system
  • baseboard
  • chassis
  • processor
  • memory
  • cache
  • connector
  • slot
All DMI types you need to use with dmidecode --type {Number}:
# Type Short Description
0 BIOS
1 System
2 Base Board
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply

Display Power supply information, enter:
# dmidecode --type 39

Display CPU information, enter:
# dmidecode --type processor

Read man page for more information:
$ man dmidecode

Restore GRUB

GRUB is a boot loader commonly used with linux operating system. It can be used to managed dual boot environment where linux and windows can coexist easily in a same machine without problem provided you install the windows OS first so that when you install linux, GRUB will overwrite Windows boot loader and automatically detect and manage both operating system the next time you boot your computer. Problems will happen if you alter your partitions outside the knowledge of GRUB, for example, you create new partition in your hard drive using windows. This will cause GRUB to automatically go into GRUB shell when boot. To restore back your GRUB is very simple, just follow easy steps below:

1. find in which partition does GRUB store its configuration file, which is your /boot partition. (hd0,2) means third partition of the first hard drive
grub> find /boot/grub/stage1
(hd0,2)

2. set the root for GRUB to be (hd0,2)
grub> root (hd0,2)

3. write GRUB to the Master boot record(MBR) of your hard drive. Change (hd0) to (hd0,2) to write GRUB to your /boot partition instead
grub> setup (hd0)

4. Reboot machine
grub> reboot

Checking hardisk information on linux

To check hardisk information such as model and serial number, there are a few useful commands like hdparm, sdparm and fdisk.

To check the information about first hardisk for PATA and SATA hardisk:
# hdparm -i /dev/sda

For SCSI disk, a different command is to be used:
# sdparm /dev/sda

To check the hardisk capacity and partitions contained in the hardisk, fdisk can be used:
# fdisk -lu /dev/sda

Setting Up An NFS Server And Client On CentOS 5.5

1 Preliminary Note

I'm using two CentOS systems here:
  • NFS Server: server.example.com, IP address: 192.168.0.100
  • NFS Client: client.example.com, IP address: 192.168.0.101

2 Installing NFS

server:
On the NFS server we run:
yum install nfs-utils nfs-utils-lib

Then we create the system startup links for the NFS server and start it:
chkconfig --levels 235 nfs on
/etc/init.d/nfs start 

client:
On the client we can install NFS as follows (this is actually the same as on the server):
yum install nfs-utils nfs-utils-lib

3 Exporting Directories On The Server

server:
I'd like to make the directories /home and /var/nfs accessible to the client; therefore we must "export" them on the server.
When a client accesses an NFS share, this normally happens as the user nobody. Usually the /home directory isn't owned by nobody (and I don't recommend to change its ownership to nobody!), and because we want to read and write on /home, we tell NFS that accesses should be made as root (if our /home share was read-only, this wouldn't be necessary).
The /var/nfs directory doesn't exist, so we can create it and change its ownership; in my tests the user and group nobody both had the ID 99 on both my CentOS test systems (server and client); when I tried to write to /var/nfs from the NFS client, I got a Permission denied error, so I did a chmod 777 /var/nfs so that everyone could write to that directory; writing to /var/nfs from the client worked then, and on the client the files written to /var/nfs appeared to be owned by the user and group nobody, but on the server they were owned by the (nonexistant) user and group with the ID 65534; so I changed ownership of /var/nfs to the user/group 65534 on the server and changed permissions of /var/nfs back to 755, and voilĂ , the client was allowed to write to /var/nfs:
mkdir /var/nfs
chown 65534:65534 /var/nfs
chmod 755 /var/nfs

Now we must modify /etc/exports where we "export" our NFS shares. We specify /home and /var/nfs as NFS shares and tell NFS to make accesses to /home as root (to learn more about /etc/exports, its format and available options, take a look at
man 5 exports
)
vi /etc/exports
/home           192.168.0.101(rw,sync,no_root_squash,no_subtree_check)
/var/nfs        192.168.0.101(rw,sync,no_subtree_check)
(The no_root_squash option makes that /home will be accessed as root.)

Whenever we modify /etc/exports, we must run
exportfs -a
afterwards to make the changes effective.

4 Mounting The NFS Shares On The Client

client:
First we create the directories where we want to mount the NFS shares, e.g.:
mkdir -p /mnt/nfs/home
mkdir -p /mnt/nfs/var/nfs

Afterwards, we can mount them as follows:
mount 192.168.0.100:/home /mnt/nfs/home
mount 192.168.0.100:/var/nfs /mnt/nfs/var/nfs

You should now see the two NFS shares in the outputs of
df -h
[root@client ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       28G  2.2G   25G   8% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                 250M     0  250M   0% /dev/shm
192.168.0.100:/home    28G  2.6G   25G  10% /mnt/nfs/home
192.168.0.100:/var/nfs
                       28G  2.6G   25G  10% /mnt/nfs/var/nfs
[root@client ~]#
and
mount
[root@client ~]# mount /dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.0.100:/home on /mnt/nfs/home type nfs (rw,addr=192.168.0.100)
192.168.0.100:/var/nfs on /mnt/nfs/var/nfs type nfs (rw,addr=192.168.0.100)
[root@client ~]#

5 Testing

On the client, you can now try to create test files on the NFS shares:
client:
touch /mnt/nfs/home/test.txt
touch /mnt/nfs/var/nfs/test.txt

Now go to the server and check if you can see both test files:
server:
ls -l /home/
[root@server ~]# ls -l /home/
total 55540
-rw-r--r-- 1 root         root                0 Sep 16 17:30 test.txt
[root@server ~]#

Installing Apache2 With PHP5 And MySQL Support On CentOS 5.6 (LAMP)

LAMP is short for Linux, Apache, MySQL, PHP. This tutorial shows how you can install an Apache2 webserver on a CentOS 5.6 server with PHP5 support (mod_php) and MySQL support.
I do not issue any guarantee that this will work for you!

1 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.

2 Installing MySQL 5.0

To install MySQL, we do this:
yum install mysql mysql-server

Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

Set passwords for the MySQL root account:
mysql_secure_installation
[root@server1 ~]# mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n]
 <-- ENTER
New password: <-- yourrootsqlpassword
Re-enter new password: <-- yourrootsqlpassword
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
 <-- ENTER
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
 <-- ENTER
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
 <-- ENTER
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
 <-- ENTER
 ... Success!

Cleaning up...


All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


[root@server1 ~]#


==========================================================================

3 Installing Apache2

Apache2 is available as a CentOS package, therefore we can install it like this:
yum install httpd

Now configure your system to start Apache at boot time...
chkconfig --levels 235 httpd on
... and start Apache:
/etc/init.d/httpd start
Now direct your browser to http://192.168.0.100, and you should see the Apache2 placeholder page:



Apache's default document root is /var/www/html on CentOS, and the configuration file is /etc/httpd/conf/httpd.conf. Additional configurations are stored in the /etc/httpd/conf.d/ directory. 

==========================================================================

Installing PHP5

We can install PHP5 and the Apache PHP5 module as follows:
yum install php

We must restart Apache afterwards:
/etc/init.d/httpd restart

Testing PHP5 / Getting Details About Your PHP5 Installation


The document root of the default web site is /var/www/html. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.


vi /var/www/html/info.php

type coding as below:-
<?php
phpinfo();
?>
Now we call that file in a browser (e.g. http://192.168.0.100/info.php):
As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support in PHP5 yet.

==========================================================================

Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:
yum search php

Pick the ones you need and install them like this:
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

Now restart Apache2:
/etc/init.d/httpd restart

Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:

 ==========================================================================

phpMyAdmin

phpMyAdmin is a web interface through which you can manage your MySQL databases.
First we enable the RPMforge repository on our CentOS system as phpMyAdmin is not available in the official CentOS 5.6 repositories:

On x86_64 systems:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
rpm -Uhv rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

On i386 systems:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uhv rpmforge-release-0.5.2-2.el5.rf.i386.rpm

phpMyAdmin can now be installed as follows:
yum install phpmyadmin

Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections not just from localhost (by commenting out the <Directory "/usr/share/phpmyadmin"> stanza):
vi /etc/httpd/conf.d/phpmyadmin.conf
#
#  Web application to manage MySQL
#

#<Directory "/usr/share/phpmyadmin">
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#</Directory>

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

Next we change the authentication in phpMyAdmin from cookie to http:
vi /usr/share/phpmyadmin/config.inc.php
[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]

Restart Apache:
/etc/init.d/httpd restart 

Afterwards, you can access phpMyAdmin under http://192.168.0.100/phpmyadmin/: