Xenserver deployment series-Virtual Machine creation and Replication

Source: Internet
Author: User
Tags configuration settings ssh secure shell

Xenserver deployment series 05 Virtual Machine creation and Replication

Job Environment


OS: xenserver 6.2

Hostname: xsr01


Gateway: IP:

1. About xenserver Virtual Machine

On xenserver, you can create virtual machines such as Windows and Linux. xenserver supports most mainstream operating systems. You can use xencenter or Xe CLI to clone the corresponding template and install the operating system. Xenserver is accompanied by a set of basic simulations (that is, the original VM) on which operating systems can be installed. A template is a "golden image" that contains all configuration settings used to instantiate a specific VM. To achieve the optimal running status, xenserver has set a predefined platform for defining virtual hardware configurations for templates applicable to various systems. The Linux template is used to create a semi-virtualized (PV) Guest System, the Windows template is used to create a hardware Virtual Machine (hvm) Guest System.

Xenserver tools must be installed for each virtual machine so that the virtual machine has fully supported configurations and can use xenserver management tools (Xe CLI or xencenter ). Although the VM can work normally without these tools, if these tools are not installed, the performance will be greatly affected. Xenserver also supports some features and features, including thorough shutdown, reboot, suspension, and real-time VM migration.

In addition to using the provided template to create a VM, you can also use three methods to create a VM: physical machine to virtual machine conversion (p2v); clone an existing VM; import an exported VM.

Ii. Use xencenter to create a VM

In view of the wide application of centos, I have been familiar with centos. In this case, we use centos as an example to describe how to create a virtual machine and related configurations.

For the deployment and storage configuration of xenserver, refer to the previous xenserver deployment recording series blog, which is not described here. Use xencener on the client to connect to the remote xsr01 host.

1. Create a VM using a template

The following operations are performed on xencenter.

Select the xsr01 host, right-click it, and select "New VM" to open the "New VM" Wizard.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/02/wKiom1OyKEfj5olfAAD_CPLDAZ4237.jpg "Title =" 01.jpg" alt = "wkiom1oykefj5olfaad_cpldaz4237.jpg"/>

Select the VM creation template. Here, select "centos 6 (64-bit )",

This list lists the templates currently supported by xenserver. Each template contains the settings required to create a new Vm with a specific operating system and the best storage. For more information, see Official documents. The practice shows that xenserver6.2 supports centos6.5.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/02/wKiom1OyKFujFqbOAADYJZ41tVk046.jpg "Title =" 02.jpg" alt = "wkiom1oykfuji boaadyjz41tvk046.jpg"/>

Enter the Virtual Machine name and optional description.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/01/wKioL1OyKErCM_g_AAC_mwE1iQQ958.jpg "Title =" 03.jpg" alt = "wkiol1oykercm_g_aac_mwe1iqq958.jpg"/>

Select the installation source for the operating system that will be installed on the new VM. Here we use the centos6.5 system image created in the local ISO repository.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/01/wKioL1OyKFzwacRMAADIzOEACdQ819.jpg "Title =" 04.jpg" alt = "wkiol1oykfzwacrmaadizoeacdq819.jpg"/>

Select the master server or cluster for the VM. In this case, there are no clusters and only xsr01 hosts are available.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/02/wKiom1OyKKOSUl0wAADC6yrTR-M091.jpg "Title =" 05.jpg" alt = "wKiom1OyKKOSUl0wAADC6yrTR-M091.jpg"/>

For the centos system, the default value is 1 virtual CPU and 1 GB virtual memory, which can be modified as needed.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/02/wKiom1OyKLixXJhSAACWfVjqnO8762.jpg "Title =" 06.jpg" alt = "wkiom1oyklixxjhsaacwfvjqno8762.jpg"/>

Allocate storage for virtual machines. Set the virtual hard disk capacity as needed and configure it on the local storage of the xsr01 host.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/02/wKiom1OyKM2xey3hAADb2wTFDzQ353.jpg "Title =" 07.jpg" alt = "wkiom1oykm2xey3haadb2wtfdzq353.jpg"/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/01/wKioL1OyKMDzC1KrAADjp3eYyac965.jpg "Title =" 08.jpg" alt = "wkiol1oykmdzc1kraadjp3eyyac965.jpg"/>

Configure the network connection settings of the virtual machine. When creating a virtual machine, you can create a maximum of four networks (generally, if the physical machine has four NICs, four networks will be automatically created here; if the physical machine has two NICs, 2 networks are automatically created. You can add NICs after the virtual machine is created. Delete the other three networks. Only Network 0 is retained.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/02/wKiom1OyKQaALXfvAAD4DMF0BlE988.jpg "Title =" 09.jpg" alt = "wkiom1oykqaalxfvaad4dmf0ble988.jpg"/>

Complete the VM creation and check the configuration properties. Then start the virtual machine to install the operating system.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/05/wKiom1OyK6DwAayMAADhQgW5So0163.jpg "Title =" 10.jpg" alt = "wkiom1oyk6dwaaymaadhqgw5so0163.jpg"/>

Start System installation. This interface is different from the general centos installation interface. Beginners will feel at a loss, because in the next installation process, we will find that this is a simple installation process, and the operation steps to simplify the partitioning are ignored.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/01/wKioL1OyKOvwoC5xAAFwBzhz0nw790.jpg "Title =" 11.jpg" alt = "wkiol1oykovwoc5xaafwbzhz0nw790.jpg"/>

After the installation is complete, the first login interface is as follows. The anaconda-ks.cfg file under the/root directory records some information when installing the system, from which you can see that the installation did not install other software packages, even the setup, VIM command corresponding software packages. Similar to centos's minimal installation mode.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/02/wKiom1OyKUjgNsiCAAEWNUTjvKU014.jpg "Title =" w.jpg" alt = "wkiom1oykujgnsicaaewnutjvku014.jpg"/>

In this case, the 30 GB virtual hard disk, 4 GB virtual memory, the virtual system uses 48 MB as the/boot partition, and the remaining capacity is a logical volume named volgroup, the volume is divided into two partitions:/root and swap, with the size of 26.5G and 3G respectively. If the capacity of the virtual hard disk is large, for example, 500 GB, the system LVM partition will have an automatic distribution similar to the following: swap 4 GB,/root 50 GB, and other capacity is/home.

The above installation conditions are difficult for many users and are difficult to adapt to actual needs. So, is there a way to install the centos System in the conventional way? The answer is yes, and it is very simple. The "other install Media" template is used.

For the "other install Media" template, official information is as follows: for advanced users, these users may try to install VMS running other unsupported operating systems. Xenserver has been tested and can only run Supported Release versions and specific versions in the provided standard template, however, it does not support any VMS installed using other installation media templates (This section is easy to understand ).

Select "Other install media". In the next step, adjust the parameters of CPU, storage, and network resources. The operation steps are the same. Finally, go to the system installation page, the familiar centos System Disk startup interface is displayed.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/01/wKioL1OyKW6hYBAlAAEhByFl-tc593.jpg "Title =" 21.jpg" alt = "wKioL1OyKW6hYBAlAAEhByFl-tc593.jpg"/>

The above is the process of creating a centos VM using xencenter. If it is a Windows system, no such situation exists. The corresponding template will be installed normally.

2. Install xenserver tools

After the system is installed, it is recommended to install xenserver tools immediately so that the VM has fully supported configurations to obtain high-speed I/O for higher disk and network performance.

No xenserver tools is installed on the VM. The most direct manifestation is that the memory usage of the VM cannot be monitored on the xencenter. As shown in. Select the newly created centos6.5vm. On the performance selection card, there are four charts, indicating the usage of the virtual CPU, memory, network, and hard disk. The second chart has no content in the virtual memory.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/02/wKiom1OyKb-xMg1xAAFbjGPvyLc190.jpg "Title =" 31.jpg" style = "float: none;" alt = "wKiom1OyKb-xMg1xAAFbjGPvyLc190.jpg"/>

Switch to the console tab, and in the drop-down list box of "DVD Driver 1" at its top, select "xenserver tools \ xs-tools.iso", which means the system inserts a xs-tools.iso disc. Then, go to the command line interface of the console, load the CD using commands, and execute the Linux/install. Sh script to install XS-tools. This operation takes effect only after the system is restarted.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/01/wKioL1OyKZGh91vKAAEs8UzRCLw346.jpg "Title =" 32.jpg" style = "float: none;" alt = "wkiol1oykzgh91vkaaes8uzrclw346.jpg"/>

After xenserver tools is installed and the system is restarted, you can see the virtual memory usage of the virtual machine in the performance selection card.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/01/wKioL1OyKZDB-Q4YAAGBDsxLD4Y662.jpg "Title =" 33.jpg" style = "float: none;" alt = "wKioL1OyKZDB-Q4YAAGBDsxLD4Y662.jpg"/>

For a Windows system, easier to operate, mount the xs-tools.iso, the system automatically opens the xenserver tools Installation Wizard. Xenserver tools must be supported by Microsoft. NET Framework 4.0 or later. If the virtual machine runs Windows 7 or a later version, you must install the Microsoft. NET Framework 4.0 component before installing xenserver tools.

Iii. VM replication and cloning

A new virtual machine is created, common software is installed, and a good luck environment is configured. In this case, you need to back up the system to quickly deploy the same system. This involves the "Copy VM" function of xenserver.

Xenserver includes two copy VM (copy Virtual Machine) modes, full copy (full copy) and fast clone (fast clone ). In general, the "replication" function in xenserver is often understood as the "clone" function in other virtualization tools. However, these two concepts are actually different in xenserver, as mentioned in the literal sense, fast clone is indeed a clone. VM clone uses the link method, while full copy is VM copy, which adopts the complete replication method.

Full copy is a complete copy of the virtual machine, the replication speed depends on the storage performance; fast clone speed is basically completed in an instant, because fast clone is directly connected to the current or renamed Base copy VDI, this mode converts the original VDI to the basic node. For the specific deep difference between the two, please refer to this blog http://xenme.com/1170

To perform virtual replication, create, install, and configure windows virtual machines as needed, and install xenserver tools. After the VM is ready, you must turn off the power of the VM.

The following example describes how to copy a new centos6.5vm. A simple operation.

Disable centos6.5vm, right-click it, and select "Copy VM" to open the "Copy Virtual Machine" dialog box.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/02/wKiom1OyKgChF6RQAACE9wIzHCg534.jpg "Title =" 41.jpg" style = "float: none;" alt = "wkiom1oykgchf6rqaace9wizhcg534.jpg"/>

Set the name of the new virtual machine and select copy mode.

Copy mode is divided into fast clone and full copy. It is very clear here.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/01/wKioL1OyKdHxOQmdAABiRUtKtcg404.jpg "Title =" 42.jpg" style = "float: none;" alt = "wkiol1oykdhxoqmdaabirutktcg404.jpg"/>

The replication progress and the time spent completing the replication are displayed in the logs of xencenter, which is the result of fast clone and full copy on the centos6.5vm.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/01/wKioL1OyKdHCcu12AAE60mJekdU283.jpg "Title =" 43.jpg" style = "float: none;" alt = "wkiol1oykdhccu12aae60mjekdu283.jpg"/>

If you run the above two copy VMS, you will find that the network is faulty. This is caused by changes in the MAC address. You need to modify the parameter hwaddr of the configuration file/etc/sysconfig/network-scripts/ifcfg-eth0 in the system, set the value to the MAC value of "device 0" in the "networking" tab corresponding to the Virtual Machine in xencenter.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/02/wKiom1OyKf_TQrxZAADL6FfXMgM680.jpg "Title =" 44.jpg" style = "float: none;" alt = "wkiom1oykf_tqrxzaadl6ffxmgm680.jpg"/>

The above MAC address-based network problems mainly occur in Linux Virtual Machine Replication. If it is a Windows virtual machine, this problem does not exist.

Iii. VM Export and Import

Xenserver allows you to import and export VMS in different formats, according to official documents. The xencenter import wizard allows you to import VMS from Disk Images (vhd and vmdk), open virtualization formats (ovf and OVA), and xenserver xva formats, you can even import VMS created on other virtualization platforms.

The Export (export) and import (import) of VM are extensive and complex. My contact is limited. In this case, we will only discuss how to use Xe CLI to import and export VMS in xenserver xva format. Xva is a unique Virtual Device format of xenserver. It is used to package a single VM into a group of files, including descriptors and disk images. The file extension is. xva.

The Virtual Machine export in xenserver is mainly used to import data to another xenserver, or to the local machine itself. My favorite VM replication method is not copy Vm, but export/import VM. After the system configuration is complete, export it as one. xva files are stored in the storage directory of the attached disk (which can be a Mobile Disk) and copied to the storage directory of other xenserver hosts. When necessary, xva files can be imported to the host system in multiple copies, run and use. It is very convenient, but it takes much longer time than the copy VM.

In this case, a gb sas hard disk is added, which is divided into two partitions, sdb1 and sdb2, and mounted to the/ISO and/Data Directories respectively. The former is used to store ISO image storage, it is used as the local ISO repository; the latter is used as the data storage, used to store exported. xva virtual machine files. The operation commands and procedures for adding a hard disk are the same as those for Red Hat Linux, which belongs to the basic skills of the IT personnel. For more information, see xenserver real-time recording system deployment-add local storage.

1. Export virtual machines

Use SSH tools (such as SSH Secure Shell client) to remotely connect to the xenserver host, or open the console of the xenserver host in the xencenter, disable the virtual machine to be exported, and then execute the following command to export the virtual machine, the name of the VM in xencenter,

Xe VM-export Vm = Virtual Machine name filename =/storage path/virtual machine name. xva

In this case, the centos6.5vm virtual machine is exported to/data. The specific command is shown in,

Note: Because this command has been executed for a long time, it is generally added after it to be run in the background. After the export is complete, an export succeeded message is displayed.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/02/wKioL1OyKiXTXeLoAAAkGZErJDU376.jpg "Title =" 51.jpg" style = "float: none;" alt = "wkiol1oykixtxeloaaakgzerjdu376.jpg"/>

When exporting a VM, you can view the export process on the xencenter log interface.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/05/wKiom1OyKwrzsMcCAADpTep3peU331.jpg "Title =" 52.jpg" alt = "wkiom1oykwrzsmccaadptep3peu331.jpg"/>

2. Import virtual machines

If you want to import a VM, run the following command. Check the VM name in advance. If the VM name does not exist, an error is returned.

Xe VM-import filename =/storage path/virtual machine name. xva

In this case, import/data/centos6.5vm. xva. The specific command is shown in. After the import is complete, the uuid is returned.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/02/wKioL1OyKiWhJiGGAAAlVFZoJOs219.jpg "Title =" 53.jpg" style = "float: none;" alt = "wkiol1oykiwhjiggaaalvfzojos219.jpg"/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/05/wKiom1OyKyKjpg8jAAELss5evbQ566.jpg "Title =" 54.jpg" alt = "wkiom1oykykjpg8jaaelss5evbq566.jpg"/>

After the import is complete, change the Virtual Machine name as needed. We recommend that you change the host name in the system.

Similar to copy VM. The MAC address of the newly imported virtual machine is also overwritten. During the first running, the network is also faulty. You need to modify the parameter hwaddr of the configuration file/etc/sysconfig/network-scripts/ifcfg-eth0 in the system, set the value to the MAC value of "device 0" in the "networking" tab corresponding to the Virtual Machine in xencenter. This problem does not exist for Windows virtual machines.

3. Export the VM to the client through xencenter

The above is the export and import of the VM on the xsr01 local machine. In fact, the VM can be directly exported to the client PC with xencenter installed. This provides great flexibility in practical applications.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/02/wKiom1OyKlSj8Mn8AAFCbkrH5iU388.jpg "style =" float: none; "Title =" 61.jpg" alt = "wkiom1oyklsj8mn8aafcbkrh5iu388.jpg"/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/02/wKioL1OyKiWiKFllAACvOGZqtKM259.jpg "style =" float: none; "Title =" 62.jpg" alt = "wkiol1oykiwikfllaacvogzqtkm259.jpg"/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/03/wKiom1OyKlTBpZOtAACzbvwXgzQ087.jpg "style =" float: none; "Title =" 63.jpg" alt = "wkiom1oykltbpzotaaczbvwxgzq087.jpg"/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/02/wKiom1OyKlOgCOubAADBCMEqwOM107.jpg "Title =" 64.jpg" style = "float: none;" alt = "wkiom1oyklogcoubaadbcmeqwom107.jpg"/>

Importing a VM from a client PC is similar to exporting a VM.

Of course, this import and export method is mainly used in a standalone running environment. In the cluster environment of the resource pool, the migration of virtual machines is more flexible and rapid.

This article from the "One Tree qingjin" blog, please be sure to keep this source http://sunshyfangtian.blog.51cto.com/1405751/1432995

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.