Sunteți pe pagina 1din 3

SMF ‐ Solaris Mangement Facility

Monday, July 23, 2007
12:01 PM

FMRI = Fault Management Resource Identifier Since the FMRI strings are fairly long, the SMF tools allow abbreviated forms of the 


3 components:         servicetype: name: instance    FMRIs to be used. The abbreviation must be unique, must match the trailing part of 
the service name (although the ":default" can be left off), and it must begin after a 
examples:  "/". So the following are acceptable abbreviations of the previous FMRI: 
svc://localhost/system/system‐log:default 
svc:/system/system‐log:default  system‐log:default 
system/system‐log:default system‐log
lrc:/etc/rc3_d/S90samba

The service types aren’t used by the system, but help the administrator in identifying the general use of
the service. These categories types are:
ƒ application — Higher level applications, such as apache
ƒ milestone — Collections of other services, such as name-services
ƒ platform — Platform-specific services, such as Dynamic Reconfiguration daemons
ƒ system — Solaris system services, such as coreadm You can use a pattern which uses
ƒ device — Device-specific services globbing rules to build regular
ƒ network — Network/Internet services, such as protocols expressions (svc:/ is automatically
ƒ site — Site specific descriptions added to the pattern if omitted)

Examples:
svcs '*print*'
svcs cron
The state of each service is one of the following: svcs dns/client
degraded – The service instance is enabled, but is running at a limited capacity.
disabled – The service instance is not enabled and is not running.
legacy_run – The legacy service is not managed by SMF, but the service can be observed. This state is only 
used by legacy services.
maintenance – The service instance has encountered an error that must be resolved by the administrator.
offline – The service instance is enabled, but the service is not yet running or available to run.
online – The service instance is enabled and has successfully started.
uninitialized – This state is the initial state for all services before their configuration has been read.

SMF commands
• svcs : report the status of service instances Key files, directories and filesystems
• svcadm : manipulate services instances (eg. enable, disable, restart, ...) • /var/svc/manifest/*
• svccfg : manipulate the repository (eg. import, export, configure, ... services) • /lib/svc/method/*
• svcprop : display properties for a given service instance • /var/svc/log/*
• inetadm : report and configure inetd based services • /var/svc/profile/*
• inetconv : convert and import services from inetd.conf • /etc/svc/repository.db  (global configuration database)
• /lib/svc/see/global.db   (minimal configuration database)
• /etc/svc/volatile (Contains transient data, eg. lock files, 
init state and some log files. Allocated from swap)
• /system/contracts (Primary interface into contract 
subsystem, to allow service instances to be restarted. 
RBAC Rights Profiles With SMF
You can use RBAC rights profiles to allow users to manage some of the SMF Indirectly related to SMF)
services, without having to give the user root access. The rights profiles
define what commands the user can run. For SMF, the following profiles have
been created:
• Service Management: User can add, delete or modify services.
• Service Operator: User can request state changes of any service Although fewer messages are printed, SMF has made the boot 
instance, such as restart and refresh.
process more observable. Each service has a log file in the
/var/svc/log directory (or the /etc/svc/volatile directory, for 
services started before the single‐user milestone) indicating when 
and how it was started, whether it started successfully, and any 
messages it may have printed during its initialization. 

How To:
# svcs ‐l network/login:rlogin                       ‐ shows the status of the rlogin service (detailed view)
# svcs ‐a                                                            ‐ shows the status of all services
# svcs ‐p network/smtp:sendmail                ‐ the "-p" option shows all the processes associated with a service
# inetadm                                                         ‐ shows the status of all services controlled by inetd
# svcs ‐D milestone/multi‐user                     ‐ shows the service instances  that are dependend  on the multi‐user milestone
# svcs ‐d milestone/multi‐user:default        ‐ shows the service instances that the multi‐user milestone is dependent on
# svcadm disable network/login:rlogin      ‐ disables the rlogin service
# svcadm disable ‐t network/login:rlogin  ‐ disables temporarly (until the next reboot) the rlogin service
# svcadm enable network/login:rlogin       ‐ enables the rlogin service
# svcadm enable ‐rt rpc/bind                        ‐ enables rpcbind. The ‐t option starts the service in temporary mode which does not change the service 
repository. The repository is not writable in single‐user mode. The ‐r option recursively starts all the dependencies of the named service.
# svcadm restart network/login:rlogin       ‐ restarts the rlogin service
# svcadm refresh network/login:rlogin       ‐ reloads service configuration and run the refresh method (if any)
# svcadm clear network/login:rlogin           ‐ marks service as repaired
# svcs ‐xv                                                          ‐ request information about the hung service.
# svcadm milestone ‐d milestone/single‐user:default       ‐ change the run‐level. The "‐d" option indicates that the default milestone should be set to 
the named FMRI. Without "‐d", "svcadm milestone" transitions the system to the named milestone immediately.
# svcprop restarter | grep milestone          ‐ check to see what the default milestone is set to for your system 

SMF Page 1
How to Restore a Service That Is in the Maintenance State SMF milestones
How to Revert to another SMF Snapshot milestone/single-user - equivalent to run level S
How to Create and Apply an SMF Profile milestone/multi-user - equivalent to run level 2
How to Change an Environment Variable for a Service milestone/multi-user-server - equivalent to run level 3
How to Change a Property for an inetd Controlled Service milestone/name-services
How to Modify a Command-Line Argument for an inetd Controlled Service milestone/devices
milestone/network
milestone/sysconfig

Other options that can be used with svcadm include


• -r enables each service instance and recursively enables its dependencies.
• -s enables each service instance and then waits for each service instance to enter the online or degraded state.
svcadm will return early if it determines that the service cannot reach these states without administrator intervention.
• -t temporarily enables or disables each service instance. Temporary enable or disable only lasts until reboot.

Booting to the single-user milestone (with "-m milestone=single-user") is slightly different than the old "boot -s". When the system is explicitly booted to
a milestone, exiting the console administrative shell will not transition the system to multi-user mode, as "boot -s" does. To move to multi-user mode
after "boot -m milestone=single-user", use the command "svcadm milestone milestone/multi-user-server:default".

svccfg manipulates the repository; Service relationships - Restart relationships defined by dependency groups
uses sub-commands to perform actions ƒ grouping
– require_all : all services are running
Common sub-commands: – require_any: at least one service is running
select <fmri> : select a service / instance – optional_all: all services running, disabled or maintenance
list : show children of the selected service – exclude_all : all services disabled, maint. or absent
listprop : display the properties for a service ƒ restart_on
setprop : change a property value for a service – none : required only for startup
delete : delete a service / instance – error : restart if dependency fails due to hw or sw error
validate <file> : validate an XML manifest file – restart : restart if dependency restart to any reason
import <file> : import a manifest file into repository – refresh : restart if dependency restarts or is refreshed
unselect : navigate to parent of current selection
listsnap : list available snapshots
selectsnap : select one of the snapshots
revert [snap] : revert back to a given snapshot

An SMF profile is an XML file that lists a set of service instances and 
whether each should be enabled or disabled. During the first boot after a 
new installation or an upgrade to the Solaris 10 release or any of the 
Legacy: While many standard Solaris services are now 
subsequent Solaris Express releases the /var/svc/profile/generic.xml
managed by SMF, the scripts placed in /etc/rc*.d continue to 
profile is applied. This file is usually symbolically linked to 
be executed on run‐level transitions. Most of the /etc/rc*.d
generic_open.xml or generic_limited_net.xml. Also, if a profile called 
scripts that were included in previous Solaris releases have 
site.xml is in /var/svc/profile during the first boot or is added between 
been removed as part of SMF. The ability to continue to run 
boots, the contents of this profile are applied. By using the site.xml profile, 
the remaining scripts allows for third‐party applications to be 
the initial set of enabled services may be customized by the administrator.
added without having to convert the services to use SMF.

An SMF manifest is an XML file that contains a complete set of properties that are associated with a service or a service instance. The files are stored in 


/var/svc/manifest. Manifests should not be used to modify the properties of a service. The service configuration repository is the authoritative source of 
configuration information. To incorporate information from the manifest into the repository, you must either run svccfg import or allow the service to 
import the information during a system boot.

The service configuration repository stores persistent  Contract: Mechanism within the kernel for restarters to stay
informed about the service instances they start.
configuration information as well as SMF runtime data for services
The repository is an SQLite database

The data in the service configuration repository includes snapshots, as well as a configuration that can be edited. Data about each service instance is 
stored in the snapshots. The standard snapshots are as follows:
○ initial – Taken on the first import of the manifest
○ running – Used when the service methods are executed
○ start – Taken at the last successful start
The SMF service always executes with the running snapshot. This snapshot is automatically created if it does not exist.
The svcadm refresh command, sometimes followed by the svcadm restart command, makes a snapshot active. The svccfg command is used to view or 
revert to instance configurations in a previous snapshot.

SMF and Booting How to Boot Without Starting Any Services

SMF provides new methods for booting a system. 1) Boot without starting any services. This command instructs the 
There is a additional system state which is associated with the all milestone.  svc.startd daemon to temporarily disable all services and start 
This milestone is different than the multiuser init state because SMF only  sulogin on the console.
knows about the services that are defined. If you have added services, such  ok boot ‐m milestone=none
as third party products, they may not be started automatically unless you use 
the following command: 2) Log in to the system as root. Enable all services.
ok boot ‐m milestone=all # svcadm milestone all

If you boot a system using one of the milestones, it is important to use the ‐s 3) Determine where the boot process is hanging. When the boot 
option as well. If you do not include the ‐s, then the system will stay in the  process hangs, determine which services are not running by running 
milestone state that you booted the system in. The system will not go into  svcs ‐a. Look for error messages in the log files in /var/svc/log. After 
multiuser state automatically by typing Control‐D. You can get into the  fixing the problems, verify that all services have started.
multiuser state by using the following command: # svcs ‐x
# svcadm milestone all
4) V if th t th l l i i d d i ti fi d

SMF Page 2
4) Verify that the console‐login service dependencies are satisfied.  
When booting a system, you can choose to use the verbose option to see  This command verifies that the login process on the console will run.
more messages. By default, the system will not display these messages. To  # svcs ‐l system/console‐login:default
boot in the verbose mode, use the following command:
ok boot ‐m verbose 5) Continue the normal booting process.

References:
Sun Microsystems Documentation: Chapter 14 Managing Services (Overview)
Sun Microsystems Documentation: Chapter 15 Managing Services (Tasks)
BigAdmin System Administration Portal: Predictive Self-Healing
Solaris Management Facility (SMF) - Workshop
Solaris 10 System Administration - Exam Prep [Bill Calkins]

SMF Page 3

S-ar putea să vă placă și