Veeampdf.s3.Amazonaws.com Whitepapers Protected Veeam Brien Posey Hands on Guide Understanding Hyper v in Windows Server 2012

October 2, 2017 | Author: teste_download | Category: Hyper V, Computer Cluster, Active Directory, Microsoft Windows, Computer Data
Share Embed Donate


Short Description

Download Veeampdf.s3.Amazonaws.com Whitepapers Protected Veeam Brien Posey Hands on Guide Understanding Hyper v in Windo...

Description

Hands-on Guide:

Understanding  Hyper-V  in Windows Server 2012

Brien Posey

Pete Zerger, Chris Henley

Understanding Hyper-V in Windows Server 2012

Contents Chapter 1. An Introduction to Hyper-V 3.0 Chapter 2. Failover Clustering

3 30

Chapter 3. Migrations 84 Chapter 4. Managing Virtual Machine Failover

123

Chapter 5. PowerShell Management

144

Chapter 6. Virtual Machine Management

181

Chapter 7. P2V Conversions

222

Chapter 8. Replication 246 Chapter 9. Hyper-V Management

273

Chapter 10. Networking 293 Chapter 11. Backing up Hyper-V

317

Chapter 12. Automation and Orchestration

336

Share this e-book with your peers

2

Understanding Hyper-V in Windows Server 2012

Chapter 1

An Introduction to Hyper-V 3.0 This chapter is designed to get you started quickly with Hyper-V 3.0. It starts with a discussion of the hardware requirements for Hyper-V 3.0 and then explains a basic Hyper-V–deployment followed by an upgrade from Hyper-V 2.0 to Hyper-V 3.0. The chapter concludes with a demonstration of migrating virtual machines from Hyper-V 2.0 to Hyper-V 3.0

3

Understanding Hyper-V in Windows Server 2012

Hyper-V 3.0 flavors Before we get started, it is worth noting that like its predecessors, Hyper-V 3.0 comes in two different flavors. Microsoft offers a standalone version of Hyper-V, or you can operate Hyper-V as a server role on top of Windows Server 2012. This book deals with Hyper-V exclusively as a server role.

Hardware requirements According to Microsoft, the minimum hardware required for deploying Windows Server 2012 includes: • A 64-bit processor operating at 1.4 GHz or higher • 512 MB of RAM • 32 GB of hard disk space • A DVD Drive • A monitor and video card with a minimum display resolution of 800 x 600 • Keyboard and mouse (or other compatible pointing device) • Internet access Because Hyper-V is designed to use the server’s hardware to host a number of virtual machines, the minimum system requirements are not suitable for Hyper-V. Specifically, you will need more memory and hard disk space, and it’s advisable to have a server with multiple sockets and/or multiple CPU cores. The servers used in the development of this book were equipped with the following: • An 8-core, 64-bit CPU • 32 GB of RAM • A 500-GB hard drive used to store the host operating system. • Four 1-TB hard drives configured as a RAID 5 array In addition to the hardware requirements listed above, the CPU must support hardware-level virtualization. It is worth noting that virtualization has been disabled by default on many servers, so you may need to enable virtualization through the system BIOS, as shown in Figure 1.1. If your server’s BIOS contains a setting for Data Execution Prevention (DEP), you will need to enable that setting as well.

4

Understanding Hyper-V in Windows Server 2012

Figure 1.1

You may need to manually enable virtualization in the server’s BIOS.

Installing Windows Server 2012 and Hyper-V 3.0 Setting up a clean installation of Windows Server 2012 and Hyper-V 3.0 is relatively simple and straightforward. First, install Windows Server 2012 by completing these steps: 1. Boot your server from the Windows Server 2012 installation media. 2. When the Windows Server 2012 splash screen launches, verify that the language, time and currency format, and keyboard or input methods are correct (Figure 1.2). Figure 1.2

Verify your installation preferences.

5

Understanding Hyper-V in Windows Server 2012

3. Click Next. 4. Click Install Now (Figure 1.3). Figure 1.3

Click Install Now.

5. Choose the operating system that you want to install (Figure 1.4). It is worth noting that a default Windows Server 2012 does not include the GUI. If you want to use the GUI then do not choose the Server Core option. Although Server Core is Microsoft’s preferred method for deploying Windows Server 2012, it is easier to manage Hyper-V through a GUI. Therefore, the instructions found throughout this book will assume that you are using the GUI. If you are interested in Server Core deployments, see Chapter 5 for a discussion about managing Hyper-V through Windows PowerShell. Figure 1.4

Choose the edition of Windows Server 2012 that you want to install.

6

Understanding Hyper-V in Windows Server 2012

6. Accept the license agreement and click Next (Figure 1.5). Figure 1.5

You must accept Microsoft’s license agreement.

7. When prompted for the type of installation you want to perform, choose the option for Custom: Install Windows Only (advanced) (Figure 1.6). Figure 1.6

Choose the option to perform a custom installation.

8. Choose the volume on which you want to install Windows and click Next (Figure 1.7).

7

Understanding Hyper-V in Windows Server 2012

Figure 1.7

Select the drive or volume on which you want to install Windows Server 2012.

9. Setup will now begin the installation process (Figure 1.8). After the Windows installation completes , you must work through a separate process to install Hyper-V. Figure 1.8

The installation process will now begin.

Deploying Hyper-V 3.0 After Windows Server 2012 is up and running, the next step is to install the Hyper-V role. To do so, follow these steps: 1. Open the Server Manager if it is not already open. 2. Choose the Add Roles and Features command from the Manage menu (Figure 1.9).

8

Understanding Hyper-V in Windows Server 2012

Figure 1.9

Choose the Add Roles and Features command.

3. When the Add Roles and Features Wizard launches, click Next to bypass the wizard’s Welcome screen. 4. Click Next. 5. Choose the Role-Based or Feature-Based Installation option (Figure 1.10). Figure 1.10

Choose the Role Based or Feature Based Installation option.

6. Click Next. 7. On the Server Selection screen, make sure that the local server is selected and click Next (Figure 1.11).

9

Understanding Hyper-V in Windows Server 2012

Figure 1.11

Make sure that your local server is selected.

8. Select Hyper-V from the list of server roles (Figure 1.12). Figure 1.12

Select the Hyper-V role.

9. If you are prompted to install additional features, click the Add Features button. 10. Click Next.

10

Understanding Hyper-V in Windows Server 2012

11. When the wizard displays the list of available features, click Next. 12. Click Next on the Hyper-V introductory screen. 13. Select the network adapters that you want to make available to your virtual machines. Be sure to reserve at least one network adapter for host management traffic (Figure 1.13). Figure 1.13

Be sure to reserve a network adapter for host management traffic.

14. Click Next. 15. At this point you will see a screen asking if you want to allow the server to send and receive live migrations of virtual machines. Live migrations are discussed in Chapter 3, so for now just click Next to accept the defaults. 16. When prompted, click Next to accept the default stores. 17. When the Confirmation screen is displayed, click the Install button.

Post deployment tasks After the installation process completes, you may need to perform a number of post-deployment tasks, which might include:

• Configure the host’s IP address • Rename the host • Join the host to a domain The sections that follow will walk you through performing each of these tasks.

11

Understanding Hyper-V in Windows Server 2012

Configure the host’s IP address In most cases, Hyper-V host servers need to have at least one NIC that is dedicated to hosting management traffic. As a best practice, you should assign a static IP address to this NIC. You can assign an IP address to the server’s management NIC as follows: 1. Move the mouse to the lower left corner of the screen and right click. Choose the Control Panel option from the right-click menu. 2. When the Control Panel appears, click on Network and Internet. 3. Click on Network and Sharing Center. 4. Click on the Change Adapter Settings link. 5. Right click on the icon representing your management NIC and choose the Properties command from the shortcut menu. 6. Assuming that IPv4 is being used, select the Internet Protocol Version 4 (TCP/IPv4) option and click the Properties button (Figure 1.14). 7. Enter the IP address that you want to assign to the NIC and click OK (Figure 1.15). Figure 1.14

Select Internet Protocol Version 4 (TCP/IPv4) and click the Properties button.

12

Understanding Hyper-V in Windows Server 2012

Figure 1.15

Provision your management NIC with a static IP address and click OK.

Rename the host Windows Server 2012 automatically assigns a unique host name to each server, but it is generally advisable to assign a more meaningful name to each Hyper-V host. Doing so will make the host management process easier. To assign a new name to your Hyper-V host server, follow these steps: 1. M ove the mouse to the lower left corner of the screen and right click. Choose the System option from the right-click menu. 2. When the System properties sheet appears, click on the Change Settings link (Figure 1.16).

13

Understanding Hyper-V in Windows Server 2012

Figure 1.16

Click the Change Settings link.

3. Verify that the Computer Name tab is selected and then click the Change button (Figure 1.17). Figure 1.17

Click the Change button.

14

Understanding Hyper-V in Windows Server 2012

4. Enter a new name for the server and click OK (Figure 1.18). Figure 1.18

Enter a new computer name and click OK.

5. Click OK to acknowledge the message indicating that you must restart your computer to apply the new name. 6. Click Close. 7. When prompted, click Restart Now (Figure 1.19). Figure 1.19

You must restart the server before your changes will take effect.

15

Understanding Hyper-V in Windows Server 2012

Join the host to a domain The process of joining a Windows Server 2012 host to a domain is very similar to that used in joining a Windows Server 2008 R2 host to a domain. To join a domain, follow these steps: 1. From the Metro interface, click the Desktop tile. 2. Move your mouse to the lower left corner of the screen and right-click on the Start tile. 3. Click on the System option on the right-click menu. 4. When the System dialog box appears, click on the Change Settings link (Figure 1.16). 5. When the System Properties sheet appears, go to the Computer Name tab and click the Change button (Figure 1.17). 6. Select the Domain option and enter the fully qualified domain name (Figure 1.18). 7. Click OK. 8. When prompted, enter a set of administrative credentials for the domain. 9. Click OK to clear the message indicating that the computer has been joined to a domain. 10. Reboot the server (Figure 1.19).

Performing an in-place upgrade from Hyper-V 2.0 If your organization is currently running Hyper-V 2.0, it is usually possible to perform an in-place upgrade to Hyper-V 3.0. In preparation for an upgrading a standalone Hyper-V 2.0 server, you must shut down any virtual machines that are currently running. To complete the upgrade, follow these steps: 1. Shut down any virtual machines that are running on the server to be upgraded. If any virtual machines are left running, the Compatibility Report will prevent the upgrade from continuing (Figure 1.20).

16

Understanding Hyper-V in Windows Server 2012

Figure 1.20

You must shut down the virtual machines prior to beginning the upgrade.

2. With Windows Server 2008 R2 still running, insert your Windows Server 2012 installation media and run the Setup program. 3. When the Windows Server 2012 splash screen appears, click Install Now (Figure 1.21). Figure 1.21

Click the Install Now button.

4. When prompted, click on the option to go online to install updates (Figure 1.22).

17

Understanding Hyper-V in Windows Server 2012

Figure 1.22

You should go online to get the latest updates.

5. Enter your product key and click Next. 6. Select whether you want to perform a server core deployment or a fullserver deployment that includes the GUI (Figure 1.23). It is worth noting that Windows Server 2012 is designed to perform a server core deployment by default. However, you cannot perform an in-place upgrade of a full Windows Server deployment (with a GUI) to a server core deployment. If you want a server core deployment, you will have to upgrade to the full GUI version of Windows Server 2012 and then uninstall the GUI later. The instructions provided in this book assume that you will be working with a full GUI-based installation. If you are interested in using Server Core, see Chapter 5 for a discussion of how to manage Hyper-V from PowerShell. Figure 1.23

Choose the edition of Windows Server 2012 that you want to install.

18

Understanding Hyper-V in Windows Server 2012

7. Click Next. 8. When prompted, accept the license agreement and click Next (Figure 1.24). Figure 1.24

You must accept Microsoft’s license agreement.

9. Choose the option to Upgrade: Install Windows and keep files, settings, and applications (Figure 1.25). Figure 1.25

Choose the option to upgrade the existing operating system.

10. Take a moment to review the Compatibility Report, which informs you of issues you need to address prior to moving forward with the upgrade (Figure 1.26). When you are finished, click Next.

19

Understanding Hyper-V in Windows Server 2012

Figure 1.26

Take a moment to read the compatibility report.

11. At this point, Windows will be installed. The remainder of the upgrade process is automated.

Migrating virtual machines from Hyper-V 2.0 to Hyper-V 3.0 One of the big disadvantages to performing an in-place upgrade is that it can cause virtual machines to be down for a significant amount of time. One way to reduce the amount of time during which virtual machines are unavailable is to perform a migration rather than an upgrade. A migration involves deploying Hyper-V 3.0 onto new hardware while your existing hardware continues to run Hyper-V 2.0. Once the deployment is complete, you can migrate the individual virtual machines from the Hyper-V 2.0 deployment to the Hyper-V 3.0 deployment.

Exporting the virtual machines The first step in migrating virtual machines from Hyper-V 2 to Hyper-V 3 is to export the virtual machines to either a network share or to removable media. To complete the export process, follow these steps: 1. Open the Hyper-V Manager on the Hyper-V 2.0 Server. 2. Select the virtual machines that you want to export (Figure 1.27).

20

Understanding Hyper-V in Windows Server 2012

Figure 1.27

Select the virtual machines that you wish to export.

3. Click on the Export link. 4. Specify a path to write the exported content (Figure 1.28). Be sure to choose a location with plenty of free storage space. Figure 1.28

Enter an export path and click the Export button.

5. Click Export. You can monitor the progress of the export by scrolling the Hyper-V Manager to view the virtual machine Status (Figure 1.29).

21

Understanding Hyper-V in Windows Server 2012

Figure 1.29

You can monitor the export process through the Hyper-V Manager.

Importing virtual machines Importing virtual machines into Hyper-V 3.0 is a relatively easy and straightforward process. You can import one or more virtual machines as follows: 1. Open the Hyper-V Manager. 2. Right-click on the name of the Hyper-V host and select the Import Virtual Machine command from the right-click menu (Figure 1.30). Figure 1.30

Right click-on your the server and select the Import Virtual Machine command from the right‑click menu.

3. When the Import Virtual Machine wizard launches, click Next to bypass the wizard’s Welcome screen. 4. Click the Browse button.

22

Understanding Hyper-V in Windows Server 2012

5. Navigate to the folder containing the virtual machine that you want to import and click the Select Folder button. 6. Choose the virtual machine that you want to import (Figure 1.31). Figure 1.31

Select the virtual machine that you want to import.

7. Click Next. 8. The next screen asks you to choose an import type (Figure 1.32). Unless you have a compelling reason to choose one of the other options, it is usually best to choose the option to Copy the Virtual Machine (Create a New Unique ID). This allows the exported virtual machine to be re‑imported later should the need ever arise.

23

Understanding Hyper-V in Windows Server 2012

Figure 1.32

Choose the appropriate import type.

9. Click Next. 10. The following screen asks if you want to store any of the virtual machine components in a different location. Generally, it is safe to accept the defaults. Click Next. 11. The wizard will now ask where you want to store the imported Virtual Hard Disks. Select a folder on an appropriate volume and click Next. 12. Verify the summary information screen and click Finish (Figure 1.33).

24

Understanding Hyper-V in Windows Server 2012

Figure 1.33

The import process begins when you click Finish.

The import process can take a considerable amount of time to complete, depending upon the size of the virtual machine and the speed of the hardware. When the import process finishes, you should see the newly imported virtual machine within the Hyper-V Manager. Before you power-up the newly imported virtual machine, you need to connect the virtual machine to a virtual switch. To do so, right click on the virtual machine and choose the Settings command from the right-click menu. When the Settings page appears, click on the Network Adapter option and then connect the virtual machine to the appropriate virtual switch (Figure 1.34). When you have finished, click OK.

25

Understanding Hyper-V in Windows Server 2012

Figure 1.34

You must connect your virtual machine to a virtual switch.

This completes the process of importing a virtual machine. Previous versions of Hyper-V required you to re-enter the IP address configuration for each virtual network adapter. However, Hyper-V 3.0 preserves the virtual machine’s IP address configuration. The only change that you might need to make to the virtual machine is to install an updated version of the Hyper-V Integration Services.

What about clusters? This chapter has discussed clean Hyper-V installations as well as the process for upgrading a Hyper-V 2.0 server to Hyper-V 3.0. Although these techniques are certainly valid, organizations that are currently running Hyper-V are often using a clustered environment. The process of building a Hyper-V cluster is discussed in detail in Chapter 2. This section explains what is involved in upgrading a Hyper-V 2.0 cluster to Hyper-V 3.0—a process that is not entirely intuitive. Microsoft’s preferred method for performing a cluster upgrade involves building an entirely new cluster. The basic idea is to create a cluster out of servers that are running Windows Server 2012. If you lack the budget to build a completely new

26

Understanding Hyper-V in Windows Server 2012

cluster, you can start small by building the new cluster with a minimum number of cluster nodes and using low-end hardware if necessary. After the migration process is complete, you can always install Windows Server 2012 onto your existing cluster hardware, join those servers to the new cluster and then remove the temporary, low-end servers from the cluster. Don’t worry too much about exceeding the maximum cluster size during the migration process, because Windows Server 2012 allows up to 63 cluster nodes. As you probably know, Hyper-V 2.0 clusters depend on the use of Cluster Shared Volumes. When you build the new Hyper-V 3.0 cluster, you must attach the cluster nodes to the existing cluster shared volume (see Chapter 2 for details). At this point, both the Hyper-V 2.0 cluster and the Hyper-V 3.0 cluster should be tied into the same Cluster Shared Volume. Once the Hyper-V 3.0 cluster is in place, verify that the Hyper-V 2.0 cluster is still functional and that the virtual machines are still running (there is no reason why they shouldn’t be, because the cluster has not been modified). Now, open the Failover Cluster Manager on one of your Windows Server 2012 servers and follow these steps: 1. Right-click on the cluster name and choose the More Actions | Migrate Roles commands from the right-click menus (Figure 1.35). Figure 1.35

Choose the Migrate Roles option.

2. When the Migrate a Cluster Wizard launches, click Next to bypass the wizards’ Welcome screen. 3. When prompted, enter the name of the old cluster from which you plan to migrate the virtual machines (Figure 1.36).

27

Understanding Hyper-V in Windows Server 2012

Figure 1.36

Enter the name of your Hyper-V 2.0 cluster.

4. Select the virtual machines that you plan to migrate and click Next (Figure 1.37). Figure 1.37

Choose the virtual machines that you want to migrate.

28

Understanding Hyper-V in Windows Server 2012

5. Choose the Virtual Network Switch that the virtual machines should use after they have been migrated to the new cluster and click Next. 6. The next screen provides an analysis of the migration. You can click the View Report button to see the full Failover Cluster Pre-Migration Report. It is worth noting that the report indicates that the cluster group and the available storage cannot be migrated. This is perfectly normal and acceptable. 7. Close the report and click Next. 8. Take a moment to verify the information displayed on the Confirmation screen and click Next. 9. When the migration completes, click Finish. Please keep in mind that Windows Server 2012 does not perform a live migration of the virtual machines. When the migration completes, the virtual machines are still running on the Hyper-V 2.0 cluster, so there are a couple of things that you need to do to complete the process. First, shut down the virtual machines on the Hyper-V 2.0 server. Second, disconnect the Hyper-V 2.0 cluster nodes from the shared storage. If you fail to do this, virtual machine corruption can occur. Finally, start the virtual machines on your new cluster. Once the virtual machines are up and running, it is safe to destroy your Hyper-V 2.0 cluster and re-provision the host servers for use in the new cluster.

Share this e-book with your peers

29

Understanding Hyper-V in Windows Server 2012

Chapter 2

Failover Clustering Chapter 2 is designed to familiarize you with your options for Hyper-V clustering. Hyper-V 3.0 allows you to build a cluster with or without shared storage, and this chapter walks you through both methods. In addition, you will learn how to provision storage using a new Windows Server 2012 feature called Windows Storage Spaces.

30

Understanding Hyper-V in Windows Server 2012

Perhaps the most important concept to understand with regard to server virtualization is that of clustering. The reason for this is simple: Server virtualization places an increased importance on server hardware. In a traditional physical datacenter the failure of a single server is typically regarded as an inconvenience, but is rarely catastrophic. In a virtual datacenter, however, this may not be the case. Each physical server hosts multiple virtual machines. Therefore, if a physical server fails then all of the virtual machines residing on that server will also fail. Hence, the failure of a single physical host can cause a major outage. The only way to protect against this type of failure is through the use of failover clustering. Failover clustering spreads a virtualized workload across multiple physical hosts. That way if a host server fails, the virtual machines can fail over to a different host server within the cluster and remain online in spite of the failure. Failover clustering is not new to Hyper-V 3.0, but Microsoft has made significant improvements to failover clustering. Many of these improvements are related to scalability. The table below compares a Hyper-V 2.0 cluster to a Hyper-V 3.0 cluster in terms of scalability. Hyper-V 2.0

Hyper-V 3.0

384

1024

Maximum number of virtual machines in a cluster

1000

4000

Maximum number of hosts per cluster

16

63

1 TB

2 TB

The maximum number of virtual machines per host that can be powered on at any given time

Maximum RAM per host server

Another major improvement that Microsoft has made with regard to failover clustering is that they have changed the storage requirements. Prior to Hyper-V 3.0, a Hyper-V cluster depended on the use of a Cluster Shared Volume. A Cluster Shared Volume is a shared storage volume that physically contains all of the virtual machine components. Because the storage is shared, it is physically accessible to all of the cluster nodes. You can see an example of shared storage architecture in Figure 2.1.

31

Understanding Hyper-V in Windows Server 2012

Figure 2.1

Previous versions of Hyper-V required failover clusters to make use of shared storage.

In Hyper-V 3.0, shared storage is no longer required for failover clustering. A failover cluster can be built without the need for a Cluster Shared Volume. In those types of clusters, the virtual machines can reside on local direct attached storage or they can even reside on certain types of file servers. The fact that you can create failover clusters without a Cluster Shared Volume is good news for smaller organizations because the cost of shared storage often puts clustered virtualization hosts financially out of reach. Even so, Microsoft recommends that Hyper-V 3.0 failover clusters make use of failover clusters whenever possible . This chapter will demonstrate the process of building failover clusters both with and without shared storage.

Cluster planning Before you begin constructing a failover cluster you will need to do some planning. Obviously you will need to decide whether the cluster will use shared storage, you’ll need to take into account a number of other considerations, including: • Domain membership — Domain membership isn’t an absolute requirement for cluster nodes, but the configuration process is a lot easier if all of the cluster nodes are members of a common Active Directory domain. Domain membership allows Kerberos authentication to be used. This chapter will assume that all cluster nodes have been joined to a common Active Directory domain. • Node names — Just as the cluster requires a cluster name, each cluster node requires a unique computer name. Although Windows Server 2012 assigns computer names automatically, it is highly recommended that you assign computer names that are more descriptive. Doing so makes it easier to figure out which node you are working on. The cluster nodes used in the examples in this chapter will be named Lab1, Lab2 and Lab3.

32

Understanding Hyper-V in Windows Server 2012

• Cluster name — The configuration process requires that a unique name be assigned to the cluster. The name you choose should be different from any of the computer names that are used within your Active Directory. • Cluster node hardware — Another important consideration is the cluster nodes themselves. The nodes do not have to use identical hardware, but they should all use the same CPU architecture and ideally they should be equipped with comparable amounts of memory. • Number of nodes — You also need to decide how many nodes to use in your cluster. In this chapter you will be building a Majority Node Set Cluster. It is best to use an odd number of cluster nodes whenever possible because a Majority Node Set Cluster requires half of the nodes plus one to remain online during a failure in order for the cluster to retain quorum. It is technically possible to build a failover cluster out of two cluster nodes (plus a file share witness), but it's recommended that you always use at least three cluster nodes. Your cluster can contain as many as 63 nodes. Of course, most clusters use far fewer than 63 nodes, and you always have the option of adding additional cluster nodes later until the maximum number of nodes has been reached. • Network adapters — Hyper-V is very flexible in terms of the network adapter requirements for cluster nodes. However, it is generally recommended that each cluster node have a minimum of three network adapters. You should reserve one adapter should be reserved for management traffic and another adapter for cluster traffic. The third (and any additional adapters) are used for virtual machine traffic. • Node IP addresses — As a best practice, you should assign a static IP address to each cluster node’s management NIC. However, you will also need to decide how you want to handle IP address assignment for the other NICs. • Cluster IP address — In addition to the IP addresses assigned to physical NICs you must assign a static IP address to the cluster. This IP address is used to communicate with the cluster as a whole rather than with an individual cluster node.

Building a failover cluster without shared storage As previously mentioned, it is possible to build a failover cluster without using shared storage. This part of the chapter will walk you through the process. You will be building a Majority Node Set cluster consisting of three cluster nodes. Keep in mind, however, that if it is within your budget, you should use shared storage whenever possible, as Microsoft recommends. This section assumes that you have installed Windows Server 2012 onto each cluster node, joined the cluster nodes to an Active Directory domain, and provisioned each node with an appropriate computer name and the necessary IP addresses.

33

Understanding Hyper-V in Windows Server 2012

Installing the failover clustering feature The first step in the configuration process is to install the Failover Clustering feature onto each cluster node. You can accomplish this task by following these steps: 1. Open the Server Manager 2. Choose the Add Roles and Features option from the Manage menu. 3. When the Add Roles and Features Wizard starts, click Next to bypass the welcome screen. 4. Choose the Role-Based or Feature-Based Installation option and click Next. 5. Verify that the correct server is selectedand click Next (Figure 2.2). Figure 2.2

You must install the Failover Clustering feature onto each of the cluster nodes.

6. When the wizard displays the list of server roles, click Next. 7. Select Failover Clustering from the list of features (Figure 2.3). If the wizard prompts you to install additional features, click the Add Features button.

34

Understanding Hyper-V in Windows Server 2012

Figure 2.3

Select the Failover Clustering feature.

8. Click Next. 9. Click Install. 10. When the installation process completes, click Close.

Building a Majority Node Set Cluster Now that the Failover Clustering Service has been installed, the next step in the process is to build the failover cluster. The steps listed in this section only need to be performed on one of the cluster nodes. To create the failover cluster, follow these steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager option from the Tools menu. 3. When the Failover Cluster Manager opens, click on the Create Cluster link, found in the Actions pane (Figure 2.4). Windows will launch the Create Cluster Wizard.

35

Understanding Hyper-V in Windows Server 2012

Figure 2.4

Click on the Create Cluster link.

4. Click Next to bypass the wizard’s Welcome screen. 5. Specify the names of the servers that you want to include in the cluster (Figure 2.5). Figure 2.5

You should specify all of the nodes that you want to include in the cluster.

36

Understanding Hyper-V in Windows Server 2012

6. Click Next. 7. You should now see a message indicating that the cluster has not yet been validated. Choose the option to run the validation tests and click Next (Figure 2.6). Windows will launch the Validate a Cluster Wizard. Figure 2.6

You must validate the cluster before you can create it.

8. Click Next to bypass the wizard’s Welcome screen. 9. Choose the Run All Tests (Recommended) option and click Next. 10. Click Next to begin the validation tests. 11. When the validation tests complete, take a moment to view the report and review any errors or warnings (Figure 2.7). Click Finish.

37

Understanding Hyper-V in Windows Server 2012

Figure 2.7

Review the validation report and check for any errors or warnings.

12. When prompted, enter a name for the cluster and assign an IP address to the cluster (Figure 2.8). The name and IP address that you use should be unique and will be used to identify the cluster as a whole. Figure 2.8

You must assign a unique name and static IP address to the cluster.

38

Understanding Hyper-V in Windows Server 2012

13. Click Next. 14. Take a moment to verify the information presented on the confirmation screen and click Next. 15. You should see a message indicating that the cluster was created successfully. Click Finish to close the wizard.

Installing the Hyper-V role The next step in the process is to install the Hyper-V role. This role must be installed onto each of the cluster nodes. To complete this process, follow these steps: 1. Open the Server Manager. 2. Choose the Add Roles and Features command from the Manage menu. 3. When the Add Roles and Features wizard appears, click Next to bypass the wizard’s Welcome screen. 4. Make sure that the Role-Based or Feature-Based Installation option is selected and click Next. 5. Select the server on which you want to deploy the Hyper-V role and click Next (Figure 2.9). Figure 2.9

Choose the server on which you want to deploy the Hyper-V role.

39

Understanding Hyper-V in Windows Server 2012

6. Select the Hyper-V option from the list of roles (Figure 2.10). Figure 2.10

Select the Hyper-V role and click Next.

7. If you are prompted to add additional features, click the Add Features button. 8. Click Next. 9. Click Next. 10. Click Next. 11. Select the network adapters that you want to connect to the virtual switch (Figure 2.11). You can select multiple network adapters, but as a best practice you should reserve a network adapter for management traffic and reserve an adapter for cluster communications (such as cluster heartbeats and live migration traffic).

40

Understanding Hyper-V in Windows Server 2012

Figure 2.11

Select the network adapters that you want to connect to the Hyper-V virtual switch.

12. Click Next. 13. Select the checkbox for Allow this Server to Send and Receive Live Migrations of Virtual Machines (Figure 2.12). Figure 2.12

Cluster nodes must be able to live migrate virtual machines.

41

Understanding Hyper-V in Windows Server 2012

14. Select the authentication protocol to be used by live migration traffic. If the cluster nodes reside in the same Active Directory domain, then you should use the Kerberos protocol. Kerberos is more secure than CredSSP and the configuration process is easier. 15. Click Next. 16. Click Next to accept the default store location. 17. Take a moment to verify the information that is displayed on the Confirmation screen and then click Install. 18. When the installation process completes, click Close and then reboot the server. 19. Repeat these steps for each node in the cluster.

Making Hyper-V fault tolerant So far you have installed the Failover Clustering feature and the Hyper-V role. Even so, Hyper-V is not yet fault tolerant. Fault tolerance is implemented on a per-virtual-machine basis. That being the case, it’s a good idea to create some virtual machines. Then you can make your virtual machines fault tolerant by following these steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager from the list of tools. 3. When the Failover Cluster Manager opens, navigate through the console tree to Failover Cluster Manager | | Roles (Figure 2.13). Figure 2.13

Navigate through the Failover Cluster Manager to Failover Cluster Manager | | Roles.

4. Click the Configure Role link, found in the Actions pane. 5. Windows will launch the High Availability Wizard. Click Next to bypass the wizard’s Welcome screen. 6. The next screen lists a variety of server roles. Select the Virtual Machine role from the list and click Next (Figure 2.14).

42

Understanding Hyper-V in Windows Server 2012

Figure 2.14

Select the Virtual Machine option and click Next.

7. Select the virtual machines that you wish to make fault tolerant and click Next (Figure 2.15). Figure 2.15

Select the virtual machines that you wish to make fault tolerant and click Next.

43

Understanding Hyper-V in Windows Server 2012

8. Verify the information displayed on the confirmation screen and click Next. 9. When the process completes you should see a message confirming that high availability was successfully configured. Click the View Report button to examine the report. Click Finish. After the virtual machines become fault tolerant, you should see them listed in the Failover Cluster Manager’s Roles container (Figure 2.16). Likewise, the Hyper-V Manager should list the virtual machine as being clustered (Figure 2.17). Figure 2.16

The virtual machine should now be listed in the Failover Cluster Manager. Figure 2.17

The Hyper-V Manager should list the virtual machine as being clustered.

44

Understanding Hyper-V in Windows Server 2012

Building a failover cluster using shared storage Even though you can build a Hyper-V 3.0 cluster without the need for shared storage, Microsoft’s preferred method for building a Hyper-V failover cluster still involves the use of a Cluster Shared Volume. In this section you will learn how to build a majority node set cluster consisting of three cluster nodes and a fourth server that hosts the Cluster Shared Volume for the cluster. This section assumes that you have installed Windows Server 2012 onto each cluster node, joined the cluster nodes to an Active Directory domain, and provisioned each node with an appropriate computer name and the necessary IP addresses. The method or building a failover cluster that utilizes shared storage is similar to that used for a shared nothing cluster. Even so, this section will walk you through the procedure in its entirety (including procedures that were demonstrated in the previous section) because the procedures have to be performed in a certain order.

Installing the Failover Clustering feature The first step in the configuration process is to install the Failover Clustering feature onto each cluster node. You can accomplish this task by following these steps: 1. Open Server Manager 2. Choose the Add Roles and Features option from the Manage menu. 3. When the Add Roles and Features Wizard starts, click Next to bypass the welcome screen. 4. Choose the Role-Based or Feature-Based Installation option and click Next. 5. Verify that the correct server is selected and click Next. 6. When the wizard displays the list of server roles, click Next. 7. Select Failover Clustering from the list of features (Figure 2.18). If the wizard prompts you to install additional features, click the Add Features button.

45

Understanding Hyper-V in Windows Server 2012

Figure 2.18

Select the Failover Clustering feature and click Next.

8. Click Next. 9. Click Install. 10. When the installation process completes, click Close.

Building a Majority Node Set Cluster Now that the Failover Clustering feature has been installed, it is time to create the cluster. Once again, you will be creating a Majority Node Set Cluster consisting of three cluster nodes. It is only necessary to perform the procedure below on a single cluster node. To create the cluster, follow these steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager option from the Tools menu. 3. When the Failover Cluster Manager opens, click on the Create Cluster link, found in the Actions pane. When you do, Windows will launch the Create Cluster Wizard. 4. Click Next to bypass the wizard’s Welcome screen. 5. Specify the names of the servers that you want to include in the cluster (Figure 2.19).

46

Understanding Hyper-V in Windows Server 2012

Figure 2.19

Specify the names of the servers that will make up the cluster.

6. Click Next. 7. You should now see a message indicating that the cluster has not yet been validated. Choose the option to run the validation tests and click Next (Figure 2.20). This will cause Windows to launch the Validate a Cluster Wizard. Figure 2.20

The cluster must be validated.

47

Understanding Hyper-V in Windows Server 2012

8. Click Next to bypass the wizard’s Welcome screen. 9. Choose the Run All Tests (Recommended) option and click Next (Figure 2.21). Figure 2.21

You must run all of the validation tests.

10. Click Next to begin the validation tests. 11. When the validation tests complete, take a moment to view the report and review any errors or warnings (Figure 2.22). Click Finish.

48

Understanding Hyper-V in Windows Server 2012

Figure 2.22

Review the validation report for any errors or warnings.

12. When prompted, enter a name for the cluster and assign an IP address to the cluster (Figure 2.23). The name and IP address that you use should be unique and will be used to identify the cluster as a whole. Figure 2.23

Specify the name and IP address to be used by the cluster.

49

Understanding Hyper-V in Windows Server 2012

13. Click Next. 14. Take a moment to verify the information presented on the confirmation screen and click Next. 15. You should now see a message indicating that the cluster was created successfully (Figure 2.24). Click Finish to close the wizard. Figure 2.24

Verify that the cluster has been created successfully.

Shared storage In the past if you wanted to use failover clustering with Hyper-V, you had to make use of shared storage in the form of a Cluster Shared Volume. Although Hyper-V 3.0 does not require a Cluster Shared Volume for clustering, shared storage is still the preferred method for building a failover cluster. As has always been the case, you can create a Cluster Shared Volume on virtually any iSCSI or Fibre Channel accessible storage device. This can include a SAN, a physical NAS appliance or even a server that is configured to act as a shared storage device. The actual method you use to provision the shared storage varies depending on the physical hardware you are using. For the sake of demonstration, this example will use a Windows Server to host the shared storage and will connect to this server using iSCSI. This server contains four physical hard disks. The first hard disk is a 250-GB disk that contains the Windows Server 2012 operating system files. The remaining three hard disks are each 500 GB in size and will be configured to act as a RAID 5 array. Keep in mind that this configuration is only being used for demonstration purposes. Real-world organizations typically use larger arrays and those arrays are often configured as RAID 6 or as RAID 10, because

50

Understanding Hyper-V in Windows Server 2012

such RAID configurations are resistant to the failures of multiple drives. For this demonstration, however, RAID 5 will work within the limitations of the lab hardware. There are two ways to create the necessary storage array. The legacy method, which will be discussed first, is the one you will have to use this method if your shared storage resides on an older version of Windows Server. The other method is the preferred method of storage provisioning in Windows Server 2012, which will be discussed second.

Legacy storage provisioning The first technique describes how to create a storage array using the Windows Disk Management Console. You will have to use if you are hosting the storage on an older version of Windows Server. This method works for Windows Server 2012 as well, but Microsoft prefers that you use a newer method called Storage Spaces. To use the Disk Management Console to create a RAID 5 array, follow these steps: 1. G o to the server’s Run prompt and enter the DISKMGMT.MSC command. This will cause Windows to open the Disk Management Console (Figure 2.25). Notice in the figure that Disk 1, Disk 2 and Disk 3 are of equal size; all are online and contain no partitions. If you need to bring a disk online, right-click on the disk and choose the Online command from the right-click menu. Figure 2.25

The Disk Management Console lists all of the server’s physical disks.

51

Understanding Hyper-V in Windows Server 2012

2. Right-click on one of the empty disks and choose the New RAID 5 volume command from the right-click menu (Figure 2.26). Windows will launch the New RAID 5 Volume Wizard. Figure 2.26

Choose the New RAID-5 Volume command.

3. Click Next to bypass the wizard’s Welcome screen. 4. Select the disk that you wish to add to the volume and click Add (Figure 2.27). Repeat this step for any additional disks that you wish to add to the new RAID 5 volume. Figure 2.27

Add the physical disks to the RAID 5 volume.

52

Understanding Hyper-V in Windows Server 2012

5. Click Next. 6. Select the drive letter that you wish to assign to the volume that you are creating (Figure 2.28). Figure 2.28

Assign a drive letter to the volume that you are creating.

7. Click Next. 8. On the following screen choose the file system that you wish to use on the new volume and decide whether to perform a quick format (Figure 2.29). Figure 2.29

Choose a file system and format the new volume.

53

Understanding Hyper-V in Windows Server 2012

9. Click Next. 10. Click Finish. 11. A warning message tells you that the operation will convert the basic disks to dynamic disks (Figure 2.30). Click Yes to continue. Figure 2.30

The disks used in the array will be converted to dynamic disks.

12. After a brief delay Windows will format and synchronize the new volume. Depending on the size of the disks that you are using, the synchronization process can take a considerable amount of time to complete. 13. When the synchronization process completes, the new volume should be displayed as Healthy (Figure 2.31). Figure 2.31

The new volume should eventually be listed as healthy.

54

Understanding Hyper-V in Windows Server 2012

Using Windows Storage Spaces As previously mentioned, using the Disk Management Console to provision a storage array will work in Windows Server 2012, but that method is primarily suited for volumes that are stored on legacy versions of Windows Server. If a storage volume is stored on Windows Server 2012, Microsoft recommends using a new feature called Windows Storage Spaces. The main benefits to using Windows Storage Spaces instead of the Disk Management Console include: • Volumes created using Windows Storage Spaces can be thin provisioned. • You can add additional physical disk space as needed. • You can choose the type of redundancy that is most beneficial. • Storage resources can be provisioned much more quickly than they can through the Disk Management Console.

Creating a storage pool The first step in the process of configuring Windows Storage Spaces is to create a storage pool. A storage pool is a collection of physical disks that act as a pool of storage resources. You can create a storage pool by completing these steps: 1. Open the Server Manager. 2. Click on the File and Storage Services option, found in the console tree. 3. Click on Disks to verify that all of the server’s disks are displayed within the console (Figure 2.32). Figure 2.32

Click on the Disks container.

4. Click on Storage Pools (Figure 2.33).

55

Understanding Hyper-V in Windows Server 2012

Figure 2.33

The Primordial pool is created by default, but you will have to manually create all other storage pools.

5. Choose the New Storage Pool option from the Task list. 6. When the New Storage Pool Wizard begins, click Next to bypass the wizard’s Welcome screen. 7. Enter a name and an optional description of the storage pool that you are creating. 8. Click Next. 9. Choose the disks that you wish to include within the storage pool (Figure 2.34). Figure 2.34

Choose the disks that you wish to include in the storage pool.

56

Understanding Hyper-V in Windows Server 2012

10. Use the Allocation drop-down for each disk to control whether the disk should be allocated as a data store, a hot spare, or a manual allocation (Figure 2.35). Figure 2.35

Specify the allocation for each disk in the storage pool.

11. Click Next. 12. Click Create. 13. When the storage pool has been created, click Close (Figure 2.36). Figure 2.36

Verify that the storage pool has been created successfully.

57

Understanding Hyper-V in Windows Server 2012

You should now see the storage pool listed in the console along with the physical disks that make up the storage pool (Figure 2.37). Figure 2.37

The completed storage pool should look like this.

Creating a virtual disk After the storage pool is created, the next step is to create a virtual disk within the storage pool. This virtual disk will act as a repository for the virtual machine components that will be stored within the Cluster Shared Volume. To create the virtual disk, follow these steps: 1. Open the Server Manager if it is not already open. 2. Click on the File and Storage Services option, found in the console tree. 3. Click on the To Create a Virtual Disk, Start the New Virtual Disk Wizard link. 4. When the New Virtual Disk Wizard starts, click Next to bypass the Welcome screen. 5. Select your storage pool from the list and click Next (Figure 2.38).

58

Understanding Hyper-V in Windows Server 2012

Figure 2.38

Select your storage pool and click Next.

6. Enter a name and an optional description for the virtual disk. 7. Click Next. 8. Choose whether you want to configure a simple virtual disk or have the virtual disk be mirrored or use parity (Figure 2.39). Figure 2.39

Choose the method Windows will use to protect your virtual disk.

59

Understanding Hyper-V in Windows Server 2012

9. Click Next. 10. Choose whether you want to thinly provision the Virtual Hard Disk or create a disk of a fixed size (Figure 2.40). Fixed size provisioning delivers better performance, but thin provisioning is more flexible and makes more efficient use of storage space. Figure 2.40

Choose the provisioning type.

11. Enter the size of the Virtual Hard Disk that you want to create (Figure 2.41).

60

Understanding Hyper-V in Windows Server 2012

Figure 2.41

Specify the size of your Virtual Hard Disk.

12. Click Next. 13. Take a moment to verify the information that is displayed on the confirmation screen and click Create. 14. After you have created the virtual disk, click Close. 15. Windows will automatically launch the New Volume wizards. Click Next to bypass the wizard’s Welcome screen. 16. When prompted, select your storage pool and the virtual disk that you have created. 17. Click Next. 18. Specify the size of the volume and click Next. 19. Assign a drive letter to the volume and click Next. 20. Choose the file system that you want to use on the volume and click Next. 21. Verify the information displayed on the confirmation screen and click Create. 22. When the volume has been created, click Close (Figure 2.42).

61

Understanding Hyper-V in Windows Server 2012

Figure 2.42

Verify that the virtual disk has been created successfully.

Building an iSCSI target As previously mentioned, Cluster Shared Volumes are normally accessed either through iSCSI or through Fibre Channel. For the sake of demonstration, this section will show you how to create an iSCSI target for the recently created storage volume. Microsoft supported configuring Windows Server 2008 R2 as an iSCSI target, but doing so required you to download an additional component. In Windows Server 2012, the iSCSI target software is built into the operating system, so there is nothing extra to download.

Starting the iSCSI Initiator Before you begin configuring the iSCSI target, it is helpful to start the iSCSI Initiator on each of the cluster nodes. The reason for doing this now is that each of the cluster nodes will be assigned an iSCSI Qualified Name (IQN). You will need to provide each node’s IQN when you configure the iSCSI target. To start each node’s iSCSI Initiator, complete these steps: 1. Open the Server Manager. 2. Choose the iSCSI Initiator command from the Tools menu 3. You should see a message indicating that the Microsoft iSCSI Service is not running. Click Yes to start the service. 4. When the iSCSI Initiator launches, go to the properties sheet’s Configuration tab and note the Initiator Name (Figure 2.43). 5. Repeat these steps for each cluster node.

62

Understanding Hyper-V in Windows Server 2012

Figure 2.43

Note the IQN for each cluster node.

Installing the iSCSI target software Although Windows Server 2012 includes the iSCSI target software, it is not installed by default. To deploy the iSCSI target software onto the server that will host your Cluster Shared Volume, follow these steps: 1. Open the Server Manager. 2. Choose the Add Roles and Features command from the Manage menu. 3. When the Add Roles and Features Wizard launches, click Next to bypass the wizard’s Welcome screen. 4. On the Select Installation Type screen, choose the Role‑Based or Feature‑Based Installation option (Figure 2.44).

63

Understanding Hyper-V in Windows Server 2012

Figure 2.44

Choose the Role-Based or Feature-Based Installation option.

5. Click Next. 6. Verify that the server that will host the Cluster Shared Volume is selected (Figure 2.45). Figure 2.45

Make sure that the server that will host the iSCSI target is selected.

64

Understanding Hyper-V in Windows Server 2012

7. Click Next. 8. On the Select Server Roles screen, verify that the File and Storage Services role is installed. This role should be installed by default. 9. Expand the File and Storage Services container. 10. Expand the File and iSCSI Services container (Figure 2.46). 11. Select the iSCSI Target Server option and the iSCSI Target Storage Provider option. If you are prompted to add additional features to support those services, click the Add Features button. Figure 2.46

Select the iSCSI Target Software and the iSCSI Target Storage Provider components.

12. Click Next. 13. Click Next on the Select Features screen (it is not necessary to deploy any additional features at this time). 14. When you reach the confirmation screen, click Install (Figure 2.47).

65

Understanding Hyper-V in Windows Server 2012

Figure 2.47

Click Install to install the iSCSI Target software.

15. When the installation completes, click Close.

Configuring the iSCSI target Now that you have installed the iSCSI target software, you need to configure it. This means creating an iSCSI virtual disk (within the virtual disk that was already created in Windows Storage Spaces). You will also need to provide the iSCSI target with an authentication method as well as the IQNs of the cluster nodes. To configure the iSCSI target software, follow these steps: 1. Open the Server Manager if it is not already open. 2. Click on the File and Storage Services option, found in the console tree. 3. Click on iSCSI. 4. Click the To Create an iSCSI Virtual Disk, Start the New iSCSI Virtual Disk Wizard link (Figure 2.48). Figure 2.48

Click the To Create an iSCSI Virtual Disk, Start the New iSCSI Virtual Disk Wizard link.

66

Understanding Hyper-V in Windows Server 2012

5. When the New iSCSI Virtual Disk Wizard begins, select your storage pool and the volume that you just created (Figure 2.49). Figure 2.49

Select the volume that you just created.

6. Click Next. 7. Specify a name and an optional description for the iSCSI virtual disk and click Next. 8. Specify a size for the iSCSI virtual disk and click Next. 9. Choose the New iSCSI Target option and click Next. 10. Enter a name and an optional description for the iSCSI target and click Next. 11. Add the names of the iSCSI initiators that will access the target. Populate the dialog box with the IQN names from the iSCSI initiators on all of your cluster nodes (Figure 2.50).

67

Understanding Hyper-V in Windows Server 2012

Figure 2.50

You must provide the IQNs of your iSCSI initiators.

12. Once all of the cluster nodes have been added to the list, click Next. 13. Although not technically required, authentication is important for iSCSI connectivity. Otherwise someone could easily spoof an IQN and gain access to your iSCSI target. The wizard gives you a choice of enabling CHAP or reverse CHAP authentication. As a best practice, you should enable CHAP and provide a strong name and password (Figure 2.51). Please note that your password must be at least 12 characters in length.

68

Understanding Hyper-V in Windows Server 2012

Figure 2.51

It is a good idea to use CHAP authentication for your iSCSI target.

14. Click Next. 15. Verify the information shown in the confirmation screen, and click Create (Figure 2.52). Figure 2.52

Take a moment to identify the iSCSI target configuration information.

16. When the process completes, click Close.

69

Understanding Hyper-V in Windows Server 2012

Attaching the cluster nodes to the iSCSI storage Now that you have created the iSCSI target and authorized the individual cluster nodes to use the target, it is time to attach the cluster nodes to the iSCSI target. You can do so by performing the following procedure on each cluster node: 1. Open the Server Manager. 2. Choose the iSCSI Initiator from the Tools menu. 3. When the iSCSI Initiator opens, go to the Targets tab. 4. Enter the IP address of the server that is hosting the iSCSI target in the Target field. 5. Click the Quick Connect button. 6. You should see your iSCSI target listed as inactive (Figure 2.53). Select the iSCSI target and click Done. Figure 2.53

Your iSCSI target should be listed as inactive.

70

Understanding Hyper-V in Windows Server 2012

7. You should now be returned to the main initiator screen with the Targets tab selected (Figure 2.54). Figure 2.54

Your target should be listed on the Targets tab.

8. Select the target, which should be listed as inactive, and click the Connect button. 9. Verify that the target name is correct and that the Add this Connection to the List of Favorite Targets option is selected (Figure 2.55).

71

Understanding Hyper-V in Windows Server 2012

Figure 2.55

You must add the target to the list of favorite targets and enable multi-path.

10. Select the Enable Multi-Path check box. This is a critical step because you won’t be able to create a Cluster Shared Volume unless this option is selected. 11. Click the Advanced button. 12. When the Advanced Settings dialog box launches, select the Enable CHAP Log On check box (Figure 2.56). Figure 2.56

You must choose the Enable CHAP Log On option and enter your CHAP credentials.

72

Understanding Hyper-V in Windows Server 2012

13. Enter the name that you specified earlier. You should enter the CHAP password into the Target Secret field. 14. Click OK. 15. Click OK. 16. When you are returned to the Targets tab, the iSCSI Target should be listed as Connected. 17. Click OK to close the iSCSI Initiator Properties sheet. 18. Repeat this procedure on the remaining cluster nodes so that each cluster node has iSCSI connectivity to the target.

Making storage available to the cluster Now that you have connected each cluster node to the iSCSI target, you must prepare the iSCSI storage for use by the cluster. This means creating the volume and configuring the cluster to recognize the shared storage. To do so, follow these steps: 1. Enter the DISKMGMT.MSC command to open the Disk Management Console. 2. When the Disk Management Console opens, locate the iSCSI volume. 3. Right-click on the disk associated with the iSCSI target and choose the Online command from the right-click menu (Figure 2.57). Figure 2.57

You must bring the Cluster Shared Volume online.

4. Right-click on the disk associated with the iSCSI target and choose the Initialize Disk command from the right-click menu. 5. When prompted, select the type of partition that you wish to use with the disk (Figure 2.58) and click OK.

73

Understanding Hyper-V in Windows Server 2012

Figure 2.58

Select the type of partition that you wish to use for your Cluster Shared Volume and click OK.

6. Right-click on the unallocated space and create a volume. Do not assign a drive letter to the volume. 7. Close the Disk Management Console. 8. Open the Server Manager. 9. Choose the Failover Cluster Manager option from the Tools menu. 10. When the Failover Cluster Manager opens, navigate through the console tree to Failover Cluster Manager | | Storage | Disks (Figure 2.59). Figure 2.59

Navigate through the Failover Cluster Manager to Failover Cluster Manager | | Storage | Disks.

11. Click the Add Disk link, found in the Actions pane. 12. The Failover Cluster Manager should automatically recognize your iSCSI Target as a disk that can be added to the cluster (Figure 2.60). Verify that the disk is selected and click OK.

74

Understanding Hyper-V in Windows Server 2012

Figure 2.60

Select the Custer Shared Volume and click OK.

13. The Failover Cluster Manager should list the disk as being available to the cluster and show the disk status as Online (Figure 2.61). It is worth noting that it can occasionally take a minute or two for the disk status to be updated. Figure 2.61

The Cluster Shared Volume should be listed within the Failover Cluster Manager.

14. With the cluster disk selected, click Add to Cluster Shared Volumes.

Installing the Hyper-V role The next step in the process is to install the Hyper-V role. You must install this role into each of the cluster nodes. You can complete this process by following these steps: 1. Open the Server Manager. 2. Choose the Add Roles and Features command from the Manage menu.

75

Understanding Hyper-V in Windows Server 2012

3. When the Add Roles and Features wizard launches, click Next to bypass the wizard’s Welcome screen. 4. Make sure that the Role-Based or Feature-Based Installation option is selected and click Next. 5. Select the server on which you want to deploy the Hyper-V role and click Next. 6. Select the Hyper-V option from the list of roles. 7. If you are prompted to add additional features, click the Add Features button. 8. Click Next. 9. Click Next. 10. Click Next. 11. Select the network adapters that you want to connect to the virtual switch (Figure 2.62). You can select multiple network adapters, but as a best practice you should reserve a network adapter for management traffic and you should reserve an adapter for cluster communications (such as cluster heartbeats and live migration traffic). Figure 2.62

Select the network adapters to be used by Hyper-V.

12. Click Next. 13. Select the checkbox for Allow this Server to Send and Receive Live Migrations of Virtual Machines (Figure 2.63).

76

Understanding Hyper-V in Windows Server 2012

Figure 2.63

Your cluster nodes must be able to live migrate virtual machines.

14. Select the authentication protocol to be used by live migration traffic. If the cluster nodes reside in the same Active Directory domain as one another then you should use the Kerberos protocol. Kerberos is more secure than CredSSP and the configuration process is easier. 15. Click Next. 16. Click Next to accept the default store location. 17. Take a moment to verify the information that is displayed on the Confirmation screen and then click Install. 18. When the installation process completes, click Close and then reboot the server. 19. Repeat these steps for each node in the cluster.

Making Hyper-V fault tolerant Now that you have installed the Hyper-V role, the next step in the process is to make Hyper-V and your virtual machines fault tolerant. The simple act of creating a virtual machine does not make the virtual machine fault tolerant. You must create the virtual machine in the correct location and you will have to designate the virtual machine as being fault tolerant. When you create a new virtual machine, the New Virtual Machine Wizard asks if you want to store the virtual machine in a different location (see Chapter 6 for details). If you want the virtual machine to be fault tolerant, you must store the virtual machine on the Cluster Shared Volume.

77

Understanding Hyper-V in Windows Server 2012

As you may recall, you created a volume on the iSCSI target, but did not assign a drive letter to it. You can access the Cluster Shared Volume at C:\ ClusterStorage\. Anything that you save to this path will reside on the Cluster Shared Volume (the iSCSI target) rather than on the local C: drive. Simply storing the virtual machines on the Cluster Shared Volume is not enough (Figure 2.64). As you can see in the figure, three virtual machines have been created, and each of these virtual machines resides on the Cluster Shared Volume. If you look at the lower middle pane in the next figure, however, you will notice that the Hyper-V Manager indicates that the virtual machine is not clustered (Figure 2.65). Figure 2.64

Virtual machines must be stored on the Cluster Shared Volume.

78

Understanding Hyper-V in Windows Server 2012

Figure 2.65

Even with the virtual machines residing on the Cluster Shared Volume, the virtual machines are not considered to be fault tolerant.

To make the virtual machine fault tolerant you must designate it as such through the Failover Cluster Manager. To do so, follow these steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager from the list of tools. 3. When the Failover Cluster Manager opens, navigate through the console tree to Failover Cluster Manager | | Roles (Figure 2.66). Figure 2.66

Navigate through the Failover Cluster Manager to Failover Cluster Manager | | Roles.

79

Understanding Hyper-V in Windows Server 2012

4. Click the Configure Role link, found in the Actions pane. 5. Windows will now launch the High Availability Wizard. Click Next to bypass the wizard’s Welcome screen. 6. The next screen lists a variety of server roles. Select the Virtual Machine role from the list and click Next (Figure 2.67). Figure 2.67

Select the Virtual Machines option.

7. Select the virtual machines that you wish to make fault tolerant and click Next (Figure 2.68).

80

Understanding Hyper-V in Windows Server 2012

Figure 2.68

Select the virtual machines that you wish to make fault tolerant.

8. Verify the information displayed on the confirmation screen and click Next. 9. When the process completes you should see a message confirming that high availability was successfully configured (Figure 2.69). Click the View Report button to examine the report. Click Finish. Figure 2.69

Click the View Report button to see a report of the operation.

81

Understanding Hyper-V in Windows Server 2012

After the virtual machines become fault tolerant, you should see them listed in the Failover Cluster Manager’s Roles container (Figure 2.70). Likewise, the Hyper-V Manager should list the virtual machine as being clustered (Figure 2.71). Figure 2.70

The Failover Cluster Manager now displays the virtual machines.

82

Understanding Hyper-V in Windows Server 2012

Figure 2.71

The Hyper-V Manager lists the virtual machines as being clustered.

Using SMB storage This chapter has focused primarily on the use of local, direct attached storage and on connecting to a Cluster Shared Volume through iSCSI. However, those are not your only options. Hyper-V is also able to store virtual machines on an SMB file share in both clustered and non-clustered environments. The use of SMB storage is generally only practical for smaller organizations because bandwidth limitations impact the number of virtual machines that can reside on a file share. The use of SMB file share storage for virtual machines is most useful when a file server has been configured to be highly available. Finally, storing virtual machines on SMB file shares is only an option if the servers involved are using SMB version 2.2 or higher. Earlier versions of SMB are not supported.

Share this e-book with your peers

83

Understanding Hyper-V in Windows Server 2012

Chapter 3

Migrations In the previous chapter, you spent a lot of time building failover clusters and making virtual machines fault tolerant. However, building the cluster is really just the beginning. It is equally important to know how to verify that your failover cluster is working properly. As a Hyper-V administrator, you will also need to know how to move virtual machines around both within and outside of the cluster. This chapter discusses all of these tasks.

84

Understanding Hyper-V in Windows Server 2012

Testing failover clustering One of the nice things about building a failover cluster is that you have the assurance that if any of your cluster nodes were to fail, the virtual machines that had been running on the failed node will automatically fail over to a node that is still functioning. Of course this raises the question of how you can test virtual machine failover. Simply shutting down a cluster node is an inadequate test because a graceful shutdown is not as abrupt as an unexpected node failure. At the same time, however, you don’t want to be yanking the power cord out of a cluster node to see what would happen in the event of a real failure. The ability to test virtual machine failover was something that was sorely lacking from Hyper-V 2.0. Thankfully, Microsoft has included a testing feature in Hyper-V 3.0.

Live migrating a VM within the cluster Although a failover cluster is designed to automatically move a virtual machine to a functioning cluster node in the event of a failure, you may occasionally want to move a virtual machine to another cluster node even if no failure has occurred. For example, if you are planning to take a cluster node down for maintenance then you would probably want to move the virtual machines to another node before doing so. Likewise, if you determine that a single cluster node is handling a disproportionate amount of the cluster’s total workload, you might decide to move some of the virtual machines to another node. Performing a live migration within a cluster is simple. To do so, complete these steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager option from the Tools menu. 3. When the Failover Cluster Manager opens, navigate through the console tree to Failover Cluster Manager | | Roles. 4. Right-click on the virtual machine that you want to live migrate and select the Move | Live Migration | Select Node commands from the right-click menus (Figure 3.1). As an alternative, you can allow Hyper-V to select the destination cluster node by choosing the Best Possible Node option.

85

Understanding Hyper-V in Windows Server 2012

Figure 3.1

You can select the destination node manually, or you can let Hyper-V pick the best node automatically.

5. Choose the cluster node to which you want to live migrate the virtual machine (Figure 3.2). Figure 3.2

Select the cluster node to which you want to live migrate the virtual machine.

86

Understanding Hyper-V in Windows Server 2012

6. Click OK. 7. You can monitor the live migration process through the Failover Cluster Manager (Figure 3.3). Figure 3.3

The Failover Cluster Manager displays the progress of the live migration.

8. When the live migration completes, the Failover Cluster Manager should report the virtual machine as running on the cluster node that you have selected (as shown in the Owner Node column) (Figure 3.4). Figure 3.4

The Owner Node column confirms that the virtual machine has been moved to a different cluster node.

Configuring a server to send and receive live migrations Hyper-V doesn’t limit you to performing virtual machine migrations within the confines of a cluster. You can also perform live migrations between standalone Hyper-V hosts or even between Hyper-V clusters, but the hosts involved must be configured to allow live migrations. If you followed the instructions from the previous chapter, your cluster should be capable of live migrating virtual machines within a cluster. However, if you have a standalone Hyper-V host that was not initially configured to allow live migrations, that host will need to be reconfigured prior to using it in any live migration scenario. To configure a Hyper-V Host to allow live migrations, follow these steps: 1. Open the Hyper-V Manager. 2. Right-click on your host server and choose the Hyper-V Settings command from the right-click menu (Figure 3.5).

87

Understanding Hyper-V in Windows Server 2012

Figure 3.5

Right-click on the listing for the host server and select the Hyper-V Settings command from the right-click menu.

3. When the Hyper-V Settings dialog box launches, select the Live Migrations option (Figure 3.6). Figure 3.6

Select the Live Migrations tab.

88

Understanding Hyper-V in Windows Server 2012

4. Select the Enable Incoming and Outgoing Live Migrations check box (Figure 3.7). Figure 3.7

You must manually enable incoming and outgoing live migrations.

5. Specify the authentication protocol to use. Kerberos is the preferred authentication protocol because it is more secure and the configuration process is easier, but it only works within a common Active Directory forest. 6. Specify the maximum number of simultaneous live migrations to allow. 7. Specify the IP addresses for the NICs with which the server is authorized to live migrate virtual machines. You can select the Use Any Available Network for Live Migration option, but this is less secure than the Use These IP Addresses for Live Migration option. 8. Click OK to complete the process.

Dealing with CPU mismatch If you plan to live migrate virtual machines between Hyper-V hosts, it is best to use identical hardware on all of your cluster nodes if possible. Of course acquiring identical hardware is not always possible. The next best thing is to use servers with identical CPUs. If you attempt to live migrate virtual machines between servers with dissimilar CPUs you will receive an error message indicating that the virtual machine is using processor-specific features and cannot be migrated (Figure 3.8).

89

Understanding Hyper-V in Windows Server 2012

Figure 3.8

You will receive an error message if the CPUs on the source and destination hosts are too dissimilar.

The solution to this problem is to enable CPU compatibility. You can accomplish this by following these steps: 1. Open the Hyper-V Manager. 2. Shut down the virtual machine. 3. Right-click on the virtual machine and choose the Settings command from the right-click menu. 4. Expand the Processor container in the resulting dialog box. 5. Select the Compatibility container. 6. Select the checkbox for Migrate to a Physical Computer with a Different Processor Version (Figure 3.9). 7. Click OK. 8. Restart the virtual machine. 9. Attempt the live migration.

90

Understanding Hyper-V in Windows Server 2012

Figure 3.9

You can overcome some live migration issues by enabling the processor compatibility feature.

It is worth noting that enabling the CPU compatibility feature does not allow you to move virtual machines between hosts with different CPU architectures (e.g., moving from a host with an Intel processor to a host with an AMD processor). Furthermore, enabling CPU compatibility might impact the virtual machine’s performance because the feature works by disabling the virtual machine’s access to some of the more advanced CPU features such as Misaligned SSE or POPCNT.

Live migrations beyond the cluster One of the really interesting things that Microsoft has done in Hyper-V 3.0 is to make it possible to live migrate virtual machines from one host to another regardless of whether or not the host servers are clustered. In Hyper-V 3.0 you can perform the following types of migrations: • Cluster node → cluster node • Cluster node → standalone host • Standalone host → cluster node • Standalone host → standalone host For the most part, Microsoft offers these types of migrations as a convenience feature. For example, suppose that you have a non-clustered Hyper-V server that is running your production virtual machines. Now suppose that you purchase some new servers and build a Hyper-V cluster. In that

91

Understanding Hyper-V in Windows Server 2012

type of situation it is possible to use live migration to move running virtual machines from the standalone server onto a cluster node. After doing so, you can configure the Failover Cluster Manager to make the virtual machines fault tolerant. Although it is easy to think of live migrations as a clustering feature, Hyper-V makes it possible to live migrate virtual machines even if the host servers that are involved in the migration process are not clustered.

Live migrating a VM to a server outside of the cluster The first technique involves moving a clustered virtual machine to a non clustered Hyper-V host. This procedure requires you to remove the virtual machine’s fault tolerance as a part of the migration process. Before you begin the migration process, choose the type of move that you want to perform. Hyper-V gives you three different options including: • Move the Virtual Machine’s Data to a Single Location – This option places all of the virtual machine components into a single location. • Move the Virtual Machine’s Data by Selecting Where to Move Each Item – This option gives you the most flexibility because it allows you to control where each virtual machine component will be placed. This is usually the option that you will use when performing cluster-to-standalone host migrations. • Move Only the Virtual Machine – This option moves the virtual machine itself to a new host, but leaves the Virtual Hard Disk in its original location on the Cluster Shared Volume. The steps below describe the procedure for moving a clustered virtual machine to a Hyper-V host that exists outside of the cluster. This procedure assumes that all of the host servers exist within a common domain and that you will be specifying where to move the various virtual machine components. To perform the virtual machine migration, follow these steps: 1. Open the Server Manager. 2. Select the Failover Cluster Manager option from the Tools menu. 3. When the Failover Cluster Manager opens, navigate through the console tree to Failover Cluster Manager | | Roles. 4. Select the virtual machine that you want to migrate away from the cluster. 5. Right-click on the virtual machine and select the Remove command from the right-click menu (Figure 3.10).

92

Understanding Hyper-V in Windows Server 2012

Figure 3.10

Right-click on the virtual machine and select the Remove command from the right‑click menu.

6. When you see the prompt asking if you want to remove the virtual machine, click Yes (Figure 3.11). Figure 3.11

Confirm that you want to remove the virtual machine from the cluster.

7. Close the Failover Cluster Manager. 8. Open the Hyper-V Manager. 9. Verify that the virtual machine is still running, and that it is not clustered (Figure 3.12).

93

Understanding Hyper-V in Windows Server 2012

Figure 3.12

Make sure that the VM is still running and that it is no longer clustered.

10. Right-click on the virtual machine and choose the Move command from the right-click menu. 11. When the Move Wizard starts, click Next to bypass the wizard’s Welcome screen. 12. Choose the Move the Virtual Machine option and click Next (Figure 3.13).

94

Understanding Hyper-V in Windows Server 2012

Figure 3.13

Choose the option to move the virtual machine.

13. When prompted, enter the name of the destination host (Figure 3.14). Figure 3.14

Specify the name of the destination host.

95

Understanding Hyper-V in Windows Server 2012

14. Click Next. 15. Choose the option to Move the Virtual Machine’s Data by selecting Where to Move the Items (Figure 3.15). Figure 3.15

Choose the option to move the virtual machine by selecting where to move each item.

16. Click Next. 17. Choose the option for moving the virtual machine’s components. It is usually acceptable to choose the option to Move the Virtual Machine’s Data Automatically (Figure 3.16). This option places the virtual machine components in the same locations on the destination host as the locations in which they resided on the source host.

96

Understanding Hyper-V in Windows Server 2012

Figure 3.16

It is usually acceptable to move the virtual machine’s data automatically.

18. Click Next. 19. Verify the information presented on the Summary screen. 20. Click Finish.

Live migrating an external VM into the cluster If you have been using Hyper-V for a while, but are new to clustering, you might encounter a situation in which you need to bring some production virtual machines into a newly built cluster. Although you can use the Export / Import method, it is usually easier to live migrate the virtual machines from the standalone Hyper-V server into the cluster. This process involves completing two main tasks: 1) migrate the virtual machine and 2) make the virtual machine fault tolerant once it is running on a cluster node. The procedure listed below assumes that the standalone Hyper-V host and all of the cluster nodes belong to the same Active Directory domain and that live migrations are enabled on all hosts. The procedure also assumes that the cluster makes use of a Cluster Shared Volume. However, the procedure can be easily adapted for environments without shared storage or for organizations in which hosts reside in multiple domains. To perform the live migration, complete the following steps: 1. Open the Hyper-V Manager on the standalone server that contains the virtual machine that is to be migrated to the cluster. 2. Right-click on the virtual machine and choose the Move command from the right-click menu.

97

Understanding Hyper-V in Windows Server 2012

3. When the Move Wizard opens, click Next to bypass the Welcome screen. 4. On the following screen, select the Move the Virtual Machine option and click Next (Figure 3.17). Figure 3.17

Select the Move the Virtual Machine option.

5. When prompted, enter the name of one of the cluster nodes (Figure 3.18). Figure 3.18

Enter the name of the destination host.

98

Understanding Hyper-V in Windows Server 2012

6. Click Next. 7. Choose the Move the Virtual Machine’s Data to a Single Location option (Figure 3.19). Figure 3.19

Move the virtual machine to a single location.

8. Click Next. 9. Switch to the specified cluster node, open Windows Explorer and navigate to C:\ClusterStorage\ (Figure 3.20).

99

Understanding Hyper-V in Windows Server 2012

Figure 3.20

Open Windows Explorer and navigate to your Cluster Shared Volume.

10. Create a folder matching the name of the virtual machine that is to be migrated. 11. Switch back to the standalone host server where the virtual machine currently resides. 12. Enter C:\ClusterStorage\\ as the destination location folder (Figure 3.21). Figure 3.21

Enter the path in which the virtual machine will be stored.

100

Understanding Hyper-V in Windows Server 2012

13. Verify that the destination folder has sufficient free disk space. The amount of disk space required is listed in the Source Location portion of the wizard’s current screen. 14. Click Next. 15. If the cluster node does not contain a virtual switch with a name matching the virtual switch that is currently in use, you will be asked to specify a virtual switch (Figure 3.22). Make your selection and click Next. Figure 3.22

Specify the virtual switch that the virtual machine will use after the migration.

16. Verify the summary information and click Finish. 17. When the migration process completes, go to the destination cluster node and verify that the virtual machine is running. 18. Switch to the destination cluster node and verify that the virtual machine is present and running (Figure 3.23).

101

Understanding Hyper-V in Windows Server 2012

Figure 3.23

Verify that the virtual machine is running in its new location.

19. Open the Server Manager. 20. Choose the Failover Cluster Manager option from the Tools menu. 21. Navigate through the Failover Cluster Manager to Failover Cluster Manager | | Roles. 22. Click on the Configure Roles link, found in the Actions pane. 23. When the High Availability Wizard launches, click Next to bypass the Welcome screen. 24. Select the Virtual Machine option and click Next (Figure 3.24).

102

Understanding Hyper-V in Windows Server 2012

Figure 3.24

Select the Virtual Machine option from the list of high availability roles.

25. Select the recently migrated virtual machine from the list of virtual machines and click Next (Figure 3.25). Figure 3.25

Select the virtual machine that you want to make highly available.

103

Understanding Hyper-V in Windows Server 2012

26. Verify that the correct virtual machine is listed on the summary screen and click Next. 27. Verify that the virtual machine was made highly available (Figure 3.26). 28. Click Finish. Figure 3.26

You can use the report to verify the success of the operation.

Cluster-to-cluster live migrations Just as you can live migrate virtual machines into and out of a cluster, you can use a similar technique to live migrate a virtual machine between clusters. When you do this, there will be a period of time during which the virtual machine is not fault tolerant, but the virtual machine will remain online throughout the migration process. The technique described in this section assumes that all of the cluster nodes exist within a common domain. It is also assumed that both clusters use shared storage, although you can easily adapt the technique to a cluster that does not use shared storage. To perform a cluster-to-cluster live migration, follow these steps: 1. Open the Server Manager. 2. Select the Failover Cluster Manager option from the Tools menu. 3. When the Failover Cluster Manager opens, navigate through the console tree to Failover Cluster Manager | | Roles. 4. Select the virtual machine that you want to migrate to another cluster (Figure 3.27).

104

Understanding Hyper-V in Windows Server 2012

Figure 3.27

Select the virtual machine that you want to move to another cluster.

5. Right-click on the virtual machine and select the Remove command from the right-click menu. 6. When you see the prompt asking if you want to remove the virtual machine, click Yes (Figure 3.28). Figure 3.28

Click Yes to remove the virtual machine from the cluster.

7. Close the Failover Cluster Manager. 8. Open the Hyper-V Manager. 9. Verify that the virtual machine is still running, and that it is not clustered (Figure 3.29). Figure 3.29

Make sure that the VM is still running and that it has been removed from the cluster.

105

Understanding Hyper-V in Windows Server 2012

10. Right-click on the virtual machine and choose the Move command from the right-click menu. 11. When the Move Wizard launches, click Next to bypass the wizard’s Welcome screen. 12. Choose the option to Move the Virtual Machine (Figure 3.30) and click Next. Figure 3.30

Choose the Move the Virtual Machine option.

13. When prompted, enter the name of the destination host. 14. Click Next. 15. Choose the option to Move the Virtual Machine’s Data to a Single Location (Figure 3.31).

106

Understanding Hyper-V in Windows Server 2012

Figure 3.31

Choose the option to move the virtual machine to a single location.

16. Click Next. 17. Switch to a node on the destination folder. 18. Open Windows Explorer and navigate to C:\ClusterStorage\ 19. Create a folder bearing the name of the virtual machine that is to be migrated. 20. Switch back to the cluster node where the virtual machine is currently running. 21. Enter the path where the virtual machine will reside. The path should be C:\ClusterStorage\\ (Figure 3.32).

107

Understanding Hyper-V in Windows Server 2012

Figure 3.32

Enter the path where the virtual machine should be stored on the destination cluster.

22. Verify that the destination folder has sufficient free disk space. The amount of disk space required is listed in the Source Location portion of the wizard’s current screen. 23. Click Next. 24. If the cluster node does not contain a virtual switch with a name matching the virtual switch that is currently in use, you will be asked to specify a virtual switch. Make your selection and click Next. 25. Verify the summary information and click Finish. 26. When the migration process completes, go to the destination cluster node and verify that the virtual machine is running. 27. Switch to the destination cluster node and verify that the virtual machine is present and running. 28. Open the Server Manager. 29. Choose the Failover Cluster Manager option from the Tools menu. 30. Navigate through the Failover Cluster Manager to Failover Cluster Manager | | Roles. 31. Click on the Configure Roles link, found in the Actions pane. 32. When the High Availability Wizard launches, click Next to bypass the Welcome screen. 33. Select the Virtual Machine option and click Next (Figure 3.33).

108

Understanding Hyper-V in Windows Server 2012

Figure 3.33

Select the Virtual Machine option from the list of roles that can be configured for high availability.

34. Select the recently migrated virtual machine from the list of virtual machines and click Next. 35. Verify that the correct virtual machine is listed on the summary screen and click Next. 36. Verify that the virtual machine was made highly available. 37. Click Finish. 38. The virtual machine should now be displayed as a clustered resource within the Failover Cluster Manager (Figure 3.34). Figure 3.34

The virtual machine should be displayed within the Failover Cluster Manager.

109

Understanding Hyper-V in Windows Server 2012

Storage live migrations Just as it is sometimes necessary to live migrate a virtual machine from one Hyper-V host to another, it is also sometimes necessary to perform a storage live migration. A storage live migration moves the virtual machine components (Virtual Hard Disks, snapshots, etc.) from one storage location to another without requiring the virtual machine itself to be moved to another host. This is helpful when the volume containing virtual machine components is running low on space or when the volume needs to be taken offline for maintenance. As is the case with live migrations, storage live migrations can be performed against a running virtual machine without causing a service interruption.

Storage migration within a cluster The technique you use to perform a storage live migration varies depending upon whether or not the virtual machine is fault tolerant. This section starts by examining a technique for clustered environments. In this example, a virtual machine is running on a Cluster Shared Volume and you will move the virtual machine to an SMB volume. To perform this type of storage live migration, complete the following steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager option from the Tools menu. 3. Navigate through the Failover Cluster Manager console to Failover Cluster Manager | | Roles. 4. Right-click on the virtual machine on which you wish to perform a storage migration and choose the Move | Virtual Machine Storage commands from the right-click menus (Figure 3.35). Figure 3.35

Right-click on a virtual machine and choose the Move | Virtual Machine Storage commands from the right-click menu.

110

Understanding Hyper-V in Windows Server 2012

5. The Cluster Storage section is displayed in the lower left portion of the Move Virtual Machine Storage window. If you have not previously performed a storage live migration at the cluster level, this window typically displays an error message stating that the network path was not found. Right-click on this error and choose the Add Share command from the right-click menu (Figure 3.36). Figure 3.36

Right-click in the Cluster Storage section and choose the Add Share option.

6. When the Add a Network Share dialog box launches, enter the UNC share name (\\servername\sharename) for the destination storage and click OK (Figure 3.37). Figure 3.37

Enter the path to the network share in UNC format.

7. Confirm that the Move Virtual Machine Storage dialog box lists the specified network share in the Shares section (Figure 3.38).

111

Understanding Hyper-V in Windows Server 2012

Figure 3.38

Verify that the UNC path is displayed in the Shares section.

8. Drag the virtual machine from the top section of the dialog box to the listing for the share that you have specified. The dialog box should update to display the items that will be moved (Figure 3.39). Figure 3.39

You should see the virtual machine components that are about to be migrated.

112

Understanding Hyper-V in Windows Server 2012

9. Click the Start button. 10. The Failover Cluster Manager should confirm that the storage migration has begun (Figure 3.40). Although the virtual machine displayed in this screen capture is powered off, the move could just as easily have been performed while the virtual machine was running. Figure 3.40

The Failover Cluster Manager should confirm that virtual machine migration has begun.

Storage migrations outside of a cluster When it comes to performing storage migrations for non-clustered virtual machines, you have three options: moving the entire virtual machine to a single location, moving the virtual machine’s data to different locations or moving only the Virtual Hard Disks. The sections below provide walkthroughs for all three types of storage migrations.

Moving all of the virtual machine’s data to a single location The first option is to move all of the virtual machine data to a single location. This is the easiest of the storage live migration options and is likely to be the option that you will use most often. To complete this type of storage live migration, follow these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine for which you wish to perform a storage migration, and select the Move command from the right-click menu (Figure 3.41). Figure 3.41

Right-click on a VM and choose the Move command from the right-click menu.

113

Understanding Hyper-V in Windows Server 2012

3. When the Move wizard launches, click Next to bypass the wizard’s Welcome screen. 4. Choose the option to move the virtual machine’s storage, and click Next (Figure 3.42). Figure 3.42

Choose the option to move the virtual machine’s storage.

5. Choose the option to Move All of the Virtual Machine’s Data to a Single Location (Figure 3.43).

114

Understanding Hyper-V in Windows Server 2012

Figure 3.43

Choose the option to move all of the virtual machine’s data to a single location.

6. Click Next. 7. Specify the folder to which you want to move the virtual machine (Figure 3.44). Pay attention to the Current Location section within the wizard’s current screen. This section tells you how much physical disk space the virtual machine is currently consuming. You must verify that there is sufficient disk space in the new location.

115

Understanding Hyper-V in Windows Server 2012

Figure 3.44

Specify the path to which you want to move the virtual machine.

8. Click Next. 9. Verify the information shown on the Summary screen. 10. Click Finish.

Moving the virtual machine’s data to different locations The second option for performing storage live migrations involves moving virtual machine data to different locations. This option is useful for storage migrations that require a bit more granular control. For instance, you can use this option to place Virtual Hard Disk files in one storage location and snapshot files in another. To perform this type of storage live migration, follow these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine for which you wish to perform a storage migration and select the New command from the right-click menu. 3. When the Move wizard launches, click Next to bypass the wizard’s Welcome screen. 4. Choose the option to move the virtual machine’s storage, and click Next. 5. Choose the option to Move the Virtual Machine’s Data to a Different Locations (Figure 3.45).

116

Understanding Hyper-V in Windows Server 2012

Figure 3.45

Choose the option to move the virtual machine’s data to different locations.

6. Click Next. 7. Choose the virtual machine components that you want to move (Figure 3.46) and click Next. Figure 3.46

Select the virtual machine components that you want to move.

117

Understanding Hyper-V in Windows Server 2012

8. If you have chosen to move the Virtual Hard Disk, you will be prompted to enter a new location for it (Figure 3.47). Enter the path to the Virtual Hard Disk’s new location and click Next. Figure 3.47

If prompted, enter a path in which to store the Virtual Hard Disk.

9. If you have chosen to move the virtual machine’s configuration, you will be prompted to enter a path to the new location (Figure 3.48). Enter a path to use for the virtual machine’s configuration and click Next.

118

Understanding Hyper-V in Windows Server 2012

Figure 3.48

Enter a path in which to store the virtual machine’s configuration.

10. If you have chosen to move the virtual machine snapshots, you will be prompted to specify a path to the new location. Enter a path and click Next. 11. If you have chosen to move the Smart Paging files, you will be prompted to enter a new location for them (Figure 3.49). Enter a path for the smart paging files and click Next.

119

Understanding Hyper-V in Windows Server 2012

Figure 3.49

Enter the path in which to store the smart paging file.

12. Verify the information on the summary screen and click Finish.

Moving only the Virtual Hard Drives The third option for performing a storage migration is to move only the Virtual Hard Disk files. This option is useful if you want to free up some storage space by moving the virtual hard disk files, but want to keep the other virtual machine components in their current location. You can complete this type of storage live migration by following these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine for which you wish to perform a storage migration, and select the New command from the right-click menu. 3. When the Move wizard launches, click Next to bypass the wizard’s Welcome screen. 4. Choose the option to move the virtual machine’s storage, and click Next. 5. Choose the option to Move Only the Virtual Machine’s Virtual Hard Disks (Figure 3.50).

120

Understanding Hyper-V in Windows Server 2012

Figure 3.50

Choose the option to move only the virtual machine’s Virtual Hard Disks.

6. Click Next. 7. Select the Virtual Hard Disks that you want to move (Figure 3.51) and click Next. Figure 3.51

Select the Virtual Hard Disks that you wish to move.

121

Understanding Hyper-V in Windows Server 2012

8. Specify the location to which you wish to move the Virtual Hard Disks and click Next (Figure 3.52). 9. Verify the information on the summary screen and click Finish. Figure 3.52

Enter the path where the virtual hard disk should be stored.

Share this e-book with your peers

122

Understanding Hyper-V in Windows Server 2012

Chapter 4

Managing Virtual Machine Failover The previous chapters show you how to build clustered Hyper-V deployments and how to migrate virtual machines within those environments. However, facilitating live migrations is only part of a Hyper-V cluster’s job. A cluster also has to keep virtual machines running, even if the server on which a virtual machine is hosted were to fail. This chapter discusses various aspects of failover planning. In this chapter you will learn about failover testing, anti‑affinity rules and virtual machine prioritization.

123

Understanding Hyper-V in Windows Server 2012

Virtual machine failover One of the big problems with server virtualization is that the virtualization host (the Hyper-V server) can become a single point of failure that can impact multiple virtual workloads. In a physical datacenter, the failure of a single server is usually an inconvenience, but it is rarely considered catastrophic. This isn’t necessarily the case in a virtual  datacenter. In a virtual datacenter, a physical server running Hyper-V hosts has multiple virtualized workloads. If this one, single physical server were to fail, all of the virtual machines that are running on that server will fail as well – unless, of course, the server is operating as a node within a failover cluster. Clustering is what keeps virtual machines running, even if the physical hardware fails.

Failover testing As you have no doubt seen in the previous chapters, there is a lot of work that goes into building a Hyper-V cluster. However, none of the hard work and expense means very much if your cluster fails to keep your virtual machines running when a hardware failure occurs. Of course you probably don’t want to wait for a disaster to happen in order to find out if your cluster is working or not. It’s better to test the cluster ahead of time. Failover cluster testing can be tricky in a production environment because you don’t want to jeopardize your production virtual machines in the testing process. And it’s never a good idea to test your clustering solution by walking through the datacenter and randomly yanking power cords out of clustered hosts. Even though this type of testing makes for an amusing story, it is hardly a recommended method. Microsoft gives you a few different methods of testing failover within your cluster. However, all of these tests tend to focus on the cluster at a high level. Microsoft does not provide a method for testing the failover of an individual virtual machine.

Validation testing The first type of testing that you can perform is a cluster validation test. If this sounds familiar, it is probably because you performed a validation test when you were preparing to build the failover cluster. Even though you may think of a validation test as a tool to use in preparation for building a cluster, you can perform these types of tests against a cluster that has already been established. The reason why this might be helpful is because cluster configurations tend to change over time and validation testing will help you spot any configuration problems that might exist within your cluster.

124

Understanding Hyper-V in Windows Server 2012

You can perform validation testing either through the Failover Cluster Manager or through PowerShell. To perform validation testing using the Failover Cluster Manager, follow these steps: 1. Open the Server Manager. 2. Select the Failover Cluster Manager command from the Tools menu. 3. When the Failover Cluster Manager opens, select the listing for your cluster within the console tree. 4. Click on the Validate Cluster link, found in the Actions pane (Figure 4.1) . Figure 4.1

Click on the Validate Cluster link.

5. When the Validate a Cluster Wizard begins, click Next to bypass the wizard’s Welcome screen. 6. Choose the option to run only the tests that you select (Figure 4.2). Figure 4.2

Choose the option to run only the tests that you select.

125

Understanding Hyper-V in Windows Server 2012

7. Click Next. 8. On the following screen, select the tests that you want to run (Figure 4.3). You can select entire categories of tests (such as Inventory, Network, or System Configuration), or you can expand a category and select individual tests within that category. Figure 4.3

Select the tests that you want to run.

9. Click Next. 10. The following screen displays your cluster disk (assuming that your cluster uses a Cluster Shared Volume) and indicates that you can select the cluster disk if you want to include it in the validation testing (Figure 4.4). However, you should only run the tests against your cluster disk if the Cluster Shared Volume has been stopped. Otherwise, the testing can cause virtual machines to fail.

126

Understanding Hyper-V in Windows Server 2012

Figure 4.4

Do not select the cluster disk if your Cluster Shared Volume is in use!

11. Click Next. 12. Take a moment and look through the confirmation screen to make sure that you have selected the proper tests. 13. Click Next to begin the tests. 14. When the tests complete, click the View Report button to view the validation report (Figure 4.5). 15. Click Finish. Figure 4.5

Click the View Report button to view the validation report.

127

Understanding Hyper-V in Windows Server 2012

Validation testing through PowerShell Just as you can perform validation testing using the Failover Cluster Manager, you can also validate clusters using PowerShell. PowerShell testing is very flexible and you are free to pick and choose the tests that you want to run. Validation testing with PowerShell is based on the Test-Cluster cmdlet. You can perform comprehensive validation testing against all of your cluster nodes by simply entering the Test-Cluster cmdlet (Figure 4.6). Keep in mind, however, that you must not test Cluster Shared Volumes that are actively being used. Figure 4.6

The Test-Cluster cmdlet can be used for comprehensive cluster validation testing.

When you first enter the Test-Cluster cmdlet, PowerShell may appear to lock up. After several seconds you should see the tests begin, as shown in Figure 4.6. When the validation testing completes, you will see a message that refers to a validation report (Figure 4.7). The validation report file is located in the C:\ Windows\Cluster\Reports folder. You can open the validation reports using Internet Explorer, as shown in Figure 4.8. Figure 4.7

The test’s output is written to a validation report.

128

Understanding Hyper-V in Windows Server 2012

Figure 4.8

Validation reports are displayed in Internet Explorer.

Keep in mind that the validation report shown in the figure above was based on a comprehensive set of cluster tests. It is possible to exercise a high degree of granular control over the testing process. Using PowerShell, you can run specific validation tests, exclude certain validation tests and direct the testing process to specific cluster nodes. The trick to using PowerShell to control the validation tests is to retrieve a list of the test names. Once you have a list of the test names (as referenced by PowerShell) you can begin to include or exclude specific tests. To get a list of all of the test names, enter the following command (Figure 4.9): Test-Cluster – List

129

Understanding Hyper-V in Windows Server 2012

Figure 4.9

You can retrieve a list of all of the validation tests.

Once you have a list of test names, it is easy to include or exclude individual tests. For example, suppose that you want to perform all of the validation tests except for those related to storage. You can do so by entering the following command: Test-Cluster –Ignore Storage Similarly, if you only want to run the system drivers test, you can enter a command like this one (Figure 4.10): Test-Cluster –Include “List System Drivers” Figure 4.10

You can tell PowerShell to run specific tests.

You can also use PowerShell to specify the cluster nodes to include in the validation tests. For example, suppose that you want to run the validation tests against nodes named Lab1, Lab2, and Lab3 (Figure 4.11). To do so, you can use the following command: Test-Cluster –Node Lab1,Lab2,Lab3

130

Understanding Hyper-V in Windows Server 2012

Figure 4.11

You can run validation tests against individual cluster nodes.

Cluster resource testing The second type of cluster testing you can perform is called cluster resource testing. Cluster resource testing lets you see how your cluster would behave if a specific resource failed. Unfortunately, this type of testing is somewhat limited and there isn’t much documentation available from Microsoft pertaining to it. There are three important things that you need to know about cluster resource testing prior to trying it: 1. Cluster resource testing simulates the failure of a cluster resource, so if you do not perform the tests carefully you could cause an outage. 2. You can only test components that Microsoft defines as cluster resources. You will find out how to get a list of these components below. 3. Often the name that Windows assigns to a cluster resource is different from the name that you give to the resource. You can use cluster resource testing to find out what would happen if a virtual machine fails, but you won’t be able to reference the virtual machine by its usual name. With that said, cluster resource testing is based on the use of the TestClusterResourceFailure cmdlet. The syntax for this cmdlet is simple. You only have to specify the name of the resource that you want to test. The trick is to figure out which resources are available for testing and the names that Windows uses for those resources. The easiest way to deal with this challenge is to enter the Get-ClusterResource cmdlet. When you do this, PowerShell displays a list of the cluster resources (Figure 4.12).

131

Understanding Hyper-V in Windows Server 2012

Figure 4.12

Use the Get-ClusterResource cmdlet to create a list of cluster resources.

Notice in the figure above that the last item on the list is Virtual Machine VM3. This virtual machine’s name is VM3, but for the purpose of cluster resource testing, the virtual machine must be referred to as Virtual Machine VM3. If you want to see what would happen if the virtual machine fails, you can enter the following command (Figure 4.13): Test-ClusterResourceFailure “Virtual Machine VM3” Figure 4.13

You can use PowerShell to simulate the failure of a virtual machine.

If you look at the Failover Cluster Manager, you can see that the virtual machine can actually go down as a result of the test (Figure 4.14). Running the test once against a virtual machine causes the virtual machine to go down for a moment and then come back up. However, running the test twice usually takes the virtual machine completely offline until you right-click on the virtual machine and choose the Start option from the right-click menu. Figure 4.14

Virtual machine failure testing takes the virtual machine offline.

132

Understanding Hyper-V in Windows Server 2012

For the most part, cluster resource failure testing is limited to the items on the list of cluster resources (Figure 4.12). The big exception, however, is that you can also test cluster disks. Suppose for example that you want to test the failure of a disk named Cluster Disk 1 (Figure 4.12). You can do so by entering the following command: Test-ClusterResourceFailure –Name “Cluster Disk 1” Figure 4.15

You can use the Test-ClusterResourceFailure cmdlet to test cluster disk failures.

Failover testing The third type of testing you can do with regard to your cluster is failover testing. Failover testing simulates the failure of an active cluster node and tests the cluster’s ability to failover to another node in the cluster. Unfortunately, Microsoft does not provide a mechanism for testing the failover of an individual virtual machine. Instead, failover testing occurs at the cluster level. To perform a failover test, follow these steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager command from the Tools menu. 3. When the Failover Cluster Manager appears, navigate through the console tree to Failover Cluster Manager | (Figure 4.16) .

133

Understanding Hyper-V in Windows Server 2012

Figure 4.16

Select your cluster within the Failover Cluster Manager.

4. Click on the More Actions link, found in the Actions pane and then click on the Simulate Failure link (Figure 4.17). Figure 4.17

Click on the Simulate Failure option.

134

Understanding Hyper-V in Windows Server 2012

5. Windows will display a warning message telling you that simulating afailure could cause clustered roles (in this case virtual machines) to be moved to another cluster node, and that service could potentially be interrupted. Click Yes to move forward with the test. 6. You can watch the failover happen in the Cluster Core Resources pane, which is located in the lower, middle portion of the Failover Cluster Manager (Figure 4.18). Figure 4.18

You can watch the failover occur in the Cluster Core Resources pane.

Anti-affinity rules In multi-tenant environments, it is sometimes necessary to configure certain virtual machines so that they never reside on the same host server. For example, if your organization were hosting virtual machines for both Coke and Pepsi, you would not want the two companies’ virtual machines to reside on a common host server. It is relatively easy to keep virtual machines separate from one another when you initially create the virtual machines. However, virtual machines are anything but static and the chances of a virtual machine remaining on the same Hyper-V host for an indefinite period of time are slim. If you have virtual machines that need to be kept separate, you can reduce the chances of those virtual machines ever ending up on a common host by using anti-affinity rules. Anti-affinity rules prevent virtual machines that must remain separate from failing over to a common host. Unfortunately, anti-affinity rules are not exactly easy to work with. These rules can only be established through PowerShell, and the process is not very intuitive. The key to understanding how the process works is to understand that for every clustered virtual machine, there is a corresponding cluster group. Each cluster group uses the same name as the virtual machine for which it was created. Anti-affinity rules are applied to cluster groups, not to virtual machines. Like other types of objects in PowerShell, cluster groups have a number of different properties (Figure 4.19). To see a list of the cluster group properties, enter the following command: Get-ClusterGroup | Select-Object *

135

Understanding Hyper-V in Windows Server 2012

Figure 4.19

Cluster groups are made up of a number of properties.

As you look at the properties in the screen capture above, you will notice that the third property from the bottom of the list is named AntiAffinityClassNames. Creating an anti-affinity rule involves assigning a value to this property. Normally you could modify this type of value by using a command like this: Get-ClusterGroup | Set-ClusterGroup – AntiAffinityClassNames However, there is just one problem with the command shown above—there is no Set-ClusterGroup cmdlet. The fact that such a command does not exist is a safety precaution—if a Set-ClusterGroup cmdlet did exist, you could potentially destroy a virtual machine if you used the cmdlet incorrectly. Since you can’t use Get-ClusterGroup and Set-ClusterGroup, you have to use a completely different approach to modifying the AntiAffinityClassNames property. Unfortunately, Windows PowerShell does not contain the code for managing the AntiAffinityClassNames property. However, you can download a PowerShell module that makes it possible to directly manipulate this property. In case you are not familiar with the concept of a PowerShell module, it is basically a collection of PowerShell cmdlets that can be bolted on to the core cmdlet set. You can download the PowerShell Module for Configuring AntiAffinityClassNames in Failover Clustering at: http://gallery.technet.microsoft.com/PowerShellmodule-for-16242485. This module is designed for use with Windows Server 2008 R2, but it works with Windows Server 2012 as well. The download consists of a ZIP file. You will need to download the ZIP file and extract its contents to the server’s hard disk. The path that you use is up to you, but you will have to enter the full path into PowerShell, so it is beneficial to use a relatively simple path. For demonstration purposes this example places the extracted files into a folder named C:\Modules.

136

Understanding Hyper-V in Windows Server 2012

Once you have extracted the zip file’s contents, you’ll need to import the module into PowerShell. Note that importing a module is not a permanent operation. The module only remains imported for as long as PowerShell is open. If you need to use the module again at a later time, you will have to import it again. Before you can import the module, you will have to configure your server’s execution policy to allow PowerShell scripts to be run. The easiest way to do this is to enter the following command: Set-ExecutionPolicy Unrestricted This command allows PowerShell to run any PowerShell script, regardless of where it came from (Figure 4.20). Obviously, there are some security implications associated with allowing unrestricted access to scripts, as explained in the text shown below (Figure 4.20). If you are concerned about security, you can set the execution policy back to Restricted when you finish working with the AntiAffinityClassNames by using the Set-ExecutionPolicy Restricted cmdlet. Figure 4.20

You must configure the execution policy to allow PowerShell scripts to be run.

With that said, you can use the following command to import the module (assuming that the module resides in C:\modules): Import-Module C:\Modules\AntiAffinityClassNames When you execute the command listed above, you will see several prompts asking if you want to allow the script to run (Figure 4.21). You must run each of these scripts in order to successfully import the module. Figure 4.21

You must import the AntiAffinityClassNames module before you can use it.

137

Understanding Hyper-V in Windows Server 2012

As previously mentioned, a PowerShell module adds cmdlets to the built-in cmdlet set. If you would like to see a list of the new cmdlets that were added, enter the following command (Figure 4.22): Get-Command –Module AntiAffinityClassNames Figure 4.22

The AntiAffinityClassNames module adds three new cmdlets to PowerShell.

Now that all of the necessary components are in place, you can begin working with anti-affinity rules. The basic idea behind these rules is that certain servers should never reside on the same hosts. You can specify these servers by adding a value to the AntiAffinityClassNames parameter. Servers with the same AntiAffinityClassNames parameter will not normally fail over to a common host. A more concrete example of how this works is a situation in which an organization has multiple virtualized domain controllers. You would never want to be in a situation in which all of your domain controllers failed over to the same host. That being the case, you could add the phrase “Domain Controller” to each domain controller’s AntiAffinityClassNames parameter to indicate that each server that uses this tag is a domain controller and that each domain controller should reside on a separate host. To be perfectly clear, the “Domain Controllers” value is just an example—you can call your anti‑affinity values anything that you want. Setting up anti-affinity rules in this manner does not guarantee that the virtual machines will never be hosted on the same server. If the cluster is ever put into a situation where there aren’t enough remaining cluster nodes to facilitate the requirements of the anti-affinity rules, Windows will place the virtual machines wherever it can. The assumption is that it is more important to keep the virtual machines running than it is to keep them separated. Now you can configure anti-affinity rules by using the Set-AntiAffinityClassNames cmdlet. This cmdlet requires you to specify the name of the cluster, the cluster group to which the rule should apply (the cluster group name is the same as the virtual machine name), and the value that you want to assign. Suppose, for example, that your cluster is named HyperVCluster and that you want to assign an AntiAffinityClassNames value of “Domain Controller” to a virtual machine named VM3. To do so, use the following command: Set-AntiAffinityClassNames –Cluster HyperVCluster –ClusterGroup VM3 – Value “Domain Controller”

138

Understanding Hyper-V in Windows Server 2012

It is worth noting that the Set-AntiAffinityClassNames cmdlet sometimes has trouble recognizing a cluster name. You may receive an error telling you to check the spelling of the cluster name. If that happens, enter the GetAntiAffinityClassNames cmdlet (Figure 4.23). By doing so, you might find that the cluster name is listed as localhost rather than by its designated name. Figure 4.23

The cluster name is sometimes listed as localhost.

When you successfully assign a value to the AntiAffinityClassNames property, PowerShell does not acknowledge the success of the operation. The easiest way to confirm that the operation was successful is to enter the GetAntiAffinityClassNames cmdlet (Figure 4.24). Figure 4.24

Use the Get-AntiAffinityClassNames cmdlet to verify the success of the operation.

Virtual machine prioritization Failover clusters are great because if a cluster node fails, the virtual machines can fail over to another node in the cluster where they continue to run. Sometimes, however, the failover process fails because of insufficient system resources. Most Hyper-V failover clusters do not use empty cluster nodes that are sitting idle, waiting for a failure to happen. More often, each cluster node hosts a number of virtual machines. If a failure occurs, the Failover Cluster Service will attempt to move the virtual machines from the failed node to another cluster node where those virtual machines can continue to run. However, if the node was already hosting some virtual machines prior to the failure, then that server may not have enough memory or CPU resources to host its own workload plus all of the virtual machines from the failed cluster node.

139

Understanding Hyper-V in Windows Server 2012

Unfortunately, there is no magic trick that you can use to make the cluster node handle all of those virtual machines from the failed cluster node. Servers only have so much memory and when all of that memory has been allocated, the server will be unable to host any additional virtual machines. Because Windows can’t expand a cluster node’s capacity so that it can handle more virtual machines, Windows instead lets you prioritize virtual machines. In any organization there are some virtual machines that are more important than others. For example, your mail server is probably more important than a redundant domain controller. By prioritizing your virtual machines, you can make sure that the most important virtual machines continue to function in a failover situation. Windows will start the highest priority virtual machines first and lower priority virtual machines in sequence until the server runs out of memory or other resources. Setting a virtual machine’s priority is easy. To do so, follow these steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager command from the Tools menu. 3. When the Failover Cluster Manager starts, select the Roles container. 4. Right-click on the virtual machine that you want to prioritize and choose the Change Startup Priority command from the right-click menu (Figure 4.25). 5. Specify the virtual machine’s priority. Figure 4.25

Specify the virtual machine’s startup priority.

As you look at the figure above, you will notice that the Failover Cluster Manager has a Priority column that displays each virtual machine’s priority. Every virtual machine has a default priority of Medium, but you can raise or lower that priority based on the virtual machine’s importance.

140

Understanding Hyper-V in Windows Server 2012

Setting the preferred owners Some organizations might prefer to have virtual machines running on certain hosts. For example, if you have a large database application, you would probably want that application to run on the host that has the fastest CPU. Hyper-V allows you to set priorities on which physical hosts your virtual machines run. To specify a preferred host, follow these steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager command from the Tools menu. 3. When the Failover Cluster Manager opens, select the Roles container. 4. Right-click on a clustered virtual machine for which you want to specify a preferred host server and select the Properties command from the right‑click menu. 5. When the Core Properties dialog box appears, select the checkbox for the virtual machine’s preferred host server (Figure 4.26). Figure 4.26

Hyper-V allows you to specify a preferred host server for any clustered virtual machine.

Although Microsoft makes it easy to specify a preferred host, there are two things that you should know about host server prioritization. First, you can specify multiple preferred servers by selecting the checkboxes for each preferred cluster node. Use the Up and Down buttons shown in the figure above to arrange the list of cluster nodes based on your preferred priority. Second, host prioritization is not guaranteed. If a virtual machine’s preferred host is offline or lacks the capacity to host a virtual machine, the virtual machine will be hosted on a cluster node other than the preferred node.

141

Understanding Hyper-V in Windows Server 2012

Failover rules The Failover Cluster Service allows you to set some ground rules for the way that virtual machines failover to other cluster nodes. These rules are all controlled through a dialog box within the Failover Cluster Manager. To access this dialog box, follow these steps: 1. Open the Server Manager. 2. Select the Failover Cluster Manager option from the Tools menu. 3. When the Failover Cluster Manager opens, select the Roles container. 4. Right-click on a clustered virtual machine. 5. Select the Properties command from the right-click menu. 6. When the virtual machine’s properties sheet appears, select the Failover tab (Figure 4.27). Figure 4.27

Failover is controlled through the settings found on the Failover tab.

Note that the Failover tab is divided into two sections. The first section allows you to define the maximum number of failovers that can occur within a given period of time. The idea is that if a virtual machine fails over repeatedly, there is probably a serious problem with that virtual machine or with the cluster and it might be better to simply take the virtual machine offline and put it into a failed state rather than allow it to keep failing over. By default, failures are capped at two failures within a six-hour period, but you can adjust these settings based on your needs.

142

Understanding Hyper-V in Windows Server 2012

The lower portion of the dialog box lets you control whether or not the virtual machine will be allowed to fail back to the server on which it was originally hosted. By default, automatic failback is disabled. However, you can enable automatic failback and configure it to happen immediately or on a scheduled basis. In most cases it is best to leave automatic failback disabled. If a failover occurred, a problem exists that caused the failover, and you don’t want your virtual machines automatically failing back to a cluster node that has an unresolved problem.

Share this e-book with your peers

143

Understanding Hyper-V in Windows Server 2012

Chapter 5

PowerShell Management In Windows Server 2008 and 2008 R2, Microsoft allowed many aspects of the Windows operating system to be managed through PowerShell. Because PowerShell was relatively new, however, there were certain operating system components (including Hyper-V) that could not be managed through PowerShell. Microsoft eventually released a PowerShell module for Hyper-V, but this module had to be downloaded separately. Thankfully, the Windows Server 2012 version of Hyper-V includes native PowerShell management capabilities. It is the goal of this chapter to familiarize you with the various ways in which Hyper-V can be managed through PowerShell.

144

Understanding Hyper-V in Windows Server 2012

Syntax simplification Before discussing PowerShell management for Hyper-V, there is some good news. While developing Windows Server 2012, Microsoft realized that non‑developers often struggled with PowerShell. In spite of what the marketing folks might say, the syntax for various PowerShell commands was often complex and completely non-intuitive. Thankfully, Microsoft decided to simplify the PowerShell syntax—especially as it relates to the Where-Object and ForEach-Object cmdlets. To show you an example of the way that the syntax has been simplified, imagine that you want to see a list of all of the processes that are running on the local Hyper-V host server. Prior to Windows Server 2012, you would have had to use this command: Get-Process | ForEach {$_.Name} The Windows Server 2012 version of PowerShell is backward compatible with the previous version, so you can still use this style of command (this is important if you want to continue using older scripts). However, Windows Server 2012 also allows you to enter commands in a simplified manner. For example, the command shown above can be simplified as: Get-Process | ForEach Name This same simplification also applies to operations in which you use operators to filter the result set. For example, prior to Windows Server 2012, to see a list of all of the processes using more than 500 handles, you would have had to use the following command: Get-Process | where {$_.Handles –gt 500} In Windows Server 2012, this command can be simplified as: Get-Process | Where Handles –gt 500

145

Understanding Hyper-V in Windows Server 2012

Attaching to a Hyper-V server The first skill you must master with regard to managing Hyper-V from PowerShell is that of attaching to a remote server. If you plan to manage Hyper-V through PowerShell by using the local server console, then you won’t have to worry about establishing a remote PowerShell connection. You can simply open a PowerShell window and enter the various cmdlets without having to do anything special. However, if you need to manage a remote host, you will first need to establish a session with that host. There are a few different ways to use a PowerShell session to control a remote Hyper-V host. One method involves using the Enter-PSSession cmdlet. To use this method, enter the Enter-PSSession cmdlet and append the name of the server that you want to attach to. Any commands that you run from this point on will execute on the remote server, but the results will be displayed in the local console. You can end the session by entering the Exit-PSSession cmdlet. For example, to establish a session with a server named Lab2, execute the Get-VM cmdlet, and then terminate the session, you would use these commands: Enter-PSSession Lab2 Get-VM ExitPSSession Notice in the screen capture (Figure 5.1) that the PowerShell prompt changes to reflect the name of the server that you are attached to. Figure 5.1

You can use the Enter-PSSession cmdlet to establish a remote PowerShell session.

Another method is to use the Invoke-Command cmdlet to execute a single command on a remote host (Figure 5.2). The trick is to specify the computer name. You can even specify multiple computer names if you separate them by commas. The actual command that you send to the remote machines must appear in braces. For example, to send the Get-VM command to computers named Lab1, Lab2 and Lab3, you would enter the following command: Invoke-command –ComputerName Lab1, Lab2, Lab3 {Get-VM}

146

Understanding Hyper-V in Windows Server 2012

Figure 5.2

You can use the Invoke-Command cmdlet to remotely execute a PowerShell command.

Keep in mind that these are the simplest methods of establishing a remote PowerShell session. Things can become more complex if you need to enter an alternative set of permissions or if you need to modify the execution policy to allow scripts to be run. For example, the block of PowerShell listed below is used to manage an Office 365 environment through PowerShell. Although Office 365 is beyond the scope of this book, this example illustrates the point that there are more complex methods of establishing remote PowerShell connectivity. Set-ExecutionPolicy RemoteSigned Import-Module MSOnline $Cred = Get-Credential $MySession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $Cred -Authentication Basic -AllowRedirection Import-PSSession $MySession

Querying virtual machines One of the most basic (but useful) things that you can do with PowerShell involves performing various queries against virtual machines. The simplest of these queries involves using the Get-VM cmdlet. Entering this cmdlet returns a list of all of the virtual machines that are present on the host (Figure 5.3). Along with the name of each virtual machine, you can also see the virtual machine’s state (whether or not it is running) along with its CPU usage, memory assigned, up time and status.

147

Understanding Hyper-V in Windows Server 2012

Figure 5.3

The Get-VM cmdlet returns a list of the virtual machines that are present on the host.

Notice in Figure 5.3 that the Get-VM cmdlet returns virtual machine information from the local server. Had we established a PowerShell session with a remote server, virtual machine information from the remote server would have been returned instead. If you need to perform a Get-VM query against a remote server, however, it may not always be necessary to establish a session with the server. Remote sessions are most useful when you need to redirect PowerShell so that all operations are performed against the remote host instead of the local host. If you simply need to retrieve a bit of information from the remote host, you can often do so by using a standard PowerShell cmdlet and appending the name of the remote server. To see how this works, imagine that you want to see a list of the virtual machines residing on a host named Prod1 (Figure 5.4). You can accomplish this by entering the following command: Get-VM –ComputerName Prod1 Figure 5.4

You can get a list of the virtual machines that reside on a specific host.

Of course, the list of virtual machines that are running on a specific host could potentially be really long. Often you might be more interested in viewing the state of a specific virtual machine rather than seeing a list of every virtual machine that exists on a host server. In this case, you can append a virtual machine name directly to the end of the Get-VM cmdlet (Figure 5.5). For example, to view the current state of a VM named Lab-DC you can enter this command: Get-VM Lab-DC Figure 5.5

You can retrieve information for a specific virtual machine.

148

Understanding Hyper-V in Windows Server 2012

Just as you can use the Get-VM cmdlet to retrieve basic information about virtual machines, you can use the Get-VMHost cmdlet to access information about host servers (Figure 5.6). Entering the Get-VMHost cmdlet by itself returns the name of your host server along with its logical processor count, memory capacity and whether or not the virtual machine is configured to allow virtual machine migrations. Figure 5.6

The Get-VMHost cmdlet retrieves information about a host server.

It is also possible to use the Get-VMHost cmdlet to retrieve information about multiple host servers at the same time. Simply append the names of the host servers that you want to query. Host server names should be separated by commas (Figure 5.7). For example, the command might look something like this: Get-VMHost Lab1,Lab2,Lab3,Prod1,Prod2 Figure 5.7

You can query multiple host servers through a single command.

Filtering the output In the previous section, you saw that it is possible to use the Get-VM (Figure 5.8) and the Get-Host cmdlets to retrieve basic information about virtual machines and host servers. Often, however, you might need to access more detailed information than what these cmdlets provide by default. Fortunately, there are a number of ways to accomplish this. Figure 5.8

You can use the Get-VM cmdlet to retrieve virtual machine information.

149

Understanding Hyper-V in Windows Server 2012

One of the nice things about PowerShell is that it allows you to use attributes and operators to filter a cmdlet’s output. Some of the commonly used operators include: Equal To

-EQ

Or

-OR

And

-AND

Like

-Like

Greater Than -GT Less Than

-LT

You can combine these operators with object attributes to retrieve very granular information about your host servers and virtual machines. One of the most basic examples of output filtering involves filtering virtual machines by name. For example, entering the Get-VM cmdlet on the host Lab1 returns listings for a number of virtual machines. On this server the name of each virtual machine reflects the virtual machine’s purpose. For example, virtual machines starting with LAB15 are lab machines related to Microsoft’s wave 15 product release (Office 15, SharePoint 15, Exchange 15, etc.). With this in mind, it might occasionally be necessary to get a list of the virtual machines that are related to wave 15 testing. In this situation, the Like operator could prove to be very handy. You can use the Like operator to list values that are similar to a target value. For instance, you can list all of the virtual machines that have names starting with Lab15 (Figure 5.9) by using the following cmdlet: Get-VM | Where Name –Like ‘Lab15*’ Figure 5.9

You can use filtering to narrow down the list of virtual machines.

Being able to filter virtual machines by name is nice, but this is not the only type of filtering you can do. It is also possible to filter on things like a virtual machine’s state. For instance, if you want to see which virtual machines are currently powered off (Figure 5.10), you can use the following command: Get-VM | Where State –EQ ‘Off’ Figure 5.10

You can filter based on a virtual machine’s state.

150

Understanding Hyper-V in Windows Server 2012

Obviously it’s handy to be able to see a list of the virtual machines that are powered off, but remember that the command shown above only looks at the current host server. What if you wanted to see a list of the running virtual machines across multiple hosts? To accomplish this, you would simply add the –ComputerName switch and the names of the hosts that should be included in the query (Figure 5.11). The command might look something like this: Get-VM –ComputerName Lab1,Lab2,Lab3,Prod1,Prod2 | Where State –EQ ‘Running’ Figure 5.11

A filtered output can contain data from multiple Hyper-V host servers.

What about clusters? So far the topic of filtering has assumed that the virtual machines are running on standalone hosts. However, virtual machine queries can also be very useful in clustered environments. Suppose, for example, that you want to see a list of all of your clustered virtual machines (Figure 5.12). You can do so by entering the following command: Get-ClusterGroup | Where GroupType –EQ ‘VirtualMachine’ | Get-VM Figure 5.12

You can use PowerShell for cluster management.

This technique becomes most useful when you apply multiple filters together. If you look at the previous screen capture you will notice that one clustered virtual machine is running and another is not. If this were a production environment with lots of virtual machines, it might be useful to compile a list of the clustered virtual machines that were not running (Figure 5.13). You could do this by entering the following command: Get-ClusterGroup | Where GroupType –EQ ‘VirtualMachine’ | Get-VM | Where State –EQ ‘Off’ Figure 5.13

You can create a list of clustered virtual machines that are not currently running.

151

Understanding Hyper-V in Windows Server 2012

In a clustered environment it isn’t just important to keep virtual machines running, it is also important to keep track of resource utilization. You can use a similar technique to the one that was just demonstrated to keep track of virtual machine memory usage within the cluster. For example, to create a list of all of the clustered virtual machines that are using more than a gigabyte of memory (Figure 5.14), you can use this command: Get-ClusterGroup | Where GroupType –EQ ‘VirtualMachine’ | Get-VM | Where MemoryAssigned –GT ‘1073741825’ Figure 5.14

You can use PowerShell to determine which VMs are consuming excessive system resources.

It is worth noting that even though PowerShell displays the memory in megabytes in this case, you must enter the MemoryAssigned value in bytes.

Getting more information So far, this chapter has discussed various filtering techniques, but often you may need more detailed information than what the various commands provide by default. The good news is that the Get-VM and the Get-VMHost cmdlets only display a small subset of the information that is actually available and it is easy to customize the commands so that just the information you need is displayed. In PowerShell, VM and VMHost both represent objects. Objects contain a collection of attributes. Therefore, the key to customizing the command output is controlling which attributes are displayed. To see the attributes that are available for the Get-VM cmdlet (Figure 5.15), enter the following command: Get-VM Lab-DC | FL *

152

Understanding Hyper-V in Windows Server 2012

Figure 5.15

A wealth of information is available for each virtual machine.

This command displays all of the available attributes in list format. Pay attention to the attribute names because you can use these names to customize the output or to apply filters. Similarly you can view all of the attributes that are available within the Get-VMHost cmdlet (Figure 5.16) by entering this command: Get-VMHost | FL *

153

Understanding Hyper-V in Windows Server 2012

Figure 5.16

You can use the Get-VMHost cmdlet to retrieve host server information.

As you can see, there is a lot of information available both for virtual machines and for host servers. But what can you do with all of this information? For starters, you can control the output of the Get-VM or the Get-VMHost cmdlets (Figure 5.17). For example, suppose that you want to see each virtual machine’s name, the name of the host on which the virtual machine currently resides and whether or not the virtual machine is clustered. You can accomplish this by entering the following command: Get-VM | FT VMName, ComputerName, IsClustered Figure 5.17

You can control the output of the Get-VM or the Get-VMHost cmdlets.

Of course, you output the values of any of the available attributes and you can also use the various attributes with operators such as –Like, -And, -GT, etc. to achieve a filtered output. It is worth noting that Microsoft provides a number of cmdlets that you can use as shortcuts to retrieve very specific information about virtual machines. For example, you can use the Get-VMMemory cmdlet to retrieve a virtual machine’s memory configuration. Likewise, you can use the Get-VMProcessor cmdlet to view a virtual machine’s virtual CPU configuration.

154

Understanding Hyper-V in Windows Server 2012

Reporting In the previous section you learned how to modify the Get-VM and the Get‑VMHost cmdlets to achieve the desired output, but you can actually take things a step further and use PowerShell as a reporting engine. You can use PowerShell to create CSV, Text and even HTML files.

Lists and tables Before moving on to the creation of these file types, there is one more aspect of the output formatting to discuss. In the previous sections, the codes FL 9 (Format-List) and FT (Format-Table) were used. Formatting a command’s output as a list (Figure 5.18) displays the information vertically. This is the most appropriate format for viewing large amounts of information on screen. Tables (Figure 5.19) display information horizontally. This table format is best for looking at multiple results, such as a listing of virtual machines. Figure 5.18

Lists display information vertically.

155

Understanding Hyper-V in Windows Server 2012

Figure 5.19

Tables display data horizontally.

It is fine to use FT and FL to view a command’s output on screen, but if you plan to write the output to a CSV or HTML file, this will not work. Instead, you will have to replace FT or FL with the Select-Object cmdlet (Figure 5.20), followed by the attributes that you want to display. For example, you might use a command like this one: Get-VM | Select-Object VMName, State, ComputerName, IsClustered, UpTime, Status Figure 5.20

Often, it is necessary to use the Select-Object cmdlet to specify what data to include in a report.

156

Understanding Hyper-V in Windows Server 2012

CSV files CSV files are almost always created in table format. CSV files are useful for outputting large amounts of information in a format that can be read by Microsoft Excel or imported into a database. You can create a CSV file by appending the Export-CSV cmdlet to whatever command you are using. It is worth noting, however, that you must manually specify the attributes to include in the output. For example, to create a CSV file containing a listing of your virtual machines, their state, the host, whether or not the virtual machine is clustered, and the virtual machine’s uptime and status (Figure 5.21), you can enter this command: Get-VM | Select-Object VMName, State, ComputerName, IsClustered, UpTime, Status | Export-CSV C:\Data\VMs.csv Figure 5.21 You can choose which fields to export to a CSV file.

Once created, you can open the CSV in Microsoft Excel (Figure 5.22). Figure 5.22

You can open CSV files in Microsoft Excel.

Text files The process of creating a text file is similar to that of creating a CSV file, but PowerShell is a bit more forgiving when it comes to creating text files. You don’t have to use the Select-Object cmdlet and can instead use FT or FL. Rather than using the Export-CSV cmdlet, you will use the Out-File cmdlet. Other than that, the commands are identical. For example, to write a list of virtual machines to a text file (Figure 5.23), you can use this command: Get-VM | FT VMName, State, ComputerName, IsClustered, UpTime, Status | Out-File C:\Data\VMs.txt

157

Understanding Hyper-V in Windows Server 2012

Figure 5.23

You can write PowerShell data to a text file.

Notice in Figure 5.23 that you can view the contents of the newly created text file by entering the Type command, followed by the path and filename of the text file. Of course, you can also open the file in Notepad or any other text editor.

HTML reports The process of creating an HTML report is similar to that of creating a text file—both use the Out-File cmdlet. However, to create an HTML report, you need to add the ConvertTo-HTML cmdlet. For example, to write a list of your virtual machines to an HTML file, use this command: Get-VM | Select-Object VMName, State, ComputerName, IsClustered, UpTime, Status | ConvertTo-HTML | Out-File C:\Data\VMs.htm Just for fun, you can modify this command so that it creates the report and automatically opens it in Internet Explorer (Figure 5.24). To do this, append the Invoke-Expression cmdlet to the end of the command as shown in the following example: Get-VM | Select-Object VMName, State, ComputerName, IsClustered, UpTime, Status | ConvertTo-HTML | Out-File CL\Data\VMs.htm | InvokeExpression C:\Data\VMs.htm Figure 5.24

You can write PowerShell data to an HTML report.

As you can see, the process of writing data to an HTML report works pretty well, but the report is very plain (Figure 5.25) and not very visually appealing. To make your reports more visually interesting, you can create a style section and incorporate it into the report.

158

Understanding Hyper-V in Windows Server 2012

Figure 5.25

By default, HTML reports are very bland.

The block of code below (Figure 5.26) creates a PowerShell variable named $a and then adds an HTML style section to that variable. The actual report is created as discussed earlier, but with a couple of differences. When it comes time to issue the ConvertTo-HTML command, you insert the –Head switch and the $a variable. You also insert the Body tag and a header. The end result is a much more attractive HTML report (Figure 5.27). This is how the code is written: $a = "" $a = $a + "BODY{background-color:peachpuff;}" $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}" $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;bordercolor: black;background-color:thistle}" $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;bordercolor: black;background-color:PaleGoldenrod}" $a = $a + "" Get-VM | Select-Object VMName, State, ComputerName, IsClustered, UpTime, Status | ConvertTo-HTML -head $a -body "Virtual Machines" | Out-File C:\Data\VMs.htm Figure 5.26

You can add HTML style elements to an HTML report.

159

Understanding Hyper-V in Windows Server 2012

Figure 5.27

HTML reports can be displayed in color.

With a little bit of imagination you can create scripts that produce color-coded reports. For example, you can list virtual machines that are offline in red and list online virtual machines in green.

Changing a virtual machine’s state So far we have discussed PowerShell solely with regard to retrieving information about a virtual machine or a host server. Although PowerShell can be a powerful reporting tool, it can also be used to interact with virtual machines. For example, you can use PowerShell to start or stop a virtual machine. There are two cmdlets you can use to change a virtual machine’s state. These include: Stop-VM Start-VM When you enter the Stop-VM cmdlet, PowerShell will attempt to gracefully shut down the specified virtual machine. If the virtual machine cannot be brought down gracefully, you will see a warning message (Figure 5.28) telling you that the virtual machine cannot be shut down. The message gives you the option of turning off the virtual machine (without a graceful shutdown) or suspending the virtual machine. Figure 5.28

You will see a warning message if a virtual machine cannot be shut down gracefully.

The Start-VM cmdlet starts the virtual machine. The only required parameter is the name of the virtual machine that you want to start (Figure 5.29).

160

Understanding Hyper-V in Windows Server 2012

Figure 5.29

You can use the Start-VM cmdlet to start a virtual machine.

Creating a virtual machine You can also use PowerShell to create virtual machines. This involves using the New-VM cmdlet. At a minimum, you need to specify the name for the new virtual machine, the virtual machine path and the name of the host on which the virtual machine will reside. For example, to create a virtual machine named PowerShellVM in the C:\VMs folder on a host named Lab1 (Figure 5.30), you would enter the following command: New-VM –Name “PowerShellVM” –Path “C:\VMs” –ComputerName Lab1 Figure 5.30

You can create virtual machines through PowerShell.

When you enter this command, you will see confirmation that the new virtual machine was created. The new virtual machine should also be displayed in the Hyper-V Manager (Figure 5.31). Figure 5.31

The new virtual machine should appear in the Hyper-V Manager.

161

Understanding Hyper-V in Windows Server 2012

Keep in mind that you will almost always have to make modifications to a newly created virtual machine before using it. When you create a virtual machine using the method discussed above, it is allocated minimal hardware that is almost never suitable for real world use. The hardware allocation includes: • 512 MB of memory • DVD drive • No virtual hard disk • No network connection • One virtual processor Fortunately, you can use PowerShell cmdlets to modify a new or an existing virtual machine.

Modifying a virtual machine As you saw in the previous section, you may need to modify a virtual machine after creating it through PowerShell. Likewise, you may occasionally need to modify an existing virtual machine’s configuration. For instance, you might need to add more memory or additional CPU cores to a virtual machine. This section discusses some techniques for modifying virtual machine hardware allocation.

Memory The resource that you will likely have to adjust more often than any other is memory. You can adjust memory by using the Set-VMMemory cmdlet. Start the process by entering the Get-VMMemory cmdlet, followed by the name of the virtual machine (Figure 5.32). This causes PowerShell to display the virtual machine’s current memory configuration. Figure 5.32

You can use the Get-VMMemory cmdlet to see a virtual machine’s memory assignment.

The easiest way to reallocate a virtual machine’s memory is to assign a static amount of memory to the virtual machine by entering the following command: Set-VMMemory –Startup For example, to add 2 GB of memory to the virtual machine named PowerShellVM (Figure 5.33), use the following command: Set-VMMemory PowerShellVM –Startup 2.0GB

162

Understanding Hyper-V in Windows Server 2012

Figure 5.33

You can use the Set-VMMemory cmdlet to allocate memory to a virtual machine.

This command sets the startup memory to 2 GB. You can verify the operation’s success by using the Get-VMMemory cmdlet. If you want to configure a virtual machine to use dynamic memory, things become a bit more complicated. You still use the Set-VMMemory cmdlet, but you have to include a specification to enable dynamic memory. You will also have to provide values for the minimum, startup and maximum memory. You can optionally set a priority and a buffer value for the virtual machine as well by using the following command: Set-VMMemory -DynamicMemoryEnabled $True –MinimumBytes -StartupBytes -MaximumBytes -Priority -Buffer For example, suppose you want to configure the virtual machine PowerShellVM to use a 1 GB of startup memory and you want to set the minimum memory to 512 MB and the maximum memory to 2 GB. Let’s also assume that you want to set the priority to 80 and the buffer to 25 (Figure 5.34). You can do this with the following command: Set-VMMemory PowerShellVM –DynamicMemoryEnabled $True – MinimumBytes 512MB -StartupBytes 1GB –MaximumBytes 2GB –Priority 80 –Buffer 25 Figure 5.34

You can also use the Set-VMMemory for configuring dynamic memory.

Now that you know how to allocate memory to a virtual machine, here are a couple of shortcuts that you can use. Keep in mind that you can use these shortcuts with any type of hardware allocation. The following example uses only memory allocation.

163

Understanding Hyper-V in Windows Server 2012

Allocating memory to multiple virtual machines The first shortcut allows you to allocate memory to multiple virtual machines simultaneously. The easiest way to accomplish this is to specify multiple virtual machine names within the Set-VMMemory cmdlet. For example, to allocate 2 GB of memory to virtual machines named NewVM1, NewVM2 and NewVM3 on a server named Lab1 (Figure 5.35), you can use the following command: Set-VMMemory NewVM1,NewVM2,NewVM3 –Startup 2.0GB Figure 5.35

You can assign memory to multiple virtual machines.

When the operation has completed, you can verify its success by specifying all three virtual machine names within the Get-VMMemory cmdlet. For example, in this situation you would enter: Get-VMMemory NewVM1,NewVM2,NewVM3 Keep in mind that this is not the only way to allocate memory to multiple virtual machines. You can also specify the virtual machines to which you want to allocate memory using filtering. For example, you can create a filter based on the virtual machine’s name or on the amount of memory that is currently allocated to the virtual machine.

Pipelining hardware allocations The other shortcut that is worth knowing is that you can actually allocate memory to a virtual machine while the virtual machine is being created. This is done by pipelining the New-VM and the Set-VMMemory cmdlets together. Suppose, for example, that you want to create a virtual machine named NewVM4 and allocate 4 GB of RAM to it (Figure 5.36). You can accomplish this by using the following command: New-VM –Name “NewVM4” –Path “C:\VMs” –ComputerName Lab1 | SetVMMemory –Startup 4GB Figure 5.36

You can assign startup memory as a virtual machine is being created.

164

Understanding Hyper-V in Windows Server 2012

Virtual network adapters Just as you may need to modify a virtual machine’s memory allocation, you may also need to provision a virtual machine with a virtual NIC. It’s best to start by viewing a virtual machine’s current virtual network adapter usage. To do this, enter the Get-VMNetworkAdapter cmdlet, followed by the virtual machine name (Figure 5.37). Figure 5.37

You can use the Get-VMNetworkAdapter cmdlet to access virtual network adapter information for a virtual machine.

In many cases, you may find that although a network adapter has been assigned to a virtual machine, you must connect that network adapter to a virtual switch. Fortunately, this is relatively easy to do. While it is possible to use a single command to attach a virtual network adapter to a virtual switch, it’s better to use variables because the virtual network adapter name and the virtual switch name may be long. Using variables reduces the chances of making a mistake by mistyping one of the names. Therefore, the first step in the process is to retrieve the name of the virtual machine’s virtual network adapter and assign this name to a variable named $VMNic using the following command: $VMNic = Get-VMNetworkAdapter –VMName The next step is to retrieve the name of the virtual switch by using the following command: Get-VMSwitch | Select-Object Name If you have multiple virtual switches, you can narrow down the results by specifying the virtual switch’s connectivity. For example, if you only want to use an external virtual switch, you can use the following cmdlet: Get-VMSwitch –SwitchType External | Select-Object Name Now you just need to connect the virtual network adapter to the virtual switch. You should be able to do this by using the Connect-VMNetworkAdapter cmdlet; however, PowerShell apparently doesn’t allow you to add the virtual switch name to a variable and use the variable to connect the virtual switch to a  virtual network adapter. Instead, you have to enter the virtual switch name in long form. The command looks something like this: Connect-VMNetworkAdapter –VMNetworkAdapter $VMNic –SwitchName “”

165

Understanding Hyper-V in Windows Server 2012

As a more concrete example, for the virtual switch on a test server named Intel(R) Gigabit CT Desktop Adapter #2 – Virtual Switch (Figure 5.38), you would use the following command: Connect-VMNetworkAdapter –VMNetworkAdapter $VMNic –SwitchName “Intel(R) Gigabit CT Desktop Adapter #2 – Virtual Switch” Figure 5.38

You must connect a virtual network adapter to a virtual switch.

Once you have connected the virtual network adapter to the virtual switch, it is a good idea to verify the connection (Figure 5.39). You can do by entering the following command: Get-VMNetworkAdapter –VMName | SelectObject VMName, Name, SwitchName Figure 5.39

You can use the Get-VMNetworkAdapter cmdlet to verify the connection.

CPU cores When you create a new virtual machine through PowerShell, Windows automatically assigns a single virtual processor to the virtual machine. In some cases, however, a single virtual processor might not be sufficient. Fortunately, PowerShell makes it possible to add virtual processors to a virtual machine. Before you attempt to modify a virtual machine’s virtual processor allocation, it is a good idea to verify the number of virtual processors currently assigned to the virtual machine (Figure 5.40). You can do this by using the following command: Get-VM | Select-Object VMName, ProcessorCount Figure 5.40

It’s a good idea to verify a virtual machine’s current virtual CPU count.

Once you have verified the virtual machine’s current virtual processor count, you can modify the number of virtual processors that are assigned to the virtual machine by using the following command: Set-VMProcessor -Count

166

Understanding Hyper-V in Windows Server 2012

For example, to assign two virtual processors to a virtual machine named NewVM1 (Figure 5.41), you can use this command: Set-VMProcessor NewVM1 –Count 2 Figure 5.41

You can use the Set-VMProcessor cmdlet to configure a virtual machine’s virtual CPU usage.

Of course there are also some other switches that you can use with the Set‑VMProcessor cmdlet. For instance, if you want to set a reserve, maximum and relative weight value, you can use a command like this: Set-VMProcessor -Count 2 –Reserve 10 – Maximum 75 – RelativeWeight 200 In case you are not familiar with these particular values, here are their meanings: • Limit –The maximum amount of time that a virtual machine is allowed to use a physical CPU. The default limit is 100% usage. • Reservation – A percentage of CPU time solely for a specific virtual machine. By default the reservation is set at 0%. • Weight – A relative weight that affects how much CPU time a virtual machine will receive. The default weight is 100. You can also use the Set-VMProcessor cmdlet to enable compatibility for older operating systems by including the –Compatibility For Older Operating Systems Enabled switch in the command, as in the following example: Set-VMProcessor -CompatibilityForOlderOperatingSystemsEnabled $true

Building a virtual machine from scratch Earlier in this chapter you saw that it is possible to build a virtual machine by using the New-VM cmdlet. However, when you use a minimum set of switches with this cmdlet, the virtual machine is lacking, to say the least. In fact, the newly created virtual machine doesn’t even have a virtual hard disk. There are a couple of ways to overcome this problem—the easiest way being to provision the virtual machine while it is being created. Although this approach can complicate the New-VM command, it does allow you to create a fully provisioned virtual machine using a single command. For example, to create a new virtual machine named NewVM4 that has a 50-GB virtual hard drive and is located at F:\NewVM4, you could enter the following command: New-VM –Name NewVM4 –NewVHDPath F:\NewVM4\disk1.VHDX – NewVHDSize 50GB –Path F:\NewVM4

167

Understanding Hyper-V in Windows Server 2012

This command (Figure 5.42) works really well for creating a virtual machine and its virtual hard disk. The problem is that the virtual machine is still a bit lacking. By default, this virtual machine is only equipped with 512 MB of memory, a single virtual processor, and the virtual network adapter is not connected to a virtual switch (Figure 5.43). Never mind the fact that you might need to create some additional virtual hard disks for the virtual machine. Figure 5.42

You can create a virtual hard disk and a virtual machine at the same time. Figure 5.43

By default, a new virtual machine is provisioned with a very modest amount of hardware resources.

Unfortunately, you can’t do much more with the New-VM cmdlet. You can specify startup memory, but that’s about it. That being the case, what follows is a set of line-by-line instructions for creating and provisioning a new virtual machine.

168

Understanding Hyper-V in Windows Server 2012

This example illustrates how to create a new virtual machine named NewVM5. The virtual machine will be equipped with two 50-GB virtual hard disks, two gigabytes of virtual memory, four virtual processors, and it will be connected to a virtual switch. Start by creating the virtual machine and its 50-GB boot drive (Figure 5.44), using the following command: New-VM –Name NewVM5 –NewVHDPath F:\NewVM5\disk1.VHDX – NewVHDSize 50GB –Path F:\NewVM5 Figure 5.44

You can create a new virtual machine from the command line.

Now that you have created the virtual machine, you need to provision it. Start by adding the second 50-GB virtual hard disk (Figure 5.45). You can create a new hard disk using this command: New-VHD F:\NewVM5\Disk2.VHDX –Size 50GB Figure 5.45

You have created a dynamically expanding virtual hard disk.

This command created a 50-GB dynamically expanding virtual hard disk. The problem is that the virtual hard disk is still not attached to the virtual machine. You can verify this by entering the Get-VMHardDiskDrive command, followed by the name of the virtual machine (Figure 5.46). Figure 5.46

The new virtual hard disk is not attached to the virtual machine.

169

Understanding Hyper-V in Windows Server 2012

This command not only displays the virtual hard disks that are in use, it also shows which IDE ports are currently in use. When you join the newly created virtual hard disk to the virtual machine, you will have to choose a set of ports that are not in use. For example, to use IDE port 0.1 you would use this command: Add-VMHardDiskDrive NewVM5 IDE 0 1 –Path F:\NewVM5\Disk2.vhdx The command does not generate any output, so to verify its success you need to reissue the Get-VMHardDiskDrive cmdlet (Figure 5.47) as shown below: Get-VMHardDiskDrive NewVM5 Figure 5.47

You must add the virtual hard disk to the virtual machine.

Now that the virtual hard disks are in place, you simply need to provision memory, CPU and network connectivity. The task of provisioning memory and CPU resources to the new virtual machine is easy (Figure 5.48) and can be accomplished using these commands: Set-VMMemory NewVM5 –Startup 4GB Set-VMProcessor NewVM5 –Count 4 Figure 5.48

Adding CPU and memory resources to the virtual machine is easy.

The last step in the process is to connect the virtual network adapter to the virtual switch. As you may recall, this isn’t a single-step process. You have to retrieve both the name of the virtual network adapter and the name of the virtual switch (Figure 5.49). To retrieve the name of the virtual adapter, use the following command: $VMNic = Get-VMNetworkAdapter –VMName Next, you need to retrieve the name of the virtual switch. You can do this by using the following command: Get-VMSwitch | Select-Object Name Now you need to connect the virtual network adapter to the virtual switch by using this command: Connect-VMNetworkAdapter –VMNetworkAdapter $VMNic –SwitchName “” You can use the following command to verify connectivity: Get-VMNetworkAdapter –VMName | SelectObject VMName, Name, SwitchName

170

Understanding Hyper-V in Windows Server 2012

Figure 5.49

Connecting the virtual machine to the network requires a few steps.

The new virtual machine is now fully provisioned. You can verify all of the virtual machine settings through the Hyper-V Manager (Figure 5.50). Figure 5.50

You can use the Hyper-V Manager to verify the virtual machine settings.

171

Understanding Hyper-V in Windows Server 2012

Deleting a virtual machine To delete a virtual machine, use the Remove-VM cmdlet. The only required parameter is the name of the virtual machine that you want to delete. Forexample, if you want to delete a virtual machine named NewVM4, use this command: Remove-VM NewVM4 When you enter this command, Hyper-V will prompt you for confirmation (Figure 5.51) before deleting the virtual machine. Figure 5.51

You can use the Remove-VM cmdlet to delete a virtual machine.

Working with virtual machine snapshots One of the most frequently used features in Hyper-V is snapshots. Snapshots allow an administrator to protect a virtual machine prior to performing a potentially dangerous operation. For example, many administrators are in the habit of creating a snapshot prior to applying a service pack to a virtual machine. That way, if the service pack happens to cause problems, the virtual machine can be easily reverted to a previous state. Snapshotting through PowerShell can be a bit complex, but the following examples will give you the basics of how it works. To take a snapshot of a virtual machine, you can use this command: Get-VM | Checkpoint-VM For example, to create a snapshot of a virtual machine named NewVM1 (Figure 5.52), you can enter the following command: Get-VM NewVM1 | Checkpoint-VM Figure 5.52

The Checkpoint-VM cmdlet is used to create snapshots.

After you have created a snapshot, you probably want to verify that the snapshot exists. One way of doing this is to select the virtual machine within the Hyper-V Manager and look at the Snapshots pane (Figure 5.53). Of course, this chapter is all about PowerShell, so if you want to verify the snapshot through PowerShell, you can use the Get-VMSnapshot cmdlet (Figure 5.54) shown below: Get-VMSnapshot –VMName

172

Understanding Hyper-V in Windows Server 2012

Figure 5.53

The new snapshot is visible through the Hyper-V Manager. Figure 5.54

You can view snapshots through PowerShell.

Things get a bit trickier if you want to restore a snapshot in order to revert a virtual machine to a prior state. You can roll back a virtual machine by using the Restore-VMSnapshot command (Figure 5.55). This command requires you to provide the name of the virtual machine and the name of the snapshot. You can enter this information manually, but it is a lot easier to use a command like this one: Restore-VMSnapshot –Name (Get-VMSnapshot –VMName “”).Name –VMName “” Figure 5.55

You can use the Restore-VMSnapshot cmdlet to revert a VM to a previous state.

For example, if you want to roll back a virtual machine named NewVM1 to the state in which it existed when the most recent snapshot was created, you can use this command: Restore-VMSnapshot –Name (Get-VMSnapshot –VMName “NewVM1”).Name –VMName “NewVM1” When you enter this command, PowerShell will prompt you to confirm that you want to perform the rollback.

173

Understanding Hyper-V in Windows Server 2012

If you decide instead to remove the most recently created virtual machine snapshot, the command syntax is exactly the same, except that you would use the Remove-VMSnapshot cmdlet (Figure 5.56) instead of the Restore‑VMSnapshot cmdlet. The syntax is as follows: Remove-VMSnapshot –Name (Get-VMSnapshot –VMName “”).Name –VMName “” Figure 5.56

The Remove-VMSnapshot cmdlet is used to delete unwanted snapshots.

It is worth noting that this command does not prompt you for confirmation before deleting the snapshot. Therefore, you should exercise extreme caution when using the Remove-VMSnapshot cmdlet.

Live migration of a virtual machine Live migrations are one of the easier functions to perform through PowerShell. The PowerShell cmdlet for live migrations is Move-VM. At a minimum this cmdlet requires you to specify the virtual machine name and the name of the host server to which the virtual machine will be moved. For example, to move the virtual machine named NewVM3 to the server Lab2, you use this command: Move-VM “NewVM3” Lab2 The problem is that the above command moves the virtual machine itself, but not the virtual machine’s storage. Therefore, the command is only appropriate if the virtual machine’s files reside on SMB storage. In most cases, you need to specify the destination storage path as an additional switch. To see how this works, imagine that you want to move the virtual machine NewVM3 to server Lab2 and you want to store the virtual machine files in F:\VMs (Figure 5.57). You can perform the migration using this command: Move-VM “NewVM3” Lab2 –DestinationStoragePath F:\VMs Figure 5.57

Use the Move-VM cmdlet for live migrations.

174

Understanding Hyper-V in Windows Server 2012

Getting help Although you can do a lot with regard to managing Hyper-V through PowerShell, the PowerShell cmdlets and their syntaxes are sometimes difficult to remember. Fortunately, Microsoft provides a number of different mechanisms to help you use PowerShell.

The question mark switch Throughout this chapter you have probably noticed that PowerShell cmdlets can sometimes use a number of optional switches. Therefore, one of the keys to using PowerShell effectively is to determine all the options for a particular cmdlet. This is easier to accomplish than it might seem. To see a list of the options that can be used with a cmdlet, simply enter the cmdlet followed by the -? switch (Figure 5.58). For example, to see all of the options for using the Get-VM cmdlet, enter the following command: Get-VM -? Figure 5.58

The question mark switch is used to retrieve the full syntax for any PowerShell cmdlet.

Any time you use the question mark switch, PowerShell asks you if you want to run the Update-Help cmdlet. The Update-Help cmdlet causes PowerShell to download the latest help files from the Internet. When the help file update completes, the full command syntax will be displayed.

Get-Help PowerShell cmdlets are a combination of nouns and verbs. Sometimes, however, it can be difficult to remember what noun-verb combinations can be used together, and this is where the Get-Help cmdlet comes into play. Get-Help can show you all of the nouns that can be used with a particular verb or all of the verbs that can be used with a specific noun. For example, in Hyper-V many of the cmdlets are designed to be used on virtual machines and therefore use VM as a noun (Get-VM, Set-VM, etc.). If you want to see all of the actions that can be performed on a VM (Figure 5.59), you can use the following command: Get-Help *-VM

175

Understanding Hyper-V in Windows Server 2012

Figure 5.59

These are all of the verbs that can be used with the VM noun.

As previously mentioned, Get-Help can be used with both nouns and verbs. Notice in Figure 5.59 that the last cmdlet on the list is Suspend-VM. If you are curious as to whether the Suspend verb can be used with nouns other than VM, you can enter this command: Get-Help Suspend-* When you enter this command (Figure 5.60), you will see that PowerShell uses the Suspend verb for a number of different purposes, some of which are not even related to Hyper-V. For example, you can use the Suspend verb to suspend a service or a print job. Figure 8.60

The Get-Help cmdlet can help you to figure out what noun and verb combinations will work together.

What-If As you have no doubt noticed throughout this chapter, some PowerShell commands are complicated. That being the case, it would be nice to have a way to make sure that you are entering the correct command before you actually press Enter. The good news is that Windows gives you a way to find out what a specific PowerShell command would do before you actually execute the command. The trick is to append the –WhatIf switch to the end of the command. For example, suppose that you weren’t quite sure what would happen if you executed the New-VM command. You could append the –WhatIf switch to the command (Figure 5.61) and PowerShell would tell you that the command would create a new virtual machine named New Virtual Machine.

176

Understanding Hyper-V in Windows Server 2012

Figure 5.61

The WhatIf switch is used to find out what will happen if you perform a certain command.

It is worth noting that not every PowerShell cmdlet can be used with WhatIf. To see which cmdlets support the use of WhatIf (Figure 5.62), enter the following command: Get-Command | Where Definition –Like *whatif* Figure 5.62

Not every cmdlet works with the WhatIf switch.

IntelliSense In addition to the PowerShell interface that is shown throughout this chapter, Microsoft also provides a feature called the PowerShell Integrated Scripting Environment (ISE). In the Windows Server 2012 version of PowerShell, the Integrated Scripting Environment contains a feature called IntelliSense, which anticipates the command that you are about to type and offers help as you enter the command. To see how this feature works, go to your Hyper-V server’s Metro interface, click the Administrative Tools tile and double-click on the Windows PowerShell ISE command (Figure 5.63), which is found on the Administrative Tools list.

177

Understanding Hyper-V in Windows Server 2012

Figure 5.63

The Windows PowerShell ISE icon is found on the Administrative Tools menu.

When the Windows PowerShell ISE window opens, start typing a PowerShell command. As you type, the IntelliSense feature will engage and help you with the command’s syntax (Figure 5.64). For instance, if you type New-V, then IntelliSense will show you all of the cmdlets that start with New-V. As you progress through the list of commands, IntelliSense even offers syntax help. Figure 5.64

Windows PowerShell ISE provides help with command syntax.

The Show-Command pane The Show-Command pane (Figure 5.65) is another feature of the Windows PowerShell ISE interface. The Show-Command add-on is displayed on the right side of the PowerShell ISE window by default, but it can be enabled or disabled through the interface’s View menu.

178

Understanding Hyper-V in Windows Server 2012

Figure 5.65

The Show-Command pane can help you to assemble PowerShell cmdlets.

As you enter a command, the Show-Command add-on displays various fields that allow you to enter values to use with the command. For example, if you were to enter the New-VM command, you could enter values such as the virtual machine’s name and startup memory. Once you have filled in the various attribute fields, you can use the buttons at the bottom of the window to run the command, insert the command into the PowerShell window or copy the command to the clipboard.

TechNet Finally, Microsoft TechNet is a great resource for getting help with PowerShell commands. The page is located at: http://technet.microsoft.com/en-us/library/ hh848559.aspx (Figure 5.66) and contains a full list of every available Hyper-Vrelated cmdlet. Clicking on a cmdlet takes you to a page that provides the full syntax (Figure 5.67) and some usage examples for the cmdlet.

179

Understanding Hyper-V in Windows Server 2012

Figure 5.66

TechNet provides a reference for all of all of the Hyper-V related cmdlets. Figure 5.67

Clicking on a link takes you to a page with the cmdlet’s syntax and usage examples.

Share this e-book with your peers

180

Understanding Hyper-V in Windows Server 2012

Chapter 6

Virtual Machine Management Although much of this book deals with managing Hyper-V, host-level management would be pointless without virtual machines. This chapter explains how to create virtual machines using the Hyper-V Manager and how to make configuration changes to virtual machines as your needs evolve.

181

Understanding Hyper-V in Windows Server 2012

Creating virtual machines Hyper-V makes it easy to create a new virtual machine. This section walks you through the process of using the New Virtual Machine Wizard to create a simple virtual machine. The various virtual machine settings and options are explained in more detail later in this chapter. 1. Open the Hyper-V Manager, right-click on your host server and then select the New | Virtual Machine commands from the right-click menu (Figure 6.1). Figure 6.1

Right-click on the host server and choose the New | Virtual Machine command.

2. When the New Virtual Machine Wizard begins, click Next to bypass the wizard’s Welcome screen. 3. Enter a unique name for the virtual machine. Keep in mind that this name is used to identify the virtual machine in the Hyper-V Manager (Figure 6.2). The name is not automatically assigned as the guest operating system’s computer name, so after you install an operating system onto the virtual machine you will have to manually rename Windows to match the virtual machine’s name. 4. Select the checkbox for Store the virtual machine in a different location and enter a path where the virtual machine should be stored. The path should normally point to a high-performance, fault tolerant storage array with plenty of free space. If the virtual machine is going to be clustered, the virtual machine location should ideally point to a Cluster Shared Volume. 5. Click Next.

182

Understanding Hyper-V in Windows Server 2012

Figure 6.2

Provide a name for the new virtual machine and specify the virtual machine’s location.

6. Enter the amount of memory to assign to the virtual machine. As an alternative, you can use dynamic memory. Dynamic memory is discussed later in this chapter (Figure 6.3). 7. Click Next. Figure 6.3

Specify the amount of memory to assign to the virtual machine.

183

Understanding Hyper-V in Windows Server 2012

8. Choose the virtual switch to which the virtual machine should be connected (Figure 6.4). 9. Click Next. Figure 6.4

Choose the virtual switch to use for network connectivity.

10. Verify that the Create a Virtual Hard Disk option is selected (Figure 6.5). 11. Enter a name for the virtual hard disk that will be created. 12. Provide a location for the virtual hard disk if necessary. In general, the location should match the virtual machine location you specified earlier. 13. Provide a size for the virtual hard disk. 14. Click Next.

184

Understanding Hyper-V in Windows Server 2012

Figure 6.5

Specify the name, location, and size of the virtual hard disk.

15. Choose the option to install an operating system from a boot CD or DVD (Figure 6.6). 16. Click Next. Figure 6.6

Choose how you want to install an operating system onto the new virtual machine.

185

Understanding Hyper-V in Windows Server 2012

17. Take a moment to verify the information displayed on the summary screen. If everything appears to be correct, click Finish. 18. Verify that the Hyper-V Manager lists the new virtual machine (Figure 6.7). Figure 6.7

The new virtual machine should be listed within the Hyper-V Manager.

Installing a guest operating system If you have followed the technique outlined above, then you have created a virtual machine, but the virtual machine does not do anything yet. You still have to install an operating system onto the new virtual machine. To do so, perform the following steps: 1. Insert an operating system installation DVD into the server’s DVD drive. 2. Double-click on the new virtual machine to open it (Figure 6.8). Figure 6.8

Open the new virtual machine and then start it.

186

Understanding Hyper-V in Windows Server 2012

3. Choose the Start option from the virtual machine’s Action menu to start the virtual machine. 4. When prompted, press any key to boot from the installation DVD. One common problem with the technique described above is that the DVD drive can only be used by one virtual machine at a time. If the DVD drive is already in use, you will receive an error message indicating that the virtual machine failed to start (Figure 6.9). Figure 6.9

You will receive this error message if the DVD drive is being used by another virtual machine.

When this happens you can fix the problem by releasing the DVD drive from the server that is currently using it. To do so, follow these steps: 1. I n the Hyper-V Manager, double click on the virtual machine that is currently using the DVD drive. This will open the virtual machine. 2. Choose the Release command from the virtual machine’s Media menu (Figure6.10). Figure 6.10

You must release the DVD drive from the virtual machine that is currently using it.

3. Close the virtual machine interface. 4. Go back to the newly created virtual machine and start the virtual machine by using the instructions previously provided.

187

Understanding Hyper-V in Windows Server 2012

Renaming virtual machines A virtual machine’s computer name and the name that is displayed through the Hyper-V Manager should always be kept in sync. Otherwise, managing virtual machines becomes very confusing. Unfortunately, Hyper-V does not automatically synchronize virtual machine names. Therefore, you will usually have to either rename the virtual machine or change its computer name. To rename a virtual machine, follow these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine you want to rename and choose the Rename command from the right-click menu (Figure 6.11). 3. Enter a new name for the virtual machine. Figure 6.11

Right-click on the virtual machine and choose the Rename command.

The exact method used to change a virtual machine’s computer name varies considerably depending on the operating system that is running on the virtual machine. To change the computer name for a virtual machine that is running Windows 8, follow these steps: 1. Open the Hyper-V Manager. 2. Double-click on the virtual machine whose name you want to change. This will display the virtual machine’s console. 3. Log in to the virtual machine. 4. Click the Desktop tile. 5. Right-click on the Start tile and choose the System command from the right-click menu (Figure 6.12).

188

Understanding Hyper-V in Windows Server 2012

Figure 6.12

Right-click on the Start tile and choose the System command.

6. When the System dialog box appears, click Change Settings (Figure 6.13). Figure 6.13

Click the Change Settings link.

7. When the System Properties sheet appears, make sure that the Computer Name tab is selected and click the Change button. 8. Enter the new computer name and click OK (Figure 6.14). A reboot will be required for the new name to take effect.

189

Understanding Hyper-V in Windows Server 2012

Figure 6.14

Enter the new computer name and click OK.

The Integration Services The Integration Services are a set of drivers that allow a virtual machine to communicate directly with the hypervisor. For those who come from a VMware background, the Integration Services are comparable to the VMware Tools. Virtual machines can function without the Integration Services, but they will perform much better if the Integration Services are installed. Virtual machines that do not use the Integration Services must rely on emulated hardware, which degrades the virtual machine’s overall performance. Unfortunately however, the Integration Services are only compatible with virtual machines that are running Windows operating systems. You can install the Integration Services by completing these steps: 1. Open the Hyper-V Manager. 2. Double-click on the virtual machine that needs to have the Integration Services installed. This will display the virtual machine’s console. 3. Select the Insert Integration Services Setup Disk command from the Action menu (Figure 6.15).

190

Understanding Hyper-V in Windows Server 2012

Figure 6.15

Choose the Insert Integration Services Setup Disk option from the Action menu.

4. When the AutoPlay screen appears, click the Install Hyper-V Integration Services option.

Upgrading the Integration Services If you upgrade a server that was previously running an earlier version of Hyper-V to Hyper-V 3.0, the upgrade process only affects the hypervisor and the host operating system. The virtual machines themselves are not altered in the process and continue to run the same version of the Integration Services they were using prior to the upgrade. A virtual machine that is running an earlier version of the Integration Services will function in a Hyper-V 3.0 environment, but the virtual machine’s performance will not achieve the level of performance that it would if it were running the current version of the Integration Services. The easiest way to tell whether or not a virtual machine is running the latest version of the Integration Services is to open the Hyper-V Manager, select the virtual machine and then select the Networking tab. If the virtual machine is running an earlier version of the Integration Services, the Status indicator will say “Degraded (Integration Services upgrade required)." You can upgrade the virtual machine’s Integration Services by following these steps: 1. Open the Hyper-V Manager. 2. Double-click on the virtual machine that needs to be upgraded. This displays the virtual machine’s console. 3. Select the Insert Integration Services Setup Disk command from the Action menu. 4. When the AutoPlay screen appears, click the Install Hyper-V Integration Services option.

191

Understanding Hyper-V in Windows Server 2012

5. This displays a message indicating that an earlier version of the Integration Services has been detected. Click OK to upgrade to the latest version of the Integration Services (Figure 6.16). Figure 6.16

Click Yes to upgrade the Integration Services.

6. When the upgrade process completes you must reboot the virtual machine. When prompted, click Yes to restart the virtual machine (Figure 6.17). Figure 6.17

Click Yes to restart the virtual machine.

Virtual machine settings As you saw earlier, the New Virtual Machine Wizard steps you through the process of creating a new virtual machine. Among other things, the wizard helps you to allocate physical hardware to the virtual machine. Over time, however, you may find that the initial hardware provisioning is inadequate. When that happens, you can change the hardware allocation for a virtual machine.

A few words of caution There are a few things to be aware of before you begin modifying a virtual machine’s hardware assignments. First, if you make a hardware allocation change to a virtual machine that is running Windows, it is possible that you will have to reactivate Windows. Whether or not you will have to reactivate the operating system depends on the number of hardware allocation changes you have made and the nature of those changes. Also be aware that in most cases you will have to shut down the virtual machine to make hardware allocation changes, although there are exceptions.

192

Understanding Hyper-V in Windows Server 2012

Accessing a virtual machine’s settings Changes to a virtual machine’s hardware usage can be made through PowerShell or through the Hyper-V Manager. Techniques for modifying hardware allocations through PowerShell are discussed in Chapter 5. If you want to modify a virtual machine’s hardware allocation using the Hyper-V Manager, follow these steps: 1. Open the Hyper-V Manager. 2. Shut down the virtual machine that you will be modifying (if necessary). 3. Right-click on the virtual machine and choose the Settings command from the right-click menu (Figure 6.18). Figure 6.18

Right-click on the virtual machine and choose the Settings command.

The Settings page allows you to modify the virtual machine’s settings. The individual settings are discussed in the sections below.

Adding hardware The first option listed on the virtual machine’s Settings screen is the Add Hardware option (Figure 6.19). You can use this option to add four different types of hardware to the virtual machine. This includes: • SCSI Controllers • Network Adapters • Legacy Network Adapters • Fibre Channel Adapters Network-related hardware is discussed in Chapter 10.

193

Understanding Hyper-V in Windows Server 2012

Figure 6.19

You can add several different types of hardware to a virtual machine.

Adding a SCSI Controller You can add a SCSI controller to a virtual machine by completing these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine to which you want to add a SCSI controller, and select the Settings command from the right-click menu. 3. When the Settings screen appears, click on Add Hardware. 4. Select the SCSI Controller option and click Add (Figure 6.20).

194

Understanding Hyper-V in Windows Server 2012

Figure 6.20

Click Add Hardware and then click on the SCSI Controller option and click Add.

5. On the following screen, click the Add button (Figure 6.21).

195

Understanding Hyper-V in Windows Server 2012

Figure 6.21

Make sure that the Hard Drive option is selected and click Add.

6. On the following screen, make sure that your new SCSI controller is selected on the Controller drop-down list (Figure 6.22). 7. Use the Location drop-down list to select a location that is not currently in use. 8. Choose either the Virtual Hard Disk option (to connect a virtual hard disk to the SCSI controller) or the Physical Hard Disk option (to connect the SCSI controller to a physical SCSI disk as a pass-through disk). 9. Specify the physical or virtual hard disk that you want to use (you can create a new virtual hard disk by clicking the New button if necessary). 10. Click OK.

196

Understanding Hyper-V in Windows Server 2012

Figure 6.22

You must choose a location that is not in use.

BIOS The Settings screen’s BIOS section allows you to configure the startup behavior for the selected virtual machine (Figure 6.23). The BIOS page contains a check‑box you can select to turn the Num Lock on or off at boot time. You can also control the boot device order by selecting a boot device and using the Move Up and Move Down buttons to change the device’s priority.

197

Understanding Hyper-V in Windows Server 2012

Figure 6.23

The BIOS screen lets you control the boot order and the startup state of the Num Lock key.

Memory The Memory page allows you to control the amount of memory that is assigned to the virtual machine (Figure 6.24). The Startup RAM field controls the amount of memory that will initially be assigned to the virtual machine. If dynamic memory is not being used, the amount of memory specified in the Startup Memory field will be available to the virtual machine the entire time that the virtual machine is powered on.

198

Understanding Hyper-V in Windows Server 2012

Figure 6.24

Use the Memory page to configure static or dynamic memory.

Dynamic memory is designed to increase a host server’s virtual machine density (thereby allowing the server to host more virtual machines than would otherwise be possible. Dynamic memory lets you provision a virtual machine with just enough memory to allow it to boot. Whenever additional memory is required, the virtual machine can request it until it reaches the maximum memory cap you define for its use. Care must be taken when using dynamic memory, because it is possible to over‑commit the server’s memory. This means than you can end up allocating more memory than what is physically installed in the server. If you want to enable dynamic memory, select the checkbox for Enable Dynamic Memory. There are five values that you must set: • Startup RAM – The startup RAM is the amount of memory that the virtual machine needs in order to boot. • Minimum RAM – The minimum RAM is the absolute minimum amount of memory that the virtual machine should ever use. Typically the Minimum RAM setting will be lower than the Startup RAM because virtual machines often consume less memory when idle than during the boot process.

199

Understanding Hyper-V in Windows Server 2012

• Maximum RAM – This setting reflects the maximum amount of memory that the virtual machine should ever use. • Memory Buffer – The memory buffer is expressed as a percentage of memory that is reserved as a buffer. This buffer accommodates sudden changes in the virtual machine’s demand for memory. • Memory Weight – The memory weight setting, controlled through a slide bar, lets you prioritize the virtual machine’s memory needs. When the host server is low on physical memory, then virtual machines that have low priority memory weights might have their requests for additional memory rejected so that memory can be made available to higher priority virtual machines.

Processors The Processors setting allows you to control the number of virtual processors that are assigned to a virtual machine. By default each virtual machine is assigned one virtual processor, but you can change this value if necessary and provision a virtual machine with additional virtual processors (Figure 6.25). Figure 6.25

You can provision a virtual machine with additional virtual processors.

200

Understanding Hyper-V in Windows Server 2012

In addition, Hyper-V lets you configure various limits on virtual processor usage as a way of preventing a virtual machine from using too many physical CPU resources. The Settings that are available to you include: • Virtual Machine Reserve (percentage) – This setting allows you to reserve a percentage of a single physical CPU core for the virtual machine. • Percent Total System Resources – The Percent Total System Resources setting allows you to control the percentage of the server’s total processing power that the virtual machine is allowed to use. • Virtual Machine Limit (percentage) – This value reflects the maximum percentage of allocated processors that the virtual machine is allowed to use. • Relative Weight – Virtual machines that have been assigned higher relative weights receive more CPU time than virtual machines with lower relative weights.

Disks When you created a virtual machine you got a taste of the process involved in setting up a virtual hard disk, but a single virtual machine often requires multiple virtual hard disks. There are several concepts that you need to understand when creating virtual hard disks in Hyper-V. One of the first decisions you need to make is the virtual hard disk format. Hyper-V lets you choose between creating a VHD- and a VHDX-based virtual hard disk. VHD is the legacy virtual hard disk format that was introduced in Windows Server 2008 and continued to be used in Windows Server 2008 R2. VHD-based virtual hard disks have a maximum capacity of just under 2 TB (2,040 GB). In contrast, VHDX is the next-generation virtual hard disk format, which was introduced in Windows Server 2012. VHDX-based virtual hard disks have a maximum capacity of 64 TB. In addition, the VHDX format is designed to be more resilient than the VHD format, thus providing better protection against disk errors that might result from power failures. Another important consideration is the type of virtual hard disk that you are creating. Hyper-V gives you three choices including: • Fixed Size • Dynamically Expanding • Differencing When you create a fixed size virtual hard disk, the virtual machine will claim the physical disk space required by the virtual hard disk as soon as the virtual hard disk is created. For example, if you create a 1-TB fixed size drive, then a 1-TB virtual hard disk file will be immediately created. The advantage to this approach is that fixed size virtual hard disks offer superior performance compared to dynamically expanding virtual hard disks.

201

Understanding Hyper-V in Windows Server 2012

Although dynamically expanding virtual hard disks don’t perform as well as fixed size virtual hard disks, they make much more efficient use of the underlying physical disk space. When you create a dynamically expanding virtual hard disk, only a small amount of disk space is initially used. Additional physical disk space is claimed only as it is needed until the virtual hard disk reaches its maximum size. For example, if you were to create a 1-TB dynamically expanding virtual hard disk, the virtual hard disk would initially consume less than 1 GB of physical disk space. As you add data to the virtual hard disk, it will gradually consume more and more physical disk space until it eventually reaches 1 TB in size. The nice thing about this approach is that physical storage space is not consumed until it is actually needed, so you won’t end up in a situation in which most of your physical storage space is locked away in mostly empty virtual hard disks. The third type of virtual hard disk that you can create is a differencing disk. Differencing disks are used in parent-child relationships with another virtual hard disk. For example, if there is a virtual hard disk that you want to preserve, you could create a differencing disk. All write operations from that point forward are directed to the differencing disk, thus ensuring that the parent virtual hard disk remains unmodified. To create a new virtual hard disk and add it to a virtual machine, complete these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine to which you want to add a new virtual hard disk and choose the Settings command from the right-click menu. 3. When the virtual machine’s Settings screen appears, select the controller to which you want to attach the new virtual hard disk (Figure 6.26). The controller must have a free port available. Each of the two IDE controllers can support up to two devices and a SCSI controller can support up to 63 devices. 4. Choose the Hard Drive option and click the Add button.

202

Understanding Hyper-V in Windows Server 2012

Figure 6.26

Choose the controller to which you want to bind the new virtual hard disk, choose the Hard Disk option and click Add.

5. Select an unused port number from the Location drop-down list (Figure 6.27). 6. Select the Virtual Hard Disk option and click the New button.

203

Understanding Hyper-V in Windows Server 2012

Figure 6.27

Choose a free location for the new virtual hard disk.

7. When the New Virtual Hard Disk Wizard opens, click Next to bypass the Welcome screen. 8. Choose the desired virtual disk format (Figure 6.28). As a general rule you should use VHDX unless there is a chance that you may eventually need to move the virtual disk or the corresponding virtual machine to a legacy Hyper-V server.

204

Understanding Hyper-V in Windows Server 2012

Figure 6.28

New virtual hard disks should always be created as VHDX.

9. Click Next. 10. Choose the virtual hard disk type (Figure 6.29). 11. Click Next. Figure 6.29

Choose the type of virtual hard disk that you want to create.

205

Understanding Hyper-V in Windows Server 2012

12. Enter a name for the virtual hard disk that you are creating and specify the location where you would like to store the new virtual hard disk (Figure 6.30). 13. Click Next. Figure 6.30

Specify a name and a location for the virtual hard disk.

14. Specify the size of the virtual hard disk that you are creating or use the option to copy the contents of a physical hard disk. 15. Click Next. 16. Take a moment to review the summary screen to make sure that all of the information that has been presented is correct. Assuming that all is well, click Finish to create the new virtual hard disk.

COM ports Virtual COM ports are a feature that you will probably never have to use. They are provided solely for backward compatibility with legacy physical servers. You can map Virtual COM ports to a named pipe by completing these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine for which you want to configure a COM port, and select the Settings command from the right-click menu. 3. When the Settings page opens, select the COM port that you want to configure (Figure 6.31). 4. Select the Named Pipe option.

206

Understanding Hyper-V in Windows Server 2012

5. Enter the pipe name. 6. If the pipe exists on a remote computer, select the checkbox for Remote Computer and enter the UNC path to the named pipe. Figure 6.31

Virtual COM ports exist solely for backward compatibility purposes.

Diskette drives Another feature that is provided solely for the purpose of providing backward compatibility with aging physical hardware is the virtual diskette drive feature. This feature allows Hyper-V to emulate a floppy disk drive. It is worth noting however, that a virtual machine cannot be configured to use a physical floppy drive. Unlike virtual hard disks, virtual diskette drives must be created outside of a virtual machine. You can create a virtual diskette drive by completing these steps: 1. Open the Hyper-V Manager. 2. Right-click on the name of the host server and select the New | Floppy Disk commands from the right-click menu (Figure 6.32). 3. Navigate to the location where you want to store the virtual floppy disk. 4. Enter a name for the virtual floppy disk and click Create.

207

Understanding Hyper-V in Windows Server 2012

Figure 6.32

Right-click on the host server and choose the New | Floppy Disk commands from the right‑click menu.

Once the virtual floppy disk has been created, you can configure a virtual machine to use it by completing these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine to which you want to attach the virtual floppy disk and select the Settings command from the right-click menu. 3. Click on Diskette Drive (Figure 6.33). 4. Click on the Virtual Floppy Disk (.VFD) File option. 5. Click the Browse button and then navigate to and select the virtual floppy disk file that you created earlier. 6. Click Open. 7. Click OK.

208

Understanding Hyper-V in Windows Server 2012

Figure 6.33

Click on Diskette Drive and specify the virtual floppy disk you created earlier.

The virtual machine name Earlier in this chapter, you saw a quick-and-dirty method for renaming a virtual machine. Sometimes, however, you might want to change a virtual machine’s name and also make some notes about how the virtual machine is to be used or why it is configured the way that it is. To do so, complete these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine and select the Settings command from the right-click menu. 3. Click on the Name option in the Management section (Figure 6.34). 4. Enter the new name for the virtual machine (if necessary) in the Name field. 5. Add any notes about the virtual machine. 6. Click OK.

209

Understanding Hyper-V in Windows Server 2012

Figure 6.34

You can rename a virtual machine and enter notes about the virtual machine’s purpose.

The Integration Services Earlier in this chapter, you learned about installing or upgrading the Integration Services. Although those techniques dealt with deploying or upgrading the Integration Services as a whole, the Integration Services are actually made up of a number of different individual components. You can enable or disable the individual Integration Services independently of one another. To verify that the Integration Services are installed and to check which Integration Services are enabled, complete these steps: 1. Open the Hyper-V Manager. 2. Right-click on a virtual machine and choose the Settings command from the right-click menu. 3. Go to the Management section and click on Integration Services (Figure 6.35). 4. Select or deselect the checkboxes to enable or disable the individual services.

210

Understanding Hyper-V in Windows Server 2012

Figure 6.35

You can enable or disable individual Integration Services components.

The smart paging file location In the section on memory, you learned that a virtual machine sometimes requires more memory to start than it needs to run. Imagine that a virtual machine requires 1 GB of memory for startup, but can run on 512 MB of memory once the startup process has completed. Now, consider a situation in which this virtual machine is restarted, but the server can’t give it the full 1 GB of memory that it needs for startup. In this type of situation, a smart paging file provides the virtual machine with the memory that it needs to start. Once startup is complete, the virtual machine goes back to using RAM. To set the smart paging file’s location for a virtual machine, complete these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine and choose the Settings command from the right-click menu. 3. Click on the Smart Paging File Location option, found in the Management section (Figure 6.36). 4. Enter the desired location for the smart paging file. 5. Click OK.

211

Understanding Hyper-V in Windows Server 2012

Figure 6.36

You can specify the location for a virtual machine’s smart paging file.

Automatic start action Hyper-V allows you to configure what happens to individual virtual machines when a host server is booted. For example, you might want to configure some virtual machines to automatically start whenever the host server comes online. Hyper-V gives you three different automatic start options including: • Nothing (the virtual machine is not automatically booted when the host server starts) • Always Start if it was Running when the Server was Stopped • Always Start this Virtual Machine Automatically If you choose to automatically start a virtual machine it is a good idea to add a startup delay. Startup delays can help reduce resource contention by preventing all of the virtual machines from booting simultaneously. The startup delay also ensures that virtual machines boot in a specific order. You can configure a virtual machine’s automatic start action by completing these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine and choose the Settings command from the right-click menu.

212

Understanding Hyper-V in Windows Server 2012

3. Locate the Management section and click on Automatic Start Action. 4. Choose the desired automatic start action (Figure 6.37). 5. Specify the desired start delay. 6. Click OK. Figure 6.37

Select the desired startup action.

Automatic stop action Just as you can specify an automatic start action for a virtual machine, you can also set an automatic stop action. The automatic stop action controls what happens to the virtual machine if the host server is shut down. Your options include: • Save the Virtual Machine State • Turn Off the Virtual Machine • Shut Down the Guest Operating System Most administrators prefer to use the Save the Virtual Machine State option. It is worth noting however, that this option requires some additional physical disk space because the contents of the virtual machine’s memory must be written to disk.

213

Understanding Hyper-V in Windows Server 2012

The next best option is shutting down the guest operating system. This option ensures that the virtual machine is brought down in a clean state. However, this option is valid only if the Integration Services are installed on the virtual machine. You can control a virtual machine’s automatic stop action by following these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine and choose the Settings command from the right-click menu. 3. Locate the Management section and click on Automatic Stop Action (Figure 6.38) 4. Choose the desired automatic stop action. 5. Click OK. Figure 6.38

Select the desired automatic stop action.

214

Understanding Hyper-V in Windows Server 2012

Virtual machine snapshots Hyper-V offers a snapshot feature for virtual machines that allows you to roll back a virtual machine to a previous state if necessary. Administrators typically create snap shots prior to making major configuration changes or installing service packs onto virtual machines.

Some words of caution Before you learn to work with snapshots, there are two things that you need to know. First, creating snapshots can degrade a virtual machine’s performance. Snapshots are based on the use of differencing disks, and the way that the differencing disks are used causes the virtual machine’s read performance to be slightly degraded. As you accumulate more and more snapshots for a virtual machine, the more the read performance will suffer. Second, snapshots are not application aware. You can do serious damage if you use snapshotting with some types of database servers. Before you use snapshots on a virtual machine, it is important to find out whether or not the applications that are running on that server are compatible with Hyper-V snapshots.

Configuring the snapshot file location Before you begin creating snapshots, it is a good idea to configure the snapshot file location. Ideally, snapshots should be stored on a faulttolerant volume that is regularly backed up. You can configure the snapshot file location by completing these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine and select the Settings command from the right-click menu. 3. When the Settings screen appears, locate the Management section and click on Snapshot File Location. 4. Enter the desired snapshot file location (Figure 6.39). 5. Click OK.

215

Understanding Hyper-V in Windows Server 2012

Figure 6.39

Enter the desired snapshot location.

Creating virtual machine snapshots You can create a virtual machine snapshot by completing these steps: 1. Open the Hyper-V Manager. 2. Select the virtual machine that you want to snapshot. 3. Right-click on the virtual machine and choose the Snapshot command from the right-click menu (Figure 6.41).

216

Understanding Hyper-V in Windows Server 2012

Figure 6.41

Right-click on the virtual machine and select the Snapshot command from the right‑click menu.

4. When the snapshot completes, the snapshot is listed in the console’s Snapshot section. The snapshot includes a date and time stamp that you can use to determine when the snapshot was created (Figure 6.42). Figure 6.42

The Snapshots pane lists a date and a time stamp for each snapshot.

Deleting snapshots Snapshots diminish a virtual machine’s read performance. That being the case, it is usually best to keep only the snapshots that you need. When a snapshot is no longer needed, you can remove it by completing these steps: 1. Open the Hyper-V Manager. 2. Select the virtual machine whose snapshots you want to delete.

217

Understanding Hyper-V in Windows Server 2012

3. Right-click on the snapshot that you want to delete and select the Delete Snapshot command from the right-click menu (Figure 6.43). 4. When you are prompted for confirmation, click the Delete button. Figure 6.43

Right-click on the unwanted snapshot and choose the Delete Snapshot command.

If you have accumulated a large hierarchy of snapshots for a virtual machine, it might be tedious to delete them one at a time. To perform a bulk removal by deleting all or a portion of the snapshot tree, complete these steps: 1. Open the Hyper-V Manager. 2. Select the virtual machine whose snapshots you want to remove. 3. Click on a point within the snapshot hierarchy that represents the oldest snapshot you want to delete. 4. Right-click on the snapshot and choose the Delete Snapshot Subtree command from the right-click menu (Figure 6.44). 5. When prompted about whether or not to delete the selected snapshot subtree, click Delete.

218

Understanding Hyper-V in Windows Server 2012

Figure 6.44

Right-click on the oldest snapshot that you want to delete and select the Delete Snapshot Subtree command from the right-click menu.

Renaming snapshots When you create a new snapshot, Hyper-V labels the snapshot with the name of the virtual machine and the date and time when the snapshot was created. However, it can be more helpful to assign the snapshot a meaningful name that indicates why you created the snapshot. You can accomplish this by performing these steps: 1. Open the Hyper-V Manager. 2. Select the virtual machine on which you want to rename a snapshot. 3. Right-click on the snapshot that you want to rename and choose the rename option from the right-click menu (Figure 6.45). 4. Rename the snapshot.

219

Understanding Hyper-V in Windows Server 2012

Figure 6.45

Right-click on the snapshot and choose the rename command.

Applying snapshots It’s best to avoid applying snapshots if you can, because there can be consequences to rolling a virtual machine back to an earlier point in time (particularly with application servers that are not intended to be used with snapshotting). However, the need to revert a virtual machine to a previous state is sometimes unavoidable. To apply a snapshot, follow these steps: 1. Open the Hyper-V Manager. 2. Select the virtual machine that you need to roll back. 3. Select the snapshot that you want to apply. 4. Right-click on the snapshot and select the Apply command from the right‑click menu (Figure 6.46).

220

Understanding Hyper-V in Windows Server 2012

Figure 6.46

Right-click on the snapshot and choose the Apply command from the right-click menu.

5. Choose whether you simply want to apply the snapshot or if you want to take another snapshot before you apply the snapshot (Figure 6.47). Using the Take Snapshot and Apply option gives you the ability to roll back the virtual machine to its current state in the event that you accidentally apply the wrong snapshot. Figure 6.47

You can optionally take another snapshot prior to applying the snapshot.

6. When the snapshot has been applied, the Now indicator will be moved to just beneath the snapshot that you have applied (Figure 6.48). The other snapshots still exist and can be applied or deleted. Figure 6.48

Share this e-book with your peers

You can delete the old snapshots after applying a snapshot.

221

Understanding Hyper-V in Windows Server 2012

Chapter 7

P2V Conversions After setting up a new Hyper-V deployment, one of the first things that you will probably want to do is to begin virtualizing your physical servers. This is what is known as physical-to-virtual or P2V conversion. Hyper-V does not contain any built-in tools for performing P2V conversions, but you can use Microsoft’s System Center Virtual Machine Manager or any number of thirdparty tools to perform the conversion.

222

Understanding Hyper-V in Windows Server 2012

Conversion planning Microsoft’s primary tool for performing P2V conversions is System Center Virtual Machine Manager (SC VMM). SC VMM provides two different methods for performing P2V conversions. You can perform an online conversion or you can perform an offline conversion. An online P2V conversion is run against a physical server that is actively running. An offline conversion takes the physical server offline prior to performing the conversion. Regardless of whether you are performing an online or offline conversion, it is extremely important that you do not use this method to perform a P2V conversion of virtual machines that have encrypted volumes. Doing so will likely render the volumes unreadable.

System Center Virtual Machine Manager online conversion Online conversions are the preferred conversion type because performing an online conversion allows the physical server to remain accessible throughout the conversion process. The actual steps to perform an online conversion vary depending on the version of System Center Virtual Machine Manager that you are using. The steps outlined below are based on System Center Virtual Machine Manager 2012 SP1. To perform an online conversion, follow these steps: 1. Open the Virtual Machine Manager Administrator Console. 2. Select the VMs and Services tab. 3. Click on Create Virtual Machine and choose the Convert Physical Machine option (Figure 7.1). Figure 7.1

Click on the Create Virtual Machine button and choose the Convert Physical Machine option.

223

Understanding Hyper-V in Windows Server 2012

4. When the Convert Physical Server (P2V) Wizard opens, enter the name or IP address of the computer that you want to convert (Figure 7.2). Figure 7.2

Enter the name or IP address of the physical computer that you want to convert.

5. Enter a set of administrative credentials for the computer that you are converting. 6. Click Next. 7. Enter a name and an optional description for the new virtual machine that will be created. 8. Click Next. 9. Click the Scan System button. The scan analyzes the target system to make sure it is suitable for conversion (Figure 7.3).

224

Understanding Hyper-V in Windows Server 2012

Figure 7.3

Click the Scan System button to perform a hardware inventory on the computer that is being converted.

10. Click Next. 11. Select the checkboxes for each of the physical machine’s hard disks that you want to convert (Figure 7.4).

225

Understanding Hyper-V in Windows Server 2012

Figure 7.4

Select each physical disk that you want to convert.

12. Make any necessary adjustments to the virtual hard disks sizes, types or channels. 13. Click Next. 14. Specify the number of virtual processors and the amount of memory that you want to assign to the virtual machine (Figure 7.5). By default, System Center Virtual Machine Manager will use the same amount of memory and the same number of processor cores as in the physical machine that you are converting. 15. Click Next.

226

Understanding Hyper-V in Windows Server 2012

Figure 7.5

Specify the hardware you want to allocate to the new virtual machine.

16. Select the Hyper-V host that will host the newly created virtual machines (Figure 7.6). Hyper-V hosts are assigned a star rating to reflect their suitability for hosting the newly created VM. 17. Click Next.

227

Understanding Hyper-V in Windows Server 2012

Figure 7.6

Select the Hyper-V host that will host the newly created virtual machine.

18. Specify a location on the target server where the virtual machine files should be stored. 19. Click Next. 20. Specify the network adapter configuration for the new virtual machine (Figure 7.7). 21. Click Next.

228

Understanding Hyper-V in Windows Server 2012

Figure 7.7

Specify the new virtual machine’s virtual network adapter configuration.

22. Specify your preferred startup action for the virtual machine (Figure 7.8). 23. Specify your preferred stop action for the virtual machine. 24. Click Next.

229

Understanding Hyper-V in Windows Server 2012

Figure 7.8

Specify a startup action and a stop action for the new virtual machine.

25. Take a moment to review the Conversion Information screen to make sure that no issues are detected (Figure 7.9). If any issues are reported, resolve them and click the Check Again button. 26. Click Next.

230

Understanding Hyper-V in Windows Server 2012

Figure 7.9

Make sure there are no issues standing in the way of the virtual machine conversion process.

27. Review the information presented on the summary screen to make sure it is correct. 28. Click the Create button to begin the conversion process. 29. Go to the Jobs tab to confirm that the conversion is being performed (Figure 7.10).

231

Understanding Hyper-V in Windows Server 2012

Figure 7.10

You can use the Jobs tab to monitor the conversion process.

System Center Virtual Machine Manager offline conversion Not all virtual machines are suitable for online conversions. For example, some virtual machines may run operating systems that are not suitable for online conversions. Likewise, some applications have been known to suffer database corruption during online conversions. If your physical server cannot be safely converted online, it is best to perform an offline conversion. An offline conversion differs from an online conversion in that System Center Virtual Machine Manager creates a Windows PE boot environment on the physical server. The server is then booted into this environment so that the server’s operating system and applications can be taken offline during the conversion process. Once again, the steps to perform a conversion vary considerably depending on the version of Virtual Machine Manager you are using. The steps used in this chapter are based on the use of System Center Virtual Machine Manager 2012 SP1. To perform an offline conversion, complete these steps: 1. Open the Virtual Machine Manager Administrator Console. 2. Select the VMs and Services tab. 3. Click on Create Virtual Machine and choose the Convert Physical Machine option (Figure 7.11).

232

Understanding Hyper-V in Windows Server 2012

Figure 7.11

Click on the Create Virtual Machine button and choose the Convert Physical Machine option.

4. When the Convert Physical Server (P2V) Wizard opens, enter the name or IP address of the computer that you want to convert (Figure 7.12).

233

Understanding Hyper-V in Windows Server 2012

Figure 7.12

Enter the name or IP address of the physical computer that you want to convert.

5. Enter a set of administrative credentials for the computer that you are converting. 6. Click Next. 7. Enter a name and an optional description for the new virtual machine that will be created. 8. Click Next. 9. Click the Scan System button. The scan will analyze the target system and make sure that it is suitable for conversion (Figure 7.13).

234

Understanding Hyper-V in Windows Server 2012

Figure 7.13

Click the Scan System button to perform a hardware inventory on the computer that is being converted.

10. Click Next. 11. Select the checkboxes for each of the physical machine’s hard disks that you want to convert (Figure 7.14).

235

Understanding Hyper-V in Windows Server 2012

Figure 7.14

Select each physical disk that you want to convert.

12. Make any necessary adjustments to the virtual hard disks sizes, types or channels. 13. Click the Conversion Options link, located in the lower left portion of the wizard. 14. Select the Offline Conversion option (Figure 7.15). It is also generally recommended that you use the option to turn off the source computer after the conversion completes.

236

Understanding Hyper-V in Windows Server 2012

Figure 7.15

Choose the Offline Conversion option.

15. Click Next. 16. Specify the IP address configuration that the boot environment should use in the conversion process (Figure 7.16). By default, the Windows PE boot environment will inherit the IP address that the physical machine is currently using (assuming that the machine has been assigned a static IP address), but you can obtain an IP address from a DHCP server or you can manually assign an IPv4 or an IPv6 address of your choosing.

237

Understanding Hyper-V in Windows Server 2012

Figure 7.16

Choose the IP address that the boot environment will use.

17. Click Next. 18. Specify the number of virtual processors and the amount of memory to assign to the virtual machine (Figure 7.17). By default, System Center Virtual Machine Manager will use the same amount of memory and the same number of processor cores as in the physical machine that you are converting. 19. Click Next.

238

Understanding Hyper-V in Windows Server 2012

Figure 7.17

Specify the hardware that you want to allocate to the new virtual machine.

20. Select the Hyper-V host for the newly created virtual machines (Figure 7.18). Hyper-V hosts have a star rating that reflects their suitability for hosting the newly created VM. 21. Click Next.

239

Understanding Hyper-V in Windows Server 2012

Figure 7.18

Select the Hyper-V host for the newly created virtual machine.

22. Specify a location on the target server where the virtual machine files should be stored. 23. Click Next. 24. Specify the network adapter configuration for the new virtual machine (Figure 7.19). 25. Click Next.

240

Understanding Hyper-V in Windows Server 2012

Figure 7.19

Specify the new virtual machine’s virtual network adapter configuration.

26. Specify the preferred startup action for the virtual machine (Figure 7.20). 27. Specify the preferred stop action for the virtual machine. 28. Click Next.

241

Understanding Hyper-V in Windows Server 2012

Figure 7.20

Specify a startup action and a stop action for the new virtual machine.

29. Take a moment to review the Conversion Information screen to make sure that no issues are detected (Figure 7.21). If any issues are reported, resolve them and click the Check Again button. 30. Click Next.

242

Understanding Hyper-V in Windows Server 2012

Figure 7.21

Make sure that there are no issues standing in the way of the virtual machine conversion process.

31. Review the information presented on the summary screen to make sure it is correct. 32. Click the Create button to begin the conversion process. 33. Go to the Jobs tab to confirm that the conversion is being performed (Figure 7.22).

243

Understanding Hyper-V in Windows Server 2012

Figure 7.22

You can use the Jobs tab to monitor the conversion process.

Using the Disk2VHD free physical disk conversion tool As previously mentioned, System Center Virtual Machine Manager is the tool of choice for performing physical to virtual conversions in a Hyper-V environment. However, System Center Virtual Machine Manager is not the only tool for the job. A number of different vendors provide conversion tools, some of which are quite expensive. If a commercial P2V tool such as System Center Virtual Machine Manager is beyond your budget, you might consider using Disk2VHD, a free tool provided by Microsoft and Sysinternals to aid in P2V conversions. Unlike System Center Virtual Machine Manager, Disk2VHD does not perform machine-level P2V conversions. Instead, it converts a physical hard disk to a virtual hard disk. You can then manually create a virtual machine and tell it to use the newly created virtual hard disk. The nice thing about this tool is that it can be run while a server is online. You can even use it on physical computers that only have one hard drive. Disk2VHD creates a VSS snapshot prior to building the VHD file, and this allows the VHD file to be stored on the same disk that is being converted. Of course the tool delivers much better performance if you are able to store the VHD file on a disk other than the one you are converting.

244

Understanding Hyper-V in Windows Server 2012

You can download the Disk2VHD utility at: http://technet.microsoft.com/en-us/ sysinternals/ee656415.aspx To use the tool, follow these steps: 1. Download and extract the Disk2VHD application. 2. Double-click on Disk2VHD.exe to launch the Disk2VHD application. 3. Click Agree to accept the license agreement. 4. Select the checkbox for the disks that you want to convert (Figure 7.23). 5. Enter a path and a file name for the VHD file that you are creating. 6. Click the Create button. Figure 7.23

Disk2VHD is a very simple tool for performing physical-to-virtual disk conversions.

Share this e-book with your peers

245

Understanding Hyper-V in Windows Server 2012

Chapter 8

Replication Of all the new features in Hyper-V 3.0, replication is a hands-down favorite. Replication makes it possible to create replica virtual machines on a secondary Hyper-V server. You can use the replica as a relatively up-to‑date backup in the event that something happens to your primary Hyper-V server.

246

Understanding Hyper-V in Windows Server 2012

How you should use replication Before you learn how to build a Hyper-V replica, you need to understand that that the Hyper-V replica feature is not intended to be a replacement for failover clustering. As explained in the earlier chapters on failover clustering, the purpose of a cluster is to make a virtual machine highly available. If a host server fails, the virtual machines that were running on that host server will instantly fail over to another cluster node. Clustering also allows host servers to be taken offline for maintenance without disrupting the virtualized workload. Hyper-V’s replica feature provides capabilities that are somewhat similar to clustering, but replicas are intended for use in smaller environments and do not have the same capabilities as clusters. Failover clusters are designed to fail over automatically, but replicas have to be failed over manually. Another important difference is that Hyper-V replicas use asynchronous replication. This means that replication works really well over low-bandwidth, high-latency links. However, the use of asynchronous replication means that replication does not happen in real time and a replica is therefore not a true mirror image of a virtual machine. Replication cycles are designed to occur every five minutes, but there are factors that can delay replication. As a general rule, larger organizations use clustering whenever possible. Replication is intended for use in smaller organizations and is a convenient way to create secondary copies of virtual machines rather than being a fault‑tolerant solution.

System requirements There aren’t any special system requirements for using replication beyond the system requirements for running Hyper-V. Each edition of Windows Server 2012 supports Hyper-V replication. However, there is a big difference in the way the two editions of Windows Server 2012 are licensed. When planning your licensing, consider the number of virtual machines that you plan to replicate and whether or not those virtual machines are running Windows Server 2012. Windows Server 2012 Standard Edition and Datacenter Edition have exactly the same capabilities. The difference between the two editions lies in the number of virtual servers for which they are licensed. Windows Server 2012 Standard Edition is licensed for up to two virtual instances of Windows Server 2012. Windows Server 2012 Datacenter Edition, on the other hand, is licensed for an unlimited number of virtual instances of the Windows Server 2012 operating system. Thus, you should consider the most appropriate licenses for both the source server and destination server (the replica host) before you start configuring replication.

247

Understanding Hyper-V in Windows Server 2012

Configuration planning Although Hyper-V’s replication feature is designed to be easy to set up, there are a number of aspects to the configuration process that you must consider before you actually set up replication. Some of the more important aspects include: • Clustering • Destination Server (hardware (NIC, storage, etc.)) • Authentication Type • Compression • Virtual Machine and Virtual Hard Disk Selection • Initial Synchronization Each of these issues is addressed in the following sections as you go through the process of setting up a replica.

Configuring basic Hyper-V replication Now that you've read about the various aspects of Hyper-V replication, you will learn how to configure replication in a non‑clustered environment. Notice that the instructions require you to perform some steps on the source server (the server containing your virtual machines) and other steps on the destination server (the server that will contain your replica virtual machines). You will have to switch back and forth between the two servers as you work through these procedures. To configure replication for a non-clustered virtual machine, complete these steps:

On the destination server 1. Open the Hyper-V Manager. 2. Select your host server. 3. Click the Hyper-V Settings link, found in the Actions pane. 4. When the host server Settings dialog box launches, select the Replica Configuration option (Figure 8.1).

248

Understanding Hyper-V in Windows Server 2012

Figure 8.1

Select the Replica Configuration container.

5. Select the checkbox for Enable this computer as a Replica server. 6. Select the checkbox corresponding to the type of authentication that you wish to use. Kerberos is the preferred authentication type. 7. Verify that Kerberos is set to use Port 80. 8. Choose the radio button to Allow replication from any authenticated server. 9. Click the Browse button. 10. Specify the path where you want replica virtual machines to be stored. 11. Take a moment to verify your settings and click OK (Figure 8.2). 12. Click OK to acknowledge the firewall warning (Figure 8.3).

249

Understanding Hyper-V in Windows Server 2012

Figure 8.2

Verify all of your settings and click OK. Figure 8.3

Click OK to acknowledge the firewall warning.

Configuring the Windows Firewall Before you can finish setting up replication, you will need to configure the Windows Firewall to allow replication traffic to pass. To do so, follow these steps: 1. Open the Control Panel. 2. Click on System and Security. 3. Click on Windows Firewall. 4. Click on Allow an app or feature through the Windows Firewall. 5. Locate Hyper-V Replica on the list of apps and features.

250

Understanding Hyper-V in Windows Server 2012

6. Enable either the Hyper-V Replica HTTP or the Hyper-V Replica HTTPS feature (Figure 8.4). 7. Click OK. Figure 8.4

Hyper-V Replica traffic must be able to pass through the Windows firewall.

On the source server Hyper-V replication makes use of two servers—a source server and a destination server. The source server is the Hyper-V server that is currently running the virtual machine. The destination server is the server to which the virtual machine will be replicated. The configuration process is performed almost entirely against the source server. To implement Hyper-V replication, perform the following steps on your source server: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine that you want to replicate. 3. Choose the Enable Replication command from the right-click menu. 4. When the Enable Replication wizard opens, click Next to bypass the wizard’s Welcome screen. 5. When prompted, enter the name of the replica server and click Next (Figure 8.5).

251

Understanding Hyper-V in Windows Server 2012

Figure 8.5

You must provide the name of the replica server.

6. Choose the most appropriate authentication type (Figure 8.6). The authentication type must match what you used on the destination server. 7. Select the checkbox for Compress the data that is transmitted over the network if you want to enable network compression. Network compression decreases bandwidth consumption, but increases CPU usage. Microsoft recommends using compression in most situations.

252

Understanding Hyper-V in Windows Server 2012

Figure 8.6

Choose whether or not to compress network traffic.

8. Click Next. 9. Select the virtual hard disks that you want to replicate (Figure 8.7). Figure 8.7

Choose the virtual hard disks that you want to replicate.

253

Understanding Hyper-V in Windows Server 2012

10. Click Next. 11. Choose the number of recovery points you want to store for the virtual machine. 12. Click Next. 13. Choose the method that you wish to use for the initial replication process (Figure 8.8). You can send the initial replica across the network or you can use removable media instead. The rest of the steps in this procedure are based on the assumption that you will send the initial replica across the network. Figure 8.8

Choose the initial replication method.

14. Specify when you would like the replication process to begin. 15. Click Next. 16. Verify the summary information. 17. Click Finish. 18. Verify that the Hyper-V Manager shows the virtual machine’s status as Initial Replication (Figure 8.9).

254

Understanding Hyper-V in Windows Server 2012

Figure 8.9

Verify that the replication process has begun.

On the destination server 1. Open the Hyper-V Manager. 2. The replicated virtual machine should be listed. The virtual machine’s status should indicate that it is receiving changes from the source server (Figure 8.10). Figure 8.10

The replica server should be receiving the replicated data from the source server.

Configuring cluster-based replication The process of setting up virtual machine replication works in largely the same way in a clustered environment as it does when you configure replication between two standalone Hyper-V servers. The primary difference is that in clustered environments you must install an additional component called the Hyper-V Replica Broker. Otherwise, replication will break down if the virtual machine is moved to another cluster node. In a clustered environment, you can replicate a virtual machine in the following ways: • From a Hyper-V cluster to a standalone host • From a Hyper-V cluster to another Hyper-V cluster • From a standalone host to a Hyper-V cluster The instructions below guide you through the process of replicating a clustered virtual machine to a standalone host (this is the most common form of cluster‑based replication). As with standalone replication, you must perform some steps on the source server (in this example, a cluster node where the VM resides) and other steps on the destination server (a standalone VM in this case). To configure the Hyper-V replica, complete these steps:

On the destination server 1. Open the Hyper-V Manager. 2. Select your host server.

255

Understanding Hyper-V in Windows Server 2012

3. Click the Hyper-V Settings link, found in the Actions pane. 4. When the host server Settings dialog box launches, select the Replica Configuration option (Figure 8.11). Figure 8.11

Select the Replica Configuration container.

5. Select the checkbox for Enable this computer as a replica server. 6. Select the checkbox corresponding to the type of authentication that you wish to use. Kerberos is the preferred authentication type. 7. Verify that Kerberos is set to use Port 80. 8. Choose the radio button to Allow replication from any authenticated server. 9. Click the Browse button. 10. Specify the path where you want replica virtual machines to be stored. 11. Take a moment to verify your settings and click OK. 12. Click OK to acknowledge the firewall warning.

256

Understanding Hyper-V in Windows Server 2012

Configuring the Windows Firewall Before you can finish setting up replication, you will need to configure the Windows Firewall to allow replication traffic to pass. To do so, follow these steps: 1. Open the Control Panel. 2. Click on System and Security. 3. Click on Windows Firewall. 4. Click on Allow an app or feature through the Windows Firewall. 5. Locate Hyper-V Replica on the list of apps and features. 6. Enable either the Hyper-V Replica HTTP or the Hyper-V Replica HTTPS feature (Figure 8.12). 7. Click OK. Figure 8.12

Hyper-V Replica traffic must be able to pass through the Windows firewall.

On the source server Normally Hyper-V replication makes use of two servers—a source server and a destination server. In a clustered environment things aren’t quite so simple. The source could be either a standalone Hyper-V host or a cluster node. The same also holds true for the destination server. The example here uses a Hyper-V cluster node as the source server and assumes that the virtual machine being replicated is running within the cluster. The destination server is the server to which the virtual machine will be replicated and, in this case, it will be a standalone Hyper-V host.

257

Understanding Hyper-V in Windows Server 2012

First you need to install the Hyper-V Replica Broker on the Hyper-V cluster. To do this, complete the following steps: 1. Open the Server Manager. 2. Choose the Failover Cluster Manager command from the Manage menu. 3. Navigate through the console tree to Failover Cluster Manager | | Roles. 4. Right-click on the Roles container and choose the Configure Role command from the right-click menu (Figure 8.13). Figure 8.13

Right-click on the Roles container and select the Configure Role command from the right‑click menu.

5. When the High Availability Wizard launches, click Next to bypass the wizard’s Welcome screen. 6. Choose the Hyper-V Replica Broker from the list of roles and click Next (Figure 8.14).

258

Understanding Hyper-V in Windows Server 2012

Figure 8.14

Choose the Hyper-V Replica Broker from the list of roles and click Next.

7. Enter a name that clients can use when connecting to the Hyper-V Replica Broker. 8. Enter an IP address that the Hyper-V Replica Broker can use and click Next. 9. Take a moment to verify the information presented on the summary screen and click Next. 10. When the installation process completes, click Finish. Now that you have installed the Hyper-V Replica Broker, the next step is to designate a virtual machine for replication. You can accomplish this task by following these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine that you want to replicate. 3. Choose the Replication | Enable Replication commands from the right‑click menu. 4. When the Enable Replication wizard begins, click Next to bypass the wizard’s Welcome screen. 5. When prompted, enter the name of the replica server and click Next (Figure 8.15).

259

Understanding Hyper-V in Windows Server 2012

Figure 8.15

You must provide the name of the replica server.

6. Choose the most appropriate authentication type. The authentication type must match what you used on the destination server. 7. Select the checkbox for Compress the data that is transmitted over the network if you want to enable network compression (Figure 8.16). Network compression decreases bandwidth consumption, but increases CPU usage. Microsoft recommends enabling compression in most situations.

260

Understanding Hyper-V in Windows Server 2012

Figure 8.16

Choose whether or not to compress network traffic.

8. Click Next. 9. Select the virtual hard disks that you want to replicate (Figure 8.17). Figure 8.17

Choose the virtual hard disks that you want to replicate.

261

Understanding Hyper-V in Windows Server 2012

10. Click Next. 11. Choose the number of recovery points you want to store for the virtual machine. 12. Click Next. 13. Choose the method that you wish to use for the initial replication process (Figure 8.18). You can perform the initial replication over the network or you can opt to use removable media instead. The remaining steps in this section assume that you are performing the initial replication over the network. Figure 8.18

Choose the initial replication method.

14. Specify when you would like the replication process to begin. 15. Click Next. 16. Verify the summary information. 17. Click Finish. 18. Click Close when you see the Replication enabled successfully dialog box (Figure 8.19). 19. Verify that the Hyper-V Manager shows the virtual machine’s status as Initial Replication.

262

Understanding Hyper-V in Windows Server 2012

Figure 8.19

Verify that the replication process was successfully enabled.

On the destination server 1. Open the Hyper-V Manager. 2. The replicated virtual machine should be listed. The virtual machine’s status should indicate that it is receiving changes from the source server (Figure 8.20). Figure 8.20

The replica server should be receiving the replicated data from the source server.

Monitoring replication health For a quick status update on a replica’s health, follow these steps: 1. Open the Hyper-V Manager. 2. Select the virtual machine that you want to check. 3. Select the Replication tab at the bottom of the window (Figure 8.21).

263

Understanding Hyper-V in Windows Server 2012

Figure 8.21

The Replication tab displays the overall replication health.

For a more comprehensive picture of the replication health, complete these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine whose health you need to determine. 3. Select the Replication | View Replication Health commands from the right-click menu (Figure 8.22). Figure 8.22

Right-click on the virtual machine and select the Replication | View Replication Health commands.

264

Understanding Hyper-V in Windows Server 2012

As you can see in the figure below, the Replication Health dialog box provides detailed information about the health of the replication process (Figure 8.23). Figure 8.23

The Replica Health dialog box provides detailed information about the health of the replication process.

It's important to know that the information provided about replication health is often inconsistent, depending on which Hyper-V server you are viewing the health information. To illustrate the accuracy problem, check out the two screen captures below: Figure 8.24

The primary replica shows Replication Error and Replication Health of Critical.

265

Understanding Hyper-V in Windows Server 2012

Figure 8.25

The secondary replica shows Replication Paused and Replication Health Warning.

As you can see in the figures above, the primary Hyper-V server shows a critical error, while the replica server shows only a warning condition. As such, the only way to reliably assess the replica’s health is to look at the health information on both the primary and the replica server.

Resolving replication errors As mentioned in the previous section, the replication feature tends to work well but replicas can sometimes fall out of sync. Checking the replication health can help you to determine whether or not your virtual machine replicas are being properly synchronized, but a health check alone will not fix replication problems. If you are planning to use the Hyper-V replica feature, it is critically important to know how to correct synchronization problems when they occur. If you suspect a replication problem, click the Reset Statistics button on the Replication Health dialog box explained in the previous section (Figure 8.26). Hyper-V has a bad habit of displaying outdated errors and warning messages, so it is important to verify that the information that you are seeing is current. If you want to preserve the existing replication health report, click the Save As button to export the replication health information to a CSV file before you reset the replication statistics.

266

Understanding Hyper-V in Windows Server 2012

Figure 8.26

Resetting the replication statistics allows you to view the most current health information.

If after checking the most recent health information, you determine that replication has stopped, try right-clicking on the virtual machine and choosing the Replication | Resume Replication commands from the right-click menus (Figure 8.27). This restarts the replication process and will usually fix the replication problem. Figure 8.27

Manually resuming replication will usually correct the replication problem.

267

Understanding Hyper-V in Windows Server 2012

If using the Resume Replication command does not fix the problem, check to make sure that your servers have plenty of free disk space and that there is still network connectivity between the servers. It’s also a good idea to check the server’s event logs for any errors.

Pausing replication If you need to take a server containing replicas offline for maintenance, it is a good idea to pause the replication process first by following these steps: 1. Open the Hyper-V Manager on the server that needs to be taken offline. 2. Right-click on the replica virtual machine. 3. Choose the Replication | Pause Replication command from the right-click menus (Figure 8.28). Figure 8.28

Right-click on a replica virtual machine and choose the Replication | Pause Replication commands from the right-click menus.

When you are finished performing maintenance on the virtual machine, you can resume the replication process by right-clicking on the replica and choosing the Replication | Resume Replication commands from the right‑click menus.

Disabling replication If you no longer wish to replicate a virtual machine, you can permanently disable replication by using Hyper-V’s Remove Replication function. To do so, follow these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine for which you want to stop replication. 3. Select the Replication | Remove Replication commands from the right‑click menus (Figure 8.29).

268

Understanding Hyper-V in Windows Server 2012

4. When prompted for confirmation, click the Remove Replication button (Figure 8.30). Figure 8.29

Select the Replication | Remove Replication options from the right-click menus. Figure 8.30

Click the Remove Replication button.

Testing the replication failover Before you perform a full-fledged failover, it is a good idea to test the replica to make sure that it is healthy and that you can perform a failover without placing the replica in jeopardy. To test the failover capabilities, complete the following steps: 1. Open the Hyper-V Manager on the destination host. 2. Right click on the virtual machine that you want to test. 3. Choose the Replication | Test Failover commands from the right-click menus (Figure 8.31)

269

Understanding Hyper-V in Windows Server 2012

Figure 8.31

Failover testing can only be performed on the destination host.

4. You will now see a message stating that you can create a separate virtual machine to verify that a recovery point is able to start successfully and that the virtual machine is running correctly (Figure 8.32). 5. Choose the recovery point from which you want to create the new virtual machine. Figure 8.32

Choose the recovery point from which you want to create the new virtual machine.

6. Click the Test Failover button. 7. You should see the replica virtual machine’s status change to Test Failover. When this process completes, a test virtual machine will be created (Figure 8.33).

270

Understanding Hyper-V in Windows Server 2012

Figure 8.33

Windows creates a test virtual machine.

8. Start the test virtual machine and verify that it functions properly. In case you are wondering, when Hyper-V creates the test virtual machine, what it is really doing is snapshotting the replica and then using a differencing disk for the test virtual machine. This allows you to boot the test virtual machine and interact with it, without having to worry about damaging your replica in the process. The replication process can continue normally throughout the testing process. When you have finished testing virtual machine failover, you must shut down and delete the test virtual machine. Keep in mind that the test virtual machine is using the same virtual hard disks as the primary replica virtual machine. This means that it is safe to delete the test virtual machine through the Hyper-V Manager, but you should not attempt to manually remove individual virtual machine components through the file system.

Performing a planned failover 1. Power down the virtual machine that you plan to fail over. 2. Right-click on the replicated virtual machine on your host server. 3. Select the Replication | Planned Failover commands from the right-click menu (Figure 8.34). Figure 8.34

Choose the Replication | Planned Failover commands from the right-click menu.

4. The Planned Failover dialog box lists the prerequisites you must meet as well as the actions you must perform as a part of the planned failover. After verifying that you have met the prerequisites, click the Failover button.

271

Understanding Hyper-V in Windows Server 2012

5. When you see a message confirming the success of the operation, click OK. 6. Verify that the virtual machine is running on the replica server.

Unplanned failover An unplanned failover is a disaster recovery technique that you should use only as a last resort. You would use unplanned failovers in situations in which your primary Hyper-V host server has failed catastrophically and you want to switch over to your replica. The reason why this is a last resort operation is because unplanned failovers almost always result in data loss. Any data that has not been replicated from the primary server to the replica is lost. You can perform an unplanned failover by completing these steps: 1. Open the Hyper-V Manager on the host server that contains your replicas. 2. Right-click on the virtual machine that you want to fail over. 3. Choose the Failover command from the right-click menu (Figure 8.35) Figure 8.35

You can perform an unplanned failover by right-clicking on a virtual machine and choosing the Failover option from the right-click menu.

Share this e-book with your peers

272

Understanding Hyper-V in Windows Server 2012

Chapter 9

Hyper-V Management So far this book has covered topics such as Hyper-V deployment, virtual machine migrations and even virtual machine creation through PowerShell. However, in any virtual datacenter there is ongoing maintenance that you must perform in order to keep your host servers and virtual machines healthy. In this chapter, you will learn about two important maintenance tasks—resource metering and patching host server clusters.

273

Understanding Hyper-V in Windows Server 2012

Resource metering In any virtual server environment, it is important to keep track of the resources that virtual machines are using. Virtual servers share a finite pool of hardware resources on the host server. If any individual virtual machine were to consume excessive resources, it could potentially rob the other virtual machines of the hardware they need. Resource metering allows you to keep track of hardware usage on a per virtual machine basis. Although it makes sense to use resource metering as a tool for measuring performance and allocating virtual machine resources, some people use resource metering as a way of facilitating chargebacks. In previous versions of Hyper-V to implement chargebacks you had to either develop a custom solution or use the Self Service Portal for System Center Virtual Machine Manager. The Self Service Portal provided a very nice interface for tracking chargebacks, but setup was tedious. Hyper-V 3.0’s resource metering capabilities do not include built-in chargeback management capabilities, but they do lay the ground work for building your own chargeback management system. Furthermore, the fact that the resource metering capabilities are PowerShell based means that developing such a solution is much easier than it would have been in the past. The nice thing about Hyper-V’s resource metering capabilities is that they are completely open ended, which means that you can easily adapt them to your own needs. Resource metering allows you to track several different vital statistics on a per virtual machine basis. These statistics include: • Average CPU usage, measured in megahertz over a period of time • Average physical memory usage, measured in megabytes • Minimum memory usage (lowest amount of physical memory) • Maximum memory usage (highest amount of physical memory) • Maximum amount of disk space allocated to a virtual machine • Total incoming network traffic, measured in megabytes, for a virtual network adapter • Total outgoing network traffic, measured in megabytes, for a virtual network adapter

Enabling resource metering Before you can use resource metering, you will need to enable it. Resource metering is a virtual machine-level operation, but you can use PowerShell to simultaneously enable resource metering for all of the virtual machines that are running on a host. The command for doing so is: Get-VM –ComputerName | Enable-VMResourceMetering For example, to enable resource metering for all of the virtual machines on a host named Lab1, you would use the following command (Figure 9.1): Get-VM –ComputerName Lab1 | Enable-VMResourceMonitoring

274

Understanding Hyper-V in Windows Server 2012

Figure 9.1

This command enables resource metering for all of the virtual machines that are running on the designated host server.

Of course, you can easily enable resource metering for a single virtual machine by altering the command slightly. For example, if you want to enable resource metering for a virtual machine named VM2, you would use the following command (Figure 9.2): Get-VM VM2 | Enable-VMResourceMetering Figure 9.2

You can enable resource metering on a per virtual machine basis.

Modifying the collection interval Hyper-V’s resource metering does not track virtual machine usage in real time. Doing so would rob the host server of memory and CPU cycles that could be better used running production workloads. Instead, the resource metering feature samples virtual machine usage on a periodic basis. By default, Hyper-V samples virtual machine resource usage once per hour (assuming that resource metering is enabled). You can modify the sampling frequency, but you have to be careful not to collect resource metering data too frequently or you could impact the virtual machines’ performance. When you modify the resource metering collection frequency, enter the frequency in HH:MM:SS (hours:minutes:seconds) format. For instance, if you want to collect resource metering data once every minute, use the following command: Set-VMHost –ComputerName -ResourceMeteringSaveInterval 00:01:00 Figure 9.3 shows an example of using this command on a host server named Lab1. Figure 9.3

This command changes the resource metering collection interval to one minute.

In the figure above, notice that you are adjusting the collection period at the host server level. You cannot change the collection period on a per virtual machine basis. Keep in mind that it's not a good idea to collect resource metering data once a minute in production environments. There is a reason why Microsoft chose to use hourly collection of metering data as the default.

275

Understanding Hyper-V in Windows Server 2012

Viewing resource metering information There are a number of different ways you can view resource metering information. For instance, ifyou want to display all of the resource metering data for a specific virtual machine the easiest way to do so is by using the following command: Get-VM | Measure-VM If you want to view the resource metering information for a virtual machine named VM2, you could use the following command (Figure 9.4): Get-VM VM2 | Measure-VM Figure 9.4

This is the easiest way to view all of the resource metering data for a specific virtual machine.

Viewing all available resource metering data The command shown in the previous section provides all of the metering data for a specific virtual machine. Recall that at the beginning of this chapter you learned how to enable resource metering for every virtual machine on the host server. You might be curious about how to create a comprehensive report of server-wide resource metering data. You can access all of the metering data that has been collected for a Hyper-V server by using a slight variation of the command used in the previous section. The command is basically the same, except that it omits the virtual machine name. The command looks like this: Get-VM | Measure-VM As an alternative, you can force this command to run against a specific Hyper-V host server by appending the –ComputerName parameter and the name of the host server to the Get-VM cmdlet. For example, to view all of the metering data for virtual machines stored on a Hyper-V server named Lab1, you would use this command: Get-VM –ComputerName Lab1 | Measure-VM You can see this command in action in Figure 9.5.

276

Understanding Hyper-V in Windows Server 2012

Figure 9.5

It is possible to view the resource metering data for all of the virtual machines on the server.

Viewing specific resource metering properties Unlike some of the PowerShell commands discussed earlier in this book, the Measure-VM cmdlet does not overwhelm you with an excessive amount of data. The resource metering feature tracks only seven values. Even so, there may be situations in which you only want to view specific values. There are a few different ways to accomplish this. For example, if you are interested in viewing only the data related to memory usage and you want to create a memory usage report for all of the virtual machines that are running on a host, you can use the Select-Object cmdlet to specify the properties you want to view. To do this you need to know the property names, which you can find by using this command: Get-VM | Measure-VM | Select-Object * When you enter this command, Hyper-V shows a full report of metering data for each virtual machine. More important, this metering data is broken into two columns (Figure 9.6). The column on the left lists all of the property names that are used by the Measure-VM cmdlet. Once you know the property names, you can customize the output to include specific properties.

277

Understanding Hyper-V in Windows Server 2012

Figure 9.6

You can use this command to determine all of the property names that are supported by the Measure-VM cmdlet.

With that in mind, use the Select-Object cmdlet to build a report that shows memory usage data for the virtual machines. Note that when you use the Select-Object cmdlet, PowerShell shows you EXACTLY what you have requested and nothing more. That being the case, you should include the VMName property, otherwise there's no way to tell which virtual machines the metering data belongs to. Use the following command (Figure 9.7): Get-VM | Measure-VM | Select-Object VMName, AvgRAM, MaxRAM, MinRAM Figure 9.7

You can filter the Measure-VM cmdlet’s output to show only specific properties.

278

Understanding Hyper-V in Windows Server 2012

Sorting the output In a variation of the technique demonstrated in the previous section, it is possible to sort the output. For example, you can sort the list by the highest average RAM value. This technique is very similar to the technique used in the previous section. The biggest difference is that you must append the Sort‑Object cmdlet and specify the sort order and the property on which to base the sort. For example, if you want to create a memory usage report like the one shown in the previous section, but you also want to sort the data by the average memory consumption (in a descending order), use the following command (Figure 9.8): Get-VM | Measure-VM | Sort-Object –Property AvgRAM –Descending | Select-Object VMName, AvgRAM, MaxRAM, MinRAM Figure 9.8

You can easily sort the resource metering data by using the Sort-Object cmdlet.

The lab server used in the examples in this chapter contains a reasonable number of virtual machines, but in the real world, a Hyper-V host might have too many virtual machines to view all of the resource metering data at once on screen. In situations like that it is useful to narrow down the list. Fortunately, PowerShell makes it possible to list only your top results. For example, if the output is too long and you only want to see the three virtual machines with the highest memory usage, you can use the –First switch and the number of virtual machines you wantto display (three in this case). The command for this is: Get-VM | Measure-VM | Sort-Object –Property AvgRAM –Descending | Select-Object –First 3 VMName, AvgRAM, MaxRAM, MinRAM As you can see, Figure 9.9 displays, the three virtual machines with the highest memory use. Figure 9.9

You can tell PowerShell to display only your top results.

279

Understanding Hyper-V in Windows Server 2012

Displaying specific resource metering results You may have noticed in some of the figures that memory usage for many of the virtual machines was zero. This happens because resource metering collects data for virtual machines whether or not they are powered on. Fortunately, PowerShell makes it easy to filter the list to hide all of the virtual machines that are powered off. One way to do this is to create a filter that displays all of the virtual machines that have minimum memory values greater than zero using the following command: Get-VM | Measure-VM | Where MinRAM -GT ‘0’ The output of this command is shown in Figure 9.10 Figure 9.10

You can filter the output to include only specific results.

Although the example above lists only virtual machines that are powered on, there are other ways to use this technique. You can also use this method to locate any resource metering data. For example, you can use the technique to locate virtual machines that are consuming over 4 GB of RAM on average or virtual machines with a very high average CPU usage.

Reporting In this chapter, you have learned how to view a variety of resource metering data. Sometimes, however, it is more beneficial to build a report. This allows you to track resource usage over time and makes it easier to view the metering data when there is too much data to view on the screen. The chapter on PowerShell contains an entire section on reporting. It shows how to build HTML-based reports and how to export data to a CSV file, which is viewable in Microsoft Excel. The use of CSV files is especially handy for tracking metering data over time.

Cluster-aware updating One of the big problems previously with managing Hyper-V clusters in Windows Server 2008 or 2008 R2 was that patching a Hyper-V cluster was a tedious and time-consuming process. If you wanted to patch the servers within the cluster using only native tools, you had to manually live migrate the virtual machines off a cluster node, patch and reboot the node, and repeat the process for each remaining cluster node.

280

Understanding Hyper-V in Windows Server 2012

There are some options for automating the process: you can automate clusterlevel patch management using System Center Orchestrator or System Center 2012 Virtual Machine Manager. The problem is that there are licensing costs associated with these tools and setting up automated patch management can be complicated. Windows Server 2012 offers a new feature called Cluster-Aware Updating. This feature allows you to patch the nodes in a Hyper-V cluster without having to manually patch each node or resort to using external tools. Cluster-Aware Updating takes a round-robin approach to patch management. It starts by placing a cluster node into maintenance mode. This causes the virtual machines that are running on the host to be automatically live migrated to the best possible node (as determined by the cluster). It is worth noting that choosing the best possible node is based solely on the amount of free memory on each cluster node. This is different from the process used by System Center 2012 Virtual Machine Manager, which uses a number of different criteria to determine the best possible cluster node. Once the virtual machines have been live migrated off the host, the server is patched and rebooted. The update process then takes the node out of maintenance mode, which in turn allows it to host virtual machines once again. The process is repeated for every node in the cluster. There are two ways to use Cluster-Aware Updating – Self Updating or Remote Updating. Self Updating is the more common of the two methods and involves running the Cluster-Aware Update tool directly on a cluster node according to a schedule that you set. Remote updating involves installing the Cluster-Aware Update tool on a computer that is not a cluster node. The computer must be running Windows Server 2012 or Windows 8.

Installing the Cluster-Aware Update tool If you plan to use self updating for the cluster, you will not need to install the Cluster-Aware Update tool, because the tool is installed by default on cluster nodes. If you want to install the tool onto a non-cluster node, the exact method depends on the operating system that is running on the computer. Assuming that the computer is running Windows Server 2012, you can install the Cluster-Aware Update tool by completing these steps: 1. Open the Server Manager. 2. Select the Add Roles and Features command from the Manage menu. 3. When the Add Roles and Features Wizard launches, click Next to bypass the Welcome screen. 4. Verify that the Role-Based or Feature-Based Installation option is selected and click Next. 5. Select the server where you want to install the tool and click Next. 6. Click Next to bypass the Server Role selection screen. 7. Select the checkbox for Failover Clustering from the list of features (Figure 9.11).

281

Understanding Hyper-V in Windows Server 2012

Figure 9.11

Select Failover Clustering from the list of available features.

8. When prompted, click the Add Features button (Figure 9.12). Figure 9.12

Click the Add Features button.

9. Click Next. 10. Take a moment to verify that the Failover Cluster Management Tools will be installed (Figure 9.13). 11. Click Install.

282

Understanding Hyper-V in Windows Server 2012

Figure 9.13

Make sure that the Failover Cluster Management Tools will be installed.

Performing a Cluster-Aware update Assuming that you are going to be performing a self update, you can perform a Cluster-Aware update by completing these steps: 1. Open the Server Manager on a failover cluster node. 2. Choose the Cluster-Aware Updating option from the Tools menu (Figure 9.14). 3. When the Cluster-Aware Updating tool opens, use the Connect to a Failover Cluster drop-down list to select a failover cluster. 4. Click the Connect button (Figure 9.15). Figure 9.14

Choose the Cluster-Aware Updating option from the Tools menu.

283

Understanding Hyper-V in Windows Server 2012

Figure 9.15

Click the Connect button.

5. Assuming that this is the first time you have performed a Cluster-Aware update, click on Configure Cluster Self-Updating Options. 6. When the Configure Self-Updating Options Wizard launches, click Next to bypass the Welcome screen. 7. You should see warning that the cluster is not configured with the Cluster‑Aware Updating clustered role (Figure 9.16). Select the checkbox for Add the CAU clustered role with self-updating mode enabled to this cluster. Figure 9.16

You must add the CAU clustered role with self-updating mode enabled to the cluster.

284

Understanding Hyper-V in Windows Server 2012

8. Click Next. 9. Set a self-updating schedule (Figure 9.17). It is best to choose an off-peak usage period. Figure 9.17

You must specify a self-updating schedule.

10. Click Next. 11. When the Advanced Options screen opens, you have the option of setting some custom update parameters or you can click Next to accept the defaults (which is usually recommended). 12. Choose whether or not you wish to receive recommended updates in the same way as important updates (Figure 9.18).

285

Understanding Hyper-V in Windows Server 2012

Figure 9.18

You can install recommended updates in the same manner as important updates.

13. Click Next. 14. Take a moment to verify that the information displayed on the summary screen is correct. 15. Click Apply. 16. Verify the success of the operation (Figure 9.19). 17. Click Close.

286

Understanding Hyper-V in Windows Server 2012

Figure 9.19

You should see a message indicating that the cluster role was added successfully.

Previewing cluster updates In order to see what the next update will consist of, you can generate an update preview by following these steps: 1. Open the Server Manager. 2. Choose the Cluster-Aware Updating option from the Manage menu. 3. Choose your cluster from the Connect to a Failover Cluster drop-down list and click Connect if necessary. 4. Click the Preview Updates for this Cluster link (Figure 9.20). Figure 9.20

Click the Preview Updates for this Cluster link.

287

Understanding Hyper-V in Windows Server 2012

5. When the Preview Updates dialog box launches, click the Generate Update Preview List button (Figure 9.21). Figure 9.21

Click the Generate Update Preview List button.

6. Windows will produce a list of updates (Figure 9.22). You can click on an item to see more detailed information about it. Figure 9.22

This is what the preview list looks like.

288

Understanding Hyper-V in Windows Server 2012

Applying updates Updates will be applied according to the schedule that you previously set. If necessary however, you can apply updates to the cluster on demand by following these steps: 1. Open the Server Manager. 2. Choose the Cluster-Aware Updating option from the Manage menu. 3. Choose your cluster from the Connect to a Failover Cluster drop-down list and click Connect if necessary. 4. Click Apply Updates to this Cluster. 5. When the Cluster-Aware Updating Wizard launches, click Next to bypass the Welcome screen. 6. When the Confirmation screen appears, click the Update button (Figure 9.23). This does not actually perform the update, but rather schedules an immediate update. Figure 9.23

Click the Update button.

7. Verify the success of the operation (Figure 9.24), and click Close.

289

Understanding Hyper-V in Windows Server 2012

Figure 9.24

Make sure that the operation was successful and click Close.

Generating a report Occasionally it may be useful to create a report as a way of verifying the patches that have been deployed to your Hyper-V cluster. The Failover Cluster Service provides a reporting function that you can use for this purpose. You can generate a cluster patching report by completing these steps: 1. Open the Server Manager. 2. Choose the Cluster-aware Updating option from the Manage menu. 3. Choose your cluster from the Connect to a Failover Cluster drop-down list and click Connect if necessary. 4. Click the Generate Report on Past Updating Runs link. 5. When the Generate Updating Run Report dialog box launches, set the date range for the report (Figure 9.25). 6. Click the Generate Report button.

290

Understanding Hyper-V in Windows Server 2012

Figure 9.25

Set the date for the report.

When the report completes, the dialog box displays all of the completed runs within the specified time period. Click on a run to display the updates that occurred as a part of that run (Figure 9.26). The lower portion of the dialog box provides statistics on the run that include information such as the amount of time that the run took to complete and the number of successful and failed updates. Figure 9.26

The Run Report provides detailed information about the patches that were applied to the cluster.

291

Understanding Hyper-V in Windows Server 2012

Clicking the Export Report button at the bottom of the screen generates an HTML version of the report, which contains highly detailed and easy‑to‑read information about the patches that were applied to the cluster nodes (Figure 9.27). Figure 9.27

It’s a good idea to export the report to HTML because it is much easier to read.

Share this e-book with your peers

292

Understanding Hyper-V in Windows Server 2012

Chapter 10

Networking Virtual machines running on a Hyper-V server typically share the server’s physical network adapters. In addition, Hyper-V supports storage networking through the use of virtual Fibre Channel. This chapter discusses techniques for configuring virtual networking and virtual Fibre Channel.

293

Understanding Hyper-V in Windows Server 2012

An introduction to the virtual switch Perhaps the most important concept with regard to Hyper-V networking is that of the virtual switch. Virtual machines communicate with one another and with the physical network by means of a virtual switch (Figure 10.1). Figure 10.1

Virtual machines communicate with one another and with the physical network through a virtual switch.

When you first install Hyper-V, the setup process asks you which network adapter you want to use with Hyper-V. When you make this choice, Hyper-V creates a virtual switch for the specified network adapter. Hyper-V also creates a virtual network adapter that the host operating system uses to communicate with the virtual switch. The virtual network adapter is assigned the name that was previously used by the physical network adapter. The only component used by this virtual network adapter is the Hyper-V Extensible Virtual Switch protocol (Figure 10.2). The virtual network adapter does not use any of the other common networking components such as TCP/IP.

294

Understanding Hyper-V in Windows Server 2012

Figure 10.2

The virtual network adapter uses only the Hyper-V Extensible Virtual Switch.

The virtual switch itself is also accessible through the Control Panel’s list of network connections. It uses the same name as the virtual network adapter, except that the letter V is appended to the beginning of the adapter name to indicate that the adapter is a virtual switch. The virtual switch inherits the physical adapter’s former IP address configuration.

Virtual switch types Although Hyper-V creates a virtual switch by default (assuming that you have allowed Hyper-V to use one of your server’s physical network adapters), the default virtual switch isn't the only virtual switch you can use. Hyper-V allows you to create multiple virtual switches, and each virtual switch offers one of three different types of connectivity including: • External – The virtual switch provides connectivity to the virtual network and to the physical network. • Internal – The virtual switch provides connectivity to virtual machines running on the host server and to the host server itself. No connectivity to the physical network is provided. • Private – A private virtual switch only provides network connectivity between virtual machines running on the host. Virtual machines with private connection cannot communicate with the host server or with the physical network.

295

Understanding Hyper-V in Windows Server 2012

Creating a virtual switch Although Hyper-V creates a virtual switch during the initial setup process, you can create additional virtual switches if needed by following these steps: 1. Open the Hyper-V Manager. 2. Right-click on the listing for the host server and choose the Virtual Switch Manager command from the right-click menu (Figure 10.3). Figure 10.3

Right-click on the host server and choose the Virtual Switch Manager command.

3. When the Virtual Switch Manager opens, make sure that the New virtual network switch option is selected. 4. Choose the type of virtual switch that you want to create. 5. Click the Create Virtual Switch button (Figure 10.4).

296

Understanding Hyper-V in Windows Server 2012

Figure 10.4

Choose the virtual switch type and click the Create Virtual Switch button.

6. Enter a name for the new virtual switch you are creating (Figure 10.5). 7. Optionally enter notes explaining the virtual switch’s purpose. 8. Select the virtual switch’s connection type. If you choose to link the virtual switch to an external network, select the network adapter that the new virtual switch will be bound to. There is also a checkbox you can select to control whether or not the management operating system will be able to access the network adapter. 9. If the virtual switch needs to communicate across a VLAN, select the checkbox for Enable Virtual LAN Identification for Management Operating System and specify a VLAN ID. 10. Click OK to create the virtual switch (Figure 10.5).

297

Understanding Hyper-V in Windows Server 2012

Figure 10.5

Click OK to create the new virtual switch.

Connecting a virtual machine to a virtual switch Connecting a virtual machine to a virtual switch is simply a matter of opening the virtual machine’s Settings page, selecting the virtual network adapter, and choosing a virtual switch. As an alternative, you can create a new network adapter and bind it to a virtual switch of your choosing. To link an existing virtual network adapter to a different virtual switch, complete these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine and choose the Settings command from the right-click menu. 3. When the settings page appears, select the network adapter. 4. Use the Virtual Switch drop-down list to select the virtual switch that you want to use. 5. Click OK (Figure 10.6).

298

Understanding Hyper-V in Windows Server 2012

Figure 10.6

Choose the virtual switch that you want to assign to the virtual machine and click OK.

Adding networking hardware When you create a virtual machine using the Hyper-V Manager, Hyper-V automatically provisions the virtual machine with a virtual NIC. However, you might need to create additional virtual NICs or other types of network interfaces. You can add three types of networking hardware to virtual machines, including: • Network Adapters • Legacy Network Adapters • Fibre Channel Adapters

Creating a new virtual network adapter To add a virtual network adapter to a virtual machine, complete these steps: 1. Open the Hyper-V Manager. 2. Shut down the virtual machine on which you want to create a new virtual network adapter. 3. Right-click on the virtual machine and select the Settings command from the right-click menu.

299

Understanding Hyper-V in Windows Server 2012

4. When the Settings screen appears, click Add Hardware. 5. Select the Network Adapter option (Figure 10.7). 6. Click Add. Figure 10.7

Click Add Hardware, select the Network Adapter option and click Add.

7. Choose the virtual switch that you want the new network adapter to connect to (Figure 10.8).

300

Understanding Hyper-V in Windows Server 2012

Figure 10.8

Select the virtual switch that the new virtual network should connect to.

8. Click OK. 9. The newly created virtual network adapter will be listed in the virtual machine’s Settings page (Figure 10.9). Figure 10.9

The virtual machine’s Settings screen now lists two virtual network adapters.

301

Understanding Hyper-V in Windows Server 2012

Configuring bandwidth management Virtual network adapters support bandwidth throttling through HyperV’s Bandwidth Management feature (note that bandwidth management is not supported for legacy network adapters). You can configure bandwidth management either as a part of the virtual network adapter creation process, or you can configure bandwidth management later. The bandwidth management feature allows you to configure minimum bandwidth maximum bandwidth, or both. Enter bandwidth limits as numerical values equaling the number of megabits per second (Mbps) that you want to allow. For unrestricted bandwidth, use a value of zero. To enable bandwidth management for an existing virtual machine, complete these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine and select the Settings command from the right-click menu. 3. When the settings page appears, select the virtual network adapter for which you want to manage bandwidth (Figure 10.10). 4. Select the checkbox for Enable bandwidth management. 5. Optionally enter the minimum bandwidth usage in Mbps. 6. Optionally enter the maximum bandwidth usage in Mbps. 7. Click OK.

302

Understanding Hyper-V in Windows Server 2012

Figure 10.10

Select the Enable Bandwidth Management checkbox and specify the minimum and maximum bandwidth usage.

Adding a legacy network adapter Legacy network adapters are useful on virtual machines that do not have the Integration Services installed. The legacy network adapter provides network connectivity to virtual machines that do not have the ability to use a regular virtual network adapter. To add a virtual network adapter to a virtual machine, complete these steps: 1. Open the Hyper-V Manager. 2. Shut down the virtual machine on which you want to create a virtual network adapter. 3. Right-click on the virtual machine and select the Settings command from the right-click menu. 4. When the Settings screen appears, click Add Hardware (Figure 10.11). 5. Select the Legacy Network Adapter option. 6. Click Add.

303

Understanding Hyper-V in Windows Server 2012

Figure 10.11

Choose the Legacy Network Adapter option and click Add.

7. Choose the virtual switch to which the legacy network adapter will be connected. 8. Click OK. VLAN identification Both virtual network adapters and legacy network adapters support the use of VLAN identification. Virtual network adapters and legacy network adapters can be configured with VLAN identification during the adapter creation process or later. You can configure an existing virtual or legacy network adapter to use a VLAN by completing these steps: 1. Open the Hyper-V Manager. 2. Right-click on the virtual machine and select the Settings command from the right-click menu. 3. When the Settings screen appears, select the network adapter to which you want to assign VLAN identification (Figure 10.12). 4. Select the checkbox for Enable virtual LAN identification. 5. Enter a VLAN identifier number. 6. Click OK.

304

Understanding Hyper-V in Windows Server 2012

Figure 10.12

Select the Enable virtual LAN identifier check box, enter a VLAN ID and click OK.

NIC teaming The problem with sharing a single physical network adapter among multiple virtual machines is that the network adapter’s bandwidth must be shared by all of the virtual machines that use it. One way to overcome this limitation is to use NIC teaming. NIC teaming involves combining multiple physical network adapters into a single logical network adapter. The aggregate bandwidth of all the NICs in the team is available to any physical or virtual server that uses the NIC team. For example, if you build a team consisting of three 10-gigabit NICs, then the NIC team would be able to deliver 30 gigabits of bandwidth. NIC teaming is also useful for fault tolerance. Normally if a physical NIC fails, all of the virtual machines using the virtual switch that is bound to that NIC will lose network connectivity. In a teamed environment, however, the failure of a single physical NIC does not cause the entire NIC team to fail. The NIC team continues to function, but at reduced capacity. It is even possible to designate a physical NIC within the team as a hot spare (which Microsoft refers to as a "standby adapter"). Thus, if a NIC fails, the spare can take over so that the team can continue to operate at full capacity.

305

Understanding Hyper-V in Windows Server 2012

NIC teaming is not new in Hyper-V 3.0. Previous versions of Hyper-V allowed the use of a NIC team, but it had to be created at the hardware level using specialized NICs that were certified by the hardware vendor for teamed use. In contrast, Hyper-V 3.0 lets you create a NIC team at the software level. The physical NICs do not have to meet any special requirements. It is possible to use a random collection of commodity NICs from multiple vendors. Windows Server 2012 lets you create NIC teams consisting of up to 32 physical NICs. For the most part, you can use a NIC team in place of a physical NIC without issue. The only exceptions are situations in which the following technologies are used: • SR-IOV • Remote Direct Memory Access (RDMA) • TCP Chimney These technologies bypass the networking stack and send traffic directly to the physical network adapters.

Teaming modes Before you can build a NIC team, you have to decide which teaming mode you want the team to use. Windows Server 2012 supports three different teaming modes including: • Switch Independent – This mode allows you to build a NIC team without having to worry about the configuration of the physical switch. If you don’t know what type of teaming mode to use, then switch independent is the safe choice. • Static Teaming Mode – This mode is switch dependent and requires the physical switch to be configured in a way that identifies the links that make up the team. • LACP – This is a special type of dynamic NIC team that allows you to reconfigure the team on the fly as needed by adding or removing physical NICs.

Building a NIC team Before you create a NIC team, it is important to realize that any static IP address assignments that have been made to the individual network adapters included in the team will be lost. You will need to assign static IP addresses later to the team as a whole, rather than to individual NICs within the team. To build a NIC team, complete these steps: 1. Open the Server Manager. 2. Click on the Local Server option. 3. Click on the Disabled link next to the NIC Teaming option (Figure 10.13).

306

Understanding Hyper-V in Windows Server 2012

Figure 10.13

NIC teaming is configured through the Server Manager.

4. When the NIC Teaming dialog box launches, click the Tasks dropdown found in the Teams section and choose the New Team option (Figure 10.14). Figure 10.14

You can create a NIC team by choosing the New Team option.

5. Enter a name for the NIC team (Figure 10.15). 6. Select the network adapters to include in the NIC team.

307

Understanding Hyper-V in Windows Server 2012

Figure 10.15

Assign a name to the NIC team and specify the network adapters that should be included in the team.

7. Click the Additional Properties link. 8. Select the Teaming Mode that you want to use (Figure 10.16). Teaming modes were explained in the previous section. Figure 10.16

Specify your preferred teaming mode.

308

Understanding Hyper-V in Windows Server 2012

9. Specify the preferred load balancing mode. You can choose between Address Hash and Hyper-V Port. Address Hash balances network traffic across all of the NICs in the team and is usually the best choice. Hyper-V Port matches virtual machines to a specific physical NIC. The Hyper-V Port method tends to waste a lot of bandwidth; it might saturate some physical network connections, while leaving others with lots of free capacity. 10. If you have chosen to use a standby adapter then select the adapter you want to use as a standby spare. 11. Click OK. Once the NIC team has been created, the Control Panel will still show the individual NICs, but it will also display a teamed NIC (Figure 10.17). Individual NICs within the team should be configured so that the only protocol bound to the NIC is the Microsoft Network Adapter Multiplexor Protocol (Figure 10.18). Windows automatically configures teamed NICs correctly, but it is important to avoid manually altering the NIC’s configurations. If you need to assign a static IP address, you should assign it to the NIC team. Figure 10.17

Windows displays the teamed NIC alongside the physical NICs.

309

Understanding Hyper-V in Windows Server 2012

Figure 10.18

The NICs making up the team should be configured to use the Microsoft Network Adaptor Multiplexor Protocol and nothing else.

Note that Hyper-V does not automatically use the newly created NIC team. If you want Hyper-V to use the NIC team, you will need to bind the NIC team to a virtual switch (Figure 10.19). Figure 10.19

You need to bind the NIC team to a virtual switch so that Hyper-V can use the NIC team.

310

Understanding Hyper-V in Windows Server 2012

Virtual Fibre Channel One of the new Hyper-V networking features that has received the most attention is virtual Fibre Channel. In the past, some physical servers were not good candidates for virtualization because they required direct connectivity to Fibre Channel storage. Virtual Fibre Channel makes it possible for a virtual machine to directly access a Fibre Channel SAN without having to use the host operating system for connectivity.

Virtual Fibre Channel requirements Before you can use virtual Fibre Channel, some requirements must be met. First, the virtual machine must run a compatible operating system. Microsoft supports virtual Fibre Channel for virtual servers running Windows Server 2008, Windows Server 2008 R2 or Windows Server 2012. The next requirement is that the host server must contain at least one physical Fibre Channel adapter. The adapter must support N_Port Virtualization (NPIV). The NPIV feature must be enabled and the adapter must be connected to an NPIV-enabled SAN. It is worth noting that many of the Fibre Channel adapters that support NPIV disable NPIV by default. For example, Emulex LightPulse LPE1150-F4 Fibre Channel adapters fully support NPIV, but NPIV is disabled by default. In this case, you can enable NPIV support by using the OneCommand Manager utility provided by Emulex (Figure 10.20). Figure 10.20

You may have to enable NPIV support on your Fibre Channel adapter before you can use Hyper-V’s virtual Fibre Channel feature.

311

Understanding Hyper-V in Windows Server 2012

Live migration planning Although Hyper-V allows you to live migrate virtual machines that use virtual Fibre Channel, you must meet some additional requirements. First, each Hyper-V server that could potentially host a virtual machine that uses virtual Fibre Channel must be equipped with physical Fibre Channel connectivity to your SAN. The second requirement is that each Fibre Channel adapter must have two separate Word Wide Names (WWNs). During the live migration process, the host server releases one of the WWNs, but not the other. The destination host uses the recently released WWN to establish connectivity to the Fibre Channel storage. For a brief moment, both hosts are connected to the Fibre Channel storage, using the two WWNs. This allows the live migration to complete without losing storage connectivity in the process. Once the destination host has established storage connectivity, the source host releases its other WWN to the destination host and the live migration is completed.

Creating a virtual SAN The first step in implementing virtual Fibre Channel is to create a virtual SAN. To do this, complete these steps: 1. Open the Hyper-V Manager. 2. Right-click on the name of the host server and choose the Virtual SAN Manager command from the right-click menu (Figure 10.21). Figure 10.21

Virtual SAN Manager command in the shortcut menu.

3. When the Virtual SAN Manager opens, click on World Wide Names (Figure 10.22). 4. Make any necessary changes to the World Wide Names.

312

Understanding Hyper-V in Windows Server 2012

Figure 10.22

Make any required changes to the World Wide Names.

5. Select the New Fibre Channel SAN option and click the Create button(Figure 10.23). Figure 10.23

Select the New Fibre Channel SAN option and click the Create button.

6. Enter a name for the new Fibre Channel SAN (Figure 10.24). One common practice is to name the SAN after the underlying Fibre Channel Host Bus Adapter. 7. Select the checkbox next to the listing for the Fibre Channel adapter. 8. Click OK.

313

Understanding Hyper-V in Windows Server 2012

Figure 10.24

Enter a name for the new virtual SAN, select the check box for the Fibre Channel adapter and click OK.

Adding a virtual Fibre Channel adapter Once you have created a virtual SAN, adding it to a virtual machine is easy. To do so, complete these steps: 1. Open the Hyper-V Manager. 2. Shut down the virtual machine to which you want to add virtual Fibre Channel connectivity. 3. Right-click on the virtual machine and select the Settings command from the right-click menu. 4. When the Settings screen appears, click Add Hardware (Figure 10.25). 5. Select the Fibre Channel Adapter option. 6. Click Add.

314

Understanding Hyper-V in Windows Server 2012

Figure 10.25

Select the Fibre Channel Adapter option and click Add.

7. Select your virtual SAN from the Virtual SAN drop-down list (Figure 10.26). 8. If you need to modify the World Wide Node Names (WWNNs) or the World Wide Port Names (WWPNs), click the Edit Addresses button and make any required modifications. 9. Click OK.

315

Understanding Hyper-V in Windows Server 2012

Figure 10.26

Select your virtual SAN from the Virtual SAN drop-down list and click OK.

Share this e-book with your peers

316

Understanding Hyper-V in Windows Server 2012

Chapter 11

Backing up Hyper-V

317

Understanding Hyper-V in Windows Server 2012

Information Technology is driven by data! Every facet of IT, from decision making, to database management, to communications, to intellectual property finds its roots in data. We have evolved our entire industry around the absolute necessity of maintaining the integrity and accessibility of our data. The 2000s saw the rise of the mega-datacenter where hundreds of thousands of square feet of insanely secured and spectacularly supported infrastructure can house the ever-growing need to store and make accessible that precious data. Microsoft has played a quiet but dominant role in the push to drive the innovation of the datacenter. They have, by all accounts, built the largest, fastest, best distributed, portable, state-of-the-art datacenter infrastructure in the world. Data drives decision making and decision making drives business. Today businesses generate data at a staggering rate. One of the key functions of every IT environment is to ensure the absolute protection of the data, and this has translated into the two critical functions of data protection and disaster recovery. Cloud, cloud, cloud, cloud, cloud! The client/server networks of the past are being replaced with a new network design paradigm—cloud! Virtualization is the gateway technology to cloud. Virtual machines (VMs) are the core components of networks. This is a pretty big departure from the client/server networks of the past where hardware was the core component. Nowhere does this make a bigger difference than in data protection and disaster recovery.

Data protection in a virtual world One of the truly amazing benefits of virtualization with Hyper-V (or any other Type 1 hypervisor for that matter) is that the hypervisor provides a layer of abstraction between the physical hardware and the virtual machines. This is a really big deal! That layer of abstraction effectively means that hardware resources can be pooled together into an abstracted set and then allocated to VMs on an as needed basis. In Hyper-V this concept is referred to as a resource pool. When you consider data protection in conjunction with Hyper-V, it is important to begin with the realization that it is the virtual machine—not the physical disk—that is the core operating component of the virtual environment. It is also important to consider that the virtual machine is a conglomerate of components that together make up a functioning VM and its underlying OS, applications, services, files, settings, etc. In the past, the prevailing strategy for data protection was primarily made up of the functions of access protection (still as important as ever but not discussed in this chapter) and backup and recovery. In a client/server network the core component was the physical disk. The OS, the applications, the files, services and drivers were all directly tied to the physical disk. Because the disk was the core component of the network, the vast majority of solutions for backup and restoration operations were designed specifically to back up disks. Companies built powerful, and sometimes complex, software implementations focused on backing up the physical disk. The majority of those tools relied on client components or agents installed on the local disk to aid in the process of monitoring the disk, generating the backup, responding to calls from a centralized software console, and reporting and alerting functions. In those

318

Understanding Hyper-V in Windows Server 2012

days the term “server backup” had reference to a specific disk drive or drive set. Since everything associated with the server was generally associated with the physical disk and each disk was “owned” by a single server, if you successfully backed up the disk, you successfully backed up the server. Of course businesses also had dedicated arrays of disks loosely connected to servers with the sole purpose being to store data. Here again the central component was the physical disk, and the backup solutions utilized the exact same strategy of disk-focused backup, and the strategy worked very well, until… One of the most significant promises of virtualization is the consolidation of server workloads onto a single set of hardware. This consolidation promises decreased capital expenditures and increased utilization percentages. While both of those are awesome for the business, consolidation also brings with it a major challenge for the traditional backup software. Virtualization is NOT centered on the physical disk. The core component of virtualization, and the cloud, is the virtual machine. Rule #1 Physical backup is not virtual backup! If you try to use your traditional backup and recovery practices (which are focused on backing up disks) they will not prove effective on your virtual machines.

How do you back up a VM in Hyper-V? That’s a really great question! Microsoft has provided a really great answer. It’s called VSS. Way back in 2003 Microsoft introduced something called the Volume Shadow Copy Service (VSS), which among other things allowed the user to make and keep multiple versions of files. In the event of loss, corruption, or a simple desire to go back to the way things used to be, VSS made it possible to easily revert to an earlier version of a file. See: http://technet.microsoft.com/en-us/library/cc757854(v=WS.10).aspx The true genius behind VSS was that it is file based (volume based is the technically correct term) and not physical disk based. VSS was relatively underappreciated and underutilized until the introduction of Hyper-V in 2008. At this time there were several obvious uses for a file-based tool like VSS that would maintain previous versions of files. Remember the majority of a Hyper-V virtual machine is contained within a single .vhd or .vhdx file. Microsoft went on to make direct recommendations about the benefits of using the VSS process to back up virtual machines and directly answered the question “How do you back up a VM in Hyper-V?” You use VSS!

VSS VSS is not an application. You won’t find it on the Start menu. It is a service and a process with multiple parts used to make image copies of files. In this particular instance those files are associated with Hyper-V. The VSS process uses a couple of different components (see Figure 11.1).

319

Understanding Hyper-V in Windows Server 2012

Figure 11.1

VSS Requestor Volume Shadow Copy Hyper-V VSS Writer

Virtual Machine VSS Requestor – As its name suggests, this software component handles various requests to the Volume Shadow Copy Service vssvc.exe. In the case of Hyper-V backup, it is looking for information about available resources to write the image of a given virtual machine. That write is going to be accomplished by an available VSS Writer. The VSS Requestor is built by the software developer unless you decide to use Windows Backup, in which case Microsoft has included a built-in VSS Requestor. Microsoft provides the Volume Shadow Copy Service SDK free in the Microsoft Download Center for those interested in the process of building a VSS Requestor. Vssvc.exe – The Volume Shadow Copy Service provides the central control infrastructure for the VSS process, handling incoming requests from requestors, identifying writers, relaying availability info back to the requestor and requests to the VSS Writer. VSS Writer – Provides the capability to write the image of the virtual machine while providing the important function of application quiescence (or quieting). This ensures that the backup of the virtual machine includes valid copies of the underlying applications and their data in a complete and usable format. In the case of backing up Hyper-V, Microsoft has provided a specific writer called the Hyper-V VSS Writer. Hyper-V VSS Writer metadata – The technical information about the actual location of the data, what should be included as part of the backup image, how the data is structured, and the configuration information for the virtual machine is all contained as part of the Hyper-V VSS Writer metadata. This information is used in conjunction with the Hyper-V VSS Writer as it processes the request for an image or backup of an existing Hyper-V VM. The components of the VSS process work in conjunction with one another to back up a virtual machine. One of the benefits of using the VSS process is that, unlike backing up physical disks, there is no need to install or configure any agents or client components on the VM in order to accomplish the backup.

320

Understanding Hyper-V in Windows Server 2012

Some cheese for your whine Change happens! There will be those who have spent lots of time, money and effort to build a backup infrastructure focused entirely on the physical disk and who will want to continue using that infrastructure in spite of the necessity for change. While the VSS process is the preferred method of backing up virtual machines, it is still technically possible (however ill advised) to use the old methods of agent-based backups to complete the task of backing up your virtual machines. In order to be successful you will be left to install the same agents you used in the old physical environment on each of your virtual machines and to expend additional time and effort to build your virtual machines so that they meet the old client/server network standards. The additional time and effort at each step of the process makes this approach prohibitive, especially in light of the dramatic benefits of choosing a VSS-based backup software solution. Could it be done? Yes! Should it be done? No!

Windows Backup As in previous versions of Windows Server, Microsoft has included Windows Backup in Windows Server 2012. This edition of Windows Backup includes a mechanism for VSS-based backups of Hyper-V virtual machines. The tool is absolutely free. It will successfully complete a VSS full or VSS copy of a virtual machine. Like previous editions of Windows Backup, there are no frills in the form of additional options. Here is how it works. In order to use Windows Backup you must add this feature in the Add Roles and Features wizard in Server Manager. Once in place, you can kick off the tool from the desktop icon or from the tools menu in Server Manager. Figure 11.2

Backups in Windows Backup are built under the Local Backup menu option in the Actions pane on the right side of the main screen (Figure 11.2, above). You can choose Backup Schedule or a Backup Once option from the Actions pane. This example uses the Backup Once option. This launches the Backup Once Wizard (See Figure 11.3).

321

Understanding Hyper-V in Windows Server 2012

Figure 11.3

You have the option of choosing to build a one-time backup based on the settings in your scheduled backups or to select the Different Options radio button, which will give you the chance to view all of the options and settings and build a unique set for this individual backup job. After selecting an option, click Next to continue to the next step in the wizard. Figure 11.4

322

Understanding Hyper-V in Windows Server 2012

Remember that Windows Backup is a traditional disk-focused backup utility, so the first option is to back up the full server (Figure 11.4). This assumes that your server is running in the old client/server model. In order to back up a VM, you will need to choose the Custom radio button so that a VSS backup may be initiated. Click Next to select items for backup. Figure 11.5

Next you get to choose what items to include in the backup by choosing the Add Items button (Figure 11.5). This launches the dialog shown in the next figure. Figure 11.6

323

Understanding Hyper-V in Windows Server 2012

Drill down to the desired VM and select it for backup, as shown in the Select Items dialog (Figure 11.6). There are two other big things to notice on this screen, indicated by the yellow exclamation icons. First, notice that if you have used data deduplication on the volume that contains this VM, the data will be backed up in the unoptimized form, meaning at its original size. Second, in order to create the backup, the virtual machine will be placed in saved state mode, meaning that any workload this VM supports will be at least temporarily unavailable. After you have selected items to include in the backup, click OK. Now you can move to the advanced settings for the backup shown in the next step of the Backup Once Wizard. Figure 11.7

Click the Advanced Settings button on the Backup Once Wizard (Figure 11.7). This takes you to the Advanced Settings dialog (Figure 11.8).

324

Understanding Hyper-V in Windows Server 2012

Figure 11.8

In Windows Backup, it is possible to set exclusions of files that you do not want to include in the backup. The Advanced Settings dialog is also where you are asked to choose whether you would like to make a VSS copy backup, which will retain the existing application log files, or make a VSS full backup, which will truncate the existing log files for the applications (Figure 11.8). After you have made a selection, click OK to move to the next step. Figure 11.9

325

Understanding Hyper-V in Windows Server 2012

Next you are given the choice of the type of destination for the backup job. Will it be housed on locally attached storage or will you use a remotely shared folder? In this example, the radio button for Local drives has been selected (Figure 11.9). Click Next to select the backup destination. Figure 11.10

Now you are given the opportunity of choosing the volume where you want the job to be stored upon completion, and you are also given summary statistics about the volume (Figure 11.10). Select the destination and click Next.

326

Understanding Hyper-V in Windows Server 2012

Figure 11.11

After you have defined the destination, the Backup Once Wizard displays a summary confirmation page. If the confirmation is correct, you can click the Backup button to start the process (Figure 11.11). Figure 11.12

327

Understanding Hyper-V in Windows Server 2012

The backup will proceed until completion and present summary statistics on status and size of data transferred. In this case, note that the entire 8.35 GB was transferred (Figure 11.12). There is no compression or deduplication in Windows Backup. Windows Backup is a general purpose, no frills, VSS capable backup tool.

Windows recovery It is often said that the whole point of backup is recovery. In the case of Windows Backup, the recovery process proceeds as follows. First, open the Windows Backup application from the tools menu from Server Manager or the Windows Backup icon on the desktop. Choose Recover from the Actions pane. This launches the Recovery Wizard. Figure 11.13

Notice that the information shown in the first step of the Recovery Wizard indicates that you can recover files, applications, volumes, or the system state; however, in this case, none of this applies because you are recovering a VM (Figure 11.13). You can really only recover the VM that you backed up in its entirety. There just isn’t a granular approach to recovering VMs in Windows Backup. This backup happens to be stored on a volume attached to this server. Click Next on the wizard to select the backup date.

328

Understanding Hyper-V in Windows Server 2012

Figure 11.14

Here you locate the backup file based on the schedule in which the backup completed. Select the appropriate date from the calendar to see available backups in the recoverable items section (Figure 11.14). Click Next on the wizard to select the recovery type. Figure 11.15

329

Understanding Hyper-V in Windows Server 2012

In this example, you are recovering a Hyper-V VM to its original location (Figure 11.15). Click Next on the wizard to select the items you wish to recover. Figure 11.16

Drill down to select the VM backup to restore (Figure 11.16). Click Next on the wizard to specify recovery options. Select the desired location for recovery. This is one place where Windows Backup exceeds expectations as it will allow recovery to an alternate location or even make a copy to a folder.

330

Understanding Hyper-V in Windows Server 2012

Figure 11.17

After choosing the recovery option, wait for the process to complete (Figure 11.17). Windows Backup is a decent utilitarian approach to backup and recovery of a VM in Hyper-V. It does not perform compression, deduplication or item-level recovery. Its biggest draw is the fact that it is free. Imagine a scenario where all the desired functionality were included in a software package while still maintaining the free price tag.

The best backup Veeam® builds the best backup software for Hyper-V. It is powerful, easy to use and affordable. In fact, Veeam builds a free edition of its backup software. The following discussion explains exactly how Veeam Backup Free Edition works. Veeam offers an easy-to-use interface based on Microsoft User Interface design guidelines.

331

Understanding Hyper-V in Windows Server 2012

Figure 11.18

From the main screen, it is easy to expand the Hyper-V server and see the virtual machines. In this case, you can see that the VM is actually up and running (Figure 11.18). Veeam will complete the backup without stopping, pausing or moving the VM to the saved state mode. Select a VM and choose Veeam Zip from the ribbon. This launches the dialog shown in the next image. Figure 11.19

Browse to a location where you want the completed backup to be stored and then click OK (Figure 11.19). This launches a summary dialog that shows how much data has been backed up and the success.

332

Understanding Hyper-V in Windows Server 2012

Figure 11.20

Click the Show Details button (note that this button toggles to Hide Details) in order to get all the information about each processing backup job (Figure 11.20). Wait for the backup to complete. The process is simple. It is important to note that Veeam Backup Free Edition includes the compression and deduplication functions. In this example, the VM was 8.3 GB and after compression and dedup, 3.3GB was transferred to the backup repository. The tool calculated the rate of compression at 2.4x. Pretty cool!

Recovering Hyper-V VMs with Veeam Backup The process of recovery with Veeam Backup Free edition is powerful. It begins by choosing Restore from the ribbon (Figure 11.21). Figure 11.21

When you select the Restore button, you will be prompted to select the backup file of your choice.

333

Understanding Hyper-V in Windows Server 2012

Figure 11.22

After you select the backup file, click Open on the dialog shown above (Figure 11.22). Figure 11.23

Veeam Backup Free Edition will load the selected backup file and show you its properties (Figure 11.23). Next, click the Restore button on the .vbk Properties dialog. Although Veeam Backup Free Edition will restore the full VM, it will also allow you to restore the VM files, such as the configuration, settings or other files necessary to run the VM beyond its .vhd or .vhdx file. Finally, you can choose to restore files from within the Windows OS of the VM, as shown in the next image. For this example you can choose files from within the Windows OS.

334

Understanding Hyper-V in Windows Server 2012

Figure 11.24

When you choose to recover files from within the Windows OS, Veeam Backup Free Edition will mount the operating system and present you with a nicely structured Windows Explorer-like view of the files (Figure 11.24). At this point you can simply browse to the files or folders you want to recover and then right-click and choose Restore from the right-click menu. Veeam Backup Free Edition is the clear choice for a powerful, easy-to-use, affordable backup for Hyper-V. Veeam also builds a backup toolset you can purchase called Veeam Backup & Replication, which adds scheduling functionality, multi VM job functions and VM replication capabilities. Veeam Backup Free Edition and the Free Trial Version of Veeam Backup & Replication can be downloaded at the veeam website www.veeam.com.

Share this e-book with your peers

335

Understanding Hyper-V in Windows Server 2012

Chapter 12

Automation and Orchestration

336

Understanding Hyper-V in Windows Server 2012

Introduction This chapter will be a bit of a departure from previous chapters in that it will focus less on the basics of Hyper-V features, installation and configuration and more on how to automate deployment and administrative actions on the Hyper-V platform in an enterprise environment. With the rise of the dynamic datacenter, cloud computing (private, public and hybrid cloud), the focus on service-driven IT has led to an increased focus on advanced automation and self-service, in which IT removes itself as the bottleneck to request fulfillment through process automation. In this model, IT becomes a service-driven organization rather than a technologydriven organization, providing service offerings through a service catalog, many of which may require little manual effort beyond approval of the request in a service desk/ticketing system. With that in mind, this chapter focuses less on Hyper-V in Windows Server 2012 and more on the tools and strategies available to automate and orchestrate advanced VM, application and virtual network deployment on Hyper-V. While PowerShell improvements in v3 secure its place as a go-to toolset in Hyper-V administration and management, it is not an end-to-end management solution for the entire virtualization lifecycle. Fortunately, in parallel to development of Windows Server 2012, Microsoft has been hard at work updating its System Center 2012 management suite to support the latest version of its Server OS and hypervisor. In Service Pack 1 for System Center 2012, Microsoft officially added support for management of Windows Server 2012 Hyper-V. As you saw in chapter 5, PowerShell has a rich set of cmdlets for managing Hyper-V. While the improvements in PowerShell in Windows Server 2012 for managing Hyper-V are significant, any organization with more than a handful of Hyper-V servers will require centralized management capabilities to effectively manage multiple Hyper-V hosts and VM guests. This is where the Microsoft System Center 2012 management suite comes into play (see Figure 12.1). The focus in this chapter will be limited primarily to two System Center 2012 components: • System Center 2012 Virtual Machine Manager (VMM), which is the standard for managing Hyper-V in the enterprise • System Center 2012 Orchestrator (Orchestrator), which provides runbook automation capabilities with out-of-the-box integration with the other System Center components (including VMM), Active Directory and third‑party platforms These two components together provide powerful automation capabilities for Hyper-V virtualization deployment management, which you will explore in depth in this chapter.

337

Understanding Hyper-V in Windows Server 2012

Figure 12.1 – Components of the System Center 2012 management suite

This chapter will spend little time on simple automation, but instead will focus more on the orchestration of processes. Although it may seem that two terms are used for the same concept, they are actually quite different. Automation is essentially advanced scripting, while orchestration requires automation coupled with decision points based on runtime conditions and business requirements (such as change management requirements). Automation is the process of automating a specific task, usually through a scripting language such as PowerShell. The task typically has one goal, though it may require several steps to achieve that goal. An example is “bring this server down for maintenance.” This may require spinning down connections to an application, stopping specific processes and then taking the application offline…but the automation is of a specific task. Orchestration, on the other hand, is the automation of a complete process. In the case of cloud computing and IT, this can also be accomplished using scripts but more often involves the use of APIs. Orchestration links a set of automated tasks into a single process (IT operational and/or business processes) and may span multiple devices, applications, solutions and even datacenters. “Bring this server down for maintenance” may actually be a single task in a larger process that is “Deploying a new version of an application.” The subtle difference between automation and orchestration is important primarily because the former is focused on automating a concrete set of steps normally handled manually but that are performed to a device or component. The latter often requires participation of intelligent infrastructure components and decision logic based on runtime conditions in the components involved in the orchestration (such as resource utilization on Hyper-V hosts as part of the criteria in determining VM placement). The infrastructure is an active participant in orchestration.

338

Understanding Hyper-V in Windows Server 2012

Workflows in PowerShell v3 At this point, it’s likely that you already appreciate the role of PowerShell in managing Hyper-V. PowerShell definitely plays a role in automating deployment, administration and maintenance in Hyper-V environments of all sizes. In PowerShell version 3, the Windows Workflow Foundation engine is integrated into PowerShell, easing the process of automating long-running, large-scale, or complex tasks that require multiple steps across multiple machines. Traditionally Windows Workflow has been a developer-only tool requiring Visual Studio and a lot of code to create a solution. In the latest PowerShell release, Microsoft has elevated workflow to an in-the-box solution that IT Pros can leverage to easily create a solution using their existing PowerShell scripting skills. Workflow provides direct support for parallel execution, retry of failed operations, and the ability to suspend and resume operations. For example, a workflow can detect a problem that requires manual intervention, notify the operator of this condition and then suspend operations until the operator corrects the situation and resumes the workflow. Authoring has been simplified through the extension of the PowerShell language with the workflow keyword. You can now easily author a workflow using the tools that ship in all Windows Server 2012 versions. The behavior of a workflow is different from a simple script or function as it includes a few more rules. However, if you know how to write a PowerShell function, you already know most of what you need to know to write a workflow. Authoring workflows using PowerShell is much easier than working with XAML, and for most IT Pros it is much easier to understand than Workflow designer tools like Visual Studio. Here is a sample PowerShell workflow that provisions five Hyper-V VMs, each with a differential disk referencing the master disk (goldimage.vhdx). The VMs will all be placed in the folder specified by the $VMBaseLoc variable, assigned to the virtual network referenced by $VMNetwork, and finally, each VM will be started.

Figure 12.2 PowerShell workflow for bulk Hyper-V VM provisioning

339

Understanding Hyper-V in Windows Server 2012

While these new PowerShell workflow capabilities are powerful, they are not a full enterprise solution for Hyper-V virtualization management and automation.

Automating Hyper-V in the enterprise with System Center 2012 System Center 2012 delivers very powerful management capabilities, so it is quite easy to get started developing advanced orchestrated Hyper-V provisioning scenarios.

Installing VMM and Orchestrator To follow the step-by-step deployment examples presented in this chapter, you will need to install the System Center 2012 VMM and Orchestrator components. You can install each of these components in a single Hyper-V VM (and you can install both in the same VM). You can download VMM and Orchestrator from the Microsoft website at http://technet.microsoft. com/en-US/evalcenter/hh505660.aspx?ocid=otc-f-corp-jtc-DPR&wt.mc_ id=TEC_103_1_4 • Instructions for installing VMM can be found on the Microsoft website at http://technet.microsoft.com/en-us/library/gg610617.aspx. To follow the examples in this chapter, you should install a VMM management server and the VMM console. You may install both on the same server. • Step-by-step instructions for installing Orchestrator can be found on the Microsoft website at http://technet.microsoft.com/en-us/library/ hh420336.aspx. This is a short and easy installation once you have a SQL Server instance in place. You may install some or all of these components on the same server. Since the Orchestrator database is fairly lightweight, you can install it on a shared SQL 2008 R2 or SQL 2012 server. To follow the examples in this chapter, you should install • An Orchestrator management server • The Orchestrator database • The Runbook Designer console • Download, register and deploy the VMM Integration Pack for Orchestrator (necessary for interacting with VMM and Hyper-V) • Download from http://www.microsoft.com/en-us/download/details. aspx?id=34611&WT.mc_id=rss_alldownloads_all) • Instructions on registering and deploying an integration pack at http://technet.microsoft.com/en-us/library/hh420346.aspx • Configure Orchestrator Connectivity to VMM (included in VMM Integration Pack Guide) Microsoft has also recorded a short YouTube video on how to install Orchestrator and import integration packs, which you can view at http://www. youtube.com/watch?v=a7F1d87vYnI

340

Understanding Hyper-V in Windows Server 2012

Stop here and complete installation of VMM and Orchestrator before moving on to the examples in the remainder of this chapter.

Adding a Hyper-V Host to VMM Have you already installed VMM? If not, go back to the ‘Installing VMM and Orchestrator’ section earlier in this chapter and refer to the installation resources provided. Once you have VMM installed, the next step is to add your Hyper-V server(s) to VMM for management. Completing these steps installs the VMM management agent on your Hyper-V host(s). To add a Hyper-V server to VMM, perform the following steps: 1. From the desktop, launch the VMM Admin Console with a user that is a member of the VMM Administrators user role 2. From the Navigation pane, select the Fabric workspace, as shown in Figure 12.3.

Figure 12.3 – Verifying Your Hyper-V host status in the VMM Admin Console

3. From the ribbon, select Add Resources → Hyper-V Hosts and Clusters, as shown in Figure 12.4. This will launch the Add Resource wizard, as shown in Figure 12.5.

341

Understanding Hyper-V in Windows Server 2012

Figure 12.4 – The Add Resources menu in the Fabric workspace

4. Assuming your Hyper-V server is a member of an Active Directory domain; select the radio button labeled Windows computers in a trusted Active Directory domain on the Resource location screen, as shown in Figure 12.5.

Figure 12.5 – Selecting Hyper-V host location

5. On the Credentials screen, select Manually enter the credentials and provide credentials with local administrator rights on the Hyper-V host, as shown in Figure 12.6.

342

Understanding Hyper-V in Windows Server 2012

Note: For additional reading on the advantages of using Run As Accounts in VMM and how to configure them, see ‘Configuring Run As Accounts in VMM’ in the VMM online documentation on the Microsoft website here.

Figure 12.6 – Manually entering Hyper-V administrator credentials

6. On the Discovery scope screen, select the radio button for Specify Windows Server computers by names and enter the names of the Hyper-V server(s) you wish to add to management in VMM, as shown in Figure 12.7.

Figure 12.7 – Specifying Hyper-V hosts for discovery

343

Understanding Hyper-V in Windows Server 2012

7. On the Target resources screen, select the checkbox next to the Hyper-V servers in the list you wish to add to manage from VMM, as shown in Figure 12.8.

Figure 12.8 – Selecting Hyper-V hosts to bring under management

8. On the Host settings screen, select the host group in which you would like to add your Hyper-V server(s). The All Hosts group is the default value and will work for this example, as shown in Figure 12.9.

Figure 12.9 – Select the host group for new Hyper-V hosts

344

Understanding Hyper-V in Windows Server 2012

9. On the Migration Settings screen, ensure that the following items are selected as shown in Figure 12.10: • Turn on incoming and outgoing live migrations • Use Credential Security Support Provider • Use any available network

Figure 12.10 – Specifying migration settings in the Add Resource wizard

10. On the Summary screen, review your selection and then click Finish to add the Hyper-V host to management in VMM. In the Jobs workspace, you will see a running job titled ‘Add virtual machine host’ as shown in Figure 12.11.

Figure 12.11 – Job details for the ‘Add virtual machine host’ job

345

Understanding Hyper-V in Windows Server 2012

Note: While basic host network settings are imported automatically, the advanced networking capabilities of Hyper-V and VMM are nearly endless. For a deep dive, see “How to Configure Global Network Settings in VMM” here.

Creating a VM template from an existing VM VMM makes it very easy to create a VM template in Hyper-V from an existing VM you have created previously. However, since the process of creating a template involves running Sysprep to generalize the operating system, it makes the VM unusable. You can work around this by simply making a copy of the existing VM, through a process known as cloning.

Step 1: Clone an existing VM You cannot clone a VM with snapshots, so prepare the VM for cloning by merging (deleting) any existing snapshots. Also, you cannot clone a running VM, so your next step is to shut down the VM you intend to clone. You can complete these two steps either in Hyper-V Manager or in the VMM Admin Console: To merge snapshots (called checkpoints in VMM): In the VMM console in the VMs and Services workspace, right-click on the VM, select Properties and then the Manage Checkpoints tab. Process the snapshots just as you would in Hyper-V Manager. To shut down: In the VMM console in the VMs and Services workspace, you can shut down gracefully by selecting the VM followed by the Shut Down button on the ribbon, visible in Figure 12.12 1. To clone your VM, select your VM from the list in the Virtual Machine tab of VMs and Services workspace. 2. From the Create menu on the Virtual Machine tab, select Clone as shown in Figure 12.12.

Figure 12.12 – The Clone option from the Create menu

346

Understanding Hyper-V in Windows Server 2012

3. On the Specify Virtual Machine Identity screen, type the name for the cloned VM. Popular options here include -Clone, or a name descriptive of the operating system running in the VM. Since these instructions are for cloning a Windows Server 2012 VM, the example uses the name WS2012-Clone. In the Description field, document the name of the VM you are cloning, as shown in Figure 12.13.

Figure 12.13 – Specify Virtual Machine Identity screen

4. On the Configure Hardware screen (shown in Figure 12.14), you can change any of the default hardware settings related to the clone VM. Configurable settings include CPU, memory, disk, network, as well as a number of advanced settings, including high availability, CPU priority, memory weight and virtual NUMA. Any changes configured here will be reflected in the VM clone and, ultimately, in the VM template you’ll create from this clone in the next step.

347

Understanding Hyper-V in Windows Server 2012

Figure 12.14 – Configure Hardware screen

5. On the Select Destination screen, you will select where the new VM will be placed. You can place the VM directly on a Hyper-V host (or host cluster) or deploy it to a private cloud, as shown in Figure 12.15. For this example, choose to deploy directly to a Hyper-V host.

Figure 12.15 – Select Destination screen

348

Understanding Hyper-V in Windows Server 2012

Note: You can configure private clouds and deploy VMs to clouds hosted on Hyper-V in VMM. You can read more about the cloud capabilities in VMM in “How to Create a Cloud in VMM 2012” on the Microsoft site here. 6. On the Select Host screen, Hyper-V hosts available for placement are shown in order of suitability (availability for placement) and resource availability (available compute, network and storage resources). If you only added one Hyper-V host, the process will be unchanged; you will simply see only the one option for deployment. If the VM cannot be created, you can find details on the blocking issue on the Rating Explanation tab above the bottom window on the Select Host screen, as shown in Figure 12.16.

Figure 12.16 – Select Host screen

7. On the Select Path screen, you select the location on the Hyper-V host where the clone will be placed. You can click the Browse button to choose an alternate storage location if you don’t like the default selection, as shown in Figure 12.17.

349

Understanding Hyper-V in Windows Server 2012

Figure 12.17 – Select Path screen

8. On the Select Networks screen, you can change the default adapter settings, which will match those of the source VM you are cloning by default. Since you are using a VM template created on the Hyper-V host you are deploying to, you can accept the defaults on this screen.

Figure 12.18 – Select Networks screen

350

Understanding Hyper-V in Windows Server 2012

9. On the Summary screen, confirm your settings and then click the Create button to create the new VM, which will become your first VM template. The Summary screen is shown in Figure 12.19.

Figure 12.19 – Summary screen

Step 2: Create a VM template from the clone Now, you are ready to create a VM template from this copy of the existing virtual machine on your Hyper-V host. 1. In the VMM Admin Console, open the Library workspace. 2. On the Home tab, in the Create group, click Create VM Template. This launches the Create VM Template wizard, as shown in Figure 12.20.

Figure 12.20 – Select Source screen

3. On the Select Source page, click From an existing virtual machine that is deployed on a host, and then click Browse (shown in Figure 12.20). This launches the Select VM Template Source screen shown in Figure 12.21.

351

Understanding Hyper-V in Windows Server 2012

Figure 12.21 – The Select VM Template Source screen

4. In the Select VM Template Source dialog box, click the VM clone you created earlier as the VM to convert into a template, click OK and then click Next. 5. On the VM Template Identity page, provide a name for the VM template and then click Next. Warning: A warning message advises you that creating a template will destroy the source virtual machine, and that any user data on the source VM may be lost. This is expected, as the template creation process runs Sysprep on the target VM. To continue, click Yes. 6. On the Configure Hardware page, you can change default settings for CPU, memory and other hardware components. When complete, click Next. Important: Under the Bus Configuration heading, make sure to verify that the virtual hard disk containing the operating system has the ‘Contains the operating system for the virtual machine’ checkbox selected. If this is not the case, any VM deployments you attempt with this template will fail.

352

Understanding Hyper-V in Windows Server 2012

Figure 12.22 – The Configure Hardware screen

7. On the Configure Operating System page, you can configure the guest operating system settings. After you have configured the guest operating system settings, click Next. Tip: If you want the VMs you deploy from this template to join an Active Directory domain automatically, make sure to select Domain / Workgroup (under the Networking heading) and provide the domain name and credentials to join the VM to Active Directory, as shown in Figure 12.23.

Figure 12.23 – The Guest Operating System screen

353

Understanding Hyper-V in Windows Server 2012

8. On the Select Library Server page, click the library server for the VM, as shown in Figure 12.24, and then click Next.

Figure 12.24 – The Select Library Server screen

9. On the Select Path page, click Browse as shown in Figure 12.25.

Figure 12.25 – The Select Path screen

10. When you click the Browse button, you will be presented with the Select Destination Folder screen shown in Figure 12.26, where you can select the folder in the library share where you want to store the VM template. Select the folder where you intend to store your VM templates, and then click OK.

354

Understanding Hyper-V in Windows Server 2012

Note: If you like to keep things tidy, you can click the Explore directory link, which opens File Explorer to the root of the library, allowing you to create folders of your own.

Figure 12.26 – The Select Destination Folder screen

11. On the Summary page, you can review your selections to confirm the settings for the template, and then click Create.

Figure 12.27 – The Summary screen

355

Understanding Hyper-V in Windows Server 2012

The Recent Jobs window will then pop up, and a job named Create Template will appear as in progress. If you double-click on the running job, you will be presented with detailed steps of the job in progress as shown in Figure 12.28.

Figure 12.28 – The Recent Jobs window

When the job completes successfully, your VM template is ready to use!

Testing Your VM template: Create and deploy a VM from template It’s a good idea to deploy a VM to ensure your template is functional before progressing to more advanced scenarios. 1. Start by selecting the VMs and Services workspace in the VMM Admin Console. 2. On the Home tab, in the Create group, click the Create Virtual Machine drop-down arrow, and then click Create Virtual Machine as shown in Figure 12.29. This launches the Create Virtual Machine wizard.

Figure 12.29 – Launching the Create Virtual Machine wizard

3. On the Select Source page, select the radio button labeled Use an existing virtual machine, VM template, or virtual hard disk. Click Browse and select the VM template you just created, as shown in Figure 12.30.

Figure 12.30 – The Select Source screen

356

Understanding Hyper-V in Windows Server 2012

4. In the Select Virtual Machine Source dialog box, click the appropriate VM template as shown in Figure 12.31, and then click OK. (Your VM template name may vary from that in the figure)

Figure 12.31 – Selecting the source VM template

5. On the Select Source page, click Next . 6. On the Specify Virtual Machine Identity page, enter a name for your VM and provide a description as shown in Figure 12.32, and then click Next.

Figure 12.32 – Selecting the source VM template

7. On the Configure Hardware page, either select the profile you want to use from the Hardware profile list, or configure the hardware settings manually. After you have configured the hardware settings, click Next. Note: If you configure a network adapter to use static IP addresses, you must also set the MAC address to static. 8. On the Select Destination page, select the Place the virtual machine on a host option as shown in Figure 12.33

357

Understanding Hyper-V in Windows Server 2012

Figure 12.33 – Selecting the destination where the VM will be placed

9. On the Select Host page, view the ratings, select the Hyper-V host on which you want to deploy the VM as shown in Figure 12.34, and then click Next. The host suggestions are based on a 0-5 star rating generated by the Intelligent Placement feature of VMM. If you want to read more about how this VMM feature works, see Understanding Virtual Machine Placement and Ratings in VMM on the Microsoft website.

Figure 12.34 – The Select Host screen

10. On the Configure Settings page, review the settings for the VM. This is your opportunity to change placement location (drive letter and path), VM network settings, VM name, etc. as shown in Figure 12.35 • In Locations, either accept the default VM path on the host for storing the VM files or click Browse to specify a different location. Optionally select the Add this path to the list of default virtual machine paths on the host check box.

358

Understanding Hyper-V in Windows Server 2012

• In Operating System Settings, click Identity Information. You can either accept or change the computer name. • In Networking, you can click a network adapter to view the configured network settings. • In Machine Resources, click Virtual Hard Disk, review and optionally modify the settings and then click Next.

Figure 12.35 – The Configure Settings screen

11. On the Add Properties page, you can configure the action to take when the host starts or stops. To prevent the VM from being migrated by PRO or dynamic optimization (the VMM features that dynamically distribute guest load across Hyper-V host clusters), you can also select the Exclude virtual machine from optimization actions check box shown in Figure 12.36. When you are finished with this step, click Next.

Figure 12.36 – The Add Properties screen

12. On the Summary page, confirm the settings and then click Create.

359

Understanding Hyper-V in Windows Server 2012

Orchestration concepts for advanced VM deployment scenarios Before diving hands-on into a more advanced orchestration example, it will be helpful to take just a couple of minutes to learn a few basic concepts related to Orchestrator. Orchestrator automation capabilities are based on the concept of runbooks (sometimes referred to as workflows), which are visual representations of your datacenter processes as they are automated in Orchestrator. You create runbooks by dragging and dropping activities into a workspace in the Runbook Designer (the primary administration and authoring interface of Orchestrator) and connecting them with links, as shown in Figure 12.37

Figure 12.37 – The Runbook Designer Console in Orchestrator 2012

Runbook Automation (RBA) is the ability to define, build, orchestrate, manage and report on runbooks that support system and network operational processes. This capability allows IT professionals to automate tasks in a Visio-like interface with a minimal need for programming and scripting (notice that this is ‘minimal need for scripting,’ not ‘without scripting’). RBA using Orchestrator can cross multiple IT management disciplines in a single automation sequence, integrating multiple IT management tools and interacting with all types of infrastructure elements to automate processes ranging from simple, such as automating self-service deployment of a VM, to the complex, such as automating self-service deployment of a group of VMs (a service). You can easily incorporate additional steps, such as sending the requestor an email notification that his VM is ready, or even adding the requestors’ departmental group to the local administrators’ group in the VM(s), which you would likely find much more challenging with script alone. While Orchestrator reduces the need for scripting, it does not eliminate the need for PowerShell in managing Hyper-V. As you have seen in the previous chapters of this book, Hyper-V cmdlets in Windows Server 2012 are fantastic for carrying out a variety of administrative tasks remotely and in bulk—all without the need for the Windows UI. Try using PowerShell to manage Hyper-V on Windows Server 2012 on a daily basis, where it meets a need not met by System Center.

360

Understanding Hyper-V in Windows Server 2012

Runbook automation (Orchestration) is really taking automation to the next level. In the sections that follow, you will learn about some of the core principles of runbook automation in Orchestrator, helping paint a picture of the possibilities of Hyper-V and virtualization management with System Center 2012. Activities and integration packs Orchestrator comes with several dozen product-agnostic activities that perform a variety of functions; these are known as Standard Activities. To expand and customize the functionality of Orchestrator, you can add additional product-specific activities, contained in packages known as integration packs (IPs). Currently, there are System Center IPs with product-specific activities available for each member product in the System Center 2012 suite, as well as many third-party applications, including several network monitoring platforms and service desk products. You can register and deploy integration packs using the Deployment Manager interface. You can even download communitydeveloped integration packs and runbook samples from codeplex.com or the TechNet Gallery. The activities in the VMM 2012 RTM Integration pack are shown below. • Create Checkpoint • Create New Disk from VHD • Create Network Adapter • Create New Disk • Create User Role • Create VM from Template • Create VM from VHD • Create VM from VM • Get Checkpoint • Get Disk • Get Network Adapter • Get User Role • Get VM • Manage Checkpoint • Move VM • Remove User Role • Remove VM • Repair VM • Resume VM • Run VMM PowerShell • Script • Shut Down VM • Start VM • Stop VM • Suspend VM

361

Understanding Hyper-V in Windows Server 2012

• Update Disk • Update Network Adapter • Update VM • Update User Role Property • Update User Role Quota In the Service Pack 1 release of System Center 2012, several new activities were added to the VMM 2012 Integration Pack to make automating deployment of services instances from VMM service templates to Hyper-V even easier. The new activities introduced in Service Pack 1 for Orchestrator 2012 include: • Apply Pending Service Update • Configure Service Deployment • Deploy Service • Get Cloud • Get Service • Get Service Configuration • Get Service Template • Get Tier • Get User Role Quota • Get VM Host • Get VM Network • Get VM Subnet • Monitor VMM Job • Scale Tier In • Scale Tier Out • Set Pending Service Update • Stop Service Each activity performs a specific action when it is executed (the precise behavior depends on how the activity is configured by the runbook author). Once an activity has completed it will output one or more data elements and trigger any activities that are linked to it. For example, the runbook in Figure 12.38 contains an activity that monitors a folder. When a file enters the folder, the activity triggers a second activity to move the file to an archive directory (there's a very basic backup approach!), which in turn links an activity to log an event.

Figure 12.38 – Sample Runbook

362

Understanding Hyper-V in Windows Server 2012

Adding decision logic to your runbooks Links connect activities in a runbook, directing the flow of activity and data within a runbook based on conditions encountered at runtime. Whenever you create a link in a runbook, by default it is configured to trigger the next activity in the runbook when the previous one succeeds. However, links also provide filtering; this allows you to limit the data arriving at the following activity in the runbook and control the flow of runbook execution based on the result of activity execution. Link conditions provide a set of author-configurable functions for creating complex decision logic involving text, numeric or timerelated data. Links configured with conditional filtering logic as described here are called Conditional Links. Configuring runbooks with multiple branches driven by conditional links is a concept called branching. To make your runbooks visually more intuitive, you can also change the display name of activities and link labels to make them more descriptive of their purpose in the runbook. You can even change the link color to highlight success and failure branches (green and red are recommended) within your runbooks. For example, look at the runbook depicted in Figure 12.39, where the link labeled “VM deployed successfully” is configured to trigger the next activity in the runbook (Send Email (success)) only if the Create VM from Template activity returns success.

Figure 12.39 – Sample VM provisioning runbook implementing conditional links and branching

Responding based on runtime conditions You can configure conditional filtering in link properties, using both include and exclude logic. The Include tab specifies the conditions that will allow data to flow to the next activity in the runbook. The Exclude tab specifies the conditions that will cause data to be excluded from the next activity in the runbook. The properties of the ‘VM deployment failed’ link in the sample VM provisioning runbook in Figure 12.39 above implements logic to send a failure email only if the VM deployment fails. The properties of this link are shown in Figure 12.40. The branches of the runbook that deal with failure conditions in orchestration are called the ‘failure branches’ of the runbook. While labeling and color-coding those links in red is not required, it makes it very easy for fellow administrators to interpret exactly what your runbook is doing at-a-glance.

363

Understanding Hyper-V in Windows Server 2012

Figure 12.40 - Link properties of ‘Service Running’ link from runbook in Figure 12.39

Note: When implementing conditional filtering, bear in mind that rules on the Exclude tab always supersede the rules on the Include tab. With the basics out of the way, you’re ready to create your first runbook to deploy VMs to Hyper-V via the web with System Center!

Building your first runbook: Deploying a VM from Orchestrator Have you already installed Orchestrator? If not, go back to the ‘Installing VMM and Orchestrator’ section earlier in this chapter and refer to the installation resources provided. Doing is the fastest path to learning, and the instructions here will help you build your first runbook. This runbook will allow you (or any self-service user you authorize) to deploy one or more VMs from Orchestrator, leveraging the Hyper-V VM template you’ve already created in VMM. The runbook you will create is shown in Figure 12.39. Now take a look at the process of creating the runbook. 1. In the Runbook Designer, right-click the Runbooks node and select New → Runbook as shown in Figure 12.41.

Figure 12.41 – Creating a new runbook in the Runbook Designer interface

2. Next, rename the runbook. Right-click on New Runbook and select Rename, as shown in Figure 12.42.

364

Understanding Hyper-V in Windows Server 2012

Figure 12.42 – Renaming your runbook

3. Rename the runbook ‘1. Deploy VM from Template.’

Figure 12.43 – Renamed runbook

4. Next, drag the following activities onto to the palette in the Runbook Designer: • From the Runbook Control category, select and drag Initialize Data onto the palette. • From the SC 2012 Virtual Machine Manager category, select and drag Create VM From Template onto the palette. • From the Notification category, select and drag Initialize Data onto the palette. Your runbook-in-progress should look similar to Figure 12.44.

Figure 12.44 – VM provisioning runbook (in progress)

5. Next, you will connect the activities your runbook. • Move your mouse over the Monitor Folder activity in the Workspace. • On the right side there will appear a small arrow (called the ‘link handle’) as shown in Figure 12.45. • Click and hold on the arrow, then drag it to the Move File activity next to the Monitor Folder activity:

365

Understanding Hyper-V in Windows Server 2012

Figure 12.45 – The link handle to connect runbook activities

Your runbook should now look similar to Figure 12.46.

Figure 12.46 – VM provisioning runbook (in progress) with links in place

6. Next, configure the parameters of the Initialize Data activity (this is the activity that accepts input from the user). Double-click the activity to open its Properties. 7. Click the Add button, which will add a parameter named Parameter 1. Click on Parameter 1 and type ‘EmailAddress’ in the box provided, as shown in figure 12.47. 8. Click the Add button again, which will add a parameter named Parameter 2. Click on Parameter 2 and type ‘VMName’ in the box provided. When complete, the properties of this activity should look like Figure 12.47.

Figure 12.47 Runbook inputs in the Initialize Data activity

9. Now, double-click the Create VM From Template activity to open the activity Properties (Figure 12.48). Set each of the values as directed below. Use the ellipsis ( ) button to browse to the value anytime it is offered.

366

Understanding Hyper-V in Windows Server 2012

• Destination Type: Host • Destination: Select your Hyper-V host • Path: Click the ellipsis and select the path

Figure 12.48 – Properties of the Create VM From Template activity

10. For the VM Name parameter, you will configure the Create VM From Template activity to derive its value from the VM Name parameter using what is known as Published Data. • To configure this runbook activity to dynamically populate a field with published data, right-click in the VM Name field and from the menu, select Subscribe → Published Data, as shown in Figure 12.49. This opens the Published Data window.

Figure 12.49 – Adding published data to a runbook activity

11. In the Activity drop-down, make sure the Initialize Data activity is selected. In the list of properties, select VMName, as shown in Figure 12.50.

367

Understanding Hyper-V in Windows Server 2012

Figure 12.50 – Selecting VMName from user input (published data)

The result should look similar to the image in Figure 12.51.

Figure 12.51 – Results of Create VM From Template activity configuration

12. To provide a value for Source Template Name, use the ellipsis to select the VM template you created earlier. 13. For Cloud Capability Profile, leave the default value. 14. Next, double-click the Send Email (success) activity to configure properties of this activity. • Subject: To configure the Subject: field (which will serve as the subject line of the email sent when the VM is provisioned successfully), you will use a combination of free text and subscribe-to-published-data technique you learned earlier. The subject line should read: “VM {VM Name from “Create VM From Template”} created successfully” • Recipients: Click the Add button and use the subscribe-topublished-data technique to configure the runbook to dynamically add {EmailAddress from “Initialize Data”}, which will dynamically add the email address supplied by the user at runtime (Figure 12.52).

368

Understanding Hyper-V in Windows Server 2012

Figure 12.52 – Configuring email notification of successful VM deployment

• Message: Using the subscribe-to-published-data technique you learned earlier along with free text, create a message body indicating to the user that the VM has been created successfully. You could even add instructions here explaining how to connect to the VM with RDP if you like!

Figure 12.53 – SMTP server configuration in the Send Email activity

15. In this task, you will modify the link to define the “failure” path for runbook logic. • Double-click on the link between the Create VM From Template and the Send Email (failure) activity. • On the right side in the condition field there is an underlined success parameter. Click on this parameter and select the failed checkbox. • Select the Options tab. • Click on the black line next to Color and select a red color. • On the General tab, change the link name to ‘VM deployment failed’ and then click Finish.

369

Understanding Hyper-V in Windows Server 2012

Figure 12.54 – Configuring link logic to trigger failure notification

16. Repeat the process for the success branch of the runbook by doubleclicking on the link between the Create VM From Template and the Send Email (success) activity. Change the color to green (Figure 12.55) and the label to ‘VM deployed successfully.’

Figure 12.55 – Configuring link appearance in the success branch

17. Click Check In on the navigation bar above the palette to save your work. And that is it! You have created your first runbook! Now you will test your runbook to verify that it works using the Runbook Tester.

Deploying a VM from a template in Orchestrator Now you will test your runbook, first using the Orchestrator Runbook Tester, then using the Orchestration console. 1. To test your runbook, click Runbook Tester on the navigation bar above the palette, as shown in Figure 12.56. This launches the Orchestrator Runbook Tester in a new window.

370

Understanding Hyper-V in Windows Server 2012

Figure 12.56 – Launching the Runbook Tester from the Runbook Designer

2. To start your runbook, click Run ( Tester as shown in Figure 12.57.

) on the navigation bar in Runbook

Figure 12.57 – The Runbook Tester Interface

3. You will be prompted to supply the values defined in the Initialize Data activity. Supply a valid email address and VM name of your choosing and then click OK, as shown in Figure 12.58.

Figure 12.58 – Providing input to your VM Provisioning runbook

371

Understanding Hyper-V in Windows Server 2012

Your runbook will now run to completion, with the Run VM From Template activity contacting the VMM server to provision a new VM (using the VM template you created earlier and specified in this runbook). If the VM is created successfully, you will receive an email indicating success as shown in Figure 12.59. If VM provisioning fails, you will receive a failure notification. Tip: After runbook execution completes, look at the detailed logging information shown in the bottom center of the Runbook Tester.

Figure 12.59 – Email notification of successful VM deployment

If you like, you can also test your runbook using the Orchestration Console. 1. Click Orchestration Console on the navigation bar above the palette, as shown in Figure 12.56. This launches the Orchestrator Runbook Tester in Internet Explorer. 2. Next, in the Runbooks pane on the left, select the folder containing your runbook. 3. In the center pane, select the Runbooks tab and then select your runbook as shown in Figure 12.60.

Figure 12.60 – Initiating your runbook from the Orchestration Console

4. Click Start Runbook in the Actions pane as shown in Figure 12.60. This will start runbook execution and open the Start Runbook interface. 5. Enter values for EmailAddress and VMName as with the previous test. 6. Select your runbook server from the Available Runbook Server(s) window and move it to the Selected Runbook Server(s) window as shown in Figure 12.61.

372

Understanding Hyper-V in Windows Server 2012

Figure 12.61 – Providing input to your VM Provisioning runbook

7. Click the Start button to provision your VM. The remainder of the runbook execution process is just as described above.

Troubleshooting your runbooks Your runbook may not execute perfectly on your first attempt, so you will likely find it helpful to know a bit about how to troubleshoot your automation sequences. However, you may have noticed that the Orchestration Console lacks the detailed logging info present in the Runbook Tester. Every runbook, when executed, generates a log that you can view in the Runbook Designer (provided object-level is enabled). The Log and Log History windows within the Runbook Designer will display the real-time and historic logs for the selected runbook. • The Log window displays the logging of the current run of the runbook. The log displays when the runbook started, and the activity currently running in the runbook will have the running label beside it. The log enables you to determine if there are any problems with specific activities in your runbook. • The Log History window, shown in Figure 12.62, displays all previous executions of the runbook you selected. The time that the runbook started and ended is displayed at the top of each log entry, and the result of each activity execution is displayed for each entry.

Figure 12.62 – Log and log history tabs in the Runbook Designer

373

Understanding Hyper-V in Windows Server 2012

Double-clicking an activity log entry in the log lets you view the result of the execution of that activity. The Details dialog displays the Name, Type, Status, Start Time and End Time of the activity. If enabled, the Details dialog also allows you to browse the Published Data of the activity when it was executed. Use this information when troubleshooting your runbook. However, because of the overhead and additional database space it consumes, object-level logging is disabled by default. When you’re testing a runbook, you can turn on object-level logging for insight into the output of each activity in your runbook. 1. To enable object-level logging, right-click the runbook and select Properties, as shown in Figure 12.63

Figure 12.63 – Accessing runbook properties

On the Logging tab, select the checkboxes next to the ‘Store Activity-specific Published Data’ and ‘Store Common Published Data.’

Figure 12.64 – Enabling object-level logging settings

374

Understanding Hyper-V in Windows Server 2012

Leveraging advanced deployment capabilities in System Center 2012 Just as with orchestration and runbook concepts, you will take a quick look at some advanced virtualization deployment capabilities in System Center 2012 Virtual Machine Manager (VMM). Specifically, you will move beyond VM templates to a new template model in the latest release of VMM called a service template. VM templates offer some great benefits, most important, the ability to deploy multiple VMs with very consistent configurations. At the same time, VM templates have some limitations, including: • You can only deploy a single VM at a time. Once deployed, a VM doesn’t contain a reference back to the VM template from which it was deployed. • There is no mechanism to track the configuration of a deployed VM against the template from which it was deployed. • There is no way to update a VM template and then easily apply those changes against deployed VMs. To address these shortcomings in System Center 2012 VMM, Microsoft added a new template type called a service template, as well as a number of new profile types. A service template can contain definitions for one or more VMs, including multiple machine tiers. VMs within a service template can be of different types—an example is a multi-tier web application. A service template can define the front-end web tier, the middle tier business logic server, and the back-end database tier. Each tier can define different configurations— hardware configuration, O/S configuration and application configuration. A service template is a source for service deployment and a configuration baseline for deployed services. Deployed instances of services maintain a reference back to the service template from which they were deployed, enabling a basis for comparison of current settings to those of the original template from which the VMs were deployed. With the many new application and networking features in VMM and Hyper-V, this may come in very handy when you want to check VMs for any drift from the expected configuration. • This opens up the capabilities for updating a deployed service by updating the service template from which it originated, then applying those changes to the deployed service instances, often without impacting application availability. • You can configure machine tiers as scale-out tiers where appropriate, which enables dynamically deploying additional VMs in the tier up to your specified maximum. • Service templates also introduce application deployment—current support is for three “first class” application deployment technologies: • WebDeploy – for IIS applications • Server App-V – for virtualized server applications • SQL DAC – abstract data tier in SQL Server 2008 R2

375

Understanding Hyper-V in Windows Server 2012

Note: “First Class” application deployment technologies refer to the fact that the metadata for deployment of these technologies is fully understood—meaning that configurations of these technologies can be customized. For additional reading on the advanced capabilities of service templates inVMM, see the topics under 'Creating Profiles and Templates in VMM’ on the Microsoft site here. For application settings that cannot be controlled through any UI setting, service templates allow for execution of scripts (PowerShell, VB, batch, SQL) before and after significant deployment steps within the service template, such as deployment of a VM or an application. Scripts defined in the service template and executed as part of the service deployment are called generic command executions (GCEs). Figure 12.65 depicts a running service instance encompassing an N-tier application containing web, application and database servers with WebDeploy and Server App-V applications, and SQL data tier deployed entirely from a service template in VMM 2012. Notice how each logical component (service, machine tier, VM and application) have unique icons so the object type is easy to identify.

Figure 12.65 – Service instance deployed via a VMM service template

Best practices for VM deployment in Hyper-V and System Center 2012: The Microsoft best practice for VM deployment (to Hyper-V or any hypervisor supported by System Center 2012) is to wrap all VM templates in service templates, whether it will be single VM or multi-tier, multi-VM configuration, and then deploy VMs from the service template. This allows for the potential to take advantage of all service template features in any deployed VM. VMs deployed from standalone VM templates CANNOT be retrofitted to service templates.

376

Understanding Hyper-V in Windows Server 2012

Configuring service templates Service templates are authored in the new Service Designer within VMM. The VMs are defined within the Service Designer with settings such as tiers, applications, OS settings, networking requirements and Load Balancers, which today include BigIP F5, NetScaler and Windows Server NLB. Service templates are not fire-and-forget objects; they are always linked with the deployed service, and the template can be used to update deployed services. Typically when you are creating a service template, deployment-specific information like hosts and load balancers is not available—you just know you need a host for the VM or a load balancer for the service. While it is outside the scope of this book, it is worth noting that service templates in VMM 2012 SP1 can be configured to deploy the service instance not only to Hyper-V on Windows Server 2012, but also many of the most recent versions of VMware, including vSphere 5.0 and 5.1.

A look at the Service Designer The Service Designer presents a simple drag-and-drop interface. When a service is first created, the author selects a basic framework (e.g., number of tiers, whether or not a load balancer is required, etc.) for the service. The template is then filled in using objects from the library palette. The Ribbon at the top provides the list of actions that can be performed in the Designer In the Designer Canvas shown in the next figure, you are looking at the service template for a StockTrader service that has four tiers—Web Tier, two business logic Middle Tiers and SQL Tier. All the tiers are connected to a logical network called Redmond. The Details pane at the bottom provides the property settings for the selected object in the canvas.

Figure 12.66 – VMM 2012 Service Designer Interface

377

Understanding Hyper-V in Windows Server 2012

Service template components With System Center 2012 VMM, the service template provides a new way to model a service. Service templates contain the definitions for VMs, their connectivity, application definitions, and they are the starting point for a VM or a service. Service templates have the following components: Service template: The service template itself, consisting of one or more computer tiers. You can configure additional settings, such as deployment order and servicing order (if the template contains multiple computer tiers) to control the order of operations during deployment and VM servicing after deployment. Computer tier: A computer tier (also called a machine tier) consists of exactly one VM template. There can be one or more computer tiers. Computer tiers can also be configured with minimum, maximum and default scale-out settings. These determine the minimum, maximum and default number of VMs hosted in the tier for use in deployment and capacity-related scale-out and scale-in operations. VM templates: • VM templates contain Hardware Profile, Guest OS Profile and reference to a VHD in the library. • In the Guest OS profile, you can define what Roles/Features need to be installed. • VM templates have one application profile, which in turn has one or more application deployments – WebDeploy, SQL DAC or Server App-V packages. Application deployments always have references to the application bits in the library. • VM templates can also contain a SQL profile, for installing a SQL server instance in a VHD that contains a Sysprep instance of SQL 2008 R2. This consists of one or more SQL deployments that can have SQL scripts and library resources for the SQL scripts. Generic command executions: Custom EXEs can run during application deployment. Examples might be installing a MSI package or enabling firewall rules. Load balancer templates: Load balancer templates can be setup for each computer tier that needs to be scaled out. Application host template: In an enterprise environment it is typical that SQL databases are deployed to existing physical SQL servers. To support this scenario, service templates can contain one or more host profiles for deploying SQL DAC packages to existing physical servers. Global settings: Any settings that need to be overridden as a part of service deployment are available at the service template level as service settings.

378

Understanding Hyper-V in Windows Server 2012

Creating a service template Creating a basic service template is a relatively simple, wizard-driven process in the VMM Administrator Console. 1. Begin by opening the console and selecting the Library workspace. 2. Next, right-click the Service Templates node in the navigation (left) pane of the runbook and select Create Service Template as shown in Figure 12.67 to launch the New Service Template wizard.

Figure 12.67 – Launching the New Service Template wizard

1. On the New Service Template screen, enter a name for your template in the spaces provided. This example uses the name ‘WebApp Service’ with a release of 1.0, as shown in Figure 12.68.

Figure 12.68 – Choosing a service template pattern

2. Click OK to open the service template in the Service Designer interface described earlier in this chapter and shown in Figure 12.69.

379

Understanding Hyper-V in Windows Server 2012

Figure 12.69 – The Service Template Designer interface

3. In the navigation (left) pane, find the VM template you created earlier and drag it onto the machine tier box in the palette of the Service Designer interface (also shown in Figure 12.69). 4. When you select the machine tier in Service Designer, the tier settings will be shown at the bottom of the designer interface, as shown in Figure 12.70.

Figure 12.70 – Machine tier settings presented in the Template Designer

5. To configure the advanced settings of the machine tier, double-click on the machine tier to open its Properties, as shown in Figure 12.71. On the General tab, select the checkbox labelled This computer tier can be scaled out. Set the Maximum instance count to 3.

380

Understanding Hyper-V in Windows Server 2012

Figure 12.71 – General settings in Tier Properties

6. On the Hardware Configuration tab, make sure that your VM template in the machine tier has network connectivity as shown in Figure 12.72. VM templates within service templates that are not connected cannot be deployed. • Also in the network properties, make sure the Dynamic IP or Static IP radio button is configured. If you do not have a DHCP server in your environment, you will need to configure a static pool of IP Addresses, as described on the Microsoft TechNet site here.

Figure 12.72 – Hardware Configuration settings in settings in Tier Properties

381

Understanding Hyper-V in Windows Server 2012

7. On the OS Configuration tab, make any changes to the OS configuration of your VM template (embedded in this service template). Don’t move on to the next tab yet, as there are some additional settings to explore that will enable advanced deployment capabilities available only within service templates.

Figure 12.73 – OS Configuration settings in Tier Properties

8. While still on the OS Configuration tab, under the Roles and Features heading, select Roles as shown in Figure 12.74. For this example, select the following roles and role services: Web Server (IIS), IIS Management Console, Web Server, Application Deployment (and all children), Common HTTP Features (and all children) and finally, Health and Diagnostics (and all children).

Figure 12.74 – Choosing OS Roles for installation in Tier Properties

382

Understanding Hyper-V in Windows Server 2012

9. Under Roles and Features, next select the Features node as shown in Figure 12.75. Select Background Intelligent Transfer Service (BITS).

Figure 12.75 – Choosing OS Features in Tier Properties

10. Moving on to the Application Configuration tab, you will see the area where application first-class deployment and GCEs (remember these?) can be configured.

Figure 12.76 – Application Configuration settings in Tier Properties

11. On the SQL Server Configuration tab, you can configure the settings for a Sysprep SQL instance inside your VM template. In this case you don’t have a Sysprep instance, so leave the defaults and continue to the next tab.

Figure 12.77 – SQL Server Configuration settings in Tier Properties

383

Understanding Hyper-V in Windows Server 2012

Note: Although the Application Configuration and SQL Server Configuration tabs appear even in VM templates, these additional configuration features are only functional inside service templates! 12. On the Custom Properties tab, you can add custom fields—name/value pairs that can be used to store values for any of your custom automation, integration or reporting needs. Accept the defaults and move on to the next tab. 13. On the Settings tab, you can configure quota points. 14. On the Dependencies tab, you will see listed any components this service template requires (e.g., VM templates, OS, hardware and application profiles). 15. With your service template configuration now complete, click the View Script button to view the PowerShell script (created by this wizard), which will be run to complete the request (if desired), and then click OK. 16. Once you’ve configured all the settings in your template, click Save and Validate on the ribbon to ensure the template is configured correctly, as shown in figure 12.78.

Figure 12.78 – Save and Validate service template settings

If there are any isssues with your service template, the issues will be detailed at the bottom of the Service Designer, as shown in Figure 12.79. If any issues appear, read the explanation provided and make corrections to the settings in your service template as required and click Save and Validate once again.

Figure 12.79 – Issues detected in validation of service template configuration

Congratulations, your service template is complete! Next, you will try to deploy a service instance to your Hyper-V server.

384

Understanding Hyper-V in Windows Server 2012

Deploying a service instance Now that you have a service template in place in your VMM instance, it’s time to deploy your first service to Hyper-V. After a service template has been created or imported into VMM, it can be deployed either through VMM itself, from Orchestrator (if you create a runbook to do so), the VMM Self-Service Portal or some other service (for example, System Center 2012 App Controller or Service Manager). As part of the deployment, you can customize computer names, configure passwords or update other instance-specific settings. If the application requires specific settings, for example a SQL connection string, you can supply this at deploy time as well. In addition, you can allow the same service template to be deployed into different environments—for example, development and production. Simply use the Import and Export wizards in the Library workspace of the VMM Administration Console (see more on importing and exporting service templates here). Service deployment behind-the-scenes: The basic deployment steps carried out by VMM are as follows: • Machine tiers are deployed based on the defined deployment order. • VMs are created, powered on, and OS profile settings applied, such as joining the VM to a domain, etc. • The VMM Guest agent is installed into the VM—the VMM Guest Agent allows application installation within the VM. • Optional pre-installation GCE are run. • Applications are installed. • Optional post-installation GCE are run. • If applicable, the VM is added to a load balancer. 1. In the Library workspace, select the Service Templates node and then the service template you created previously. Click the Configure Deployment button on the ribbon (Figure 12.80). The Create Service screen opens.

Figure 12.80 – Configuring deployment of a new service instance

2. In the Create Service window, click the Browse button and select the service template you just created from the window provided, as shown in Figure 12.81

385

Understanding Hyper-V in Windows Server 2012

3. Provide a descriptive name for your service in the box provided, select the host group containing your Hyper-V server in the Destination drop‑down list and click OK, also shown in Figure 12.81.

Figure 12.81 - Assigning Service Name and Deployment Location

4. This opens the Deployment Preview shown in Figure 12.82. Here you can change service settings (e.g., VM name, administrator password). After making any necessary adjustments, click Refresh Preview in the ribbon to refresh recommended placement settings. Note: If you have multiple Hyper-V servers, the placement recommendation is made automatically by the Intelligent Placement feature in VMM. Read more about this feature on the Microsoft TechNet site here.

Figure 12.82 – Viewing VMM Hyper-V host placement recommendations

5. Finally, click Deploy Service on the ribbon of the Deployment Preview window to deploy your service.

386

Understanding Hyper-V in Windows Server 2012

Figure 12.83 – The Deploy Service button (on the ribbon)

6. You’ll be prompted one last time with a Deploy service pop-up, where you will have the opportunity to view the PowerShell (created by this wizard), which will be used to deploy your service. Click Deploy to initiate the service deployment.

Figure 12.84 – Final deployment confirmation and the View Script button

7. Navigate to the VMs and Services workspace of your VMM Administrator Console, where your service instance should appear almost instantly, reflecting a status of “Deploying” while the deployment is in progress.

Figure 12.85 – Service instance deployment in progress

387

Understanding Hyper-V in Windows Server 2012

8. If you would like to view the progress of your service deployment at a more granular level of detail, navigate to the Jobs workspace and look for a job in progress named “Create Service Instance.”

Figure 12.86 – Service instance deployment job details

Congratulations! When the job completes successfully, you will have successfully deployed your first service. While this was just a basic example, it provides you with a base of knowledge that will help you progress to more advanced Hyper-V deployment scenarios.

Hyper-V self-service deployment While a deep dive into virtualization self-service is beyond the scope of this book, you will no doubt be interested in how to make all of the deployment and servicing capabilities you’ve learned accessible to the end users in your organization. Fortunately, Microsoft provides a number of options based on your deployment needs. The capabilities, pros and cons of each option are described here. VMM 2012 Self-Service Portal The VMM self-service portal has been around in previous versions, but receives little attention in conversations around Windows Server 2012 Hyper-V and System Center 2012. Intended to be a departmental solution for self‑service in test and development environments, VMM lacks the features of some of the other self-service portal options offered by Microsoft, with no support for multi-tenancy, Orchestrator runbooks or visibility into the latest features of VMM templates. Orchestrator Web Console The Orchestrator Web Console, which you have you seen in this chapter, does enable deployment of Hyper-V guests via Orchestrator runbooks communicating with VMM 2012, but with a minimal interface. There is no validation of user input nor management capability beyond what is provided in runbooks that you author. As a result, this interface receives little attention in discussions related to virtualization self-service

388

Understanding Hyper-V in Windows Server 2012

System Center 2012 App Controller App Controller is a Silverlight-based web portal that provides a common self‑service experience that can help you easily configure, deploy and manage VMs and services across private and public clouds. App Controller is very lightweight and quick to deploy—just one of the reasons it is a popular self‑service portal for virtualization in private cloud and datacenter scenarios involving Hyper-V and System Center 2012 technologies. Other advantages of App Controller include its native support for the new features in VMM, including service template and delegation of access and capacity (clouds and tenants). Additionally, App Controller supports deployment of Hyper-V hosts in Windows Azure, providing access to both private cloud and public cloud resources in a single pane of glass. The primary cons to using App Controller for self-service are its lack of extensibility in customizing the portal interface, as well as a lack of integration with service desk solutions, resulting in a change management challenge for some organizations. System Center 2012 Service Manager Self-Service Portal System Center 2012 Service Manager (SCSM) is the service desk solution from Microsoft, not only providing integration with VMM, Orchestrator and other System Center components, but also a highly customizable and extensible self‑service portal. SCSM supports integration of Orchestrator runbooks into service offerings presented in a central Service Catalog, as well as robust approval and notification workflow capabilities. Because SCSM hosts the CMDB, integration with incident, service and change management is automatic. For organizations wishing to implement an extensible, enterprise virtualization self-service strategy, SCSM is the most robust option. You should now have a better picture of the key components utilized in Hyper-V management and automation in the enterprise.

Share this e-book with your peers

389

Understanding Hyper-V in Windows Server 2012

About the Author Brien Posey is a freelance technical writer who has received Microsoft's MVP award 9 times for his work with Exchange Server, Windows Server, IIS, and File Systems Storage. Brien has written or contributed to about three dozen books, and has written well over 4,000 technical articles and white papers for a variety of printed publications and Web sites. In addition to his writing, Brien routinely speaks at IT conferences and is involved in a wide variety of other technology related projects.

About Veeam Software Veeam® Software develops innovative solutions for VMware backup, Hyper-V backup, and virtualization management. Veeam Backup & Replication™ is the #1 VM Backup solution. Veeam ONE™ is a single solution for real‑time monitoring, resource optimization, documentation and management reporting for VMware and Hyper-V. Veeam extends deep VMware monitoring to Microsoft System Center with Veeam Management Pack™ (MP), and to HP Operations Manager with Veeam Smart Plug-In™ (SPI). Veeam also provides free virtualization tools. Learn more by visiting www.veeam.com.

Share this e-book with your peers

390

Understanding Hyper-V in Windows Server 2012

Modern Data Protection

Built for Virtualization

Powerful

Easy-to-Use

Veeam Backup & Replication #1 VM Backup for VMware and Hyper-V Virtualization changes everything – especially backup. If you’ve virtualized on VMware or Hyper-V, now is the time to move up to the data protection solution Built for Virtualization: Veeam Backup & Replication. Unlike traditional backup that suffers from the “3C” problem (missing capabilities, complexity and cost), Veeam is:  Powerful: Restore an entire virtual machine (VM) or an individual file, email or database record in 2 minutes  Easy-to-Use: It just works!  Affordable: No agents to license or maintain, works with your existing storage, and includes deduplication, VM replication, Microsoft Exchange recovery, and more! Join the 58,000 organizations who have already modernized their data protection with Veeam. Download Veeam Backup & Replication today!

GOLD AWARD NEW TECHNOLOGY

GOLD AWARD

NEW TECHNOLOGY

To learn more, visit http://www.veeam.com/backup

391

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF