Translate

Sunday, 10 February 2013

Software RAID in Linux

Software RAID in Linux

For configuration software RAID , First we need to undrstand what is raid, why its use or require.

Here we are not goining in dept, we are covering the importants points to know raid and understand it.

RAID stands for Redundant Array of Inexpensive Disks or Independent Disks ..

RAID use to give redunsy or fault tolerance by redundant data on multiple disks

main typeof RAID

RAID 0 :  Disk Striping using for Performance
RAID 1 : Mirroring using for Fault Tolerance (minimum two disks require one disk is mirror of other)
.
.
.
RAID5 : striping with distributed parity using for Speed and Fault Tolerance (minimum three disks require)

we can use raid level as per our requirement or enviroment or need like we can use RAID (1+5) , here we are using both raid 1 and 5, we ca use raid 1 for our OS and raid 5 for our data.

Now come to praticle :-)

To Install Software RAID we require the following package

Package name : mdadm

#yum install mdadm -y                       (Hope u have learn how to install yum from previous blog :-)

Now create the required partition

#mdadm -C /dev/md0 -n3 /dev/sda11 /dev/sda12 /dev/sda13 -l5

mdadm : array /dev/md0 started

-C for create
-n3 for number of disk
-l5 for level of raid

more flags u can get from man mdadm command

To see the detail information of /dev/md0

#mdadm -D /dev/md0

To format the raid meta device

#mkfs.ext3 /dev/md0

Mount the partition

#mkdie /raid_dir
#mount /dev/md0 /raid_dir

#df -hT                                  (we can check by df command for its mounting status)

wright some content inside the raid partition

#cd /raid_dir
#cat > testfile
this is the test file

#ll
testfile

To add a new device as spare

#mdadm -a /dev/md0 /dev/sda14
#mdadm -D /dev/md0
#mdadm /dev/md0 -f /dev/sda12
mdadm: set /dev/sda12 faulty in /dev/md0

To see more information of /dev/md0
#mdadm -D /dev/md0

To remove the faulty device

#mdadm /dev/md0 -r /dev/sda12
mdadm: hot remove /dev/sda12

#mdadm -D /dev/md0

To stop the raid unmount the meta device.

#umount /dev/md0
#mdadm -S /dev/md0
mdadm:stoped /dev/md0

To activate or assemble the raid meta device

#mdadm -A /dev/md0 /dev/sda11 /dev/sda13 /dev/sda14
mdadm: /dev/md0 has been started with 3 devices.

#mdadm -D /dev/md0


This is all in software RAID in Linux. Hope you like this.Please comment and suggestion require for motivation and improvement.





Sunday, 27 January 2013

Configuration of IP addresh in RHEL

How to assign IP address to RHEL machine

 
first to check the configuration file.
 
 # ls ifcfg-et*
    ifcfg-eth0
file will start with ifcfg-* , Here we have "ifcfg-eth0"
 
Now edit this file by using "vi editor" ( to know details about "vi" please read previous blog) .
 
# vi ifcfg-eth0
DEVICE=eth0                                                           : divice name of network card
HWADDR=08:00:27:25:f6:f0                                   : MAC address
ONBOOT=yes                                                            : It will start automatically after boot (yes)
IPADDR=192.168.80.10                                            : IP address of system
BOOTPROTO=none                                                  : DHCP off
NETMASK=255.255.255.0                                        : subnet mask of machine
TYPE=Ethernet                                                           : Type of LAN
GATEWAY=192.168.80.1                                         : Gateway of machine
IPV6INIT=no                                                              : IP version 6 disable
After this start/restart the network service
 
/etc/init.d/network restart
 
# /etc/init.d/network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
#
To check the assign IP address use "ifconfig"
 
# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 08:00:27:25:F6:F0
          inet addr:192.168.80.10  Bcast:192.168.80.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe25:f6f0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:54022 errors:0 dropped:0 overruns:0 frame:0
          TX packets:936 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3276156 (3.1 MiB)  TX bytes:145609 (142.1 KiB)
 
 
 
 

VI editor in RHEL 6

How to use VI editor..

To open a file use vi <filename>

e.g.

# vi test

use following key to edit the file by vi

i - insert the text at current cursor position.
I - insert the text at beginning of line.
a - appends the text after cuurent cursor position.
A - appends the text at end of line.
o - inserts a line below currnet cursor position.
O - inserts a line above currnet cursor position.
r - replace a single char at current cursor position.

Commands at execute mode

:q             - quit without saving
:q!           - quit forcefully without saving
:w            - save
:wq!         - save & quit forcefully
:x             - save & quit
:sh           - providing temporary shell
:se nu      - setting line number
:se nonu   - removing line number

Saturday, 26 January 2013

Commands for Linux Part 5

Basic command for Linux Part 5

12) To Search a word and file from single or multiple files's


For word use grep command

Option 1:

   #command word (to be search) files (from you are searching)

example :
# grep gdm /etc/passwd /etc/group /etc/shadow
/etc/passwd:gdm:x:42:42::/var/lib/gdm:/sbin/nologin
/etc/group:gdm:x:42:
/etc/shadow:gdm:!!:15727::::::

 Option 2 :

#cat (for read or open the file) file (from you are searching) | (pipe) word (to be search)

example :

# cat /etc/passwd |grep gdm
gdm:x:42:42::/var/lib/gdm:/sbin/nologin


For file use find command

find - search for files in a directory

#command (find) file (from you are searching) Synopsis (here using name means by name we are searching) file (to be search)

example:

#find /etc/ -name passwd
/etc/pam.d/passwd
/etc/passwd


continue..
 

Basic command for Linux Part 4

Basic command for Linux Part 4

10) To copy files and directories

 cp - copy files and directories

#cp <source>  <destination>

To copy file:

example:
# cp test /root/
# cd /root/
# ll test
-rw-r--r--. 1 root root     0 Jan 23 03:04 test
To copy folders

#cp -r dirtest/ /test/

11) To move directories and files

 mv - move (rename) files

DESCRIPTION ;
       Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

# mv dirtest/ /root/dirtest/
# cd /root/dirtest/
# ll
total 4
drwxr-xr-x. 2 root root 4096 Jan 23 03:08 dirtest
[#
To rename the file or directories :

# mv dirtest test
# ll
total 4
drwxr-xr-x. 2 root root 4096 Jan 23 03:08 test

continue....

Sunday, 20 January 2013

Basic command for Linux Part 3

 Basic command for Linux Part 3


8) Creating a single directory

#mkdir test

To creating multiple directories

#mkdir test test1 test2 test3

To create neated directories

#mkdir -p test1/test2/test3/test4

To see the tree structure

#ls -R test
test1:
test2

test1/test2:
test3

test1/test2/test3:
test4

test1/tes2/test3/test4
#


9) To change the directory

go to the directory

#cd test1

Back to previous directory

#cd ..

Go to the one more down

#cd ../..

To check present working directory

#pwd

10)  To remove files

#rm test1
to remove regular file "test1" ? y

To remove empty file

#rmdir test

To remove a dirctory

#rm -rf test

continue....

Saturday, 19 January 2013

Basic command for Linux Part 2

Basic command for Linux Part 2

 
6) How to see file stating with word e.g f
 
#ls f*
 
 To see a file have middle string as disk

#ls /bin/*disk*

To see a file whose length is 3 characters

 #ls ???

To see a file which start with single char & end up with nay number of character

#ls ?edh*


7) How to create a file

#cat > test

how to see file content

#cat test

to append a file

#cat >> test

How to create a emply file

# touch test1

How to create multiple  file with one command

#touch test2 test3 test4  ... so on


continue....
 

Commands for Linux Part 1

Basic command for Linux Part1


1) To check the present working directory

#pwd

Example :

[root@test7 ~]# pwd
/root

2) To show contents of directory (folder)

#ls

Example:

[root@test7 ~]# ls
anaconda-ks.cfg  Desktop  install.log  install.log.syslog
[root@test7 ~]#
3) to see more details including the permission regarding the contents of directory (Folder)

#ls -l or #ll

Example:

[root@test7 ~]# ls -l
total 60
-rw------- 1 root root  1131 Dec 25 14:16 anaconda-ks.cfg
drwxr-xr-x 2 root root  4096 Dec 25 14:28 Desktop
-rw-r--r-- 1 root root 36541 Dec 25 14:16 install.log
-rw-r--r-- 1 root root  3684 Dec 25 14:15 install.log.syslog
[root@test7 ~]#

[root@test7 ~]# ll
total 60
-rw------- 1 root root  1131 Dec 25 14:16 anaconda-ks.cfg
drwxr-xr-x 2 root root  4096 Dec 25 14:28 Desktop
-rw-r--r-- 1 root root 36541 Dec 25 14:16 install.log
-rw-r--r-- 1 root root  3684 Dec 25 14:15 install.log.syslog
[root@test7 ~]#

4) To see all contents including hidden files of a drectory (Folder)

#ls -a

Example:

[root@test7 ~]# ls -a
.                .bash_history  .bashrc  .dmrc     .gconfd  .gnome2_private    .ICEauthority       .metacity  .tcshrc
..               .bash_logout   .cshrc   .eggcups  .gnome   .gstreamer-0.10    install.log         .nautilus  .Trash
anaconda-ks.cfg  .bash_profile  Desktop  .gconf    .gnome2  .gtkrc-1.2-gnome2  install.log.syslog  .redhat    .xsession-errors

5) to see tree structure of nested directories

#ls -R

Example:
[root@test7 ~]# ls -R Desktop/
Desktop/:
test
Desktop/test:
test1
Desktop/test/test1:
[root@test7 ~]#

continue........

Thursday, 17 January 2013

How to change the Linux server name (hostname) ..

How to change the Linux server name (hostname) ..

To set the hostname just type the command hostname with name of server

# hostname test7

to check the hostname of server

[root@localhost ~]# hostname
test7
[root@localhost ~]#
Now this is not permanent , once you reboot the system it will change to previous name.

To set permanent hostname put the enytry in /etc/sysconfig/network file

#vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=test7
wq!
#
 

how to get the Linux OS version

how to get the Linux OS version...


To get the Linux OS version just follow any one method


1) Read the /etc/redhat-release file

[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
[root@localhost ~]#
2) use lsb_release command

[root@localhost ~]# lsb_release -a
LSB Version:    :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Release:        5.5
Codename:       Tikanga
[root@localhost ~]#
3) by  /etc/issue file

[root@localhost ~]# cat /etc/issue
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Kernel \r on an \m
[root@localhost ~]#

Here OS version is RHEL 5.5

First option is best to get correct information : # cat /etc/redhat-release

Wednesday, 16 January 2013

YUM server configuration in Linux step by step

How to configure YUM server in Linux


First of all mount your Linux OS iso on your system. for this insert the DVD and follow the followig process

1) mount the DVD

#mount /dev/dvd /mnt

2)After mounting the DVD type df -hT command to check the status of DVD mount

#df -h

3)Than go to the directory.Check is there any file exist with name of .repo

#cd /etc/yum.repos.d
#ls -ltr


4)if not  create a file with name of .repo, here we are creating with name of yum.repo .

#touch yum.repo

5) edit the .repo file with fillowing details ( we are using minimum requirment)

[root@localhost yum.repos.d]# cat yum.repo
[Server]
name=server
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
#
Note : /mnt/Server : is location where rpm repository is available or created by default in OS iso it is present in "Server" direcotry

6) Than clean the existing setting and update it with new one
#yum clean all
#yum list
7) Finally you have Yum server to install your packages

#yum install package name




Tuesday, 15 January 2013

Softlink & Hard Link


Difference between Softlink & Hard Link

 
Hardlink :-

1.        Hard link works with same inode number on source & destination files

2.        The size of shortcut file same as equal to original file

3.        Hard link can be only in same file system

4.        if shortcut file removed then data will be persistent or available

5.        Hardlink only create for files not directories

Softlink :-

1     Softlink  link works with different  inode number on source & destination files

2.       The size of shortcut file is total number of character in path

3.       Softlink link can be in different or network  file system

4.       if shortcut file removed then data will be lost

5.      softlink can be create on both files or directory

What command can you use to review boot messages in Linux

What command can you use to review boot messages in Linux

#dmesg or #dmesg |more (for page vise view)

The dmesg command displays the system messages contained in the kernel ring buffer. By using this command immediately after booting your computer, you will see the boot messages.

Monday, 14 January 2013

how to get the Linux server hardware information (hardware vender Serial number , model numbre , BIOS details etc)

how to get the serial number of Linux machine..


Run the below command
 
#dmidecode |more
 
It will show you hardware information and serial number of Linux machine..
 
serial number will come under the tab of system information.

This is a very useful tool from this you will get the all the system details : hardware vender Serial number , model numbre , BIOS details etc.

 

Sunday, 13 January 2013

Monitoring tools for system performance in Linux

How to monitor system performance in Linux


 
#1: top - Process Activity Command
#2: vmstat - System Activity, Hardware and System Information
#3: w - Find Out Who Is Logged on And What They Are Doing
#4: uptime - Tell How Long The System Has Been Running
#5: ps - Displays The Processes
#6: free - Memory Usage

How to configure password policy in Linux

How to configure password policy in Linux 


Configure Password Policy

#vi /etc/login.defs
 
Edit the file as follows:
 
PASS_MAX_DAYS 42
PASS_MIN_DAYS 7
PASS_MIN_LEN 8
PASS_WARN_AGE 14
 
Type ESC:x! to save and exit

Types of files in Linux and how can we check..

How many types of files in Linux and how can we check..


Just type ls -ltr.. it will show you the list of file and at first column you will see following word

#ls -ltr
....




d = directory
- = regular file
l = symbolic link
s = Unix domain socket
p = named pipe
c = character device file
b = block device file

Saturday, 12 January 2013

Disabling Graphical mode in RHEL

How to disable X Windows at System Boot in Linux


# vi /etc/inittab

Find line:
id:5:initdefault:
Replace with:
id:3:initdefault:
Save and close the file. Restart the server. You can also drop to text mode by typing init command "

# init 3

Friday, 11 January 2013

error :skiping packages broken with dependency in yum


How to handle skiping packages with dependency problems in yum linux

# yum -y upgrade --skip-broken
OR
# yum -y update --skip-broken

"NO KEY error" in YUM installtion in RHEL 6

"NO KEY error" in  YUM

How to resolve NO KEY error in installation through YUM in Linux.

 
# find / -name "*GPG*"
#rpm --import *GPG* (from where you have put rpm and repo.)
 
than try to run yun install your problem should resolve :-)