前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >LVM-HOWTO/学习笔记(四)

LVM-HOWTO/学习笔记(四)

作者头像
力哥聊运维与云计算
发布2019-06-28 11:35:15
3460
发布2019-06-28 11:35:15
举报

1. 做一个快照的备份

产生一个快照lv

代码语言:javascript
复制
# lvcreate -L592M -s -n dbbackup /dev/ops/databases 
代码语言:javascript
复制
lvcreate -- WARNING: the snapshot must be disabled if it gets full
代码语言:javascript
复制
lvcreate -- INFO: using default snapshot chunk size of 64 KB for "/dev/ops/dbbackup"
代码语言:javascript
复制
lvcreate -- doing automatic backup of "ops"
代码语言:javascript
复制
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,将会很容易

代码语言:javascript
复制
# pvmove /dev/hdb
代码语言:javascript
复制
pvmove -- moving physical extents in active volume group "dev"
代码语言:javascript
复制
pvmove -- WARNING: moving of active logical volumes may cause data loss!
代码语言:javascript
复制
pvmove -- do you want to continue? [y/n] y
代码语言:javascript
复制
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

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

代码语言:javascript
复制
# 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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2011-08-19 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Remove the unused disk
  • Add it to the volume group
  • Move the data
  • Remove the unused disk
相关产品与服务
对象存储
对象存储(Cloud Object Storage,COS)是由腾讯云推出的无目录层次结构、无数据格式限制,可容纳海量数据且支持 HTTP/HTTPS 协议访问的分布式存储服务。腾讯云 COS 的存储桶空间无容量上限,无需分区管理,适用于 CDN 数据分发、数据万象处理或大数据计算与分析的数据湖等多种场景。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档