RHEL5上制作软件RAID 并在软件RAID基础上做LVM(3)

-x(--spare-devices=)参数指定冗余磁盘的数量。另外,对于full的阵列(例如已经有2个磁盘的RAID1),则直接使用-add参数,mdadm会自动把冗余的磁盘作为spare disk。

7.删除RAID

#mdadm -S /dev/md0

#rm /dev/md0

删除/etc/mdadm.conf文件;去除/etc/fstab文件中相关的行。

最后,用fdisk对磁盘进行重新分区。

 

三 RAID之上建立LVM

1.前面还有一个/dev/sde没有处理,下面先把它建立成一个RAID1

[root@ ~]# fdisk /dev/sde

The number of cylinders for this disk is set to 1044.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sde: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-1044, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): +5000M

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (610-1044, default 610):

Using default value 610

Last cylinder or +size or +sizeM or +sizeK (610-1044, default 1044):

Using default value 1044

Command (m for help): p

Disk /dev/sde: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sde1 1 609 4891761 83 Linux

/dev/sde2 610 1044 3494137+ 83 Linux

Command (m for help): t

Partition number (1-4): 1

Hex code (type L to list codes): fd

Changed System type of partition 1 to fd (Linux raid autodetect)

Command (m for help): t

Partition number (1-4): 2

Hex code (type L to list codes): fd

Changed System type of partition 2 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/sde: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sde1 1 609 4891761 fd Linux raid autodetect

/dev/sde2 610 1044 3494137+ fd Linux raid autodetect

Command (m for help): w

The partition table has been

Calling ioctl() to re-read partition table.

Syncing disks.

 

完成分区后,执行:

[root@ dev]# cd /dev/

[root@ dev]# ls -l md0

brw-r----- 1 root disk 9, 0 Aug 1 21:58 md0

[root@ dev]# mknod md1 b 9 1

[root@ dev]# mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sde1 /dev/sde2

mdadm: largest drive (/dev/sde1) exceed size (3494016K) by more than 1%

Continue creating array? y

mdadm: array /dev/md1 started.

 

好了,RAID1也做完了,验证一下

[root@ dev]# mdadm -Ds

ARRAY /dev/md0 level=raid5 num-devices=3 UUID=28a22990:eac5c231:3fe907f1:1145e264

ARRAY /dev/md1 level=raid1 num-devices=2 UUID=57f24dd1:aed3606c:d467132e:a6b3a010

 

2. 开始建立LVM

首先确保/dev/md0已经卸载,使用#umount /mnt/software

(1)创建PV

[root@ ~]# pvcreate /dev/md0

Physical volume "/dev/md0" successfully created

[root@ ~]# pvcreate /dev/md1

Physical volume "/dev/md1" successfully created

[root@ ~]# pvdisplay

--- Physical volume ---

PV Name /dev/sda2

VG Name VolGroup00

PV Size 13.90 GB / not usable 21.45 MB

Allocatable yes (but full)

PE Size (KByte) 32768

Total PE 444

Free PE 0

Allocated PE 444

PV UUID BntsgG-UJLv-agT2-lZ7C-dXY2-51FB-Jxd5tA

--- NEW Physical volume ---

PV Name /dev/md0

VG Name

PV Size 16.00 GB

Allocatable NO

PE Size (KByte) 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID GriJk2-wyfl-o0CI-NY7t-g75X-zIx3-FJHf1u

--- NEW Physical volume ---

PV Name /dev/md1

VG Name

PV Size 3.33 GB

Allocatable NO

PE Size (KByte) 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID SImCO1-RmvK-OgfZ-dCFZ-LJNC-8wun-Bd9qzS

 

(2)创建VG

[root@ ~]# vgcreate LVMonRaid /dev/md0 /dev/md1

Volume group "LVMonRaid" successfully created

[root@ ~]# vgscan

Reading all physical volumes. This may take a while...

Found volume group "VolGroup00" using metadata type lvm2

Found volume group "LVMonRaid" using metadata type lvm2

 

创建了一个LVMonRaid的卷组。

(3)创建LV

[root@ ~]# lvcreate --size 5000M --name LogicLV1 LVMonRaid

Logical volume "LogicLV1" created

[root@ ~]# lvcreate --size 5000M --name LogicLV2 LVMonRaid

Logical volume "LogicLV2" created

[root@ ~]# lvscan

ACTIVE '/dev/VolGroup00/LogVol00' [12.88 GB] inherit

ACTIVE '/dev/VolGroup00/LogVol01' [1.00 GB] inherit

ACTIVE '/dev/LVMonRaid/LogicLV1' [4.88 GB] inherit

ACTIVE '/dev/LVMonRaid/LogicLV2' [4.88 GB] inherit

注:上面两条记录是装系统时默认创建的。

 

(4)格式化创建文件系统,并挂载使用

[root@ ~]# mkfs.ext3 /dev/LVMonRaid/LogicLV1

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

640000 inodes, 1280000 blocks

64000 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1312817152

40 block groups

32768 blocks per group, 32768 fragments per group

16000 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@ ~]# mkfs.ext3 /dev/LVMonRaid/LogicLV2

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

640000 inodes, 1280000 blocks

64000 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1312817152

40 block groups

32768 blocks per group, 32768 fragments per group

16000 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@ ~]# mkdir /mnt/doc

[root@ ~]# mkdir /mnt/music

[root@ ~]# mount -t ext3 /dev/LVMonRaid/LogicLV1 /mnt/doc

[root@ ~]# mount -t ext3 /dev/LVMonRaid/LogicLV2 /mnt/music

如果要开机自动挂载,更改/etc/fstab文件,添加如下两行:

/dev/LVMonRaid/LogicLV1     /mnt/doc   ext3   defaults     0    0

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wywyxg.html