专栏首页力哥聊运维与云计算LVM-HOWTO/学习笔记(四)

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

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • LVM-HOWTO/学习笔记(三)

    A data centre machine has 6 disks attached as follows:

    力哥聊运维与云计算
  • LVM-HOWTO/学习笔记(五)

    First, make sure that no users are accessing files on the active volume, then un...

    力哥聊运维与云计算
  • LVM-HOWTO/学习笔记(一)

    # lvcreate -i2 -I4 -l100 -nanothertestlv testvg

    力哥聊运维与云计算
  • CentOS 6.8 创建 RAID-5

    参考文档:https://cloud.tencent.com/developer/article/1562726

    用户5630738
  • Redis 一二事(2) - 在spring中使用jedis 连接调试单机redis以及集群redis

    Redis真是好,其中的键值用起来真心强大啊有木有, 之前的文章讲过搭建了redis集群 那么咋们该如何调用单机版的redis以及集群版的redis来使用缓存...

    风间影月
  • fail-safe fail-fast知多少

    我们在使用集合类的时候,通常会需要去遍历集合中的元素,并在遍历中对其中的元素进行处理。这时候我们就要用到Iterator,经常写程序的朋友应该都知道,在Iter...

    程序那些事
  • vmware安装ubuntu12.04嵌套安装xen server(实现嵌套虚拟化)

    环境准备 软件:vmware workstation 9.0      ubuntu-12.04.2-server-amd64(官方下载) 硬件:确认CPU支持...

    cloudskyme
  • 小知识:从官方镜像安装owncloud

    cd /var/www/html/apps && git clone https://github.com/nextcloud/passman.git

    超级大猪
  • 【PAT甲级】Course List for Student

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 ...

    喜欢ctrl的cxk
  • Linux标准/错误输出重定向

    Y大宽

扫码关注云+社区

领取腾讯云代金券