Disk management-RAID 1

Source: Internet
Author: User

1. What is RAID1?

RAID1, which can be called an image, writes data to multiple disks. For example, if A group of data is called A, data exists like this: A and A. In this way, data security is high, but performance is poor.

Two or more groups of N disks are used as images for each other. In some multi-threaded operating systems, the read speed is good, and the write speed is slightly reduced. Unless the primary disk and image with the same data are damaged at the same time, the operation can be maintained as long as a disk is normal, with the highest reliability. RAID 1 is an image. The principle is to store data on the primary hard disk and write the same data on the image hard disk. When the primary hard disk (physical) is damaged, the image hard disk replaces the primary hard disk. Because there is an image hard disk for data backup, the data security of RAID 1 is the best at all RAID levels. However, no matter how many disks are used as RAID 1, only the capacity of one disk is counted, which is the lowest level of disk utilization on all RAID.

Recommended reading:

Debian soft RAID Installation notes-use mdadm to install RAID1

Is RAID too hard?

Common RAID technology introduction and demo (Multi-chart)

The most common disk array in Linux-RAID 5

RAID0 + 1 and RAID5 Performance Test Results

2. RAID1 demonstration

Step 1: partition the disk

# Partition/dev/sdb
Root @ serv01 ~] # Fdisk/dev/sdb
# Partition/dev/sdc
Root @ serv01 ~] # Fdisk/dev/sdc
 
[Root @ serv01 ~] # Ls/dev/sdb
Sdb sdb1
[Root @ serv01 ~] # Ls/dev/sdc
Sdc sdc1

Step 2: Create RAID1

[Root @ serv01 ~] # Mdadm-C/dev/md1-l 1-n2/dev/sdb1/dev/sdc1
Mdadm:/dev/sdb1 appears to contain anext2fs file system
Size = 208812 K mtime = Wed Jul 3122: 17: 43 2013
Mdadm:/dev/sdb1 appears to be part of araid array:
Level = raid0 devices = 0 ctime = Thu Jan 1 07:00:00 1970
Mdadm: partition table exists on/dev/sdb1but will be lost or
Meaningless after creating array
Mdadm: Note: this array has metadata at thestart and
May not be suitable as a boot device. If you plan
Store'/boot' on this device please ensure that
Your boot-loader understands md/v1.x metadata, or use
-- Metadatabase = 0.90
Continue creating array? Y
Mdadm: Defaulting to version 1.2 metadata
Mdadm: array/dev/md1 started.
# Formatting
[Root @ serv01 ~] # Mkfs. ext4/dev/md1
Mke2fs 1.41.12 (17-May-2010)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
Stride = 0 blocks, Stripe width = 0 blocks
131072 inodes, 523853 blocks
26192 blocks (5.00%) reserved for the superuser
First data block = 0
Maximum filesystem blocks = 536870912
16 block groups
32768 blocks per group, 32768 fragments pergroup
8192 inodes per group
Superblock backups stored on blocks:
32768,98304, 163840,229 376, 294912
 
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystemaccounting information: done
 
This filesystem will be automaticallychecked every 36 mounts or
180 days, whichever comes first. Use tune2fs-c or-I to override.

Step 3 Mount

[Root @ serv01 ~] # Mount/dev/md1/web
[Root @ serv01 ~] # Cat/etc/fstab
 
#
#/Etc/fstab
# Created by anaconda on Tue Jul 2300: 54: 37 2013
#
# Accessible filesystems, by reference, aremaintained under '/dev/disk'
# See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info
#
UUID = 110fab7c-85c4-4bae-9114-98bc2ada24d8/ext4 ults 1 1
UUID = ab434325-bf02-48e9-8ce7-78494a8ac71e/boot ext4 ults 1 2
UUID = 02ed2b3b-b7e1-493d-9a43-8e1dcac8aa6f/opt ext4 ults 1 2
UUID = a088a35a-16d8-456a-a177-95c769c16e41swap swap defaults 0 0
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0

Step 4 modify the configuration file

# Append content to the/etc/fstab file
[Root @ serv01 ~] # Echo "/dev/md1/webext4 defaults 1 2">/etc/fstab
# View File Content again
[Root @ serv01 ~] # Cat/etc/fstab
 
#
#/Etc/fstab
# Created by anaconda on Tue Jul 2300: 54: 37 2013
#
# Accessible filesystems, by reference, aremaintained under '/dev/disk'
# See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info
#
UUID = 110fab7c-85c4-4bae-9114-98bc2ada24d8/ext4 ults 1 1
UUID = ab434325-bf02-48e9-8ce7-78494a8ac71e/boot ext4 ults 1 2
UUID = 02ed2b3b-b7e1-493d-9a43-8e1dcac8aa6f/opt ext4 ults 1 2
UUID = a088a35a-16d8-456a-a177-95c769c16e41swap swap defaults 0 0
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
/Dev/md1/web ext4 defaults 1 2
# Create the mdadm. conf file
[Root @ serv01 ~] # Mdadm -- detail-scan>/etc/mdadm. conf

Step 5 simulate hard disk failure

# Restart
[Root @ serv01 ~] # Reboot
# Copy content
[Root @ serv01 ~] # Cp/boot/*/web/-rvf
# Clear disk, o clear, and save
[Root @ serv01 ~] # Fdisk/dev/sdb
# Copy content
[Root @ serv01 ~] # Cp/etc/*/web/-rvf

# Restart
[Root @ larrywen Desktop] # ssh 192.168.1.11
Root@192.168.1.11's password:
Last login: Thu Aug 1 17:55:43 2013 from 192.168.1.1
[Root @ serv01 ~] # Cat/proc/mdstat
Personalities: [raid1]
Md1: active raid1 sdc1 [1] sdb1 [0]
2095415 blocks super 1.2 [2/2] [UU]

Unused devices: <none>
 
[Root @ larrywen Desktop] # ssh 192.168.1.11
Root@192.168.1.11's password:
Last login: Thu Aug 1 18:05:58 2013 from 192.168.1.1
# Viewing Status
[Root @ serv01 ~] # Cat/proc/mdstat
Personalities: [raid1]
Md1: active raid1 sdc1 [1]
2095415 blocks super 1.2 [2/1] [_ U]

Unused devices: <none>
 
[Root @ serv01 ~] # Mdadm -- detail/dev/md1
/Dev/md1:
Version: 1.2
Creation Time: Thu Aug 11:58:09 2013
Raid Level: raid1
Array Size: 2095415 (2046.65 MiB 2145.70 MB)
Used Dev Size: 2095415 (2046.65 MiB 2145.70 MB)
Raid Devices: 2
Total Devices: 1
Persistence: Superblock is persistent
 
Update Time: Thu Aug 1 :07:522013
State: clean, degraded
Active Devices: 1
Working Devices: 1
FailedDevices: 0
Spare Devices: 0
 
Name: serv01.host.com: 1 (localto host serv01.host.com)
UUID: a8930aef: a5ddcdde: 789a11bf: 40f7eed6
Events: 23
 
Number Major Minor RaidDevice State
0 0 0 0 removed
1 8 33 1 active sync/dev/sdc1
# Copy content
[Root @ serv01 web] # cp/boot/*.-rvf
[Root @ serv01 web] # mount
/Dev/sda2 on/type ext4 (rw)
Proc on/proc type proc (rw)
Sysfs on/sys type sysfs (rw)
Devpts on/dev/pts type devpts (rw, gid = 5, mode = 620)
Tmpfs on/dev/shm type tmpfs (rw, rootcontext = "system_u: object_r: tmpfs_t: s0 ")
/Dev/sda1 on/boot type ext4 (rw)
/Dev/sda5 on/opt type ext4 (rw)
/Dev/md1 on/web type ext4 (rw)
None on/proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/Dev/sr0 on/iso type iso9660 (ro)
[Root @ serv01 web] # df-h
Filesystem Size Used Avail Use % Mounted on
/Dev/sda2 9.7 GB 1.1G 8.1G 12%/
Tmpfs 188 M 0 188 M 0%/dev/shm
/Dev/sda1 194 M 25 M 160 M 14%/boot
/Dev/sda5 4.0G 137 M 3.7G 4%/opt
/Dev/md1 2.0G 54 M 1.9G 3%/web
/Dev/sr0 3.4G 3.4G 0 100%/iso

Next, let's take a look at the highlights of page 2nd:

  • 1
  • 2
  • Next Page

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.