lvm镜像实验

实验环境

# uname -a

Linux localhost.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

cat /etc/redhat-release

CentOS Linux release 7.0.1406 (Core)


添加两块新硬盘做来实验。

wKiom1PtX7yylvJZAABhCMNAMwM147.gif

操作步骤

创建分区

先分别在两个磁盘上创建六个分区,然后查看分区

# fdisk /dev/sdb

# fdisk /dev/sdc

# 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: 0x000eebc4

 

   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 label type: dos

Disk identifier: 0xadd8c239

 

   Device  Boot      Start         End      Blocks    Id  System

/dev/sdb1            2048     2099199     1048576    83  Linux

/dev/sdb2          2099200     4196351     1048576    83  Linux

 

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

Disk label type: dos

Disk identifier: 0xe5fdf0d8

 

   Device  Boot      Start         End      Blocks    Id  System

/dev/sdc1            2048     2099199     1048576    83  Linux

/dev/sdc2          2099200     4196351     1048576    83  Linux

 

建立RAID

开始创建RAID,首现将硬盘,每两个一组做成raid 1级别的raid盘。利用命令mdadm

# mdadm -C /dev/md1 -a yes -l 1 -n 2 /dev/sdb1/dev/sdc1

mdadm: Note: this array has metadata at the start  and

    may not  be suitable as a boot device.  If you  plan to

    store  '/boot' on this device please ensure that

    your  boot-loader understands md/v1.x metadata, or use

     --metadata=0.90

Continue creating array? y

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md1 started.

 

 

再创建RAID 0卷。利用命令mdadm

# mdadm -C /dev/md0 -l 0 -n 2 /dev/sdb2 /dev/sdc2

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md0 started.

然后可以查看一下

# cat /proc/mdstat

Personalities : [raid1] [raid0]

md0 : active raid0 sdc2[1] sdb2[0]

       2096128 blocks super 1.2 512k chunks

     

md1 : active raid1 sdc1[1] sdb1[0]

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

     

unused devices: <none>

 

建立lvm

首现创建PV―物理卷

# pvcreate /dev/md0

   Physical volume "/dev/md0" successfully created

创建了物理卷,我们就可以把它加入到卷组中

# vgcreate vg1 /dev/md0

   Volume group "vg1" successfully created

有了vg,我们可以进一步划分,划分我们想要的逻辑卷

# lvcreate -L 1G -n lv1 vg1

   Logical volume "lv1" created

最后我们可以格式化lv1

# mkfs.ext4 /dev/vg1/lv1

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=128 blocks, Stripe width=256  blocks

65536 inodes, 262144 blocks

13107 blocks (5.00%) reserved for the  super user

First data block=0

Maximum filesystem blocks=268435456

8 block groups

32768 blocks per group, 32768 fragments  per group

8192 inodes per group

Superblock backups stored on blocks:

         32768, 98304, 163840, 229376

 

Allocating group tables: done                           

Writing inode tables: done                           

Creating journal (8192 blocks): done

Writing superblocks and filesystem  accounting information: done

最后将lv1挂载到我们的目录下就完成了

# mkdir /data

# mount /dev/vg1/lv1 /data

你可能感兴趣的:(linux,release,Minimum,Physical)