Master one of the most innovative Nicholas A. Solter ... · is an engineer on the Zones team at Sun...
Transcript of Master one of the most innovative Nicholas A. Solter ... · is an engineer on the Zones team at Sun...
Solter, Jelinek, Miner
The book you need to succeed!
Master one of the most innovative new open source operating systemsThe latest version of OpenSolaris is here—and this comprehensive guide is your one-stop gateway to it all. You’ll start with a basic crash course in OpenSolaris, including command lines and shells, the GNOME Desktop, systems administration, and other essential topics. Later chapters focus on application development, networking, virtualization, DTrace, and other topics that will transform you into a power user. Find practical tips, step-by-step tutorials, and exact command lines and screenshots you can use right away.
Nicholas A. Solteris an engineer at Sun Microsystems and core contributor to the OpenSolaris HA Clusters community group. He is lead author of Professional C++.
Gerald Jelinekis an engineer on the Zones team at Sun and a core contributor to the OpenSolaris Zones community group.
David Miner is an engineer at Sun, a co-lead for the OpenSolaris distribution, and architect of the Caiman installer.
Shelving Category:COMPUTERS / Operating Systems / UNIX
Reader Level:Beginning to Advanced
$49.99 USA$59.99 Canada
www.wiley.com/compbooks
Nicholas A. Solter, Gerald Jelinek, and David Miner
OpenSolaris™
Op
enS
olaris
™
• Explore the OpenSolaris operating environment—from GNOME® to the bash shell, vim text editor, and more
• Connect printers, USB devices, and other peripherals to your desktop
• Master systems administration, including ZFS and NFS file systems, networking, directory services, and security
• Observe and debug the system with the innovative Dynamic Tracing (DTrace) facility and other monitoring tools
• Share a single physical machine among multiple users and processes with xVM, VirtualBox™, and other virtualization tools
• Deploy web services using Apache, Apache Tomcat, MySQL®, and other open source web stack applications
• Write and debug applications in C, C++, Java®, Ruby, Python®, and other languages
Explore the OpenSolaris operating environment
Master networking and systems administration
Deploy web services using open source applications
OpenSolaris™ Bible
Nicholas A. SolterGerald JelinekDavid Miner
Wiley Publishing, Inc.
OpenSolaris™ Bible
Published byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com
Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-38548-7
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Library of Congress Cataloging-in-Publication Data:
Solter, Nicholas, 1977-OpenSolaris bible / Nicholas Solter, Gerald Jelinek, David Miner.
p. cm.Includes index.ISBN 978-0-470-38548-7 (paper/website)1. OpenSolaris (Electronic resource) 2. Operating systems
(Computers) 3. Open source software. I. Jelinek, Gerald. II. Miner,David. III. Title.
QA76.76.O63S6526 2009005.3 — dc22
2008049814
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form orby any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permittedunder Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written per-mission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copy-right Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600.Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing,Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online athttp://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations orwarranties with respect to the accuracy or completeness of the contents of this work and specifically dis-claim all warranties, including without limitation warranties of fitness for a particular purpose. No war-ranty may be created or extended by sales or promotional materials. The advice and strategies containedherein may not be suitable for every situation. This work is sold with the understanding that the publisheris not engaged in rendering legal, accounting, or other professional services. If professional assistance isrequired, the services of a competent professional person should be sought. Neither the publisher nor theauthor shall be liable for damages arising herefrom. The fact that an organization or Website is referred toin this work as a citation and/or a potential source of further information does not mean that the authoror the publisher endorses the information the organization or Website may provide or recommendations itmay make. Further, readers should be aware that Internet Websites listed in this work may have changedor disappeared between when this work was written and when it is read.
For general information on our other products and services or to obtain technical support, please contactour Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 orfax (317) 572-4002.
Library of Congress Cataloging-in-Publication Data is available from the publisher.
Trademarks: Wiley, the Wiley logo, and related trade dress are trademarks or registered trademarks ofJohn Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not beused without written permission. All other trademarks are the property of their respective owners. WileyPublishing, Inc., is not associated with any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print maynot be available in electronic books.
To my children, Kai and Katja. — Nicholas Solter
To my wife, Sarah, who had no idea we would be moving when Iwas in the middle of this book, but who was always encouraging
and supportive. — Jerry Jelinek
I dedicate this book to my wife, Kris. I hope she doesn’t regrettelling me, while I was considering participating, that I won’t
regret having written it! — Dave Miner
About the AuthorsNicholas Solter has worked at Sun Microsystems for more than eight years in the areas of highavailability and distributed systems. In his work on the Solaris Cluster product, he has imple-mented clustering support for core Solaris features such as Zones and SMF. He was the techni-cal lead in open sourcing the Solaris Cluster product and is currently leading the effort to runSolaris Cluster on the OpenSolaris distribution.
In addition to his work at Sun, Nicholas has experience in the computer game industry atDigital Media International and Electronic Arts. He is also the lead author of Professional C++(Wrox) and has taught C++ at the college level.
Nicholas studied computer science at Stanford University, where he earned bachelor of science(with distinction) and master of science degrees, with a concentration in systems. When notworking, he enjoys spending time with his family, playing basketball, reading, and playing in theColorado snow (having been deprived of winters growing up in Southern California).
Gerald Jelinek has been an engineer at Sun Microsystems for a total of almost 20 years,although not contiguously. He currently works on the Zones virtualization subsystem in Open-Solaris. In the past, he has worked on a wide variety of projects, including system installation,JumpStart, printing, a variety of system administration tools, and the Solaris Volume Manager. Alittle-known fact is that he personally assembled the various project bits and burned the Solaris2.0 golden CD. In addition to Sun, Gerald has worked at several other companies.
Gerald graduated from Washington University in St. Louis with a B.S. in computer science,and from the University of Colorado with an M.S. in computer science. He and his wife, Sarah,spend most of their free time fixing up the 85-year-old house they recently moved into.
David Miner has been an engineer at Sun Microsystems for nearly two decades. He is presentlythe lead for the Caiman installer project and co-lead for the OpenSolaris distribution. Duringhis time at Sun he has worked primarily in the areas of system administration and networkingand has been a significant contributor to a variety of projects in both fields, including the Solarisadmintool and sysidtool, PC-NFS, the Solaris DHCP server and DHCP Manager managementtool, and the Service Management Facility (SMF). Prior to Sun, Dave worked at Prime Computeron TCP/IP networking.
David graduated from Michigan State University with a B.S. (with honors) in computer science.In his spare time, Dave is an avid golfer and hoopster. He and his wife, Kris Corwin, are theadoptive parents of a small pack of retired racing greyhounds.
CreditsExecutive EditorBob Elliott
Development EditorMaryann Steinhart
Technical EditorPeter Baer Galvin
Production EditorDassi Zeidel
Copy EditorLuann Rouff
Editorial ManagerMary Beth Wakefield
Production ManagerTim Tate
Vice President and Executive GroupPublisherRichard Swadley
Vice President and Executive PublisherBarry Pruett
Project Coordinator, CoverLynsey Stanford
ProofreaderJosh Chase, Word One
IndexerTed Laux
Cover IllustrationJoyce Haughey
Cover DesignerMichael E. Trent
AcknowledgmentsMany people contributed directly and indirectly to this book. We would first like to thank BobElliot, executive editor at Wiley, for letting us write this book, and our agent, David Fugate ofLaunchBooks Literary Agency, for helping to make the project possible. Our editors, MaryannSteinhart, Dassi Zeidel, and Luann Rouff, excellently guided us through the writing and revisionprocess, while Peter Baer Galvin provided invaluable technical feedback and corrections.
Additionally, we would like to thank the following people, who reviewed one or more chapters:Alexandre Chartre, Bonnie Corwin, Thorsten Fruauf, Moinak Ghosh, Susan Kamm-Worrell, andJohn Levon. Thank you, also, to Steve McKinty for providing the content on Open HA ClusterGeographic Edition. Any remaining errors are, of course, our own.
A special thanks goes to Sanjay Nadkarni, who provided the camera Dave used in completingthe examples in Chapter 5 during a trip to Sun’s Broomfield campus.
We also want to acknowledge the thousands of engineers over the past 40 years who havecontributed to the code that is now OpenSolaris. Additionally, we would like to recognizeSun Microsystems’ courageous step of open sourcing the Solaris operating system to createOpenSolaris, and the combined wisdom and numerous contributions of the OpenSolariscommunity. Although we are employees of Sun and members of the OpenSolaris community,the contents of this book are our own, and do not necessarily reflect the views of these entities.
Finally, we would like to thank our respective spouses, Sonja Solter, Sarah Jelinek, and Kris Cor-win, for bearing with us through this process and tolerating our long nights and weekends spenton this book.
Introduction ..................................................................................................................................xxix
Part IChapter 1: What Is OpenSolaris? ......................................................................................................3Chapter 2: Installing OpenSolaris ...................................................................................................19Chapter 3: OpenSolaris Crash Course ............................................................................................47
Part IIChapter 4: The Desktop ................................................................................................................103Chapter 5: Printers and Peripherals ..............................................................................................135Chapter 6: Software Management .................................................................................................167
Part IIIChapter 7: Disks, Local File Systems, and the Volume Manager ................................................191Chapter 8: ZFS ..............................................................................................................................223Chapter 9: Networking .................................................................................................................263Chapter 10: Network File Systems and Directory Services .........................................................331Chapter 11: Security ..................................................................................................................... 369
Part IVChapter 12: Fault Management ....................................................................................................451Chapter 13: Service Management .................................................................................................465Chapter 14: Monitoring and Observability ..................................................................................503Chapter 15: DTrace .......................................................................................................................529Chapter 16: Clustering OpenSolaris for High Availability ...........................................................575
Part VChapter 17: Virtualization Overview ............................................................................................649Chapter 18: Resource Management ..............................................................................................659Chapter 19: Zones .........................................................................................................................693Chapter 20: xVM Hypervisor ........................................................................................................741Chapter 21: Logical Domains (LDoms) ........................................................................................787Chapter 22: VirtualBox .................................................................................................................823
xi
Contents at a Glance
Part VIChapter 23: Deploying a Web Stack on OpenSolaris ..................................................................845Chapter 24: Developing on OpenSolaris ......................................................................................869
Index ..............................................................................................................................................937
xii
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
Part I
Chapter 1: What Is OpenSolaris? . . . . . . . . . . . . . . . . . . . . . . 3Introduction to OpenSolaris ...................................................................................................3
OpenSolaris code ...........................................................................................................3OpenSolaris distributions ..............................................................................................4OpenSolaris community ................................................................................................4
OpenSolaris Features ...............................................................................................................5The ‘‘Open’’ in OpenSolaris ....................................................................................................6
Open source software basics .........................................................................................6Open source licenses .....................................................................................................7OpenSolaris licenses ......................................................................................................8Open development ........................................................................................................9What open source OpenSolaris means to you .............................................................9
The History of OpenSolaris .....................................................................................................9Comparing OpenSolaris to Other Operating Systems .........................................................11
OpenSolaris and Solaris ..............................................................................................11OpenSolaris and Linux ................................................................................................11OpenSolaris and BSD ..................................................................................................13
Getting Involved in OpenSolaris ...........................................................................................13Running OpenSolaris ..................................................................................................13Participating in discussion lists ...................................................................................14Finding OpenSolaris user groups ...............................................................................14Contributing to OpenSolaris .......................................................................................15
OpenSolaris Development Process ........................................................................................15Resources ...............................................................................................................................16Summary ................................................................................................................................17
Chapter 2: Installing OpenSolaris . . . . . . . . . . . . . . . . . . . . . 19Solaris Express Community Edition .....................................................................................20Schillix ...................................................................................................................................21BeleniX ...................................................................................................................................22NexentaCore ..........................................................................................................................23MartUX ..................................................................................................................................24MilaX ......................................................................................................................................25
xiii
Contents
OpenSolaris ............................................................................................................................26History of the OpenSolaris distribution .....................................................................26What OpenSolaris includes .........................................................................................27Will OpenSolaris run on my hardware? .....................................................................28Downloading OpenSolaris ...........................................................................................29Booting the OpenSolaris CD .......................................................................................30Installing OpenSolaris .................................................................................................33Booting OpenSolaris ....................................................................................................41Installing OpenSolaris in a virtual machine ...............................................................43
Resources ...............................................................................................................................45Summary ................................................................................................................................46
Chapter 3: OpenSolaris Crash Course . . . . . . . . . . . . . . . . . . . 47Discovering the Desktop .......................................................................................................47
Overview ......................................................................................................................48Managing windows ......................................................................................................49Navigating files and directories ...................................................................................49Using the Internet .......................................................................................................51Office suite ...................................................................................................................52Multimedia ...................................................................................................................52Printers and peripherals ..............................................................................................53Customizing GNOME .................................................................................................53Logging out and shutting down .................................................................................53
Using the Command Line .....................................................................................................54Shells ............................................................................................................................54Executing commands ..................................................................................................55Shell History ................................................................................................................57Environment variables .................................................................................................58Command paths ..........................................................................................................59Managing files ..............................................................................................................61Redirection ...................................................................................................................64Job control ...................................................................................................................64Customizing Bash ........................................................................................................65Text editors ..................................................................................................................66Running privileged commands ...................................................................................68
Switching Languages and Locales .........................................................................................71Changing locale in GNOME .......................................................................................71Changing locale in a terminal session ........................................................................73Changing the default system locale ............................................................................74Changing keyboard layout and input languages ........................................................74Installing additional languages ....................................................................................75
Getting Online .......................................................................................................................75Network AutoMagic ....................................................................................................75Manual network configuration ....................................................................................75Troubleshooting network connections .......................................................................77
xiv
Contents
Adding Software ....................................................................................................................78Finding and installing software ...................................................................................78Alternative repositories ................................................................................................80
Developing on OpenSolaris ...................................................................................................82Connecting Remotely ............................................................................................................82System Administration ..........................................................................................................83
System information .....................................................................................................83Processes and services .................................................................................................85Users, groups, and roles ..............................................................................................89Storage and file systems ..............................................................................................92Log files .......................................................................................................................95Booting and shutting down ........................................................................................95Managing boot environments .....................................................................................97Managing GRUB and the OpenSolaris boot archive ..................................................97
Resources ...............................................................................................................................99Summary ................................................................................................................................99
Part II
Chapter 4: The Desktop . . . . . . . . . . . . . . . . . . . . . . . . . 103
Desktop Customization .......................................................................................................103Desktop session .........................................................................................................103Locking the session ...................................................................................................104Customizing the panel ..............................................................................................105Customizing your desktop’s appearance ..................................................................106Other preferences ......................................................................................................107
Desktop Sharing ..................................................................................................................108Internet Applications ...........................................................................................................110
Web browsing with Firefox ......................................................................................110E-mail and calendar ..................................................................................................112Instant messaging ......................................................................................................116
Media Applications ..............................................................................................................119Audio .........................................................................................................................119Video ..........................................................................................................................122
Graphics Applications .........................................................................................................122Screenshots ................................................................................................................122Viewing images ..........................................................................................................122Organizing and editing images .................................................................................123
System Administration ........................................................................................................125Users and groups ...................................................................................................... 125Keyring Manager .......................................................................................................127Disk Usage Analyzer ..................................................................................................127Log File Viewer .........................................................................................................128
xv
Contents
Performance Monitor ................................................................................................129Power management and statistics .............................................................................129
Other Applications ..............................................................................................................130Troubleshooting ...................................................................................................................131
X server startup .........................................................................................................131GNOME session startup ............................................................................................132
Resources .............................................................................................................................132Summary ..............................................................................................................................133
Chapter 5: Printers and Peripherals . . . . . . . . . . . . . . . . . . . . 135Printing ................................................................................................................................135
Automatic printer configuration with Presto ............................................................136Manual printer configuration ....................................................................................138PPD management ......................................................................................................147
Scanners ...............................................................................................................................148USB Devices .........................................................................................................................149
Keyboards and mice ..................................................................................................149MP3 players ...............................................................................................................150Webcams ...................................................................................................................150Digital cameras ..........................................................................................................153
Audio ...................................................................................................................................156Serial Devices and Modems ................................................................................................156
Serial ports .................................................................................................................156USB-to-serial converters ............................................................................................157Modems .....................................................................................................................159
Network Interfaces ..............................................................................................................159Power Management and UPSs ............................................................................................161
Configuring power management ..............................................................................161Uninterruptible power supply (UPS) ........................................................................162
Device Drivers .....................................................................................................................163Resources .............................................................................................................................164Summary ..............................................................................................................................165
Chapter 6: Software Management . . . . . . . . . . . . . . . . . . . . 167Package Management ..........................................................................................................167
IPS concepts ..............................................................................................................168Package names and versions .....................................................................................169Installing packages with Package Manager ...............................................................171Removing packages ...................................................................................................172Viewing, verifying, and searching packages .............................................................173
Updating Your Software ......................................................................................................177Boot Environment Management .........................................................................................180
Viewing boot environments ......................................................................................180Activating and renaming boot environments ...........................................................182Creating and destroying boot environments ............................................................183
xvi
Contents
Mounting boot environments ...................................................................................185Managing a Package Repository ..........................................................................................185Building Your Own Distribution ........................................................................................ 187Resources .............................................................................................................................188Summary ..............................................................................................................................188
Part III
Chapter 7: Disks, Local File Systems, and the Volume Manager . . . . . . 191Disks ....................................................................................................................................192
Disk device names .....................................................................................................192Formatting and labeling ............................................................................................193Removable media ......................................................................................................196RAM disk ...................................................................................................................198lofi ..............................................................................................................................198SANs ..........................................................................................................................198iSCSI ..........................................................................................................................199I/O Multipathing .......................................................................................................202Remote replication ....................................................................................................203Other Disk Utilities ...................................................................................................203
File System Management .....................................................................................................205Mounting and unmounting file systems ...................................................................205Monitoring file systems .............................................................................................206File systems and shutting down ...............................................................................207
devfs .....................................................................................................................................207UFS ......................................................................................................................................207
Creating a UFS File System ......................................................................................208Logging ......................................................................................................................209UFS Mount Options ..................................................................................................209Checking and Repairing a UFS File System .............................................................209Quotas .......................................................................................................................211Backup, Snapshots, and Restore ...............................................................................212
Swap Space ..........................................................................................................................214Other Local File Systems .................................................................................................... 216
pcfs ............................................................................................................................ 216hsfs .............................................................................................................................216tmpfs ..........................................................................................................................216lofs .............................................................................................................................217SAM-QFS ...................................................................................................................217FUSE ..........................................................................................................................217
The Volume Manager ..........................................................................................................217Creating the metadb ..................................................................................................218Creating a metadevice ...............................................................................................218Other commands and features ..................................................................................220
xvii
Contents
Resources .............................................................................................................................221Summary ..............................................................................................................................222
Chapter 8: ZFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223ZFS Basics ............................................................................................................................224Managing ZFS Pools ............................................................................................................226
Mirrors .......................................................................................................................227RAID Z .......................................................................................................................231Spare devices .............................................................................................................232Data scrubbing ..........................................................................................................234Migration ...................................................................................................................235Pool properties ..........................................................................................................237Pool history ...............................................................................................................239Monitoring ZFS performance ....................................................................................240
ZFS Datasets ........................................................................................................................241ZFS file systems .........................................................................................................241ZFS volumes ..............................................................................................................243ZFS snapshots ............................................................................................................245ZFS clones .................................................................................................................248Dataset replication and backups ...............................................................................249Dataset properties ......................................................................................................251ZFS encryption ..........................................................................................................257
ZFS Delegated Administration ............................................................................................258ZFS Versioning ....................................................................................................................259Resources .............................................................................................................................261Summary ..............................................................................................................................262
Chapter 9: Networking . . . . . . . . . . . . . . . . . . . . . . . . . . 263Network Interfaces ..............................................................................................................263
Displaying IP interfaces .............................................................................................265Configuring interfaces automatically with NWAM ..................................................267Configuring interfaces manually ...............................................................................271Logical interfaces .......................................................................................................276IP multipathing .........................................................................................................278Link aggregation ........................................................................................................285Configuring virtual LAN interfaces ...........................................................................287Configuring a virtual NIC .........................................................................................288Configuring IP tunnels ..............................................................................................288PPP and PPP over Ethernet .......................................................................................290
Network Services .................................................................................................................290Domain Name System ...............................................................................................290Multicast DNS ...........................................................................................................299Dynamic Host Configuration Protocol .....................................................................300File Transfer Protocol ................................................................................................305Network Time Protocol .............................................................................................306
xviii
Contents
Mail service ................................................................................................................308HTTP .........................................................................................................................309inetd ...........................................................................................................................309
OpenSolaris As a Router or Firewall ..................................................................................313Routing ......................................................................................................................313Configuring a firewall with IP filter ..........................................................................318TCP Wrappers ...........................................................................................................322
Troubleshooting ...................................................................................................................324netstat ........................................................................................................................ 324ping and traceroute ...................................................................................................325Snoop .........................................................................................................................326SNMP .........................................................................................................................328
Resources .............................................................................................................................328Summary ..............................................................................................................................329
Chapter 10: Network File Systems and Directory Services . . . . . . . . 331
Introduction to NFS ............................................................................................................332Introduction to CIFS ...........................................................................................................332Managing File Sharing .........................................................................................................333
Installing sharing packages .......................................................................................334Share groups and sharemgr ......................................................................................334Configuring sharing services with sharectl ...............................................................338Configuring the CIFS service in workgroup mode ..................................................340Automatic sharing of user home directories with CIFS ...........................................341Advanced CIFS server topics ....................................................................................341
Accessing Files with NFS ....................................................................................................342Manual NFS mounts .................................................................................................343Mounting NFS shares with the automounter ...........................................................344NFS security ..............................................................................................................346NFS monitoring and troubleshooting .......................................................................349
Accessing Files with CIFS ...................................................................................................349OpenSolaris Naming Services .............................................................................................353
The name service switch ...........................................................................................353Name service caching with nscd ..............................................................................354Troubleshooting name service lookups ....................................................................355
NIS .......................................................................................................................................355Configuring a NIS client ...........................................................................................356Configuring a NIS master server ..............................................................................360Configuring a NIS slave server .................................................................................362Managing NIS maps ..................................................................................................364Leaving a NIS domain ...............................................................................................365
LDAP ....................................................................................................................................365OpenSolaris as an LDAP server ................................................................................366OpenSolaris as an LDAP client .................................................................................366
xix
Contents
Resources .............................................................................................................................367Summary ..............................................................................................................................368
Chapter 11: Security . . . . . . . . . . . . . . . . . . . . . . . . . . . 369Security Overview ............................................................................................................... 369
Being a global security citizen ..................................................................................370Organization of this chapter .....................................................................................371
Preventing Unauthorized Access .........................................................................................371User education and physical security .......................................................................372Pluggable Authentication Modules (PAM) ................................................................372Password management ..............................................................................................375Firewalls .....................................................................................................................379Secure by Default (SBD) ...........................................................................................380
Limiting the Damage ...........................................................................................................384Role-based access control ..........................................................................................384Privileges ....................................................................................................................394Restricted shell ..........................................................................................................398Access control lists ....................................................................................................399Encrypted files ...........................................................................................................404Message digests ..........................................................................................................405Preventing user stack execution ...............................................................................406Zones and resource management .............................................................................406
Ensuring Secure Communication .......................................................................................406Secure Shell ...............................................................................................................408IP security ..................................................................................................................413
Detecting Attacks .................................................................................................................420Logs ............................................................................................................................420Basic Audit Reporting Tool .......................................................................................422Solaris Auditing .........................................................................................................425Virus scanning ...........................................................................................................430
Kerberos ...............................................................................................................................431Clock synchronization ...............................................................................................431Setting up the key distribution center ......................................................................433Setting up the Kerberos clients .................................................................................434Starting Kerberized services ......................................................................................435Creating Kerberos accounts ......................................................................................436Managing tickets ........................................................................................................437Using Kerberized services .........................................................................................438Kerberized NFS .........................................................................................................439Configuring PAM for Kerberos .................................................................................441Kerberos logs .............................................................................................................444Enhancing Kerberos availability ................................................................................445
Trusted Extensions ..............................................................................................................445Resources .............................................................................................................................446Summary ..............................................................................................................................448
xx
Contents
Part IV
Chapter 12: Fault Management . . . . . . . . . . . . . . . . . . . . . . 451Predictive Self-Healing ........................................................................................................451
Fault managed resource identifiers ...........................................................................452Fault management versus service management ........................................................453
Fault Management Overview ..............................................................................................453FMD pluggable modules ...........................................................................................454Knowledge articles ....................................................................................................454Fault management hardware support .......................................................................455
Fault Management Commands ...........................................................................................455fmadm ........................................................................................................................455fmstat .........................................................................................................................456fmdump .....................................................................................................................457Other fault management commands ........................................................................459
Using Fault Management ....................................................................................................461Resources .............................................................................................................................464Summary ..............................................................................................................................464
Chapter 13: Service Management . . . . . . . . . . . . . . . . . . . . . 465Processes and Services .........................................................................................................465SMF By Example .................................................................................................................468
The service manifest ..................................................................................................472Service method script ................................................................................................479Service management commands ...............................................................................481
SMF Machinery ................................................................................................................... 490Restarters ...................................................................................................................490SMF repository ..........................................................................................................493The manifest-import service .....................................................................................495Milestones and init compatibility .............................................................................496Profiles .......................................................................................................................499
Customizing SMF Services ..................................................................................................500Resources .............................................................................................................................501Summary ..............................................................................................................................501
Chapter 14: Monitoring and Observability . . . . . . . . . . . . . . . . 503Getting System Configuration Information ........................................................................504Primary Utilities ...................................................................................................................509
uptime ........................................................................................................................509ps ...............................................................................................................................509prstat ..........................................................................................................................510vmstat ........................................................................................................................512mpstat ........................................................................................................................514iostat ..........................................................................................................................515
/proc .....................................................................................................................................516
xxi
Contents
Kstats ...................................................................................................................................518Other Utilities ......................................................................................................................519
cpustat .......................................................................................................................519truss ...........................................................................................................................520intrstat ........................................................................................................................521lockstat .......................................................................................................................522sar ..............................................................................................................................523
Logs ......................................................................................................................................524syslog .........................................................................................................................524Log management .......................................................................................................525User activity ...............................................................................................................525
SNMP ...................................................................................................................................526Resources .............................................................................................................................527Summary ..............................................................................................................................527
Chapter 15: DTrace . . . . . . . . . . . . . . . . . . . . . . . . . . . 529Getting Started .....................................................................................................................530Tracing Syntax .....................................................................................................................535
Program structure ......................................................................................................535Probes ........................................................................................................................536Predicates ...................................................................................................................539Actions .......................................................................................................................541
The dtrace Command .........................................................................................................559Advanced Tracing ................................................................................................................560
Tracing during boot ..................................................................................................560Buffering ....................................................................................................................560Speculative tracing ....................................................................................................562Postmortem tracing ...................................................................................................563Standalone programs .................................................................................................564
User-Level and High-Level Language Tracing ....................................................................564The pid provider .......................................................................................................564The sdt provider ........................................................................................................565User-level data ...........................................................................................................568Tracing Java programs ..............................................................................................569Tracing programs in other languages .......................................................................572
Resources .............................................................................................................................573Summary ..............................................................................................................................574
Chapter 16: Clustering OpenSolaris for High Availability . . . . . . . . . 575Introduction to High-Availability Clusters .........................................................................575Overview of Open High Availability Cluster ......................................................................576
Cluster infrastructure ................................................................................................577Cluster agents ............................................................................................................578
Setting Up a Cluster ............................................................................................................579Hardware requirements and configuration ...............................................................579
xxii
Contents
Installing the cluster software ...................................................................................583Configuring the cluster .............................................................................................584
Using the Cluster .................................................................................................................589Managing services ......................................................................................................589Making Apache highly available ...............................................................................590Making Apache scalable ............................................................................................600
Advanced Cluster Administration .......................................................................................606Shutting down the cluster .........................................................................................606Service management ..................................................................................................606Volume management .................................................................................................622Zones As Logical Nodes ............................................................................................622Network load balancing ............................................................................................627Other cluster commands ...........................................................................................628
Making Custom Services Highly Available .........................................................................631SMF Proxy .................................................................................................................631Generic data service ..................................................................................................633
Disaster Recovery with Open High Availability Cluster ....................................................634Terminology ..............................................................................................................635Open HA Cluster Geographic Edition ......................................................................635Setting up a Geographic Edition configuration ........................................................636Topology and architecture ........................................................................................637Installing and configuring Geographic Edition ........................................................638Geographic Edition operations .................................................................................642
Resources .............................................................................................................................643Summary ..............................................................................................................................645
Part V
Chapter 17: Virtualization Overview . . . . . . . . . . . . . . . . . . . 649Benefits of Virtualization .....................................................................................................650Types of Virtualization ........................................................................................................651
Resource management ...............................................................................................651Operating-system-level virtualization .......................................................................651Full virtualization ......................................................................................................652Comparison of virtualization layers ..........................................................................654Other virtualization solutions ...................................................................................655
Comparing Virtualization Solutions ....................................................................................655Virtualization and a Graphical Display ...............................................................................657Virtualization Administration ..............................................................................................658Summary ..............................................................................................................................658
Chapter 18: Resource Management . . . . . . . . . . . . . . . . . . . . 659Introduction to Resource Management ...............................................................................659Projects and Tasks ...............................................................................................................660
xxiii
Contents
The project database .................................................................................................661Determining the default project ................................................................................662Changing tasks ..........................................................................................................663Configuring projects ..................................................................................................663Managing by project and task ..................................................................................665
Resource Controls ............................................................................................................... 665Using rctls ..................................................................................................................666rctl Syntax ..................................................................................................................667rctl list ........................................................................................................................668Project rctls ................................................................................................................668
Resource Caps .....................................................................................................................671Resource Pools .....................................................................................................................672
Configuring a pool ....................................................................................................672Binding a pool to a project .......................................................................................675Dynamically binding to a pool .................................................................................675Monitoring pools .......................................................................................................676Advanced pool configuration ....................................................................................676The dynamic pool daemon .......................................................................................680
Processor Sets ......................................................................................................................682Scheduling ...........................................................................................................................682
The Fair Share Scheduler ..........................................................................................684Managing scheduling classes .....................................................................................686CPU caps ...................................................................................................................687
Accounting ...........................................................................................................................687Legacy accounting .....................................................................................................687Extended accounting .................................................................................................688
Resources .............................................................................................................................691Summary ..............................................................................................................................692
Chapter 19: Zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693Introduction to Zones .........................................................................................................693Uses of Zones ......................................................................................................................694Getting Started with Zones .................................................................................................694
Configuring a zone ....................................................................................................694Installing a zone ........................................................................................................696Booting a zone ...........................................................................................................697Logging in to a zone .................................................................................................698Halting a zone ...........................................................................................................699
Advanced Zone Configuration ............................................................................................699Resource management ...............................................................................................699Networking ................................................................................................................705Sparse root versus whole root ..................................................................................708Other zonecfg features ..............................................................................................710
Advanced zoneadm Features ...............................................................................................719Moving a zone on the same machine .......................................................................719
xxiv
Contents
Moving a zone from one machine to another ..........................................................719Cloning a zone ..........................................................................................................723Uninstalling a zone ....................................................................................................724
Ongoing Zones Administration ...........................................................................................724Preconfiguring system identity ..................................................................................724Zones-related processes .............................................................................................725Accessing a zone ........................................................................................................725Monitoring .................................................................................................................726Dynamically reconfiguring a zone ............................................................................729SMF ............................................................................................................................731Backup and restore ....................................................................................................731Software management ...............................................................................................732Other tools .................................................................................................................733
Limitations to Zones ............................................................................................................733Branded Zones .....................................................................................................................734
The ipkg brand ..........................................................................................................735The lx brand ..............................................................................................................735Experimental Linux 2.6 support ...............................................................................738Other brands .............................................................................................................738Implementation .........................................................................................................739
Resources .............................................................................................................................739Summary ..............................................................................................................................740
Chapter 20: xVM Hypervisor . . . . . . . . . . . . . . . . . . . . . . . 741xVM Concepts .....................................................................................................................742Getting Started with xVM ...................................................................................................744
Installing the xVM software and booting under the hypervisor ..............................744Configuring and installing a guest domain ..............................................................746Logging in to a guest domain ...................................................................................748Basic management of a guest domain ......................................................................748
Advanced xVM Administration ...........................................................................................751Command line interfaces ..........................................................................................751Installation .................................................................................................................751Monitoring .................................................................................................................757Ongoing management ...............................................................................................761Domain console .........................................................................................................767SMF services ..............................................................................................................768
Live Migration .....................................................................................................................769Enabling live migration .............................................................................................770Migrating a domain ...................................................................................................771
Virtual Devices .....................................................................................................................772CPUs ..........................................................................................................................772Memory ......................................................................................................................776Virtual disks ..............................................................................................................778Networking ................................................................................................................780
xxv
Contents
Other devices .............................................................................................................782Devices in HVM domains .........................................................................................782
Troubleshooting ...................................................................................................................782Logs ............................................................................................................................782DomU core dumps ....................................................................................................783Dom0 core dump ......................................................................................................784DTrace .......................................................................................................................784
Resources .............................................................................................................................785Summary ..............................................................................................................................785
Chapter 21: Logical Domains (LDoms) . . . . . . . . . . . . . . . . . . 787Introduction to LDoms .......................................................................................................787LDom Concepts ...................................................................................................................788
Types of domains ......................................................................................................788Types of services and devices ...................................................................................789
Getting Started with LDoms ...............................................................................................791Checking the firmware ..............................................................................................791Installing the management software .........................................................................792Administrative privileges ...........................................................................................792Configuring the control domain ...............................................................................792Configuring a guest domain .....................................................................................795Logging in to a guest domain ...................................................................................798Booting and installing a guest domain .....................................................................798
Advanced LDom Administration ........................................................................................800Monitoring .................................................................................................................800ldmd daemon ............................................................................................................803Delayed reconfiguration ............................................................................................803Virtual I/O services ....................................................................................................804Physical I/O ...............................................................................................................808Creating services in a different domain ....................................................................810CPU, memory, and MAU ..........................................................................................810Virtual Disks ..............................................................................................................812Networking ................................................................................................................813Console ......................................................................................................................814Variables ....................................................................................................................816Other administrative subcommands .........................................................................817Managing configurations on the system controller ..................................................818Migrating a domain from one machine to another ..................................................818Hardening the control domain .................................................................................820
Resources .............................................................................................................................820Summary ..............................................................................................................................821
Chapter 22: VirtualBox . . . . . . . . . . . . . . . . . . . . . . . . . . 823Getting Started .....................................................................................................................824
Configuring and installing a virtual machine ...........................................................824
xxvi
Contents
Booting and installing the guest OS .........................................................................826Managing VirtualBox ...........................................................................................................828
The running VM window .........................................................................................829The VirtualBox management GUI .............................................................................830
Advanced Features ..............................................................................................................833Guest additions ......................................................................................................... 833The management CLI ................................................................................................835Networking ................................................................................................................836Storage .......................................................................................................................837Remote access ............................................................................................................840Programmatic interfaces ............................................................................................841Running within a zone ..............................................................................................841
Resources .............................................................................................................................842Summary ..............................................................................................................................842
Part VI
Chapter 23: Deploying a Web Stack on OpenSolaris . . . . . . . . . . . 845The Web Stack on OpenSolaris ..........................................................................................845The AMP Stack ....................................................................................................................847
Installing the AMP stack ...........................................................................................847Configuring Apache ..................................................................................................848Configuring PHP .......................................................................................................850Configuring MySQL ..................................................................................................851Web applications .......................................................................................................853Alternatives to Apache, MySQL, and PHP ...............................................................854
Java-based Web Services .....................................................................................................859Apache Tomcat ..........................................................................................................859GlassFish Application Server .................................................................................... 864
Resources .............................................................................................................................866Summary ..............................................................................................................................866
Chapter 24: Developing on OpenSolaris . . . . . . . . . . . . . . . . . 869Java Development ................................................................................................................869
Compilers and tools ..................................................................................................870Debugging with JDB ..................................................................................................871
C and C++ Development ....................................................................................................875Compilers and tools ..................................................................................................875OpenSolaris C APIs ...................................................................................................878Debugging ..................................................................................................................879
Other Languages ..................................................................................................................891Perl .............................................................................................................................891Python ........................................................................................................................891Ruby on Rails ............................................................................................................892
xxvii
Contents
PHP ............................................................................................................................893Shell scripting ............................................................................................................893
Build Automation ................................................................................................................894NetBeans ..............................................................................................................................894
NetBeans overview ....................................................................................................895NetBeans for Java ......................................................................................................897NetBeans C and C++ development ...........................................................................903NetBeans plug-ins .....................................................................................................906NetBeans web application development ...................................................................907
Source Code Management ...................................................................................................912CVS ............................................................................................................................913Subversion .................................................................................................................918Mercurial ....................................................................................................................922
Building IPS Packages .........................................................................................................926IPS actions .................................................................................................................927IPS package example .................................................................................................927
Crash Dumps and Kernel Debugging .................................................................................929Core files and crash dumps ......................................................................................929Kernel debugging ......................................................................................................931
Resources .............................................................................................................................934Summary ..............................................................................................................................936
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 937
xxviii