LVM-HOWTO/学习笔记(四)

  

1.         做一个快照的备份

产生一个快照lv

# lvcreate -L592M -s -n dbbackup /dev/ops/databases 
lvcreate -- WARNING: the snapshot must be disabled if it gets full
    
lvcreate -- INFO: using default snapshot chunk size of 64 KB for "/dev/ops/dbbackup"
    
lvcreate -- doing automatic backup of "ops"
    
lvcreate -- logical volume "/dev/ops/dbbackup" successfully created

Mount the snapshot volume

We can now create a mount-point and mount the volume

# mkdir /mnt/ops/dbbackup

# mount /dev/ops/dbbackup /mnt/ops/dbbackup

mount: block device /dev/ops/dbbackup is write-protected, mounting read-only

Do the backup

I assume you will have a more sophisticated backup strategy than this!

# tar -cf /dev/rmt0 /mnt/ops/dbbackup

tar: Removing leading `/' from member names

 

Remove the snapshot

When the backup has finished you can now unmount the volume and remove it from the system. You should remove snapshot volume when you have finished with them because they take a copy of all data written to the original volume and this can hurt performance.

# umount /mnt/ops/dbbackup

# lvremove /dev/ops/dbbackup

lvremove -- do you really want to remove "/dev/ops/dbbackup"? [y/n]: y

lvremove -- doing automatic backup of volume group "ops"

              lvremove -- logical volume "/dev/ops/dbbackup" successfully removed

 

2.         移除老的硬盘

 

如果在其他硬盘上有足够的空间PE,将会很容易

# pvmove /dev/hdb
pvmove -- moving physical extents in active volume group "dev"
    
pvmove -- WARNING: moving of active logical volumes may cause data loss!
pvmove -- do you want to continue? [y/n] y
pvmove -- 249 extents of physical volume "/dev/hdb" successfully moved

这个过程可能很漫长,因为要复制数据过去,使用-v参数,可以看到过程

 

Remove the unused disk

We can now remove the old IDE disk from the volume group.

# vgreduce dev /dev/hdb
vgreduce -- doing automatic backup of volume group "dev"
        
vgreduce -- volume group "dev" successfully reduced by physical volume:
        
vgreduce -- /dev/hdb

如果没有足够的空间,需要先添加新的硬盘

# pvcreate /dev/sdf

Add it to the volume group

As developers use a lot of disk space this is a good volume group to add it into.

# vgextend dev /dev/sdf
vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte
        
vgextend -- doing automatic backup of volume group "dev"
        
vgextend -- volume group "dev" successfully extended

Move the data

Next we move the data from the old disk onto the new one. Note that it is not necessary to unmount the file system before doing this. Although it is *highly* recommended that you do a full backup before attempting this operation in case of a power outage or some other problem that may interrupt it. The pvmove command can take a considerable amount of time to complete and it also exacts a performance hit on the two volumes so, although it isn't necessary, it is advisable to do this when the volumes are not too busy.

# pvmove /dev/hdb /dev/sdf
pvmove -- moving physical extents in active volume group "dev"
        
pvmove -- WARNING: moving of active logical volumes may cause data loss!
pvmove -- do you want to continue? [y/n] y
pvmove -- 249 extents of physical volume "/dev/hdb" successfully moved

Remove the unused disk

We can now remove the old IDE disk from the volume group.

# vgreduce dev /dev/hdb
vgreduce -- doing automatic backup of volume group "dev"
        
vgreduce -- volume group "dev" successfully reduced by physical volume:
        
vgreduce -- /dev/hdb

你可能感兴趣的:(职场,学习笔记,lvm,howto,休闲)