Sie sind auf Seite 1von 33
S ERVICE M ANAGEMENT F ACILITY (SMF) IN THE S OLARIS ™ 10 O PERATING
S ERVICE M ANAGEMENT F ACILITY (SMF) IN THE S OLARIS ™ 10 O PERATING

SERVICE MANAGEMENT FACILITY (SMF)

IN THE SOLARIS™ 10 OPERATING SYSTEM

Rob Romack, PTS (Mid-Range Server Group)

Sun BluePrints™ OnLine — February 2006

Server Group) Sun BluePrints™ OnLine — February 2006 Part No 819-5150-10 Revision 1.1, 2/20/06 Edition:

Part No 819-5150-10 Revision 1.1, 2/20/06 Edition: February 2006

© 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, CA 95054 USA

All rights reserved.

This product or document is protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation. No part of this product or document may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. Third-party software, including font technology, is copyrighted and licensed from Sun suppliers.

Parts of the product may be derived from Berkeley BSD systems, licensed from the University of California.

Sun, Sun Microsystems, the Sun logo, Solaris, Sun BluePrints, Sun Enterprise, OpenSolaris, BigAdmin, and SunDocs are trademarks, registered trademarks, or service marks of Sun Microsystems, Inc. in the U.S. and other countries.

UNIX is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd.

Oracle is a registered trademark of Oracle Corporation.

The OPEN LOOK and Sun™ Graphical User Interface was developed by Sun Microsystems, Inc. for its users and licensees. Sun acknowledges the pioneering efforts of Xerox in researching and developing the concept of visual or graphical user interfaces for the computer industry. Sun holds a non-exclusive license from Xerox to the Xerox Graphical User Interface, which license also covers Sun’s licensees who implement OPEN LOOK GUIs and otherwise comply with Sun’s written license agreements.

RESTRICTED RIGHTS: Use, duplication, or disclosure by the U.S. Government is subject to restrictions of FAR 52.227-14(g)(2)(6/87) and FAR 52.227-19(6/87), or DFAR 252.227-7015(b)(6/95) and DFAR 227.7202-3(a). DOCUMENTATION IS PROVIDED “AS IS” AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS HELD TO BE LEGALLY INVALID.

OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS HELD TO BE LEGALLY INVALID.

Please

Recycle

OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS HELD TO BE LEGALLY INVALID.

Table of Contents

Table of Contents

Sun Microsystems, Inc.

. An Introduction to SMF Services

About This Document

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

Features and Benefits of

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

2

SMF SMF Restarters SMF Service Instances Components of a SMF Service

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

3

3

3

4

SMF

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

5

. Service Executable

Service Methods

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

5

5

Service Log Files

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

5

Service Identifiers — FMRIs

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

5

Administering SMF Services

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

7

Service States

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

8

An Example of Using SMF Administrative Commands

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

9

Administering Network Services with

11

inetd as a Restarter Creating a New SMF Service Constructing a New SMF Service — An

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

13

15

15

Service Dependencies.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

18

Dependency Attributes

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

20

Service Dependency

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

21

SMF Initialization at

Milestone Services and System Booting

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

22

23

Specifying a Milestone Dependency on a

24

Resolving Dependency Cycles

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

25

Another Dependency Example — Direct Root

27

Summary

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

28

About the Author

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

28

References

. Accessing Sun Documentation Online

. Ordering Sun Documents

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

28

29

29

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

1-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

Service Management Facility (SMF) in the Solaris 10 Operating System

Introduction

A significant challenge in today's data centers is the demand for increased service levels in environments

that feature increasing complexity. The Solaris™ 10 Operating System (OS) introduces a new foundation that improves service levels by detecting and correcting component failures while simplifying systems management. This foundation — known as Predictive Self-Healing — includes new technologies that Sun has incorporated into its hardware and software products to maximize availability in the event of system faults. Overall, Predictive Self-Healing simplifies system administration and helps to contribute to a lower total cost of ownership (TCO) in the data center.

A key component of Predictive Self-Healing is the new Service Management Facility (SMF) in the

Solaris 10 OS. SMF is designed to simplify the management of system and application services. It delivers

new and improved ways to control services, and tries to restart failed services automatically. In addition, SMF allows administrators to define the relationships between services. It is now possible to define a service that is dependent on other services — a dependent service will not run unless the other services that it requires are already running. Through a set of new administrative interfaces, SMF allows services to be easily and consistently configured, enabled, and controlled, at the same time providing better visibility

of errors and improved debugging capabilities to resolve service-related problems quickly when they occur.

About This Document

This BluePrint Article is intended for system administrators. It introduces the functionality provided by the Service Management Facility (SMF) and demonstrates the use of new SMF administrative commands. It assumes that the reader has a reasonable level of knowledge of the Solaris OS (in particular, of OS versions prior to Solaris 10), or of other UNIX ® systems in general. The article makes the assumption that the reader is not already familiar with SMF or other specifics of the Solaris 10 OS.

This BluePrint Article addresses the following topics:

• Features and benefits of SMF

• The SMF repository, SMF services, and service instances

• Components of a service, including SMF manifests and service identifiers

• How to administer SMF services, including SMF commands and examples of how to perform common SMF administrative tasks

• How to administer network services in SMF using the inetadm interface

• An example of how to create a new SMF service

• Service dependencies and examples of how dependencies are defined

• SMF initialization at boot time

• Milestone services and how to associate services with milestones

• Dependency cycles and the process of resolving them

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

2-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

In this article, the Courier font is used to represent command line entries, file names, or excerpts from system files. When examples of a command are given, the use of bold Courier type represents what is typed by the user, while regular-face Courier type indicates system prompts or system output.

An Introduction to SMF Services

In the most general sense, SMF services provide capabilities to applications and other services, both local and remote. In the Solaris 10 OS, most system services — such as network services (ftp, telnet, rlogin, etc.), file system services, security services, device services, print services, cron services, and so forth — are implemented as SMF services. Besides typical UNIX ® system services, the SMF management framework is designed to support third-party software application services, including web services and database services (such as starting an Oracle ® database daemon). In addition to representing running daemons, SMF services can also represent the configuration of a subsystem, the software state of a device, or a set of other services.

Features and Benefits of SMF SMF offers many advantages, including:

• Simplified service administration. Services are objects that can be viewed and easily managed with a few simple administrative commands.

• Automated restart of failed services. SMF monitors service processes, and can proactively restart a service when it detects an administrative error, hardware fault, or service death.

• Persistent service configuration. Service definitions and configurations persist across reboots, even after installing OS upgrades or patches.

• Explicit dependencies. Relationships are defined between services to reflect that some services rely on the availability of other services.

• Easier debugging. Individual service log files make it easier to determine why a service isn't running.

• Faster boot/shutdown processes. SMF parallelizes the start/stop of services when possible.

• Delegated service administration. Administrators can securely delegate service-related tasks to non-root users, including the ability to configure, start, stop, or restart services.

In previous versions of the Solaris OS, init executed a series of rc scripts, which ran sequentially to start all system services. With SMF and the Solaris 10 OS, most system services are no longer started from rc scripts. Legacy rc scripts will continue to work, but moving customized rc scripts to SMF is strongly recommended — SMF-managed services are easier to administer and control, and debugging service- related problems is much easier.

In earlier versions of the Solaris OS, there was little consistency in how services were managed (especially

in the process of enabling and disabling them). In the past, to disable a service or daemon, administrators

often renamed a particular rc script to something that the system would ignore upon reboot. A common problem with this was patch installation or upgrades, which might restore the renamed files. SMF provides

a more consistent and persistent means of managing services — for system and application services alike.

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

3-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

SMF Repository

At the core of SMF is the configuration repository, which stores service configuration information in local memory and local files. The repository provides a persistent way to enable or disable services, a consistent view of service state, and a unified interface to get and set service configuration properties. The repository provides a snapshot of each service’s configuration at the time that the service successfully starts, which allows the service to be easily restored to a known good configuration.

SMF Restarters

In the Solaris 10 OS, the init process starts up the SMF master restarter daemon svc.startd. (a restarter is simply a program that restarts a service). The svc.startd daemon queries the SMF repository to locate other system services, and starts them according to their dependencies, in parallel whenever possible. This is in contrast to earlier versions of the Solaris OS and other UNIX ® operating systems that use rc scripts to start services in a serial fashion. As the SMF master restarter daemon initializes services, it enforces defined dependency relationships between services, starting only those services where dependency requirements have been met. (Dependencies are discussed later in this article — see “Service Dependencies” on page 18.)

Each service specifies a restarter which is used to initialize the service. If a service has not specified a restarter, then the default restarter svc.startd is used. If another restarter is specified, it is called a “delegated restarter”. For many network services (such as rlogin, ftp, etc.), the Solaris OS defines inetd as the service restarter. The delegated restarter inetd performs some common actions (such as port binding) on behalf of the services it manages.

In addition to starting services, restarters keep track of service failures and dependency events. This allows a restarter to automatically restart a service when it detects a service has failed or one of its required dependencies is no longer available. In this way, restarters help to simplify and automate some service-related tasks.

SMF Service Instances

It is not uncommon for a system to run multiple copies of the same service, usually with slightly different configurations. For example, a web server is a service, but a specific web server daemon configured to listen on port 80 is an instance of that service. To facilitate configuration sharing, SMF extracts configuration properties for each service from service instances, which are represented in the repository by service instance objects. Service instance objects are children of service objects, and may contain configuration properties that are shared between the instances. If an instance does not explicitly override a configuration property, then it inherits property values from the parent service object.

The following example clarifies the distinction between a service and a service instance. The remote login server daemon, in.rlogind, has three distinct modes. By offering each mode as a separate instance of the same service, SMF can use a single, common configuration for all three, while allowing the administrator to enable or disable each mode independently. In the Solaris 10 OS, the service is named network/login and the service instances are:

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

4-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

• Instance 1: svc:/network/login:rlogin (rlogin)

• Instance 2: svc:/network/login:klogin (rlogin with Kerberos)

• Instance 3: svc:/network/login:eklogin (rlogin with Kerberos and encryption)

Components of a SMF Service

A SMF service may have some or all of the following entities associated with it:

• A SMF manifest that defines the default set of service properties

• One or more methods that define how the service’s restarter interacts with the service

• One or more executables (or daemons) called by the methods to implement the service

• A log file that records the output of the service

• A Fault Management Resource Identifier (FMRI) used to identify a specific service instance

Minimally, a service can be defined using a set of methods and an FMRI, although some services may use

all of the entities listed above. To illustrate SMF concepts and terminology, Figure 1 shows the files,

executables, and identifiers associated with the cron service.

/lib/svc/method/svc-cron Service Start Method /usr/sbin/cron SMF Service Service Manifest Executable Files and
/lib/svc/method/svc-cron
Service Start
Method
/usr/sbin/cron
SMF Service
Service
Manifest
Executable
Files and Identifiers
for the cron
service
Service
Service
Identifier
Log
(FMRI)

/var/svc/manifest/system/cron.xml

svc:/system/cron:default

/var/svc/log/system-cron:default.log

Figure 1. Files and identifiers related to the cron service

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

5-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

SMF Manifests

A SMF manifest is an XML file that contains a complete set of properties associated with a service or a

service instance. System manifest files are stored in /var/svc/manifest, although manifests may exist

elsewhere. (Note that only manifests in /var/svc/manifest are imported during boot.) SMF manifest files

are used to create configurations within the repository, which then maintains the authoritative source of

configuration information for all service instances. To import configuration properties from a new service’s

manifest into the repository, an administrator can either run svccfg import or allow the service to import

the information during a system boot. (See the service_bundle(4), svccfg(1M), or smf_bootstrap(5)

man pages.)

Note – It is not supported to change the properties of system services by directly modifying SMF manifest files provided in the Solaris 10 OS. If Solaris OS or ISV-delivered manifests are modified directly, customizations may not be preserved across software upgrades. The recommended way to change service configuration properties stored in the repository is with the svccfg command.

Service Methods

Methods are used by a restarter to interact with the service, and typically may be an executable, a shell

script, or a keyword (such as “:kill”). For services managed by the master restarter svc.startd, methods

are often shell scripts similar to traditional rc scripts in previous Solaris OS versions. The restarter

svc.startd uses a “start method” to initialize a service, a “stop method” to halt it, and optionally a “refresh

method” to reread its configuration. Methods for many system services reside in the /lib/svc/method

directory. (For more information, see smf_method(5) or svc.startd(1M) man pages.)

Service Executable

In some cases, a start method invokes a service executable, which is responsible for providing the

capabilities of the service. The daemon /usr/sbin/cron, for example, is the executable for the cron

service (refer back to Figure 1). A service executable may also be invoked directly as a method.

Service Log Files

A service's restarter may specify a log file to capture information about the service. (For example,

svc.startd logs actions about specific services to each service’s log file in /var/svc/log.) Log files in

/var/svc/log differ from log file(s) associated with an executable that may be invoked as part of the

service. For example, the log file for the cron service is /var/svc/log/system-cron:default.log,

whereas /var/cron/log contains the output of the daemon /usr/sbin/cron.

Service Identifiers — FMRIs

Each service instance is named with a Fault Management Resource Identifier (FMRI), which is used with

SMF administrative commands to specify the service instance to be acted upon. An FMRI usually contains

three parts separated by colons:

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

6-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

# svc:/network/login:rlogin

The first part of the FMRI — the svc prefix — indicates that the FMRI describes a Solaris SMF service. The second part gives the name of the service, in this case, network/login. The third part identifies the service instance (in this example, rlogin, which is an instance for the remote login service).

Equivalent formats for an FMRI include:

svc://localhost/system/system-log:default

svc:/system/system-log:default

system/system-log:default

The full FMRI describes a service uniquely (and should be used in shell scripts), but abbreviated forms are easier to type and work as long as there is only one instance and SMF would infer that instance. The following short-form could be used, for example, and SMF would infer the instance to be used:

system-log

The “default” name is used for the default instance of a service:

svc:/network/rpc/bind:default

In this case “default” is the default instance of svc:/network/rpc/bind.

See the SMF command man pages, such as svcadm(1M) or svcs(1), for instructions about which FMRI formats are appropriate.

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

7-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

Administering SMF Services

Table 1 contains a summary of commands that are frequently used to administer SMF services. For common service-related tasks, Table 2 compares commands typically used in earlier OS versions to comparable SMF commands.

Table 1. SMF Management Tools

Command

Description

Examples

 

#

svcs -a

Lists all services, enabled or not.

#

svcs -p [FMRI]

Lists any processes associated with each service instance.

svcs

Displays information about service instances

#

svcs -l FMRI

Displays details about a particular service.

 

#

svcs -x

Displays all broken services and gives a reason as to why SMF believes the service is broken. This command is a powerful troubleshooting tool,

and can also be run with a “verbose” (-v) option.

 

# svcadm enable foo

# svcadm refresh print/server

svcadm

Issues requests for actions on executing services, including enabling, disabling, and restarting service instances

Enables and refreshes a service instance. (Note that it is necessary to refresh a service after any configuration changes via svccfg.)

#

svcadm disable -t cron

 

Disables the cron service temporarily (until the next reboot). To disable a service persistently across reboots, do not use the “-t” option.

 

svccfg import /var/svc/manifest/system/foo.xml Imports a service manifest into SMF.

#

 

Displays and manipulates the contents of the SMF repository

#

svccfg delete FMRI

svccfg

Deletes (removes) the service definition from the SMF repository.

 

#

svccfg

With no options, enters the svccfg interactive shell. In the interactive

shell, the “help” subcommand lists other available subcommands.

 

Retrieves property values from the SMF repository (with an output format appropriate for use in shell scripts)

#

svcprop -p propertygroup/property FMRI

svcprop

Retrieves property values for the specified service instance.

#

svcprop -p start/exec system/cron

 

For the cron service, retrieves the start method property.

 

#

inetadm -p

inetadm

Display global defaults for all inetd services. See also

Provides the ability to observe and configure network services controlled by inetd

“Administering Network Services with inetadm” on page 11.

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

8-Service Management Facility (SMF) in the Solaris 10 Operating System

Table 2. A Comparison of Common Tasks

Sun Microsystems, Inc.

Task

Old Procedure

Comparable SMF Procedure

 

To disable system services like cron:

To disable system services like cron:

rm /etc/rc2.d/S75cron (Repeat after every cron patch application and system upgrade.)

svcadm disable cron

Enabling and

disabling

services

Later to enable cron, reinstall:

/etc/rc2.d/S75cron

Later to enable system services like cron:

svcadm enable cron

To enable inetd services (like finger), edit /etc/inet/inetd.conf and uncomment the service to be enabled. Then issue:

To enable inetd services (like finger:) svcadm enable finger

pkill -HUP inetd

Stopping

/etc/init.d/sshd stop

svcadm disable -t ssh (The "-t" indicates that the requested action should be temporary until the next reboot.)

services

Starting

/etc/init.d/sshd start

svcadm enable -t ssh

services

Restarting

/etc/init.d/sshd stop; /etc/init.d/sshd start

svcadm restart ssh

services

Refreshing

configuration kill -HUP `cat /var/run/sshd.pid`

the service

svcadm refresh ssh

In the comparable SMF commands, the last argument to svcadm is the service’s FMRI. Note that the command svcadm can only be used for SMF services (services started and stopped in rc scripts can still be started and stopped as before, but cannot be managed using SMF commands).

Service States At any point in time, a service instance may have one of the following states:

• uninitialized: This state is the initial state for all services before their configuration has been read or before their restarter has started.

• disabled: The service instance is not enabled and is not running.

• offline: The service instance is enabled, but cannot be started until its dependencies are met.

• online: The service instance is enabled and has successfully started.

• degraded: The service instance is enabled and running, but at less than full capacity.

• maintenance: The service instance has encountered an error that must be resolved by the administrator.

• legacy_run: This state is used only for legacy services. Legacy services cannot be controlled by SMF commands. (See the Solaris 10 System Administration Guide: Basic Administration (817-1985-xx), Chapter 14, “Managing Services".)

The svcs command displays the state, state time, and FMRI of service instances by default (use “-o” for alternate display options).

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

9-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

An Example of Using SMF Administrative Commands

A

good way to learn about the SMF administrative commands is through an example. To illustrate the use

of

some commonly used commands, the example given here breaks the print service and then fixes it.

Troubleshooting most service-related issues involves many of the same steps used to identify and resolve the problem in this example.

The example includes the following steps:

1. Modifying the configuration for the service (in which an error is made)

2. Restarting it (which causes it to fail)

3. Viewing the log file (which points to the error)

4. Modifying the configuration again (to repair the service configuration)

5. Restarting it (which is successful)

To modify the configuration of the print service, use svccfg in interactive mode to list the available services (for brevity, only an excerpt of the full svccfg output is given below):

# svccfg svc:> list system/console-login milestone/devices system/device/local

network/initial

network/loopback

network/physical

system/svc/restarter

system/filesystem/root

application/print/server

Select the service to be modified (print/server), and list the properties specifically for that service:

svc:> select print/server svc:/application/print/server> listprop start/exec astring "/lib/svc/method/print-svc start"

The output shows that the start method (the start-up script) for the print service is

/lib/svc/method/print-svc.

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

10-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

Modify the name of the start method using the setprop command. Change the name of the method to a non-existent file, which will subsequently cause an error when the print service is restarted. After making the change, refresh the configuration so that the change to the service’s properties takes effect and then restart the service:

svc:/application/print/server> setprop Usage: setprop pg/name = [type:] value

svc:/application/print/server> setprop start/exec = astring: "/lib/svc/method/print-svc.1 start"

svc:/application/print/server> quit

(exit the svccfg interactive session)

#

#

svcadm refresh print/server

#

svcadm restart print/server

Since the start method for the service (lib/svc/method/print-svc.1) does not exist, the service fails when it attempts to start.

To troubleshoot SMF service problems, begin by running svcs -xv. Many times, this simple command can point to what is broken and suggest a possible cause:

# svcs -xv

svc:/application/print/server:default (LP print server) State: maintenance since Sat Apr 30 09:38:25 2005 Reason: Start method failed repeatedly, last exited with status 1. See: http://sun.com/msg/SMF-8000-KS See: man -M /usr/share/man -s 1M lpsched See: /var/svc/log/application-print-server:default.log Impact: 1 dependent service is not running:

svc:/application/print/rfc1179:default

The output indicates a problem with the service’s start method (it failed repeatedly) and suggests looking at

the log of the broken service — /var/svc/log/application-print-server:default.log. The log file

(shown below) indicates the source of the problem — the start method /lib/svc/method/print-svc.1 was not found:

#

tail /var/svc/log/application-print-server:default.log

[

Feb 6 11:27:52 Method "start" exited with status 1 ]

[ Feb 6 11:27:53 Executing start method ("/lib/svc/method/print-svc.1 start") ] /sbin/sh: /lib/svc/method/print-svc.1: not found

Now that the problem is clearly identified, it can be fixed using the svccfg command (this time via the command line mode rather than the interactive mode). Once the start method is correctly defined for the service, the configuration can be refreshed and the service restarted:

Service Management Facility (SMF) in the Solaris 10 Operating System — February 2006

11-Service Management Facility (SMF) in the Solaris 10 Operating System

Sun Microsystems, Inc.

# svccfg -s print/server setprop start/exec = astring:'"/lib/svc/method/print-svc start"'

# svcadm refresh print/server

# svcadm restart print/server

However, there is still a problem — the service is stuck in the maintenance state:

# svcs -p print/server

STATE

STIME

FMRI

maintenance

20:35:35 svc:/application/print/server:default

A service in the maintenance state requires administrative intervention. To remove a service from the maintenance state, an administrator needs to explicitly “clear” the service to signal that all necessary repairs are completed before the service can be restarted. After a service has been repaired, it must be cleared before it will go online. If it is not cleared, it will remain in the maintenance state. Use svcadm to clear the service as follows:

# svcadm clear print/server

# svcs -p print/server

STATE

STIME

FMRI

online

20:41:20 svc:/application/print/server:default

20:41:20

1480 lpsched

Now the print service is online and ready to accept service requests.

Administering Network Services with inetadm

The management of built-in network services in the Solaris 10 OS is now handled through SMF. The Internet services daemon, inetd(1M), has been rewritten as a part of SMF, and configuration data for network services is now stored in the SMF repository rather than in /etc/inet/inetd.conf. This allows the SMF tools to be used to control and observe inetd-based network services.

Any records remaining in /etc/inet/inetd.conf after an OS upgrade to the Solaris 10 OS, or later created by installing additional software, must be converted to SMF and imported into the SMF repository using inetconv(1M) — otherwise the service will not be available. To provide compatibility for services which have not yet been converted to SMF, entries can be added to inetd.conf using traditional syntax, and the utility inetconv will convert the new services to SMF. The command inetconv should always be run after changing /etc/inet/inetd.conf. Note that inetconv is run automatically during the first reboot after an OS installation or upgrade. If inetd.conf has been modified since inetconv was run, then inetd sends reminder messages to syslog.

After inetd.conf has converted a service, inetadm