Service management facility was first introduced in Solaris 10 for managing system and application services. This replaces the legacy init scripts and other startup scripts.
Configuration files and directories
The files and directories used to manage/troubleshoot and configure SMF are :
/etc/svc/repository.db | The actual database of SMF |
/etc/svc/volatile | Logs for early booting issues |
/lib/svc/bin/svc.startd | Master restarter daemon |
/lib/svc/bin/svc.configd | Repository daemon |
/var/svc/manifest/system | Service XML files |
/lib/svc/method | Startup shell script |
/var/svc/log | Service log files are stored here |
FMRI (Fault Management Resource Identifier)
Every service has a FMRI which includes the service name and instance name. For example :
svc:/system/cron (longer form) svc:/system/cron:default (include the instance)
Whats the difference between a service and instance of a service
Consider the web service. A specific web server configured to listen on port 80 is an instance of the web service. The first instance of every service is normally tagged as tagged as the default instance. For example cron will have the default instance “svc:/system/cron:default”.
Components of a service
Most services are made up of 4 components. Consider the example of cron service :
XML file | /var/svc/manifest/system/cron.xml |
Daemon | /usr/sbin/cron |
FMRI | system/cron (short form)svc:/system/cron (longer form)svc:/system/cron:default (include the instance) |
Log file | /var/svc/log/system-cron:default.log |
SMF commands
The different commands that are used to manage services and make configuration changes are :
svcs | displays information about service |
svcadm | Manage the state of the service instances |
svcprop | retrieve service configuration properties |
svccfg | import, export, and modify service configurations |
Getting information on services
1. To list all the services (enable/disabled/maintenance) :
# svcs -a STATE STIME FMRI legacy_run 17:54:51 lrc:/etc/rc3_d/S81volmgt online 13:47:55 svc:/network/telnet:default online 13:47:55 svc:/network/nfs/rquota:default online 13:47:55 svc:/network/ftp:default ........
2. To list all processes associated with each service instance, if any :
# svcs -p online 13:47:45 svc:/system/sac:default 13:47:45 223 sac 13:47:45 227 ttymon online 13:47:45 svc:/system/cron:default 13:47:45 226 cron ..........
3. To list all the details about a service :
# svcs -l system/cron fmri svc:/system/cron:default name clock daemon enabled true state online next_state none state_time Thu Dec 30 13:47:45 2004 logfile /var/svc/log/system-cron:default.log restarter svc:/system/svc/restarter:default contract_id 41 dependency require_all/none svc:/system/filesystem/local (online) dependency require_all/none svc:/milestone/name-services (online)
4. To display broken services and the reason behind it :
# svcs -xv svc:/application/print/server:default (LP print server) State: disabled since Wed Mar 02 10:28:00 2005 Reason: Disabled by an administrator. See: http://sun.com/msg/SMF-8000-05 See: man -M /usr/share/man -s 1M lpsched Impact: 1 dependent service is not running: svc:/application/print/rfc1179:default
SMF service states
Each SMF service will have one of the state mentioned in the table below. Using the svcadm commands the states can be changed.
uninitialized | initial state of all services until svc.startd moves them to another state |
offline | Enabled but not running |
online | Enabled and running |
maintenance | Broken due to some reason |
disabled | disabled instance |
legacy-run | Service not managed directly by SMF |
Service dependencies
Service may depend on other service(s). Unless these services are not online, the dependent service will not start.
1. To check dependent services (Service I depend on)
# svcs -d /system/filesystem/local STATE STIME FMRI online 20:08:17 svc:/system/filesystem/minimal:default online 20:08:19 svc:/milestone/single-user:default
2. To check which services depends on a particular service (Services that depend on me) :
# svcs -D /system/filesystem/local online 20:08:19 svc:/network/shares/group:default online 20:08:19 svc:/system/cron:default online 20:08:19 svc:/application/opengl/ogl-select:default online 20:08:20 svc:/network/nfs/status:default ......
Service start/stop
Now that we’ve looked at the services and FMRI of the services, we can enable/disable the services using the svcadm command. Make sure all the required dependency service are online before you online the service.
# svcadm enable [service] | To enable a service |
# svcadm disable [service] | To disable a service |
# svcadm disable -t [service] | Temporarily disable a service untill next reboot |
# svcadm clear [service] | To clear a service in maintenance mode |
# svcadm refresh [service] | To refresh service to re-read the configuration files. |
Retrieving service configuration properties
Any service will have multiple properties associated with it. The syntax to list the property value of a services is :
# svcprop -p [property] [service]
For example, to displays the shell script that starts the cron daemon :
# svcprop -p start/exec system/cron /lib/svc/method/svc-cron
Modifying service configuration properties
The service configuration properties can be changed using the 3 modes of svccfg command
* Interactive mode * From a file that contains a series of subcommands * Command line mode
# svccfg svc:> select system/console-login svc:/system/console-login> setprop ttymon/terminal_type = astring: vt100 svc:/system/console-login> quit
Make sure you refresh or clear (in case service is broken) the service to re-read the configuration changes you made.
# svcadm refresh system/console-login
SMF milestones
SMF milestones are services that aggregate multiple services and describe a specific state of system. Sone of the milestones represent the run levels. To list all the milestones :
# svcs milestone* STATE STIME FMRI online Jun_30 svc:/milestone/unconfig:default online Jun_30 svc:/milestone/config:default online Jun_30 svc:/milestone/devices:default online Jun_30 svc:/milestone/network:default online Jun_30 svc:/milestone/single-user:default online Jun_30 svc:/milestone/name-services:default online Jun_30 svc:/milestone/self-assembly-complete:default online Jun_30 svc:/milestone/multi-user:default online Jun_30 svc:/milestone/multi-user-server:default