首页 > 代码库 > Linux RAID 1

Linux RAID 1

磁盘管理RAID1

 

POC环境

linux上添加2块新的30GB硬盘启动

wKiom1PtkdHiSLicAACAaqOUmpE700.gif

cat /etc/redhat-releasecat

 

Name        : mdadm                        Relocations: (not relocatable)
Version     : 3.2.5                             Vendor: Red Hat, Inc.
Release     : 4.el6                         Build Date: Fri 07 Dec 2012 12:14:45 AM CST
Install Date: Fri 01 Aug 2014 06:07:09 PM CST      Build Host: x86-003.build.bos.redhat.com
Group       : System Environment/Base       Source RPM: mdadm-3.2.5-4.el6.src.rpm
Size        : 860588                           License: GPLv2+
Signature   : RSA/8, Mon 28 Jan 2013 10:48:06 PM CST, Key ID 199e2f91fd431d51
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL         : http://www.kernel.org/pub/linux/utils/raid/mdadm/
Summary     : The mdadm program controls Linux md devices (software RAID arrays)
Description :
The mdadm program is used to create, manage, and monitor Linux MD (software
RAID) devices.  As such, it provides similar functionality to the raidtools
package.  However, mdadm is a single program, and it can perform
almost all functions without a configuration file, though a configuration
file can be used to help with some common tasks.

操作

分区

 

 fdisk -l

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: 0x00000000

 

 

Disk /dev/sdc: 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: 0x00000000

 

创建目录,将光盘挂载到目录下,进入sdb硬盘

wKiom1PtklOi-8BeAAA86mQsso4888.gif

 

 

 进入硬盘创建sdb1 查看

Fdisk /dev/sdb1

wKiom1PtkwKiXFCdAAAXukh0uoM712.gif

/dev/sdc进行操作

 

fdisk -l /dev/sdc

 

Disk /dev/sdc: 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: 0x8f7a12ed

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1        1        3916    31455238+  fd  Linux raid autodetect

 

 

进入挂载目录安装rpm mdadm

cd /mnt/packages

wKiom1Ptky3AKwaYAABOK9GD1t4456.gif

 

 

建立RAID1

使sdb1 sdc1 阵列

mdadm -C /dev/md0 -l 1 -n 2 /dev/sdb1 /dev/sdc1

wKioL1PtlGbhwtdoAABjvRbPNZ4422.gif

进入查看是否建立成功

Cat  /proc/mdstart

wKioL1PtlIWiwi2KAAA_53y9VnU595.gif

 

 

 

 

 

 

 创建文件系统

格式化该磁盘阵列

mkfs.ext4 /dev/md0

wKioL1PtlOjTsYa1AAByMNA0owc154.gif

 

创建目录DATA

Mkdir /mnt/data

wKiom1Ptk-eT6zPGAAA7vT_C3jk864.gif

md0挂载到data

Mount /dev/md0 /mnt/DATA

 

wKioL1PtlR6j6kvdAABN9bE1VmE871.gif

 

 

 

在文件fatab下追加内容

vi /etc/fstab

/dev/md0         /data         ext4    defaults        0 0

 

wKiom1PtlCjRTV6DAABiZZl1v9k958.gif

写入配置文件

mdadm -Ds >> /etc/mdadm.conf

 wKioL1PtlV3Q_FPWAAA6vNpd8Zo234.gif

 

重新启动

 reboot