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.古いHDDを取り外す
 
他のハードディスク(HDD)に十分なスペース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

十分なスペースがない場合は、新しいハードディスク(HDD)を追加する必要があります.
# 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