lvm 备份_从远程服务器复制和备份LVM支持的Xen DomU

lvm 备份

LVM’s snapshot feature enables us to duplicate an LVM backed Xen DomU in seconds inside of the same volume group. When we want to duplicate LVM backed Xen DomU from a remote server, we need to make use of LVM’s snapshot function and tools like scp and dd. Backing up the DomU is only part of the process of duplicating one DomU. We can finish the backing up work after copying DomU’s image to remote server. How to duplicate and back up LVM backed Xen DomU from remote server is introduced in this post.

LVM的快照功能使我们能够在几秒钟内在同一卷组中复制LVM支持的Xen DomU 。 当我们要从远程服务器复制LVM支持的Xen DomU时,我们需要使用LVM的快照功能以及诸如scp和dd之类的工具。 备份DomU只是复制一个DomU的过程的一部分。 将DomU的映像复制到远程服务器后,我们可以完成备份工作。 本文介绍了如何从远程服务器复制和备份LVM支持的Xen DomU。

假设和我们的目标: (Assumption and our goal:)

There are Xen DomU virtual machines in LVM logical volume /dev/vg_xen/vm-10.0.0.123/ on server 10.0.0.10 (remote server).

服务器10.0.0.10(远程服务器)上的LVM逻辑卷/dev/vg_xen/vm-10.0.0.123/中有Xen DomU虚拟机。

Now we want to duplicate the virtual machine vm-10.0.0.123 to vm-10.0.0.124 which we want to stored in logical volume vm-10.0.0.124 in volume group vg_xen on server 10.0.0.11 (local server). vm-10.0.0.124‘s IP will be 10.0.0.124. There are 6 steps to duplicate this virtual machine. If we just need to back up it, we can just use step 1 to setp 3.

现在,我们要将虚拟机vm-10.0.0.123复制到vm-10.0.0.124 ,我们要将其存储在服务器10.0.0.11(本地服务器)上的卷组vg_xen中的逻辑卷vm-10.0.0.124中。 vm-10.0.0.124的IP为10.0.0.124。 复制该虚拟机有6个步骤。 如果只需要备份它,则可以使用步骤1来设置3。

1.在远程服务器上复制LVM逻辑卷 (1. Duplicate the LVM logical volume on remote server)

We can duplicate the LVM volume group on remote server by making a snapshot of it. The snapshot is a clone of the logical volume. We can make a new logical volume vm-10.0.0.123-snapshot as the snapshot of logical volume vm-10.0.0.123:

我们可以通过对其进行快照来在远程服务器上复制LVM卷组。 快照是逻辑卷的克隆。 我们可以制作一个新的逻辑卷vm-10.0.0.123-snapshot作为逻辑卷vm-10.0.0.123的快照

# lvcreate -L20480 -s -n 'vm-10.0.0.123-snapshot' /dev/vg_xen/vm-10.0.0.123

Here the size of the new logical volume is 20G as the same of the original one.

在这里,新逻辑卷的大小为20G,与原始逻辑卷相同。

Here we should make sure that vm-10.0.0.123 is power off to avoid the situation there are “write” that is still in DomU’s cache.

在这里,我们应该确保vm-10.0.0.123是 关闭电源以避免出现DomU缓存中仍然存在“写入”的情况。

2.使用远程服务器上的dd工具将快照保存到图像文件 (2. Save the snapshot to image file using dd tool on remote server)

We can use dd command to save a image of the new created snapshot logical volume of the DomU:

我们可以使用dd命令保存新创建的DomU快照逻辑卷的映像:

# dd if=/dev/vg_xen/vm-10.0.0.123-snapshot of=/lhome/xen-image/vm-10.0.0.123-lv.img bs=1k

This process may take several minutes or more depending on the size of the logical volume and the hard disk’s speed.

此过程可能需要几分钟或更长时间,具体取决于逻辑卷的大小和硬盘的速度。

3.将DomU的映像从远程映像复制到本地服务器 (3. Copy the DomU’s image to the local server from the remote one)

We can transfer the image from remote server after finishing the dd command on remote server.

在远程服务器上完成dd命令后,我们可以从远程服务器传输映像。

# scp -c arcfour root@10.0.0.10:/lhome/xen-image/vm-10.0.0.123-lv.img /lhome/xen-image/

We set “-c arcfour” to get higher transfer speed of scp.

我们设置“ -c arcfour”以获得更高的scp传输速度。

4.在本地服务器上为新的DomU创建逻辑卷 (4. Create logical volume for the new DomU on local server)

We can do this simultaneously with step 3. We create a new logical volume vm-10.0.0.124 under volume group vg_xen on local server:

我们可以与步骤3同时进行。在本地服务器的卷组vg_xen下创建一个新的逻辑卷vm-10.0.0.124:

# lvcreate -L20480 -n 'vm-10.0.0.124' vg_xen

The size of the logical volume is the same as the one of the DomU in remote server.

逻辑卷的大小与远程服务器中DomU的大小相同。

5.从映像复制逻辑卷中的数据 (5. Duplicate the data in the logical volume from the image)

In this step, we use the dd command to copy data from the image file to the newly created logical volume:

在此步骤中,我们使用dd命令将数据从映像文件复制到新创建的逻辑卷:

# dd if=/lhome/xen-image/vm-10.0.0.123-lv.img of=/dev/vg_xen/vm-10.0.0.124 bs=1k

This may also take some time to finish.

这可能还需要一些时间才能完成。

6.更改本地服务器上新DomU的配置文件 (6. Change the profile for new DomU on local server)

After making the clone of the VBD. We can create a profile for the new DomU. This is the content of /lhome/xen/vm-10.0.0.124/vm.run:

制作完VBD的克隆后。 我们可以为新的DomU创建配置文件。 这是/lhome/xen/vm-10.0.0.124/vm.run的内容:

name="10.0.0.124"
cpus=2
memory=2048
disk=['phy:vg_xen/vm-10.0.0.124,xvda,w' ]
vif=[ 'bridge=eth0' ]
bootloader = "/usr/bin/pygrub"
on_reboot = 'restart'
on_crash = 'restart'

The name and disk entry are changed.

名称和磁盘条目已更改。

7.启动新的虚拟机并配置新的虚拟机 (7. Start the new virtual machine and configure the new virtual machine)

We can start the new DomU and enter it’s console:

我们可以启动新的DomU并进入它的控制台:

# xm create /lhome/xen/vm-10.0.0.124/vm.run
# xm console 10.0.0.213

#xm创建/lhome/xen/vm-10.0.0.124/vm.run
#xm控制台10.0.0.213

Or directly:

或直接:

# xm create -c /lhome/xen/vm-10.0.0.124/vm.run

After logging in vm-10.0.0.124, we can edit the network configuration file:

登录vm-10.0.0.124后,我们可以编辑网络配置文件:

#  vi /etc/sysconfig/network-scripts/ifcfg-eth0

Change the IPADDR to 10.0.0.124 from 10.0.0.123. Then restart eth0:

将IPADDR从10.0.0.123更改为10.0.0.124。 然后重启eth0:

# ifdown eth0
# ifup eth0

#ifdown eth0
#ifup eth0

Make sure this interface doesn’t have HWADDR by commenting out the line that specify HWADDR if we use Xen bridge network.

如果我们使用Xen桥接网络,请注释掉指定HWADDR的行,以确保此接口没有HWADDR

Log out of vm-10.0.0.124 and then use “Ctrl + ]” to exit the xm console.

注销vm-10.0.0.124,然后使用“ Ctrl +]”退出xm控制台。

The new virtual machine vm-10.0.0.124 which is the clone of vm-10.0.0.123 except the IP and the Dom0 on top of which it is running is ready to use now. This process can be written into one script.

现在可以使用新的虚拟机vm-10.0.0.124,它是vm-10.0.0.123的克隆,除了IP和运行于其之上的Dom0。 该过程可以写入一个脚本中。

For more tutorials about Xen, please refer to Xen Solution.

有关Xen的更多教程,请参考Xen解决方案

翻译自: https://www.systutorials.com/duplicating-and-backing-up-lvm-backed-xen-domu-from-a-remote-server/

lvm 备份

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值