Friday, December 27, 2013

SMF Services


SMF Services:

As we all know that from Solaris 10 on-wards legacy method of starting and stopping service has been replaced by SMF (Service management facility) service management. Here we are not going in depth of SMF history and theory.Here we will see how to get the list of SMF service installed in server,how to see the dependencies and dependents services,Service tree map and complete information about the services.And also we will the reason for the service fault using svcs -xv command. - See more at: http://www.unixarena.com/2013/05/smf-service-management-facilityservice.html#sthash.7uSEzLAM.dpuf

 As we all know that from Solaris 10 on-wards legacy method of starting and stopping service has been replaced by SMF (Service management facility) service management. .Here we will see how to get the list of SMF service installed in server,how to see the dependencies and dependents services,Service tree map and complete information about the services.And also we will the reason for the service fault using svcs -xv command.

Service listing and Dependencies check
Important command of SMF service listing:
SMF Service Information

svcs -a
Lists all installed services
svcs -d FMRI
Lists all dependencies for FMRI
svcs -d FMRI
Lists all dependents for FMRI
svcs -p FMRI
Show the service dependencies tree map
svcs -l FMRI
Provides a complete information about FMRI
svcs -x
Show reason for the service fault
svcs -xv
Verbose mode debugging information
 
 

1.How to list the configured services from SMF ? 
# svcs -a 
This output will give list of legacy services,online services,disabled services and offline services.
bash-3.00# svcs -a |head
STATE          STIME    FMRI
legacy_run     May_17   lrc:/etc/rcS_d/S50sk98sol
legacy_run     May_17   lrc:/etc/rc2_d/S05vmware-tools
legacy_run     May_17   lrc:/etc/rc2_d/S10lu
legacy_run     May_17   lrc:/etc/rc2_d/S20sysetup
legacy_run     May_17   lrc:/etc/rc2_d/S40llc2
legacy_run     May_17   lrc:/etc/rc2_d/S42ncakmod
legacy_run     May_17   lrc:/etc/rc2_d/S47pppd
legacy_run     May_17   lrc:/etc/rc2_d/S70uucp
legacy_run     May_17   lrc:/etc/rc2_d/S72autoinstall
bash-3.00# svcs -a |tail
online         May_17   svc:/system/basicreg:default
online         May_17   svc:/system/zones:default
online         May_17   svc:/application/cde-printinfo:default
online         May_17   svc:/application/graphical-login/cde-login:default
online         May_17   svc:/system/vxdbd:default
online         May_17   svc:/system/xprtld:default
online         May_17   svc:/system/webconsole:console
online         May_17   svc:/application/autoreg:default
offline        May_17   svc:/application/print/ipp-listener:default
offline        May_17   svc:/application/print/rfc1179:default
bash-3.00# svcs -a |wc -l
     238
bash-3.00#

2.How to check specific service status ?
bash-3.00# svcs zones
STATE          STIME    FMRI
online         May_17   svc:/system/zones:default
bash-3.00# svcs vxdbd
STATE          STIME    FMRI
online         May_17   svc:/system/vxdbd:default
bash-3.00# svcs -a |grep zones
disabled       May_17   svc:/system/tsol-zones:default
online         May_17   svc:/system/zones:default

3.How to see complete service information and log file name ?
bash-3.00# svcs -l svc:/system/zones:default
fmri         svc:/system/zones:default
name         Zones autoboot and graceful shutdown
enabled      true
state        online
next_state   none
state_time   Fri May 17 20:08:30 2013
logfile      /var/svc/log/system-zones:default.log
restarter    svc:/system/svc/restarter:default
dependency   require_all/none svc:/milestone/multi-user-server (online)

4.To see how many services depends on particular service ?(Ex:svc:/system/zones:default) 
bash-3.00# svcs -D svc:/system/zones:default
STATE          STIME    FMRI
Here none of the system services are depends on zones services.

5.To see what are the services required to start particular service ? 
bash-3.00# svcs -d svc:/system/zones:default
STATE          STIME    FMRI
online         May_17   svc:/milestone/multi-user-server:default
i.e "Zones" service depends on "multi-user-server" service. 

6.How do you see service dependency map ?
bash-3.00# svcs -p svc:/application/graphical-login/cde-login:default
STATE          STIME    FMRI
online         May_17   svc:/application/graphical-login/cde-login:default
               May_17       3429 dtlogin
               May_17       3692 fbconsole
               May_17       3733 Xorg
               May_17       4070 dtlogin
               May_17       4145 dtgreet
7.How to check SMF services status using one command ?
The below command will report if there is an issue with SMF services.
bash-3.00# svcs -xv
svc:/application/print/server:default (LP print server)
 State: disabled since Fri May 17 20:07:30 2013
Reason: Disabled by an administrator.
   See: http://sun.com/msg/SMF-8000-05
   See: man -M /usr/share/man -s 1M lpsched
Impact: 2 dependent services are not running:
        svc:/application/print/rfc1179:default
        svc:/application/print/ipp-listener:default
  

Service Management facility administration:In the last post we have seen how to list the services using SMF commands and here we will see how to administrate those FMRI(Service) using SMF commands.In Solaris Operating system administration, You should have fair enough knowledge to  start,stop,restart the SMF service.And also you should know how to troubleshoot if the service is not coming to online.In the end of the post we will see how to backup and restore the SMF repository. svcadm is a command which will be used to administrate the SMF services.

Note:Solaris 10 still supports legacy method of stopping and starting service using rc scripts.

From man page of svcadm,
bash-3.00# svcadm
Usage: svcadm [-v] [cmd [args ... ]]

        svcadm enable [-rst]  ...      - enable and online service(s)
        svcadm disable [-st]  ...      - disable and offline service(s)
        svcadm restart  ...            - restart specified service(s)
        svcadm refresh  ...            - re-read service configuration
        svcadm mark [-It]   ... - set maintenance state
        svcadm clear  ...              - clear maintenance state
        svcadm milestone [-d]        - advance to a service milestone

        Services can be specified using an FMRI, abbreviation, or fnmatch(5)
        pattern, as shown in these examples for svc:/network/smtp:sendmail

        svcadm  svc:/network/smtp:sendmail
        svcadm  network/smtp:sendmail
        svcadm  network/*mail
        svcadm  network/smtp
        svcadm  smtp:sendmail
        svcadm  smtp
        svcadm  sendmail

1. How To enable the SMF service ? 

First you list the service which you want to enable using svcs command.Then you can use svcadm to enable the service and you can monitor the service status using svcs command.
Sometimes you need to use complete FMRI(svc:/network/ipfilter:default)
bash-3.00# svcs ipfilter
STATE          STIME    FMRI
disabled       May_17   svc:/network/ipfilter:default
bash-3.00# svcadm enable ipfilter
bash-3.00# svcs ipfilter
STATE          STIME    FMRI
offline*       11:44:16 svc:/network/ipfilter:default
bash-3.00# svcs ipfilter
STATE          STIME    FMRI
online         11:44:31 svc:/network/ipfilter:default


2.How to Disable the SMF service ?
You can disable the service using svcadm disable command and check the staus using svcs.
bash-3.00# svcadm disable  svc:/network/ipfilter:default
bash-3.00# svcs  svc:/network/ipfilter:default
STATE          STIME    FMRI
disabled       11:50:00 svc:/network/ipfilter:default

3.How to Enable/Disable service temporarily ?

 In SMF ,we have an option to enable/disable the service temporarily.This disable will not persist across the reboot.You see that temporary flag in the enabled status.
bash-3.00# svcadm disable -t svc:/network/ipfilter:default
bash-3.00# svcs -l svc:/network/ipfilter:default
fmri         svc:/network/ipfilter:default
name         IP Filter
enabled      false (temporary)
state        disabled
next_state   none
state_time   Sat May 25 11:53:10 2013
logfile      /var/svc/log/network-ipfilter:default.log
restarter    svc:/system/svc/restarter:default
dependency   require_all/restart file://localhost/etc/ipf/ipf.conf (online)
dependency   require_all/none svc:/system/filesystem/usr (online)
dependency   require_all/restart svc:/network/pfil (online)
dependency   require_all/restart svc:/network/physical (online)
dependency   require_all/restart svc:/system/identity:node (online)
bash-3.00#

bash-3.00# svcadm enable -t svc:/network/ipfilter:default
bash-3.00#
bash-3.00# svcs -l svc:/network/ipfilter:default
fmri         svc:/network/ipfilter:default
name         IP Filter
enabled      true (temporary)
state        online
next_state   none
state_time   Sat May 25 12:12:11 2013
logfile      /var/svc/log/network-ipfilter:default.log
restarter    svc:/system/svc/restarter:default
dependency   require_all/restart file://localhost/etc/ipf/ipf.conf (online)
dependency   require_all/none svc:/system/filesystem/usr (online)
dependency   require_all/restart svc:/network/pfil (online)
dependency   require_all/restart svc:/network/physical (online)
dependency   require_all/restart svc:/system/identity:node (online)

4.How to restart the service ?
bash-3.00# svcadm restart  svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
online         12:13:16 svc:/network/ipfilter:default
bash-3.00# date
Sat May 25 12:13:27 IST 2013

5.How to reload the configuration by without restarting the service ?
bash-3.00# svcadm refresh svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
online         12:14:29 svc:/network/ipfilter:default
bash-3.00#

6.How to mark  the service to maintenance state ?
bash-3.00# svcadm mark -It maintenance svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
maintenance    12:16:01 svc:/network/ipfilter:default

7.How to clear the service from maintenance state ?
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
maintenance    12:16:01 svc:/network/ipfilter:default
bash-3.00# svcadm clear svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
online         12:17:58 svc:/network/ipfilter:default
 


Service Management facility administration:In the last post we have seen how to list the services using SMF commands and here we will see how to administrate those FMRI(Service) using SMF commands.In Solaris Operating system administration, You should have fair enough knowledge to  start,stop,restart the SMF service.And also you should know how to troubleshoot if the service is not coming to online.In the end of the post we will see how to backup and restore the SMF repository. svcadm is a command which will be used to administrate the SMF services.

Note:Solaris 10 still supports legacy method of stopping and starting service using rc scripts.

From man page of svcadm,
bash-3.00# svcadm
Usage: svcadm [-v] [cmd [args ... ]]

        svcadm enable [-rst]  ...      - enable and online service(s)
        svcadm disable [-st]  ...      - disable and offline service(s)
        svcadm restart  ...            - restart specified service(s)
        svcadm refresh  ...            - re-read service configuration
        svcadm mark [-It]   ... - set maintenance state
        svcadm clear  ...              - clear maintenance state
        svcadm milestone [-d]        - advance to a service milestone

        Services can be specified using an FMRI, abbreviation, or fnmatch(5)
        pattern, as shown in these examples for svc:/network/smtp:sendmail

        svcadm  svc:/network/smtp:sendmail
        svcadm  network/smtp:sendmail
        svcadm  network/*mail
        svcadm  network/smtp
        svcadm  smtp:sendmail
        svcadm  smtp
        svcadm  sendmail

1. How To enable the SMF service ? 

First you list the service which you want to enable using svcs command.Then you can use svcadm to enable the service and you can monitor the service status using svcs command.
Sometimes you need to use complete FMRI(svc:/network/ipfilter:default)
bash-3.00# svcs ipfilter
STATE          STIME    FMRI
disabled       May_17   svc:/network/ipfilter:default
bash-3.00# svcadm enable ipfilter
bash-3.00# svcs ipfilter
STATE          STIME    FMRI
offline*       11:44:16 svc:/network/ipfilter:default
bash-3.00# svcs ipfilter
STATE          STIME    FMRI
online         11:44:31 svc:/network/ipfilter:default


2.How to Disable the SMF service ?
You can disable the service using svcadm disable command and check the staus using svcs.
bash-3.00# svcadm disable  svc:/network/ipfilter:default
bash-3.00# svcs  svc:/network/ipfilter:default
STATE          STIME    FMRI
disabled       11:50:00 svc:/network/ipfilter:default

3.How to Enable/Disable service temporarily ?

 In SMF ,we have an option to enable/disable the service temporarily.This disable will not persist across the reboot.You see that temporary flag in the enabled status.
bash-3.00# svcadm disable -t svc:/network/ipfilter:default
bash-3.00# svcs -l svc:/network/ipfilter:default
fmri         svc:/network/ipfilter:default
name         IP Filter
enabled      false (temporary)
state        disabled
next_state   none
state_time   Sat May 25 11:53:10 2013
logfile      /var/svc/log/network-ipfilter:default.log
restarter    svc:/system/svc/restarter:default
dependency   require_all/restart file://localhost/etc/ipf/ipf.conf (online)
dependency   require_all/none svc:/system/filesystem/usr (online)
dependency   require_all/restart svc:/network/pfil (online)
dependency   require_all/restart svc:/network/physical (online)
dependency   require_all/restart svc:/system/identity:node (online)
bash-3.00#

bash-3.00# svcadm enable -t svc:/network/ipfilter:default
bash-3.00#
bash-3.00# svcs -l svc:/network/ipfilter:default
fmri         svc:/network/ipfilter:default
name         IP Filter
enabled      true (temporary)
state        online
next_state   none
state_time   Sat May 25 12:12:11 2013
logfile      /var/svc/log/network-ipfilter:default.log
restarter    svc:/system/svc/restarter:default
dependency   require_all/restart file://localhost/etc/ipf/ipf.conf (online)
dependency   require_all/none svc:/system/filesystem/usr (online)
dependency   require_all/restart svc:/network/pfil (online)
dependency   require_all/restart svc:/network/physical (online)
dependency   require_all/restart svc:/system/identity:node (online)

4.How to restart the service ?
bash-3.00# svcadm restart  svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
online         12:13:16 svc:/network/ipfilter:default
bash-3.00# date
Sat May 25 12:13:27 IST 2013

5.How to reload the configuration by without restarting the service ?
bash-3.00# svcadm refresh svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
online         12:14:29 svc:/network/ipfilter:default
bash-3.00#

6.How to mark  the service to maintenance state ?
bash-3.00# svcadm mark -It maintenance svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
maintenance    12:16:01 svc:/network/ipfilter:default

7.How to clear the service from maintenance state ?
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
maintenance    12:16:01 svc:/network/ipfilter:default
bash-3.00# svcadm clear svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE          STIME    FMRI
online         12:17:58 svc:/network/ipfilter:default

As we all know that from Solaris 10 on-wards legacy method of starting and stopping service has been replaced by SMF (Service management facility) service management. Here we are not going in depth of SMF history and theory.Here we will see how to get the list of SMF service installed in server,how to see the dependencies and dependents services,Service tree map and complete information about the services.And also we will the reason for the service fault using svcs -xv command. - See more at: http://www.unixarena.com/2013/05/smf-service-management-facilityservice.html#sthash.7uSEzLAM.dpuf
As we all know that from Solaris 10 on-wards legacy method of starting and stopping service has been replaced by SMF (Service management facility) service management. Here we are not going in depth of SMF history and theory.Here we will see how to get the list of SMF service installed in server,how to see the dependencies and dependents services,Service tree map and complete information about the services.And also we will the reason for the service fault using svcs -xv command. - See more at: http://www.unixarena.com/2013/05/smf-service-management-facilityservice.html#sthash.7uSEzLAM.dpuf