Solaris 10 Services

There is a new feature to the way Solaris 10 handles services, this feature is called Service Management facility (SMF).

Terminology

Fault managed resource identifiers (FMRI) identifies services

            svc :/system/system- log:default

  svc: Service type
  /system/system-log Name
  :default Instance

The repository is the source for all known services on the system, it imports the service manifest into the database and then never references the manifest again.

The manifest properties are the following and are contained in a xml file (see appendix A).

A milestone is a predefined set of capabilities for a set of services, similar to a run level

File locations

SMF log files /var/svc/log
SMF log files /etc/svc/volatile
SMF manifests /var/svc/manifest/*
SMF method /lib/svc/method/*

Daemons

start svc daemon svc.startd
svc configuration daemon svc.configd

Service Commands   

Show the state of all services svcs a
Show detailed information svcs l
Show the dependencies svcs d
Show the dependents svcs D
show the processes of a service svcs p
Explain why the service failed svcs x
verbose information svcs v
Disable a service (stop) svcadm disable
Enabled a service (start) svcadm enable
restart a service svcadm restart
Reread the config file (HUP) svcadm refresh
Put service into maintenance/degrade mode svcadm mark
Start a service to the desired milestone level svcadm milestone
Show values for a given property svcprop p
show details from a snapshot svcprop s

INETD services commands

List all configured inetd services inetadm
Detailed information on a inetd service inetadm -l
enable a inetd service inetadm -e
disable a inetd service inetadm -d

Administration

If a service fails to start

            # svcs –xv

To modify the properties of an inetd service

  # inetadm –m spray bind_addr=”192.168.0.1”
# inetadm –l spray

Repair a corrupt repository using the default repository

Script # /lib/svc/bin/restore_repository          (follow the prompts)

Note: all old repositories are in /etc/svc you can use an old one in place of the global

Manually # pstop “ pgrep svc.startd”
# kill svc.configd
# cp /etc/svc/repository.db /etc/svc/repository.bad

Global zone
# cp /lib/svc/seed/global.db /etc/svc/repository.db
# reboot

Non-Global zone
# cp /lib/svc/seed/nonglobal.db /etc/svc/repository.db
# reboot (only reboot zone)

Note: all old repositories are in /etc/svc you can use an old one in place of the global

Start service interactively during boot

 

Ok> boot –m milestone=none (login as root)

# svcadm milestone –t all         (enable all services)
# svcs –l                         (look for hanging services and check log files /var/svc/log)

continue with normal boot procedures

Other boot commands are:

Ok> boot –m verbose               (verbose output)
Ok> boot –m debug                  (very verbose output)

Manifests

To check the integrity of a manifest xml file

       # /usr/bin/xmllint mysvc.xml

To import your service manifest
       # /usr/sbin/svccfg -v import /var/svc/manifest/site/mysvc.xml                                                                   

Appendix A – screen shots

List of services configured

# svcs

legacy_run      Mar_02    lrc :/etc/rc3_d/S80mipagent
legacy_run      Mar_02    lrc :/etc/rc3_d/S81volmgt
legacy_run      Mar_02    lrc :/etc/rc3_d/S82initsma
legacy_run      Mar_02    lrc :/etc/rc3_d/S84appserv
legacy_run      Mar_02    lrc :/etc/rc3_d/S90samba
online          Mar_02    svc:/system/svc/ restarter:default
online          Mar_02    svc:/network/ pfil:default
online          Mar_02    svc:/system/ filesystem/root:default
online          Mar_02    svc:/network/ loopback:default
online          Mar_02    svc:/milestone/name- services:default
offline         Mar_02    svc:/application/print/ ipp-     listener:default
offline         Mar_02    svc:/application/print/rfc1179:default

A detailed list of a service

# svcs –l sendmail

fmri          svc:/network/ smtp:sendmail
name          sendmail SMTP mail transfer agent
enabled       true
state         online
next_state    none
state_time    Thu 03 Mar 2005 07:05:07 AM GMT
logfile       / var/svc/log/network-smtp:sendmail.log
restarter     svc:/system/svc/ restarter:default
contract_ id   216
dependency    require_all/refresh file://localhost/etc/mail/sendmail.cf (online)
dependency    require_all/refresh file://localhost/etc/nsswitch.conf (online)
dependency    optional_all/none svc:/system/ filesystem/autofs (online)
dependency    require_all/none svc:/system/ filesystem/local (online)
dependency    require_all/none svc:/network/service (online)
dependency    require_all/refresh svc:/milestone/name-services (online)
dependency    optional_all/refresh svc:/system/ identity:domain (online)
dependency    optional_all/none svc:/system/system-log (online)

Appendix B – sendmail manifest

# cat ./ network/smtp-sendmail.xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
        Copyright 2004 Sun Microsystems, Inc.   All rights reserved.
        Use is subject to license terms.
        ident    "@(#) smtp-sendmail.xml   1.11     04/12/16 SMI"
        NOTE:   This service manifest is not editable; its contents will
        be overwritten by package or patch operations, including
        operating system upgrade.   Make customizations in a different
        file.
-->
<service_bundle type='manifest' name=' SUNWsndmr :sendmail'>
<service
        name='network/smtp'
        type='service'
        version='1'>

        <single_instance/>

        <dependency
            name='fs-local'
            grouping='require_all'
            restart_on='none'
            type='service'>
                <service_fmri value='svc:/system/filesystem/local'/>
        </dependency>

        <dependency
            name='network-service'
            grouping='require_all'
            restart_on='none'
            type='service'>
                <service_fmri value='svc:/network/service'/>
        </dependency>

        <dependency
            name='name-services'
            grouping='require_all'
            restart_on='refresh'
            type='service'>
                <service_fmri value='svc:/milestone/name-services'/>
        </dependency>

        <dependency
            name='identity'
            grouping='optional_all'
            restart_on='refresh'
            type='service'>
                <service_fmri value='svc:/system/identity:domain'/>
        </dependency>

        <dependency
             name='system-log'
            grouping='optional_all'
            restart_on='none'
            type='service'>
                <service_fmri value='svc:/system/system-log'/>
        </dependency>

        <instance name='sendmail' enabled='false'>

                <dependency
                    name='config-file'
                    grouping='require_all'
                    restart_on='refresh'
                    type='path'>
                        <service_fmri
                            value='file://localhost/etc/mail/sendmail.cf'/>
                </dependency>

                <dependency
                    name='nsswitch'
                    grouping='require_all'
                    restart_on='refresh'
                    type='path'>
                        <service_fmri
                            value='file://localhost/etc/nsswitch.conf'/>
                </dependency>

                <!--
                If autofs is enabled, wait for it to get users' home
                directories.
                -->
                <dependency
                    name='autofs'
                    grouping='optional_all'
                    restart_on='none'
                    type='service'>
                        <service_fmri value='svc:/system/filesystem/autofs'/>
                </dependency>

                <dependent
                        name='smtp-sendmail_multi-user'
                        grouping='optional_all'
                        restart_on='none'>
                                <service_fmri
                                    value='svc:/milestone/multi-user'/>
                </dependent>

                <!--
                Sendmail is hard-coded to sleep for 60 seconds if it cannot
                determine the FQHN, so the timeout for start must be longer
                than that.For details, see
                http://www.sendmail.org/vendor/sun/differences.html#3.2
                -->

                <exec_method
                        type='method'
                         name='start'
                        exec='/lib/svc/method/smtp-sendmail start'
                        timeout_seconds='120'/>

                <exec_method
                        type='method'
                        name='stop'
                         exec='/lib/svc/method/smtp-sendmail stop %{ restarter/contract}'
                        timeout_seconds='60'/>

                <exec_method
                        type='method'
                        name='refresh'
                         exec='/lib/svc/method/smtp-sendmail refresh'
                        timeout_seconds='60'/>

                <property_group name='startd' type='framework'>
                        < propval name='ignore_error' type='astring'
                             value='core,signal'/>
                </property_group>

                <property_group name='general' type='framework'>
                        <propval name='action_authorization' type='astring'
                                value='solaris.smf.manage.sendmail'/>
                </property_group>

                <template>
                        <common_name>
                                <loctext xml :lang='C'>
                                sendmail SMTP mail transfer agent
                                </ loctext>
                        </common_name>
                        <documentation>
                                <manpage title='sendmail' section='1M'
                                    manpath='/usr/share/man'/>
                        </documentation>
                </template>
        </instance>
        <stability value='Unstable'/>
</service>
</service_bundle>