LVM Mirror Raid1管理.docx_第1页
LVM Mirror Raid1管理.docx_第2页
LVM Mirror Raid1管理.docx_第3页
LVM Mirror Raid1管理.docx_第4页
LVM Mirror Raid1管理.docx_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

测试环境:CentOS 5.10 x64,sda 20G,sdb 1G,sdc 2G.一、 创建逻辑卷镜像关系的步骤:1)通过pvcreate命令将linux分区处理成物理卷(PV);2)通过vgcreate命令将创建好的物理卷处理成卷组(Vg);3)通过lvcreate命令使用 m1 参数将卷若干个PV组成一个逻辑镜像卷(Lv);之后我们可以对镜像逻辑卷进行格式化,挂载,删除等操作。二、 创建磁盘分区首先将sbc和sdc分区,并创建三个pv(sdb1、sdc1、sdc2),其中sdb1作为数据盘,sdc1作为镜像盘,sdc2作为日志盘,日志盘不应太小(一般10G左右)。1)将sdb分区rootCentos # fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent wont be recoverable.Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1First cylinder (1-130, default 1): Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-130, default 130): +1024MCommand (m for help): pDisk /dev/sdb: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sdb1 1 125 1004031 83 LinuxCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.rootCentos #2)将sdc分区rootCentos # fdisl /dev/sdcbash: fdisl: command not foundrootCentos # fdisk /dev/sdcDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent wont be recoverable.Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1First cylinder (1-261, default 1): 1Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): +1024MCommand (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 2First cylinder (126-261, default 126): Using default value 126Last cylinder or +size or +sizeM or +sizeK (126-261, default 261): +1000MCommand (m for help): pDisk /dev/sdc: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sdc1 1 125 1004031 83 Linux/dev/sdc2 126 248 987997+ 83 LinuxCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.3)重读分区表rootcentos # partprobe如果sdb、sdc是FC、iscsi、DAS存储,且配置了多路径,则使用如下命令更新分区表,若还未更新就只能 init 6 重启服务器了:kpartx a /dev/mapper/mpathbp1 然后 ls /dev/mapper/ 查看分区设备4)pvcreate 创建pv 设备rootCentos # pvcreate /dev/sdb1 /dev/sdc1 /dev/sdc2 Writing physical volume data to disk /dev/sdb1 Physical volume /dev/sdb1 successfully created Writing physical volume data to disk /dev/sdc1 Physical volume /dev/sdc1 successfully created Writing physical volume data to disk /dev/sdc2 Physical volume /dev/sdc2 successfully createdrootCentos # 查看pv设备表:rootcentos # pvscan (或者pvs,或者 pvdisplay查看详细信息包括pv uuid) PV /dev/sda2 VG VolGroup00 lvm2 19.88 GB / 0 free PV /dev/sdb1 lvm2 980.50 MB PV /dev/sdc1 lvm2 980.50 MB PV /dev/sdc2 lvm2 964.84 MB Total: 4 22.73 GB / in use: 1 19.88 GB / in no VG: 3 2.86 GBrootCentos #5)vgcreate创建 vg0物理卷组rootCentos # vgcreate vg0 /dev/sdb1 /dev/sdc1 /dev/sdc2 Volume group vg0 successfully createdrootCentos #三、 创建LVM Mirror镜像卷rootCentos # lvcreate -L 970M -m1 -n mirror vg0 /dev/sdb1 /dev/sdc1 Rounding up size to full physical extent 972.00 MB Logical volume mirror createdrootCentos # lvdisplay /dev/vg0/mirror 查看/dev/vg0/mirror - Logical volume - LV Name /dev/vg0/mirror VG Name vg0 LV UUID vX60P8-MmjC-tNX8-w2jI-t2qt-AZnD-Rnj0IN LV Write Access read/write LV Status available # open 0 LV Size 972.00 MB Current LE 243 Mirrored volumes 2 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:5rootCentos # lvs -a -o +devices 查看当前LVM中设备状态rootCentos # mkfs.ext3 /dev/vg0/mirror 格式化lvm,创建文件系统四、 管理lvm mirror卷1)破坏一个pv设备(sdb1),然后再查看lvs状态,发现少了一个pv设备sdb1:rootCentos # dd if=/dev/zero of=/dev/sdb1 count=1010+0 records in10+0 records out5120 bytes (5.1 kB) copied, 0.000856 seconds, 6.0 MB/s2)把损坏的pv从vg0卷组删除(缩小vg0卷组):rootCentos # vgreduce -removemissing -force vg0Couldnt find device with uuid kJc1oG-Ua0R-RDiC-KaJ5-oomD-cH9Q-2DbWQ2.Wrote out consistent volume group vg0rootCentos #因为上面我们是手动破坏pv,如果是pv离线或者减少vg的pv设备,使用如下指令:rootCentos # vgreduce vg0 /dev/sdb1移除之后发现vg0详细信息中没有了Mirrored volumes选项rootCentos # vgdisplay /dev/vg0 - Volume group - VG Name vg0 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 9 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 1.91 GB PE Size 4.00 MB Total PE 490 Alloc PE / Size 243 / 972.00 MB Free PE / Size 247 / 988.00 MB VG UUID q620jv-Oc9a-pUlg-q6wM-TFXl-wAa7-jh40FsrootCentos #3)扩展vg0卷组:rootCentos # vgextend vg0 /dev/sdb1 扩展vg0卷组 Writing physical volume data to disk /dev/sdb1 Physical volume /dev/sdb1 successfully created Volume group vg0 successfully extendedrootCentos # pvs 查看pv状态 PV VG Fmt Attr PSize PFree /dev/sda2 VolGroup00 lvm2 a- 19.88G 0 /dev/sdb1 vg0 lvm2 a- 980.00M 980.00M /dev/sdc1 vg0 lvm2 a- 980.00M 8.00M /dev/sdc2 vg0 lvm2 a- 980.00M 980.00M4)镜像卷组数据恢复:rootCentos # lvconvert -m1 /dev/vg0/mirror /dev/sdb1 /dev/sdc1 /dev/sdc2 vg0/mirror: Converted: 0.0% vg0/mirror: Converted: 43.6% vg0/mirror: Converted: 83.5% vg0/mirror: Converted: 100.0%rootCentos #lvs -a -o +devices 查看mirror卷组状态,会看到三个pvrootCentos # lvdisplay /dev/vg0/mirror 查看lvm mirror详细信息,Mirrored volumes再次出现 - Logical volume - LV N

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论