How to use Mdadm to establish RAID 5 storage in CentOS4.4

Source: Internet
Author: User
Tags hex code
& Nbsp; 1. Environment 1. the operating system is CentOS4.4, and the mdadm software is provided by the system. the version is 1.6.0-32. hda is installed with four hard disks, sda, sdb, sdc, and sdd, which are raid 5. sdd is hot backup. II. Preparation 1. first, format the four SCSI hard disks. Input the command fdisk?  

I. environment

1. the operating system is CentOS4.4, and the mdadm software is provided by the system. the version is 1.6.0-3.

2. hda is installed with four hard disks, sda, sdb, sdc, and sdd, which are raid 5. sdd is hot backup.

2. preparation

1. first, format the four SCSI hard disks. Input the command fdisk? L. The system displays information about sda, sdb, sdc, and sdd, and prompts that the disk does not contain a valid partition table.

2. [root @ centos/] # fdisk/dev/sda

Command (m for help): n # enter the letter n to add a new partition.

Command action

E extended

P primary partition (1-4)

P # Create a primary partition.

Partition number (1-4): 1 # you can create four primary partitions. enter 1 here to create the first Partition.

First cylinder (1-1044, default 1): # because the hard disk is divided into one partition, press enter by default.

Using default value 1

Last cylinder or + size or + sizeM or + sizeK (1-1044, default 1044 ):

Using default value 1044

Command (m for help): t # Change the partition's file system ID.

Selected partition 1

Hex code (type L to list codes): fd # fd Linux raid auto

Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): w # save and exit

3. follow the steps above to process four hard disks. then, run the command fdisk? L check again. we can see that four hard disks have been prepared.

III. configuration

1. creating raid is very simple. you only need one command.

[Root @ centos/] # mdadm-C-v/dev/md0-l5-n3/dev/sda1/dev/sdb1/dev/sdc1-x1/dev/sdd1

# See the help mdadm -- create -- help

Mdadm: layout defaults to left-connected Ric

Mdadm: chunk size defaults to 64 K

Mdadm: size set to 8388544 K

Mdadm: array/dev/md0 started.

[Root @ centos/] #

2. create a file system as ext3

[Root @ centos/] # mkfs. ext3/dev/md0

Create directory/mnt/raid and Mount

[Root @ centos/] # mkdir/mnt/raid

[Root @ centos/] # mount/dev/md0/mnt/raid

3. understand raid status

[Root @ centos/] # mdadm-D/dev/md0

4. start and stop

Before stopping, you need umount and then mdadm? S/dev/md0

Start: [root @ centos/] # mdadm-A/dev/md0/dev/sda1/dev/sdb1/dev/sdc1/dev/sdd1

If a configuration file has been created, run the command mdadm? As/dev/md0

5. about the configuration file

The system contains a configuration file sample/usr/share/doc/mdadm-1.6.0/mdadm. conf-example, refer to create/dev/mdadm. in the conf configuration file, you can also run the command mdadm? Ds to view details, and then use vi to edit and save the text file

[Root @ centos/] # vi/etc/mdadm. conf

DEVICE/dev/sd [abcd] 1

ARRAY/dev/md0 level = raid5 num-devices = 3 UUID = 63cb965b: 79486986: d389c551: 67677f20

To enable the system to automatically mount the raid directory after reboot, you need to modify the/etc/fstab file and add the following line:/dev/md0/mnt/raid ext3 defaults 0 0

IV. fault testing

1. create a file under/mnt/radi before testing

[Root @ centos raid] # ll/| tee./ls.txt

The mdadm built-in command can mark a hard disk as damaged. For more information, see "help mdadm -- manage? H.

The sda hard disk is damaged during the fault test.

[Root @ centos/] # mdadm/dev/md0-f/dev/sda1

Mdadm: set/dev/sda1 faulty in/dev/md0

2. view the status

[Root @ centos/] # more/proc/mdstat

Personalities: [raid5]

Md0: active raid5 sdd1 [3] sdc1 [2] sdb1 [1] sda1 [4] (F)

16771584 blocks level 5, 64 k chunk, algorithm 2 [3/2] [_ UU]

[===>...] Recovery = 22.8% (1916928/8385792) finish = 1.9 min speed = 55892 K/sec

Unused devices:

[Root @ centos/] #

Because the sdd hard disk is hot standby, the system displays the raid reconstruction progress of 22.8%, and the sda1 mark (F ).

Wait and check again:

[Root @ centos/] # more/proc/mdstat

Personalities: [raid5]

Md0: active raid5 sdd1 [0] sdc1 [2] sdb1 [1] sda1 [3] (F)

16771584 blocks level 5, 64 k chunk, algorithm 2 [3/3] [UUU]

Unused devices:

[Root @ centos/] # mdadm-D/dev/md0

/Dev/md0:

Version: 00.90.01

Creation Time: Fri Jun 1 13:00:31 2007

Raid Level: raid5

Array Size: 16771584 (15.99 GiB 17.17 GB)

Device Size: 8385792 (7.100 GiB 8.59 GB)

Raid Devices: 3

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.