Pro OpenSolaris A New Open Source OS for Linux Developers and Administrators Harry J. Foxwell, PhD and Christine Tran Pro OpenSolaris: A New Open Source OS for Linux Developers and Administrators Copyright © 2009 by Harry J. Foxwell and Christine Tran All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-1891-3 ISBN-13 (electronic): 978-1-4302-1892-0 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editors: Michelle Lowman, Frank Pohlmann Technical Reviewer: Sam Nicholson Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Kylie Johnston Copy Editor: Kim Wimpsett Associate Production Director: Kari Brooks-Copony Production Editor: Richard Ables Compositor: Diana Van Winkle, Van Winkle Design Group Proofreader: Nancy Sixsmith Indexer: Becky Hornyak Interior Designer: Diana Van Winkle, Van Winkle Design Group Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail (cid:107)(cid:110)(cid:96)(cid:97)(cid:110)(cid:111)(cid:41)(cid:106)(cid:117)(cid:60)(cid:111)(cid:108)(cid:110)(cid:101)(cid:106)(cid:99)(cid:97)(cid:110)(cid:41)(cid:111)(cid:94)(cid:105)(cid:42)(cid:95)(cid:107)(cid:105), or visit (cid:100)(cid:112)(cid:112)(cid:108)(cid:54)(cid:43)(cid:43)(cid:115)(cid:115)(cid:115)(cid:42)(cid:111)(cid:108)(cid:110)(cid:101)(cid:106)(cid:99)(cid:97)(cid:110)(cid:107)(cid:106)(cid:104)(cid:101)(cid:106)(cid:97)(cid:42)(cid:95)(cid:107)(cid:105). For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail (cid:101)(cid:106)(cid:98)(cid:107)(cid:60)(cid:93)(cid:108)(cid:110)(cid:97)(cid:111)(cid:111)(cid:42)(cid:95)(cid:107)(cid:105)(cid:40) or visit(cid:28)(cid:28) (cid:100)(cid:112)(cid:112)(cid:108)(cid:54)(cid:43)(cid:43)(cid:115)(cid:115)(cid:115)(cid:42)(cid:93)(cid:108)(cid:110)(cid:97)(cid:111)(cid:111)(cid:42)(cid:95)(cid:107)(cid:105). Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at (cid:100)(cid:112)(cid:112)(cid:108)(cid:54)(cid:43)(cid:43)(cid:115)(cid:115)(cid:115)(cid:42)(cid:93)(cid:108)(cid:110)(cid:97)(cid:111)(cid:111)(cid:42)(cid:95)(cid:107)(cid:105)(cid:43)(cid:101)(cid:106)(cid:98)(cid:107)(cid:43)(cid:94)(cid:113)(cid:104)(cid:103)(cid:111)(cid:93)(cid:104)(cid:97)(cid:111). The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at (cid:100)(cid:112)(cid:112)(cid:108)(cid:54)(cid:43)(cid:43)(cid:115)(cid:115)(cid:115)(cid:42)(cid:93)(cid:108)(cid:110)(cid:97)(cid:111)(cid:111)(cid:42)(cid:95)(cid:107)(cid:105). To my sons, Andrew, Michael, and Edward, as inspiration and example, and to my wife, Eileen, for making it all possible. —Harry J. Foxwell This book is dedicated to my parents. You are the mountain and the spring; you made everything possible. And to Steve, who kept the lights on every night I came home late. —Christine Tran Contents at a Glance About the Authors .................................................................xiii About the Technical Reviewer ...................................................... xv Acknowledgments ............................................................... xvii Introduction ......................................................................xix PART 1 Getting Started (cid:78)(cid:0)(cid:78)(cid:0)(cid:78) CHAPTER 1 Introducing OpenSolaris .........................................3 CHAPTER 2 The Advantages of Developing with OpenSolaris .................17 CHAPTER 3 Getting and Installing OpenSolaris ..............................27 CHAPTER 4 A Familiar User and Developer Environment and More ...........51 PART 2 Working with OpenSolaris (cid:78)(cid:0)(cid:78)(cid:0)(cid:78) CHAPTER 5 SMF: The Service Management Facility ..........................69 CHAPTER 6 The ZFS File System ............................................89 CHAPTER 7 OpenSolaris and Virtualization .................................111 PART 3 Exploiting OpenSolaris’s (cid:78)(cid:0)(cid:78)(cid:0)(cid:78) Unique Features CHAPTER 8 A Development Environment on OpenSolaris ....................153 CHAPTER 9 Innovative OpenSolaris Features ...............................205 PART 4 Appendixes (cid:78)(cid:0)(cid:78)(cid:0)(cid:78) APPENDIX A Recommended Reading and Viewing ...........................233 APPENDIX B OpenSolaris 2009.06 ..........................................239 INDEX ........................................................................243 v Contents About the Authors .................................................................xiii About the Technical Reviewer ...................................................... xv Acknowledgments ............................................................... xvii Introduction ......................................................................xix PART 1 Getting Started (cid:78)(cid:0)(cid:78)(cid:0)(cid:78) CHAPTER 1 Introducing OpenSolaris .....................................3 The True Name of Open Source Software ............................5 What You’ll Find and Learn in This Book .............................7 The Origin of OpenSolaris. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 Goals and Future Directions .......................................10 That Troublesome CDDL License ..................................11 The OpenSolaris Community: OpenSolaris.org .......................12 Essential URLs ..................................................15 Summary .......................................................15 CHAPTER 2 The Advantages of Developing with OpenSolaris .........17 OpenSolaris Qualities ............................................17 OpenSolaris Is Free .........................................18 OpenSolaris Is Open Source ..................................19 OpenSolaris Runs on “Commodity” Hardware Platforms .........20 OpenSolaris Runs High- Quality Application Software ............22 You Can Get a Software Support Subscription for OpenSolaris ....22 vii viii (cid:78)CONTENTS OK, It’s Like Linux. So What? ......................................23 Scalability .................................................23 Service Management ........................................23 ZFS .......................................................24 DTrace ....................................................24 Virtualization ...............................................25 Security ...................................................25 Summary .......................................................26 CHAPTER 3 Getting and Installing OpenSolaris ........................27 Installation Choices ..............................................29 Checking Your System ...........................................30 Live CD Booting .................................................34 Direct “Bare- Metal” Installation ...................................36 Multiboot Installation .............................................36 Installing OpenSolaris as a Guest VM (Recommended) ...............37 Are We There Yet? ...............................................47 Summary .......................................................50 CHAPTER 4 A Familiar User and Developer Environment and More ...51 At Home with GNOME ............................................51 The CLI, for the GUI- averse .......................................55 To su, or Not to sudo? ............................................56 Boot and Reboot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57 Updating Your Kernel Build ...................................59 Other Administrative Tasks .......................................62 Adding New Users ..........................................62 Printing ....................................................64 Summary .......................................................65 (cid:78)CONTENTS ix PART 2 Working with OpenSolaris (cid:78)(cid:0)(cid:78)(cid:0)(cid:78) CHAPTER 5 SMF: The Service Management Facility ...................69 What’s a Service? ...............................................70 A Bit About Milestones ......................................74 More About Services ........................................74 Creating Your Own Services ......................................81 Summary .......................................................88 CHAPTER 6 The ZFS File System ........................................89 Exploring the Basic ZFS Features ..................................91 Creating and Managing ZFS Storage Pools ..........................94 Creating a ZFS Pool .........................................95 Managing Boot Environments with ZFS .......................108 Summary ......................................................110 CHAPTER 7 OpenSolaris and Virtualization ............................111 Zones and Containers ...........................................118 Creating a Zone ...........................................120 Global and Local Zone Environments .........................124 Cloning a Zone ............................................127 Managing Zones ...........................................128 Using the Zone ............................................129 Managing Zone Resources ..................................130 More OpenSolaris Virtualization ..............................133 VirtualBox ................................................134 The xVM Hypervisor ........................................136 Installing the OpenSolaris 2008.11 xVM Hypervisor ............138 BrandZ ...................................................145 LDoms ...................................................148 Summary ......................................................150 x (cid:78)CONTENTS PART 3 Exploiting OpenSolaris’s (cid:78)(cid:0)(cid:78)(cid:0)(cid:78) Unique Features CHAPTER 8 A Development Environment on OpenSolaris ............153 Introducing the Web Stack and AMP ..............................154 Getting the AMP Stack ..........................................154 Taking a Tour of the Command- Line Package Manager .........156 Making a Case for Containers ....................................162 Building Applications for a Container Environment ..................163 Introducing Zones and Discrete Privileges ....................163 Qualifying Your Application for Zones .........................164 Installing Tomcat in a Container ..................................165 Installing MySQL ...............................................172 Taking a Quick Tour of NetBeans IDE .............................175 Using Subversion ...............................................179 Creating the Repository and Managing Files ...................179 Using the Manage Access Control Method ....................183 Integrating NetBeans with Other Products .........................191 Integrating with Tomcat ....................................191 Integrating with Subversion .................................193 Putting It All Together with IPS ...................................200 Summary ......................................................204 CHAPTER 9 Innovative OpenSolaris Features ..........................205 DTrace ........................................................205 Probes ...................................................207 Providers .................................................208 DTrace Scripts ............................................208 A Simple Example .........................................209 DTrace Aggregations .......................................210 DTrace Community Contributions ............................212 DTrace and Java ..........................................218 (cid:78)CONTENTS xi The Tracker Utility: Where’s That File? ............................219 The OpenSolaris Distro Constructor ...............................220 The Device Driver Utility .........................................222 And Now for a Little Entertainment ................................223 OpenSolaris Educational Resources ...............................226 The OpenSolaris Curriculum Development Resources ..........226 OpenSolaris Learning Cloud Service ..........................227 Summary ......................................................229 PART 4 Appendixes (cid:78)(cid:0)(cid:78)(cid:0)(cid:78) APPENDIX A Recommended Reading and Viewing .....................233 Books .........................................................233 Blogs and Wikis ................................................234 Developer Resources ...........................................234 Learning and Training ...........................................235 Linux to OpenSolaris Translation .................................235 Newsletter .....................................................235 User Groups ...................................................236 Videos ........................................................236 Web Sites .....................................................236 White Papers ..................................................237 APPENDIX B OpenSolaris 2009.06 .......................................239 SPARC Support .................................................239 Project Crossbow ...............................................240 Encrypted ZFS File System ......................................240 CUPS Printing ..................................................241 Other Anticipated Features ......................................241 INDEX ........................................................................243
Description: