Friday, January 24, 2014

SMF (Service Management Facility) In Solaris

Managing Services is different in Solaris when compared with linux systems. The SMF - Service management facility a new system included in the Solaris which performs the task of managing services in solaris.

Linux usually stores start and stop files in /etc/rc*.d location which will do the start and stop of the services. These same location are available as files in Solaris or may be an empty locations.

In order to learn how the SMF works we need to learn some basic commands on how to handle these,


enabling or disabling of the services in solaris is done using the svcadm command and we can use svcs command to see the status of the services

svcs –a : list all the services by their state

oracle@solaris_11X:/etc$ svcs -a | head
STATE             STIME    FMRI
legacy_run      0:16:01 lrc:/etc/rc2_d/S20sysetup
legacy_run      0:16:02 lrc:/etc/rc2_d/S47pppd
legacy_run      0:16:02 lrc:/etc/rc2_d/S72autoinstall
legacy_run      0:16:02 lrc:/etc/rc2_d/S73cachefs_daemon
legacy_run      0:16:02 lrc:/etc/rc2_d/S89PRESERVE
disabled          0:15:54 svc:/network/rpc/meta:default
disabled          0:16:00 svc:/network/rpc/rstat:default
disabled          0:16:06 svc:/application/x11/xvnc-inetd:default
disabled          0:16:07 svc:/network/nfs/rquota:default

in order to enable/disable services in Solaris we can use

svcadm enable network/http:apache2
svcadm disable network/http:apache2

If you enable or disable a service and reboot your machine the service will be restored to the state last specified.

If you see the output of the svcs –a command ,we can see FMRI which is called fault management resource identifier which identifies the service. Some of the services have an instance name on the end (the :default of svc:/network/rpc:default).There can be multiple instances of a single service executing on the system at one time.

The _nal thing to note is the STATE column. This column is telling us the current state of each service. The legacy run state is for services that are still executing from the old /etc/rc*.d scripts. Other states include disabled and online which gives us the necessary data.

There is one more state called offline lists all of the services that were unable to start, or had a service fault, and have been taken offline by SMF.

Svcs –xv will give information about the services that are offline and also a reason for that. The svcs -x output also gives pointers on where you can go for information on the current issue. These can be pointers to websites, log messages or man pages. These are typically very handy resources in diagnosing and correcting the issue at hand.

# svcs -x
svc:/network/physical:default (physical network interfaces)
State: disabled since Thu Sep 28 15:33:17 2006
Reason: Disabled by an administrator.
See: ifconfig(1M)

# svcs -xv
svc:/network/physical:default (physical network interfaces)
State: disabled since Thu Sep 28 15:33:17 2006
Reason: Disabled by an administrator.
See: man -M /usr/share/man -s 1M ifconfig
Impact: 5 dependent services are not running:

Some more command include,

  • svcs -a: Lists all services currently installed, including their state.
  • svcs -d FMRI: Lists dependencies for FMRI.
  • svcs -D FMRI: Lists dependents for FMRI.
  • svcs -l FMRI: Provides a long listing of information about FMRI; includes dependency information
  • svcs -p FMRI: Shows relationships between services and processes.
  • svcs -t: This change is temporary (does not persist past a boot).
  • svcs -x: Explains why a service is not available.
  • svcs -xv: Verbose debugging information.

  • svcadm clear FMRI: Clear faults for FMRI.
  • svcadm disable FMRI: Disable FMRI.
  • svcadm enable FMRI: Enable FMRI.
  • svcadm refresh FMRI: Force FMRI to read config file.
  • svcadm restart FMRI: Restart FMRI. 
There are some more commands that we need to learn when dealing with Services in Solaris. They are

svccfg  - command which use to configures services
inetadm – command which will be used to administer inetd services.
inetconv – command which will be used to convert inetd services to SMF.

The inetd daemon is a special network process that runs on each system and starts server processes that do not automatically start at boot time.

Network services can be independently enabled or disabled using the inetadm command.
inetadm    ==> to list the current state of all network facilities

Consider starting and stopping the telnet service using inetadm command like,

inetadm | grep telnet        ==> to view if telnet is enabled or not

inetadm -d telnet        ==> to disable the telnet facility
inetadm | grep telnet

inetadm -e telnet        ==> to enable the telnet facility
inetadm | grep telnet

inetadm -l telnet        ==> to list the details about telnet

These services managed by inetadm can be converted to SMF services using inetconv command. There are three main types of services provided by SMF.Transient, Wait and Contract services. Transient services are often con_guration services requiring no long-running process. Wait services run for the lifetime of the child process and are restarted when the process exits. Contract services are the standard system daemons and require processes which run forever once started. The death of all processes in a contract service is considered a service error which will cause the service to restart.

More to Come , happy learning