ptg From the Library of Lee Bogdanoff Practical Virtualization Solutions ptg From the Library of Lee Bogdanoff Negus Software Solutions Series Christopher Negus, Series Editor Visit informit.com/softwaresolutions for a complete list of available products. ptg Your Practical, Hands-On Guides to Getting Real Results with Free Software E ach book in the Negus Software Solutions Series encourages and challenges you to advance in the free software world. Boot the live DVD or CD that comes with each book and watch the applications and content described in the book come to life before your eyes. When you are finished, you will know how to use, customize, and rebuild that free and open source software yourself. Start as a novice by trying out examples and finish as a professional, mastering the many topics covered in the series—from building PHP/MySQL sites to customizing Live CDs and more. From the Library of Lee Bogdanoff N E G U S S O F T WA R E S O L U T I O N S S E R I E S Practical Virtualization Solutions ptg Virtualization from the Trenches Kenneth Hess and Amy Newman An Imprint of Pearson Education Upper Saddle River, NJ ■Boston■Indianapolis■San Francisco New York ■Toronto ■Montreal■London■Munich■Paris■Madrid Cape Town ■Sydney■Tokyo ■Singapore■Mexico City From the Library of Lee Bogdanoff Many of the designations used by manufacturers and sellers to distinguish their Editor-in-Chief products are claimed as trademarks. Where those designations appear in this book, Mark Taub and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. Executive Editor Debra Williams Cauley The authors and publisher have taken care in the preparation of this book, but make Development Editor no expressed or implied warranty of any kind and assume no responsibility for errors Songlin Qiu or omissions. No liability is assumed for incidental or consequential damages in con- nection with or arising out of the use of the information or programs contained Managing Editor herein. Kristy Hart Project Editor The publisher offers excellent discounts on this book when ordered in quantity for Jovana San Nicolas-Shirley bulk purchases or special sales, which may include electronic versions and/or cus- tom covers and content particular to your business, training goals, marketing focus, Copy Editor and branding interests. For more information, please contact Barbara Hacha Indexer U.S. Corporate and Government Sales Cheryl Lenser (800) 382-3419 [email protected] Proofreader Leslie Joseph For sales outside the United States, please contact Technical Reviewers International Sales Jesse Keating [email protected] Joe Brockmeier Visit us on the Web: informit.com/ph Publishing Coordinator Kim Boedigheimer Library of Congress Cataloging-in-Publication Data: Cover Designer Hess, Kenneth, 1961- Alan Clements Practical virtualization solutions : virtualization from the trenches / Kenneth Hess, Compositor Amy Newman. — 1st ed. Jake McFarland p. cm. ISBN 978-0-13-714297-2 (pbk. : alk. paper) 1. Virtual computer systems. 2. Virtual computer systems—Manage- ptg ment. I. Newman, Amy, 1971- II. Title. QA76.9.V5H47 2009 005.4’3—dc22 2009029966 Copyright © 2010 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc. Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax (617) 671-3447 ISBN-13: 978-0-137-14297-2 ISBN-10: 0-137-14297-8 Text printed in the United States on recycled paper at R.R. Donnelley in Crawfordsville, Indiana. First printing October 2009 From the Library of Lee Bogdanoff For Melissa, Connor, Walker, and Maria and ptg For Eric, Jakob, and Rebecca From the Library of Lee Bogdanoff This page intentionally left blank ptg From the Library of Lee Bogdanoff Contents Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi ptg Part I Virtualization Basics and Technology Choices . . . . . . . . . 1 Chapter 1 To Virtualize or Not to Virtualize?. . . . . . . . . . . . . . . . . . 3 A Virtual History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Virtualization Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Virtualization Workload Candidates. . . . . . . . . . . . . . . . . . . . . . . . . 4 Consolidating Web Services with VMs . . . . . . . . . . . . . . . . . . . . . . . 4 Mean Time to Restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Aging Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Infrastructure That Is Out of Capacity . . . . . . . . . . . . . . . . . . . . . 5 Underutilization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Economy of Virtualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Practical Aspects of Virtualization . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Minimizing Hardware Costs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Providing Disaster Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Consolidating Idle Workloads . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Balancing Loads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Software Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 vii From the Library of Lee Bogdanoff viii Contents Centralized Server Management. . . . . . . . . . . . . . . . . . . . . . . . . 13 Power Conservation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Faster Server Deployment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Service Commoditization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Chapter 2 Comparing Virtualization Technologies. . . . . . . . . . . . . 17 Guest OS/Host OS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 VMware Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Sun xVM (VirtualBox). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Hypervisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Citrix Xen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 VMware ESX/VMware ESXi. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Microsoft Hyper-V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Emulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Bochs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 QEMU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Microsoft Virtual PC and Virtual Server . . . . . . . . . . . . . . . . . . . 20 ptg Kernel-Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 KVM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 User-Mode Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Shared Kernel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Solaris Containers (Zones). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 OpenVZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 In the Virtual Trenches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Chapter 3 VMware Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 The VMware Server Console. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Creating Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Customizing Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Virtual Machine Files and Folders. . . . . . . . . . . . . . . . . . . . . . . . . . 41 File and Folder Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 File Names and Roles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 VMware Server in the Real World. . . . . . . . . . . . . . . . . . . . . . . . . . 44 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 From the Library of Lee Bogdanoff Contents ix Chapter 4 VMware ESXi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 The Virtual Infrastructure Client Console. . . . . . . . . . . . . . . . . . . . 47 Creating Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Customizing Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Virtual Machine Files and Folders. . . . . . . . . . . . . . . . . . . . . . . . . . 61 File and Folder Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 File Names and Roles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 VMware ESXi in the Real World . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Chapter 5 Citrix XenServer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 XenServer, the Hypervisor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 XenCenter—The Xen Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Creating Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Customizing Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Virtual Machine Files and Folders. . . . . . . . . . . . . . . . . . . . . . . . 82 Resource Pools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Virtual Machine Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 ptg Converting a VM to a Template . . . . . . . . . . . . . . . . . . . . . . . . . 83 Installing a New VM from the Template. . . . . . . . . . . . . . . . . . . 83 XenServer in the Real World. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Chapter 6 Microsoft Virtual PC. . . . . . . . . . . . . . . . . . . . . . . . . . . 87 The VPC Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Creating Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Customizing Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Virtual Machine Files and Folders. . . . . . . . . . . . . . . . . . . . . . . . . 100 File and Folder Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 File Names and Roles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Chapter 7 Microsoft Hyper-V . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 The Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Creating Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Customizing Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . 110 From the Library of Lee Bogdanoff