Introduction
If you're using a ZFS volume as the root disk for a domain, you can make use of the snapshotting facilities to quickly "clone" another domain with the same configuration. By taking a clone of the root disk, you can very quickly provision similar domains, and even better, the nature of the clone means the only extra storage used is that of the differences between the domains.We're working on ways of automating this procedure, but for now these are the steps you'll need to take.
Step-by-step
First, we need to shutdown the domain we're cloning so we can take a consistent snapshot of the disk:
xm shutdown -w domain1
Alternatively, you might want to do a sys-unconfig in the domain so
the new clone will come up with the configuration screens.
Now we take a snapshot of the root disk used by 'domain1', and then a clone (writable snapshot) :
zfs snapshot pool/domain1-root@clone
zfs clone pool/domain1-root@clone pool/domain2-root
If you now do a zfs list, you should see the snapshot and clone
present, and using next to no additional disk space. For our last
step, we need to duplicate domain1's configuration. First dump
the configuration to a file:
virsh dumpxml domain1 >domain1.xml
cp domain1.xml domain2.xml
You will need to make at least three changes. First, you will want a new name for your domain, so edit this line:
<name>domain1</name>
with the new name:
<name>domain2</name>
Second, you must remove the UUID line so virsh will generate a new
domain configuration. Remove the line that looks like this:
<uuid>72bb96b6e6cf13594fb0cd1290610611</uuid>
Finally we have to point to the new disk by editing the following line:
<source dev='/dev/zvol/dsk/export/domain1-root'/>
to be:
<source dev='/dev/zvol/dsk/export/domain2-root'/>
Finally, tell virsh about the new domain:
virsh define domain2.xml
Now you can boot your cloned domain!
本文介绍如何使用ZFS文件系统的快照功能来快速克隆带有相同配置的域。通过关闭源域并创建其根磁盘的快照,然后制作一个可写的克隆,可以高效地复制出几乎相同的域配置,且仅占用实际变化部分的存储空间。
148

被折叠的 条评论
为什么被折叠?



