Two 30 GB hard disks for RAID 1

Source: Internet
Author: User

In this experiment, we need to add two new 30 GB hard disks.

[[Email protected] ~] # Uname-


Linux zzsrv1.localdomain 3.10.0-123. el7.x86 _ 64 #1 SMP mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux


We can display the disk without restarting it.

[[Email protected] ~] # Echo "---">/sys/class/scsi_host/host0/scan

[[Email protected] ~] # Echo "---">/sys/class/scsi_host/host1/scan

[[Email protected] ~] # Echo "---">/sys/class/scsi_host/host2/scan

View Disks

[[Email protected] ~] # Fdisk-l


Disk/dev/SDA: 42.9 GB, 42949672960 bytes, 83886080 sectors

Units = sectors of 1*512 = 512 bytes

Sector size (logical/physical): 512 bytes/512 bytes

I/O size (minimum/optimal): 512 bytes/512 bytes

Disk label type: DoS

Disk identifier: 0x0003747c


Device boot start end blocks ID system

/Dev/sda1*2048 1026047 512000 83 Linux

/Dev/sda2 1026048 83886079 41430016 8e Linux LVM


Disk/dev/SDB: 32.2 GB, 32212254720 bytes, 62914560 sectors

Units = sectors of 1*512 = 512 bytes

Sector size (logical/physical): 512 bytes/512 bytes

I/O size (minimum/optimal): 512 bytes/512 bytes



Disk/dev/SDC: 32.2 GB, 32212254720 bytes, 62914560 sectors

Units = sectors of 1*512 = 512 bytes

Sector size (logical/physical): 512 bytes/512 bytes

I/O size (minimum/optimal): 512 bytes/512 bytes


Install mdadm

[[Email protected] ~] # Mount/dev/CDROM/mnt/CDROM/

[[Email protected] ~] # Cd/mnt/CDROM/packages/

[[Email protected] packages] # ls mdadm *

Mdadm-3.2.6-31.el7.x86_64.rpm


[[Email protected] packages] # rpm-IVH mdadm-3.2.6-31.el7.x86_64.rpm

Warning: mdadm-3.2.6-31.el7.x86_64.rpm: Header V3 RSA/sha256 signature, key ID f4a80eb5: nokey

Preparing... ################################### [100%]

Package mdadm-3.2.6-31.el7.x86_64 is already installed


Partition a disk

[[Email protected] packages] # fdisk/dev/SDB

[[Email protected] packages] # fdisk/dev/SDC


Create raid1 volume

[[Email protected] ~] # Mdadm-CV/dev/md0-L1-N2/dev/sdc1/dev/sdb1

Mdadm:/dev/sdc1 appears to contain an ext2fs File System

Size = 31456256 K mtime = Thu Jan 1 08:00:00 1970

Mdadm: Note: This array has metadata at the start 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

Mdadm:/dev/sdb1 appears to contain an ext2fs File System

Size = 31456256 K mtime = Thu Jan 1 08:00:00 1970

Mdadm: size set to 31439744 K

Continue creating array? (Y/n) y

Mdadm: defaulting to version 1.2 metadata

Mdadm: array/dev/md0 started.


[[Email protected] ~] # Cd/

[[Email protected]/] # Cat/proc/mdstat

Personalities: [raid1]

Md0: Active raid1 sdb1 [1] sdc1 [0]

31439744 blocks super 1.2 [2/2] [UU]

[========> ...... Resync = 41.6% (13101184/31439744) finish = 1.5 min speed = 199772 K/sec


Unused devices: <none>


Format a raid volume

[[Email protected] packages] # mkfs. ext4/dev/md0

Mke2fs 1.42.9 (28-dec-2013)

Filesystem label =

OS type: Linux

Block size = 4096 (log = 2)

Fragment size = 4096 (log = 2)

Stride = 0 blocks, stripe width = 0 blocks

1310720 inodes, 5238496 Blocks

261924 blocks (5.00%) reserved for the Super User

First data block = 0

Maximum filesystem blocks = 2153775104

160 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768,983 04, 163840,229 376, 294912,819 200, 884736,160 5632, 2654208,

4096000


Allocating group tables: Done

Writing inode tables: Done

Creating Journal (32768 blocks): Done

Writing superblocks and filesystem accounting information: Done



[[Email protected] packages] # mkdir/Data

[[Email protected] packages] # Mount/dev/md0/Data

[[Email protected] packages] # ll/data/

Total 16

Drwx ------ 2 root Root 16384 Aug 15:31 lost + found

[[Email protected] packages] # mdadm-Ds

Array/dev/md0 metadata = 1.2 name = zzsrv1.localdomain: 0 UUID = c2fe6a35: 461511e9: 7e9bf672: 9baeb95c

[[Email protected] packages] # mdadm-DS>/etc/mdadm. conf



[[Email protected] packages] # vi/etc/fstab

Add at last

/Dev/md0/Data ext4 defaults 0 0


[[Email protected] packages] # mdadm-Ds

Array/dev/md0 metadata = 1.2 name = zzsrv1.localdomain: 0 UUID = c2fe6a35: 461511e9: 7e9bf672: 9baeb95c

[[Email protected] packages] # mdadm-DS>/etc/mdadm. conf


[[Email protected] packages] # reboot

[[Email protected] ~] # Mount

/Dev/mapper/VolGroup-lv_root 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)

/Dev/sda1 on/boot type ext4 (RW)

/Dev/md0 on/Data Type ext4 (RW)

None on/proc/sys/fs/binfmt_misc type binfmt_misc (RW)


[[Email protected] ~] # Cat/proc/mdstat

Personalities: [raid1]

Md0: Active raid1 sdb1 [0] sdc1 [1]

31438720 blocks super 1.2 [2/2] [UU]


Unused devices: <none>


We can simulate faults.

Delete A 30 GB hard disk

It may take a while to view the log


SD 2: 0: 1: 0: [SDB] unhandled error code

SD 2: 0: 1: 0: [SDB] Result: hostbyte = did_no_connect driverbyte = driver_ OK

SD 2: 0: 1: 0: [SDB] CDB: Write (10): 2a 00 00 00 00 47 00 00 01 00

MD: super_written gets error =-5, uptodate = 0

MD/raid1: md0: disk failure on sdb1, disabling device.

MD/raid1: md0: Operation Continuing on 1 devices.

Raid1 conf printout:

--- WD: 1 RD: 2

Disk 0, Wo: 1, O: 0, Dev: sdb1

Disk 1, Wo: 0, O: 1, Dev: sdc1

Raid1 conf printout:

--- WD: 1 RD: 2

Disk 1, Wo: 0, O: 1, Dev: sdc1

SD 2: 0: 1: 0: [SDB] unhandled error code

SD 2: 0: 1: 0: [SDB] Result: hostbyte = did_no_connect driverbyte = driver_ OK

SD 2: 0: 1: 0: [SDB] CDB: Write (10): 2a 00 00 00 00 47 00 00 01 00

MD: super_written gets error =-5, uptodate = 0

MD/raid1: md0: disk failure on sdb1, disabling device.

MD/raid1: md0: Operation Continuing on 1 devices.



[[Email protected] ~] # Cat/proc/mdstat

Personalities: [raid1]

Md0: Active raid1 sdb1 [0] (f) sdc1 [1]

31438720 blocks super 1.2 [2/1] [_ u]


Unused devices: <none>


If a fault occurs, we need to reconstruct raid1.

Simulate recovery and add a new 30 GB hard disk


[[Email protected] ~] # Fdisk-L/dev/SDB


Disk/dev/SDB: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 Cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Sector size (logical/physical): 512 bytes/512 bytes

I/O size (minimum/optimal): 512 bytes/512 bytes

Disk identifier: 0x9b6ff607


Device boot start end blocks ID system

/Dev/sdb1 2048 62914559 31456256 83 Linux



Add new component online



[[Email protected] ~] # Mdadm/dev/md0-A/dev/sdb1

Mdadm: added/dev/sdb1

[[Email protected] ~] # Cat/proc/mdstat

Personalities: [raid1]

Md0: Active raid1 sdb1 [2] sdc1 [1]

31438720 blocks super 1.2 [2/1] [_ u]

[=> ......] Recovery = 7.0% (2201920/31438720) finish = 2.4 min speed = 200174 K/sec


Unused devices: <none>


In the log, we can see the reconstruction process.

MD: bind <sdb1>

MD: Recovery of RAID array md0

MD: Minimum _ guaranteed _ speed: 1000 kb/SEC/disk.

MD: using maximum available idle Io bandwidth (but not more than 200000 KB/sec) for recovery.

MD: Using 128 K window, over a total of 31438720 K.

MD: md0: Recovery done.


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.