Linux raid1 build tutorial

Source: Internet
Author: User

Linux raid1 environment setup and usage instructions

  1. Why should I build the linuxraid1 environment?

Linux raid1 is the most common Hard Disk redundancy backup solution for Linux servers. It can ensure the security of hard disk data when the hard disk is damaged. Of course, the premise is that at least one hard disk is good. It is often used together with the reiserfs software to fully ensure the stability of the Linux Server (raid1 physically performs real-time hot backup of hard disk data, and reiserfs logically backs up the file system ).

  1. How to build a Linux raid1 Environment

  1. Prepare at least two hard disks for RAID 1, preferably two hard disks of the same type and capacity.

  2. Use fdisk to partition the hard disk (use SDA as an example)

# Fdisk/dev/SDA

# M (you can enter the M command to obtain help information)

# N (Add a new partition, select the primary partition type, and then select the start and end positions of the partition. if you want

If the disk is divided into one partition, select default for all partitions)

# T (to change the partition type, enter the letter L to obtain the list of types. Here we select FD, that is, linuxraid

Auto type)

# W (save and Exit)

  1. Download and install the disk array management tool mdadm

# Yum install mdadm

  1. Use mdadm to create and manage Disk Arrays

# Mdadm -- create -- Auto = Yes/dev/md0 -- level = 1 -- raid-devices = 2 -- spare-devices = 1

/Dev/sda1/dev/sdb1/dev/sdc1

The number of disks is 1. If any of the disk arrays is damaged, the backup disk automatically

You can also use a backup disk instead of a backup disk,

Let's change and synchronize the data manually)

# Mkfs-T ext3/dev/md0 (create a file system and use a disk array like a hard disk)

# Mount/dev/md0/mnt (Mount disk array)

  1. You can use the following command to view the disk array status

# Cat/proc/mdstat (or the following command can also be used)

# Mdadm -- detail/dev/md0

  1. Set the disk array to auto-mount upon startup

# Mdadm-d-s>/etc/mdadm. conf (Save the disk array information to the configuration file first, otherwise the system starts

/Dev/md127)

# Vi/etc/fstab (edit the fstab file and add the following script)

/Dev/MD5/mnt ext3 defaults 00

  1. How do I delete a disk array?

# Mdadm/dev/md0 -- f ail/dev/sda1 -- remove/dev/sda1

# Mdadm/dev/md0 -- f ail/dev/sdb1 -- remove/dev/sdb1 (Mark sda1 disk as bad disk and

Remove)

# Mdadm -- stop/dev/md0

# Mdadm -- zero-superblock/dev/sda1

# Mdadm -- zero-superblock/dev/sdb1 (clear the raid flag in the disk)

  1. If a hard disk breaks down, how can we manually replace and synchronize data?

# Mdadm/dev/md0 -- f ail/dev/sda1 -- remove/dev/sda1 (Mark sda1 disk as bad disk and

Remove)

# Mdadm/dev/md0 -- add/dev/sdc1

New Hard Disk Partition. After the partition is completed, the data is automatically synchronized from sda1

Step to sdc1)

# Cat/proc/mdstat (check the MD status, which can be sync or Resync)

  1. If one hard disk breaks down, how can we take the remaining hard disk to another machine and read the data?

# Mdadm -- create -- Auto = Yes/dev/md0 -- level = 1 -- force -- raid-devices = 1/dev/sda1 (directly obtain

This hard disk is used to create a disk array with only one hard disk.

However, the first step is to install the hard disk on the machine)

# Mount/dev/md0/mnt

To see our data in the MNT directory)

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.