11
2024
07
16:54:43

虚拟机快照时如何冻结IO

一、基本原理

冻结IO


# fsfreeze -f /mnt/backup/


测试


# echo 'this is a testcat '>> /mnt/backup/test1.txt


挂起.不能写入信息


解冻:


# fsfreeze -u /mnt/backup/


二、QGA冻结IO

1、在虚拟机中安装qemu-ga,


# yum install qemu-guest-agent


2、修改安装后的qemu-ga配置文件/etc/sysconfig/qemu-ga


FSFREEZE_HOOK_ENABLE=1

#BLACKLIST_RPC="guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush"


3、将虚拟机关机,在虚拟机配置文件libvirt.xml中的下面添加下述配置,并重新启动虚拟机


<channel type='unix'>

   <source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>

   <target type='virtio' name='org.qemu.guest_agent.0'/>

</channel>


3、测试是否正常:


# virsh qemu-agent-command 90 '{"execute":"guest-info"}'

{"return":{"version":"0.12.1","supported_commands":[{"enabled":true,"name":"guest-set-vcpus"},{"enabled":true,"name":"guest-get-vcpus"},{"enabled":true,"name":"guest-network-get-interfaces"},{"enabled":true,"name":"guest-suspend-hybrid"},{"enabled":true,"name":"guest-suspend-ram"},{"enabled":true,"name":"guest-suspend-disk"},{"enabled":true,"name":"guest-fstrim"},{"enabled":true,"name":"guest-fsfreeze-thaw"},{"enabled":true,"name":"guest-fsfreeze-freeze"},{"enabled":true,"name":"guest-fsfreeze-status"},{"enabled":true,"name":"guest-file-flush"},{"enabled":true,"name":"guest-file-seek"},{"enabled":true,"name":"guest-file-write"},{"enabled":true,"name":"guest-file-read"},{"enabled":true,"name":"guest-file-close"},{"enabled":true,"name":"guest-file-open"},{"enabled":true,"name":"guest-shutdown"},{"enabled":true,"name":"guest-info"},{"enabled":true,"name":"guest-set-time"},{"enabled":true,"name":"guest-get-time"},{"enabled":true,"name":"guest-ping"},{"enabled":true,"name":"guest-sync"},{"enabled":true,"name":"guest-sync-delimited"}]}}


#直接用virsh命令,freeze文件系统


# virsh qemu-agent-command 90 '{"execute":"guest-fsfreeze-freeze"}'

{"return":1}


freeze后,可以查询当前虚拟机文件系统的状态,表明是frozen


# virsh qemu-agent-command 90 '{"execute":"guest-fsfreeze-status"}'

{"return":"frozen"}


thaw(解封)文件系统


# virsh qemu-agent-command 90 '{"execute":"guest-fsfreeze-thaw"}'

{"return":1}


thaw后,文件系统为解封状态


# virsh qemu-agent-command 90 '{"execute":"guest-fsfreeze-status"}'

{"return":"thawed"}



三、OpenStack中适配

设置镜像元数据(kilo以后版本都支持)


# nova image-meta 9010b84d-a223-4ece-83e5-09848we45645 set hw_qemu_guest_agent=yes

————————————————




推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://hqyman.cn/post/7047.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: