How to Use Mdadm to establish Raid5 storage in CentOS 4.4

Source: Internet
Author: User
Tags hex code

 

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. Run the fdisk-l command. 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 the four hard disks, and run the command fdisk-l to check again. You can see that the 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

Umount is required before stopping, 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. conf configuration file. You can also run the command mdadm-Ds to view the 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 details, refer to the 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.