LVM Using snapot to backup data–from google searching..

This is a Daily script

#!/bin/bash
DIR=/root/backup
BACKUP_CMD=backup-lv.sh

VG=/dev/vg1 #whichever folder your xen files located at)
LV[0]=xen-1 # (name of diff, xen machines/guests)
LV[1]=xen-2
LV[2]=xen2-data #xen2 is a web server with large amount of data
LV[3]=xen-3

cd $DIR
COUNT=0
CAT_STR=""
while [ $COUNT -lt ${#LV[@]} ]
do
./$BACKUP_CMD $VG/${LV[$COUNT]} &> last-backup-${LV[$COUNT]}
CAT_STR="${CAT_STR} last-backup-${LV[$COUNT]}"
MOO=$((COUNT++))
done

ls -lh /mnt/system_backups/ &> last-backup-ls
cat $CAT_STR last-backup-ls > last-backup.txt
echo "daily backup report attached" | mutt -s "$HOSTNAME daily backup report" -a last-backup.txt MyEmail@MyCompany.com

Continue reading “LVM Using snapot to backup data–from google searching..”

逻辑卷管理LVM(Logical Volume Manager)

LVM HOW TO

                                 History:2009-12-25
今天研究了一下LVM (Logical Volume Manager)。在网上查了一些资料,于是自己做个总结。不知道大家有没有用过PQ(PowerQuest 的 partition magic)。
这个软件其实就是Unix/Linux下的PQ。了解下这个,再往下说,相信对于很多熟悉PC机操作的朋友就不陌生了。LVM的重点就在于灵活的调整使用硬盘空间的大小,对于存储需求高的人来说很方便。
在说逻辑卷管理之前,先说几点相关的知识:
1.    PV Physical Volume 物理卷标
2.    VG Volume Group    卷标组
3.    PE Physical Extend  物理扩展块(VG的基本单位)
4.    LV Logical Volume  逻辑卷标 (VG切成的可以供系统使用的不的存储块)
下边是鸟哥的图
lvm

所使用相关的工具

Pv\vg\lv

PV

  • pvcreate :将硬盘设备设备成PV (Initialize a disk or partition for use by LVM)
  • pvscan :搜索系统中PV块 (Scan all disks for physical volumes)
  • pvdisplay :显示系统中pv 的状态信息(display attributes of a physical volume)
  • pvremove :移除PV分区。不具有PV属性(remove a physical volume)

VG

  • vgcreate :建立卷标组。(vgcreate – create a volume group)
  • vgscan :搜索系统中的VG是否存在 (scan all disks for volume groups and rebuild caches)
  • vgdisplay :显示VG的状态 (display attributes of volume groups)
  • vgextend :在VG内增加额外的PV;(add physical volumes to a volume group)
  • vgreduce :在VG内移除PV (reduce a volume group)
  • vgchange :改变VG的属性。(change attributes of a volume group);
  • PS:设备是否启用active? —鸟哥的解释
  • vgremove :删除VG *remove a volume group)

LV

很容易PV就不介绍了,大家有兴趣看一下man lv(balabalabal…)

Partprobe\dumpe2fs

好下边就开始做了。

准备好LinuxLVM的Partition (用Fdisk工具)
/dev/sdb5               1          19      152554+  8e  Linux LVM
/dev/sdb6              20          38      152586   8e  Linux LVM
/dev/sdb7              39          57      152586   8e  Linux LVM
/dev/sdb8              58          74      136521   8e  Linux LVM

生成PV

Syntax:pvcreate PhysicalVolume
pvcreate /dev/hda{6,7,8,9}
Physical volume "/dev/sdb5" successfully created
Physical volume "/dev/sdb6" successfully created
Physical volume "/dev/sdb7" successfully created
Physical volume "/dev/sdb8" successfully created

生成VG

vgcreate –s(extensionsize) VolumeGroupName PhysicalVulomes

vgcreate -s 32M myvg /dev/sdb{5,6,7}
Volume group "myvg" successfully created

生成LV

lvcreate –Ll [-n/--name LogicalVolumeName] logicalVolume VolumeGroupName
lvcreate -L 200M -n mylv myvg
  Rounding up size to full physical extent 224.00 MB
  Logical volume "mylv" created
lvdisplay
  --- Logical volume ---
  LV Name                /dev/myvg/mylv
  VG Name                myvg
  LV UUID                tayCTI-On0h-DN4u-DunR-SRWR-Mmet-oqm9jX
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                224.00 MB
  Current LE             7
  Segments               3
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0
这样我们就完成了一个LV的操作,接下来我们把生成的LV格式化一下就可以用了。
mkfs.ext3 /dev/myvg/mylv
mkdir /mnt/lvm
mount –t ext3 /dev/mvg/mylv /mnt/lvm
 
df –m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda2                 4965      2832      1881  61% /
/dev/sda1                   99         9        86   9% /boot
none                       169         0       169   0% /dev/shm
/dev/mapper/myvg-mylv
                           217         7       200   3% /mnt/lvm
赶紧去试试吧!