Raid阵列与lvm逻辑卷组(下)

本文介绍如何通过磁盘分区及Raid5创建逻辑卷的过程。首先对磁盘进行分区,接着创建两个Raid5阵列,之后将这些磁盘资源转化为物理卷并创建卷组,最终创建出逻辑卷并完成格式化与挂载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

案例二:使用磁盘分区和磁盘阵列(Raid5)创建逻辑卷

要求:使用2块磁盘分区进行逻辑卷的创建,3块磁盘做Raid5后创建成逻辑卷

1.磁盘分区(/dev/sdc不做分区,使用整块磁盘。/dev/sdd,/dev/sde,/dev/sdf分区方法相同,这里不再赘述)

[root@lyt ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

 

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

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)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

 

Disk /dev/sdb: 21.4 GB, 21474836480 bytes

 

255 heads, 63 sectors/track, 2610 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-2610, default 1): 

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +200M

Command (m for help): t

 

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p 

Disk /dev/sdb: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

 

   Device Boot      Start         End      Blocks   Id  System、

 

/dev/sdb1               1          25      200781   8e  Linux LVM

Command (m for help): w 

 

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@lyt ~]# 

2.创建Raid5(使用/dev/sdd1,/dev/sde1,/dev/sdf1)

[root@lyt ~]# mdadm -Cv /dev/md0 -l 5 -n 3 /dev/sdd1 /dev/sde1 /dev/sdf1   #C表示创建,v表示显示详细信息,md0是设备。-l表示创建raid的级别,-n表示成员数量

mdadm: layout defaults to left-symmetric

mdadm: chunk size defaults to 64K

mdadm: size set to 200704K

mdadm: array /dev/md0 started.

[root@lyt ~]# mdadm -Cv /dev/md1 -l 5 -n 3 /dev/sdd2 /dev/sde2 /dev/sdf2

 

mdadm: layout defaults to left-symmetric

mdadm: chunk size defaults to 64K

mdadm: size set to 200704K

mdadm: array /dev/md1 started.。

[root@lyt ~]# cat  /proc/mdstat     #查看状态

Personalities : [raid6] [raid5] [raid4] 

md1 : active raid5 sdf2[2] sde2[1] sdd2[0]

      401408 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]

      

md0 : active raid5 sdf1[2] sde1[1] sdd1[0]

      401408 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]

      

unused devices: <none>

 

[root@lyt ~]# mdadm --detail /dev/md0    #查看md0的详细信息

 

/dev/md0:

        Version : 0.90

  Creation Time : Mon Dec 24 21:09:25 2012

     Raid Level : raid5

     Array Size : 401408 (392.07 MiB 411.04 MB)

  Used Dev Size : 200704 (196.03 MiB 205.52 MB)

   Raid Devices : 3

  Total Devices : 3

Preferred Minor : 0

    Persistence : Superblock is persistent

 

    Update Time : Mon Dec 24 21:12:38 2012

 

          State : clean

 Active Devices : 3

Working Devices : 3

 Failed Devices : 0

  Spare Devices : 0


         Layout : left-symmetric

     Chunk Size : 64K

 

           UUID : b5680dee:d452c142:037e51af:5c72eea9

         Events : 0.2

 

    Number   Major   Minor   RaidDevice State

 

       0       8       49        0      active sync   /dev/sdd1

       1       8       65        1      active sync   /dev/sde1

       2       8       81        2      active sync   /dev/sdf1 

[root@lyt ~]# mdadm --detail /dev/md1    #查看md1的详细信息

 

/dev/md1:

        Version : 0.90

  Creation Time : Mon Dec 24 21:10:02 2012

     Raid Level : raid5

     Array Size : 401408 (392.07 MiB 411.04 MB)

  Used Dev Size : 200704 (196.03 MiB 205.52 MB)

   Raid Devices : 3

  Total Devices : 3

Preferred Minor : 1

    Persistence : Superblock is persistent

 

    Update Time : Mon Dec 24 21:12:40 2012

 

          State : clean

 Active Devices : 3

Working Devices : 3

 Failed Devices : 0

  Spare Devices : 0

 

         Layout : left-symmetric 

 

     Chunk Size : 64K

 

           UUID : 931454bb:a68d6779:fa0087fb:b8609ca6

         Events : 0.2

 

    Number   Major   Minor   RaidDevice State

 

       0       8       50        0      active sync   /dev/sdd2

       1       8       66        1      active sync   /dev/sde2

       2       8       82        2      active sync   /dev/sdf2

[root@lyt ~]# 

3.创建物理卷

[root@lyt ~]# pvcreate /dev/sdb1   #分区

  Physical volume "/dev/sdb1" successfully created

[root@lyt ~]# pvcreate /dev/sdc    #整块磁盘

  Physical volume "/dev/sdc" successfully created

[root@lyt ~]# pvcreate /dev/md0    #Raid5创建成物理卷

  Physical volume "/dev/md0" successfully created

[root@lyt ~]# pvcreate /dev/md1    #Raid5创建成物理卷

  Physical volume "/dev/md1" successfully created

4.创建卷组

[root@lyt ~]# vgcreate testvg /dev/sdb1 /dev/sdc /dev/md0 /dev/md1

  /dev/cdrom: open failed: Read-only file system

  Attempt to close device '/dev/cdrom' which is not open.

  Volume group "testvg" successfully created

5.创建逻辑卷

[root@lyt ~]# lvcreate -L 1000M -n testlv testvg   #-L表示大小,-n表示名字

  Logical volume "testlv" created

6.格式化逻辑卷

[root@lyt ~]# mkfs -t ext3 /dev/testvg/testlv    #格式化

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

128000 inodes, 256000 blocks

12800 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=264241152

8 block groups

32768 blocks per group, 32768 fragments per group

16000 inodes per group

Superblock backups stored on blocks: 

32768, 98304, 163840, 229376

 

Writing inode tables: done                            

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 25 mounts or

 

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

[root@lyt ~]# 

7.挂载

[root@lyt ~]# mkdir /testlv

[root@lyt ~]# mount /dev/testvg/testlv /testlv/

[root@lyt ~]# ll /testlv/

total 16

drwx------ 2 root root 16384 Dec 24 21:24 lost+found

[root@lyt testlv]# df -h 

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                       18G  2.6G   15G  15% /

/dev/sda1              99M   12M   82M  13% /boot

tmpfs                 179M     0  179M   0% /dev/shm

/dev/mapper/testvg-testlv

                      985M   18M  918M   2% /testlv










本文转自 liuyatao666 51CTO博客,原文链接:http://blog.51cto.com/5503845/1125110,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值