Use mdadm in CentOS4.4 to establish Raid5

Source: Internet
Author: User
Tags hex code
In CentOS4.4, use mdadm to create Raid5 -- Linux Enterprise Application-Linux server application information. The following is a detailed description. 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

Total Devices: 4

Preferred Minor: 0

Persistence: Superblock is persistent



Update Time: Fri Jun 1 13:23:49 2007

State: clean

Active Devices: 3

Working Devices: 3

Failed Devices: 1

Spare Devices: 0



Layout: left-lateral ric

Chunk Size: 64 K



Number Major Minor RaidDevice State

0 8 49 0 active sync/dev/sdd1

1 8 17 1 active sync/dev/sdb1

2 8 33 2 active sync/dev/sdc1

3 8 1-1 faulty/dev/sda1

UUID: 63cb965b: 79486986: d389c551: 67677f20

Events: 0.16 [root @ centos/] #

3. Remove the damaged hard disk

[Root @ centos/] # mdadm/dev/md0-r/dev/sda

Mdadm: hot removed/dev/sda

[Root @ centos/] #

So far, we can take down damaged hard disks.

4. Add a new hard disk to raid

In the new hard disk access system, correct partitioning should be performed, and it is best to keep the same device number as the previous hard disk replacement. Then execute the command

[Root @ centos/] # mdadm/dev/md0-a/dev/sda

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.