xen vm安装

Have you ever needed to backup your Citrix Xen Virtual Machines (VMs) but didn’t want to break the bank doing it? HTG has just the bash script for you with Xen-pocalypse.

您是否曾经需要备份Citrix Xen虚拟机(VM),但又不想为此付出大笔资金呢? HTG只有Xen-pocalypse可以为您提供bash脚本。

Image by h.koppdelaney, Stuck in Custom and Hotfortech.

图片由h.koppdelaney提供 , 保留 在Custom和Hotfortech中 。

One of the nice things in Citrix Xen is that many of its features are free of charge. With that said, if you want the “Automated VM protection and recovery” feature, you would have to start paying for the “Advance” license. Even then, you are only paying for disk level backups, which aren’t sufficient for many types of workloads like Active directory, Databases & Etc. To overcome this you might want the “Live memory snapshot and revert”, which can save the entire machine state, including the contents of RAM. However, that feature is part of the “Enterprise” and “Platinum” editions, which are even more expensive. It is not that we at HTG are dismissing the value of a true backup software, but if you’re on a tight budget and don’t mind some downtime for the backup operation, you might find Xen-pocalypse to be a perfectly reasonable solution before you make the budget commitment.

Citrix Xen的优点之一是它的许多功能都是免费的。 话虽如此,如果您想要“虚拟机自动保护和恢复”功能,则必须开始支付“高级”许可证。 即使这样,您也只需要支付磁盘级备份,对于许多类型的工作负载(如Active Directory,Databases等)来说,这还不够。要解决此问题,您可能需要“实时内存快照并还原”,这样可以保存整个备份。机器状态,包括RAM的内容。 但是,该功能是“ Enterprise”和“ Platinum”版本的一部分,价格更高。 并不是说HTG会放弃真正备份软件的价值,但是如果您的预算有限并且不介意备份操作出现停机,您可能会发现Xen-pocalypse是一个非常合理的解决方案在您做出预算承诺之前。

总览 (Overview )

The “use case”: You have a couple of VMs that require a backup. The “turning off a VM and exporting it as a file” from the “Xen Center” using right clicks works ok, but you want this process to happen automatically and on a schedule. This Bash script uses the “XE” command to perform its duties. XE is the Xen command line interface (CLI), automatic equivalent for issuing the “right clicks” in the “Xen Center”. We will be calling the script from Cron which will supply the “scheduling” part. In its simplest form, the backup flow is:

“用例”:您有几个需要备份的VM。 右键单击“ Xen Center”中的“关闭VM并将其导出为文件”可以正常使用,但是您希望此过程自动按计划进行。 该Bash脚本使用“ XE”命令执行其职责。 XE是Xen命令行界面(CLI),相当于在“ Xen Center”中发出“右键单击”的自动功能。 我们将从Cron调用脚本,该脚本将提供“计划”部分。 以最简单的形式,备份流程为:

  • Turn off the target VM.关闭目标虚拟机。
  • Export the VM as a file to the backup location.将VM作为文件导出到备份位置。
  • If the VM was turned on, before the backup started, it will be turned back on.如果打开了虚拟机,则在备份开始之前,它将重新打开。

Lets get cracking :)

让我们开始吧:)

获取脚本 (Obtain the script)

Xen-pocalypse can be freely obtained from github, using the regular git methods. With that said, if you’re not versed in git yet, you can grab the zip file with this link. As the script needs to run on one of your Xen servers, you should extract it there so that execution permissions are preserved.

Xen-pocalypse可以使用常规git方法从github免费获得。 话虽如此,如果您还不熟悉git ,则可以使用此链接来获取zip文件。 由于脚本需要在您的Xen服务器之一上运行,因此您应该在该服务器上将其解压缩,以便保留执行权限。

wget https://github.com/aviadra/Xen-pocalypse/archive/master.zip
unzip master

wget https://github.com/aviadra/Xen-pocalypse/archive/master.zip
unzip master

While the above would work, you are advised to use the GIT method, so that you may benefit from future updates.

尽管上述方法可行,但建议您使用GIT方法,以便将来可以从中受益。

获取SendEmail(可选) (Obtain SendEmail (optional))

We’ve written about the SendEmail perl program in the past, so there is no need to reiterate here. Suffice it to say, it works the same way on Linux as it does on Windows.

过去 , 我们已经撰写了有关SendEmail perl程序的文章 ,因此无需在此重复。 可以说,它在Linux上的工作方式与Windows上的工作方式相同。

While enabling email is optional, it is highly recommended because then the script will be able to:

虽然启用电子邮件是可选的,但强烈建议您启用它,因为该脚本将能够:

  • Inform you when it started & finished running.开始运行并结束运行时通知您。
  • Alert you of any errors it was able to detect and handle.提醒您它能够检测和处理的任何错误。
  • Inform of backup disqualifications due to space issues. (This behavior can be disabled if not desired)通知由于空间问题而取消备份资格。 (如果不需要,可以禁用此行为)

Download it to the Xen server and extract.

将其下载到Xen服务器并解压缩。

wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
tar xvzhf sendEmail-v1.56.tar.gz

wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
tar xvzhf sendEmail-v1.56.tar.gz

Note the location where you extracted it to. You will need it for the settings file.

请注意将其提取到的位置。 设置文件将需要它。

定义标签 (Defining Tags)

Citrix Xen gives you the ability to configure “Custom Fields” for filtering capabilities. We will create the Fields and then populate them with the information used by Xen-pocalypse. Xen-pocalypse recognizes 3 control TAGs which designate the name of the tag for backup and the parent to child relationships. If you are not intending on using the file input method, you MUST create at least the backup tag name field.

Citrix Xen使您能够配置“自定义字段”以进行过滤。 我们将创建字段,然后使用Xen-pocalypse使用的信息填充它们。 Xen-pocalypse识别3个控制TAG,这些TAG分别指定了备份的标签名称和父子关系。 如果您不打算使用文件输入法,则必须至少创建备份标签名称字段。

To do this, open the server’s or even a VM’s properties. In the navigation pane, select “Custom Fields”.

为此,请打开服务器甚至VM的属性。 在导航窗格中,选择“自定义字段”。

If this is the first time you define a relationship (as in the example above), you will not have any fields to input data into, so you need to create them. To do this, click on “Edit Custom Fields” in the dialog box that pops up, click on “Add…”

如果是第一次定义关系(如上例所示),则将没有任何字段可向其中输入数据,因此需要创建它们。 为此,请在弹出的对话框中单击“编辑自定义字段”,然后单击“添加…”

Create three (3) “Text” type fields. One will be called “BackupTAG” and the others “Parent” and “Children”.

创建三(3)个“文本”类型字段。 一个将被称为“ BackupTAG”,另一个将被称为“父母”和“孩子”。

Note: The names of the custom fields, have been “hard coded” into the script, so you MUST not deviate from the spelling above, unless you change the relevant code as well.

注意:自定义字段的名称已“硬编码”到脚本中,因此,除非您也更改了相关代码,否则不得偏离上面的拼写。

Once all fields have been created, you should see:

创建所有字段后,您应该看到:

Close the window.You should now have the “BackupTAG”, “Parent” and “Children” fields to fill, as in the picture below.

关闭窗口。您现在应该填写“ BackupTAG”,“ Parent”和“ Children”字段,如下图所示。

Now all you have to do is designate which VMs belong to what “BackupTAG”. For example, in the company where the script was grown, we had VMs that were to be backed up weekly on Thursday and Friday, a schedule for our Atlassian product VMs and some that were to be backed up only monthly. So our overview looked like:

现在,您要做的就是指定哪些VM属于“ BackupTAG”。 例如,在生长脚本的公司中,我们有要在周四和周五每周进行备份的VM, Atlassian产品VM的时间表以及一些仅每月进行备份的时间表。 因此,我们的概述如下所示:

Where for example “weekly-fri” was the text we have inputted into the “BackupTAG” “Custom Field”. Neat huh? :)

例如,在“ weekly-fri”是我们输入到“ BackupTAG”“ Custom Field”中的文本。 整洁吗? :)

Parents & Children (optional)

父母与子女(可选)

The real beauty of this script is that it supports “parent” to “child” relationships. That is, it is possible to set a list of “child” VMs that would be turned off and backed-up before the parent, and that these children will only be turned back on once the parent has finished its backup and has been turned back on. This is useful in cases where turning off the parent VM will cause the service in the child to become unavailable. Such a thing would mean the service on the child VM would be unavailable twice, once for the child’s backup process and once for the parent’s. Creating this relationship overcomes that problem.

该脚本的真正优点是它支持“父”到“子”关系。 也就是说,可以设置将在父级之前关闭和备份的“子级” VM的列表,并且只有在父级完成备份并返回后,这些子级的虚拟机才会重新打开。上。 在关闭父虚拟机将导致子虚拟机中的服务不可用的情况下,这很有用。 这样的事情意味着子VM上的服务将两次不可用,一次用于子节点的备份过程,一次用于父节点的备份过程。 建立这种关系克服了这个问题。

For example, all of our Atlassian VMs used a single DataBase (DB) VM, which was also set to be backed up. So by noting that the DB VM is a “Parent” to the other VMs, a proper order of shutdown -> backup -> startup, can be ensured.

例如,我们所有的Atlassian VM都使用一个数据库(DB)VM,该VM也已设置为要备份。 因此,通过注意DB VM是其他VM的“父级”,可以确保关闭->备份->启动的正确顺序。

At the time of this writing, this function has a couple of caveats:

在撰写本文时,此函数有两个警告:

  1. The names of the VMs that are to have such a relationship cannot contain spaces. You will have to remove spaces from your VM names, for they will be space delimited, as in the example below.具有这种关系的VM的名称不能包含空格。 您将必须从VM名称中删除空格,因为它们将以空格分隔,如下例所示。
  2. There can be only one parent. Designating more than one isn’t even planned for, not to mention tested.

    只能有一个父母。 甚至没有计划指定多个,更不用说经过测试了。

To create this relationship, go into the VM’s properties. If this is a “parent”, write who its children are and if this is a “child”, write who his parent is. For example:

要创建此关系,请进入VM的属性。 如果这是“父母”,请写出其孩子是谁,如果这是“孩子”,请写出其父母是谁。 例如:

Note: Not designating a Parent for a child may cause the child to be started before its parent is ready, and could cause it to be backed up twice.

注意:不为孩子指定父母,可能会导致孩子在其父母准备好之前开始,并且可能导致对其进行两次备份。

FILE方法(可选) (The FILE method (Optional))

For historical reasons, Xen-pocalypse also supports getting the list of VMs to be backed up as a text file. While the “code” is still in there, the functionality is severely inferior to the TAGs method and therefore it is not recommended. With that said, if you prefer to use the list method for some reason, the following restrictions apply:

由于历史原因,Xen-pocalypse还支持将要备份的VM列表作为文本文件进行备份。 虽然“代码”仍然存在,但功能严重不如 TAGs方法,因此不建议使用。 话虽如此,如果您出于某种原因更喜欢使用list方法,则适用以下限制:

  1. The names of the VMs cannot contain any spaces or special characters.

    VM的名称不能包含任何空格或特殊字符。

  2. There can be only one VM name per line.每行只能有一个VM名称。
  3. Blank lines are not allowed.不允许空白行。

To generate the list, either copy the VM’s name from the Xen center, or execute on a Xen host:

要生成列表,请从Xen中心复制VM的名称,或在Xen主机上执行:

xe vm-list | grep name-label | awk '{ print $4 }' | sort

xe vm-list | grep name-label | awk xe vm-list | grep name-label | awk '{ print $4 }' | sort '{ print $4 }' | sort

Copy the list above into a regular text file.

将上面的列表复制到常规文本文件中。

备份位置 (The backup location)

While randomly poking  around in Citrix Xen, I have found that the Storage Repositories (SRs) are available for use under “/var/run/sr-mount/%UUID%” where UUID is the unique identifier of the SR, which can be obtained from the GUI.

在Citrix Xen中随机访问时,我发现可以在“ / var / run / sr-mount /%UUID%”下使用存储库 (SR),其中UUID是SR的唯一标识符,可以是从GUI获取。

This means we can use the regular “Next -> Next -> Finish” wizard to create the mount to the desired backup location, and then have the script use that path (as apposed to messing with mounting from the command line), but doing so is beyond the scope of this guide.

这意味着我们可以使用常规的“下一步->下一步->完成”向导来创建到所需备份位置的装载,然后让脚本使用该路径(与从命令行进行装载有关 ),但是因此超出了本指南的范围。

To Create a new “mount”, right click the server name and select New SR.

要创建新的“装载”,请右键单击服务器名称,然后选择“新建SR”。

In this example we will point Xen to a windows share, so choose “Windows File Sharing (CIFS)”:

在此示例中,我们将Xen指向Windows共享 ,因此选择“ Windows文件共享(CIFS)”:

Complete the Next -> Next -> Finish.

完成下一步->下一步->完成。

Obtain the SR’s UUID

获取SR的UUID

To obtain an SR’s UUID, simply click on its name in the Xen Center and go to the “General” tab.

要获取SR的UUID,只需在Xen Center中单击其名称,然后转到“常规”标签。

In order to copy the UUID, simply right click it an choose “copy”.

为了复制UUID,只需右键单击它,然后选择“复制”。

With this information at hand, you are ready to edit the settings file.

有了这些信息,您就可以编辑设置文件了。

配置设置文件。 (Configure the Settings file.)

The Xen-pocalypse project comes bundled with a “settings” file template. This template should be edited to reflect your setup and passed as the first argument to the script. The settings file designates the following:

Xen-pocalypse项目与“设置”文件模板捆绑在一起。 应该编辑此模板以反映您的设置,并将其作为第一个参数传递给脚本。 设置文件指定以下内容:

The method for obtaining the VMs to be backed up – The default method is TAGs. You may change this to FILE, but this is not recommended.

获取要备份的VM 的方法 –默认方法是TAG。 您可以将其更改为FILE,但是不建议这样做。

The location of the backup destination – If you have followed the guide to this point, you only have to replace the %UUID% with the SR’s as it was obtained from above.

备份目标的位置 –如果您已按照指南进行操作,则只需用从上面获得的SR替换%UUID%即可。

The location of SendEmail  – If you have opted to enable Email, you need to input where you have extracted the perl executable here.

SendEmail的位置 –如果您选择启用电子邮件,则需要在此处输入提取perl可执行文件的位置。

Email details – Again, if you have enabled email, you need to define details such as: To, From, Servername/IP & etc’.

电子邮件详细信息–同样,如果启用了电子邮件,则需要定义详细信息,例如:“收件人”,“发件人”,“服务器名/ IP等”。

Compression – This is set to “No” by default, because while enabling it will produce a smaller backup file, it will also cause the backup procedure to run for a considerably longer amount of time.

压缩 –默认情况下将其设置为“否”,因为启用它会生成较小的备份文件,但也会导致备份过程运行相当长的时间。

Check for free space on the destination – This will have the script check that making the VM’s backup will not cause the backup location’s free space to fall beneath 10GB. This is done to ensure the most amount of VMs are backed up instead of just one very large VM. The calculation is done using the gross disk size total of all the HDs associated with the VM.

检查目标上的可用空间 –这将执行脚本检查,以确保虚拟机的备份不会导致备份位置的可用空间低于10GB。 这样做是为了确保备份最多数量的VM,而不是仅备份一个非常大的VM。 使用与VM关联的所有HD的磁盘总大小来完成计算。

Debugging  – The default is to have debugging turned off with the value “0” (zero). You should not need to turn this on, but if you do, more information is noted in the troubleshooting segment.

调试 –默认情况下,调试将关闭,其值为“ 0”(零)。 您不需要打开它,但是如果您这样做,则会在故障排除部分中指出更多信息。

执行/计划 (Execution/Scheduling)

In its simplest form, an invocation of Xen-pocalypse would look like:

以最简单的形式,Xen-pocalypse的调用看起来像:

./Xen-backup.sh settings.cfg weekly-fri

./Xen-backup.sh settings.cfg weekly-fri

Where in the case above, we are inside the directory that holds the script & the settings file. The “Tag” the script will look for is “weekly-fri”.

在上述情况下,我们位于保存脚本和设置文件的目录中。 脚本将查找的“标签”为“每周星期五”。

As noted above, we will use Cron to schedule the execution. Before we go into the configuration, it is highly recommended that you configure the already installed SSMTP package on your Xen server. While this is an optional step, doing so will give you a backwash collector. Having such a “backwash collector” may alert you of things the script isn’t able to.

如上所述,我们将使用Cron安排执行时间。 在进行配置之前, 强烈建议您在Xen服务器上配置已经安装的SSMTP软件包 。 尽管这是一个可选步骤,但这样做将为您提供反冲洗收集器。 拥有这样的“反洗收集器”可能会警告您脚本无法执行的操作。

Enter into cron’s editing more by issuing:

通过发出以下命令进一步进行cron的编辑:

crontab -e

crontab -e

If you have followed the instructions above and you want to add a scheduled backup for Friday at 18:01 (6:01PM), input the below:

如果您已按照上述说明进行操作,并且想在星期五18:01(6:01 PM)添加计划的备份,请输入以下内容:

01 18 * * fri /root/Xen-pocalypse-master/Xen_Backup.sh /root/Xen-pocalypse-master/settings.cfg weekly-fri

01 18 * * fri /root/Xen-pocalypse-master/Xen_Backup.sh /root/Xen-pocalypse-master/settings.cfg weekly-fri

The above is correct assuming your script and settings file are both under “/root/Xen-pocalypse-master/”.

如果您的脚本和设置文件都在“ / root / Xen-pocalypse-master /”下,则以上内容是正确的。

故障排除 (Troubleshooting)

While I’ve put a lot of effort into making the script as easy to use and as foolproof as possible, “The world is a bigger lab”. The information below may help you ascertain what is the source of your troubles.

尽管我已经尽了最大的努力来使脚本尽可能易于使用和简化,但是“世界是一个更大的实验室”。 下面的信息可以帮助你确定是什么的来源你的烦恼 。

Progress

进展

You may want to use this one liner to quickly “watch” all tasks in progress, to see if they actually progressing at all or if they are actually stuck.

您可能希望使用这种衬板来快速“监视”所有正在进行的任务,以查看它们是否真正在进行中或是否被卡住。

while [ -e /dev/null ]; do for VM in "$( xe task-list | grep uuid | awk '{print $5}' )" ; do  xe task-param-get  param-name=progress uuid=$VM ;sleep 1; done; done

while [ -e /dev/null ]; do for VM in "$( xe task-list | grep uuid | awk '{print $5}' )" ; do xe task-param-get param-name=progress uuid=$VM ;sleep 1; done; done

To stop watching, use Ctrl+C to brake the “while loop”.

要停止观看,请使用Ctrl + C制动“ while循环”。

Logging

记录中

All “logging” is collected by the Xen host running the script in the syslog mechanism. This of course can be viewed with:

Xen主机通过syslog机制中的脚本来收集所有“日志记录”。 当然,可以通过以下方式查看:

less +F /var/log/messages

less +F /var/log/messages

You are looking for the key word “Xen-pocalypse”.

您正在寻找关键字“ Xen-pocalypse”。

Note: Citrix has set a two (2) day retention policy for syslog of its servers. You may want to keep that in mind for postmortems.

注意:Citrix已为其服务器的系统日志设置了两(2)天的保留策略。 您可能要记住事后验尸。

Debugging

调试

As noted in the settings file segment, there is a directive to enable debugging.  Enabling debugging will cause the script to output verbose logging to the console and castrate it from sending emails and actually performing the exports, unless the relevant flags are also set. The possible flags are noted in the settings file template and they enable you to granularly define what you want to debug.

如设置文件部分所述,有一个指令可启用调试。 启用调试将导致脚本将详细的日志记录输出到控制台,并从发送电子邮件和实际执行导出中cast割它,除非也设置了相关标志。 可能的标志在设置文件模板中注明,它们使您可以细化定义要调试的内容。

It is my hope that you haven’t needed any debugging and you are reaping the fruits of my labor :)

我希望您不需要任何调试,并且正在收获我的劳动成果:)



Thrust, my man, you are about to become number one decepticon…

推力,我的男人,您将成为第一骗子...

翻译自: https://www.howtogeek.com/131181/how-to-backup-citrix-xen-vms-for-free-with-xen-pocalypse-bash/

xen vm安装

xen vm安装_如何使用Xen-pocalypse(Bash)免费备份Citrix Xen VM相关推荐

  1. xen vm安装_如何使用Xen-Phoenix(Bash)免费还原Citrix-Xen VM

    xen vm安装 Have you ever had the need to bulk restore your Citrix-Xen VMs for a disaster recovery (DR) ...

  2. 如何升级浏览器_绿茶浏览器app下载安装_绿茶浏览器软件最新版免费下载

    绿茶浏览器是由联想官方生产的移动浏览器软件. 它的优点在于其紧凑性. 至于稳定性和流畅性,现在许多浏览器的性能都很好,可以正常使用. 快速浏览所需的网页和其他内容. 软件介绍 绿茶浏览器是联想创建的一 ...

  3. xen虚拟化实战系列(二)之xen虚拟机安装

    xen虚拟化实战系列文章列表 xen虚拟化实战系列(一)之xen虚拟化环境安装 xen虚拟化实战系列(二)之xen虚拟机安装 xen虚拟化实战系列(三)之xen虚拟机复制 xen虚拟化实战系列(四)之 ...

  4. Xen vtpm安装随笔

    vtpm相关文档 1 xen环境(包括vtpm)的搭建 1 xen的安装 在shell下依次执行: # yum install -y zlib-devel.i386 libX11-devel.i386 ...

  5. Xen虚拟机安装Windows8

    Xen虚拟机安装Windows8 本文主要讲解在xen环境下如何安装Windows8系统虚拟机,主机系统是Ubantu14.04. 转载请注明出处. 目录 Xen虚拟机安装Windows8 安装前硬件 ...

  6. 虚拟化工具Xen的安装配置详解

    上一篇介绍了虚拟化的基础知识:这里来介绍具体的虚拟化工具的配置使用: 一.Xen的安装配置详解: 1.配置yum源 http://mirrors.163.com/centos/6.5/xen4/x86 ...

  7. vm安装xenserver_使用XenServer,Java和Apache CloudStack启动VM

    vm安装xenserver Apache CloudStack is an open-source management server for running a private cloud infr ...

  8. Juniper Space License Issue on Citrix Xen Environment

    Based on Juniper "Junos Space Virtual Appliance Installation and Configuration Guide" , Ju ...

  9. 安装VM及在VM下安装Ghost XP系统图文教程,附PQ分区及VM共享教程 z

    安装VM及在VM下安装Ghost XP系统图文教程,附PQ分区及VM共享教程 z http://blog.sina.com.cn/s/blog_58dae96501000710.html 第一章:安装 ...

最新文章

  1. 给windows装个Mac黑苹果虚拟机
  2. EZBioCloud:16S和原核基因组物种注释和新种鉴定
  3. 语音任务关键--噪声未必能听得到
  4. HDU 4001 To Miss Our Children Time(2011年大连网络赛 A 贪心+dp)
  5. Fortran执行语句中的“双冒号” ::
  6. JavaFX鼠标点击事件
  7. 自学成才翁_以自学成才的设计师的身份在产品表旁导航。
  8. 人脸库对比(百度人脸识别)(Java版)
  9. 『STATISTICS』傻瓜弄懂t检验
  10. Excel如何取消合并单元格并填充空单元格
  11. InfoPath 2007 常见问题
  12. 什么是SSD TRIM (by quqi99)
  13. 液晶坏点如何鉴别 LCD显示器选购之道
  14. c语言实验作业在dev蜗居的思路,C语言程序设计实验(共5篇)
  15. 含有一般疑问句的歌_七年级——一般现在时
  16. 浏览器标签页形式运行【js代码】,小书签
  17. ValueError: Expected parameter scale of distribution Normal to satisfy the constraint GreaterThan
  18. 计算机的最新发展趋势
  19. C# 编写Windows Service(windows服务程序)
  20. 设置tabBarItem图片渲染

热门文章

  1. 10分钟掌握Hive小文件过多如何解决?
  2. Linux高性能服务器开发——进程篇
  3. 网易笔试题-疯狂的队列
  4. 4.[QT | border_image]调整背景图片和边框距离
  5. 原生js的Ajax实例
  6. 【阿里云天池AI龙珠计划-Python训练营】学习笔记task1
  7. 万豪集团2023年中国市场酒店数量将超500家,进一步布局长三角、大湾区、环渤海 | 美通社头条...
  8. chatPDF | 别再自己读文献了!让chatGPT来帮你读吧!~
  9. quota 详解---quota 是什么
  10. TClientDataSet学习笔记