Solaris 11 – How to Manage Solaris SMF Services

How to Disable a Service Instance

Use the following procedure to disable a service. The service status change is recorded in the service configuration repository. Once the service is disabled, the disabled state will persist across reboots. The only way to get the service running again is to enable it.

  1. Become an administrator 
  2. Check the dependents of the service you want to disable.If this service has dependents that you need, then you cannot disable this service.
    # svcs -D FMRI
  3. Disable the service.
    # svcadm disable FMRI

How to Enable a Service Instance

Use the following procedure to enable a service. The service status change is recorded in the service configuration repository. After the service is enabled, the enabled state will persist across system reboots, however the service will start only if all dependencies are met.

  1. Become an administrator 
  2. Enable a service.
    # svcadm enable FMRI
  3. Verify that the service has been enabled.
    # svcs -x FMRI
  4. Enable service dependencies.If required dependencies are disabled, enable them with the following command:
    # svcadm enable -r FMRI

Example 11 Enabling a Service in Single-user Mode

The following command enables rpcbind. The -t option starts the service in temporary mode which does not change the service repository, so this change will not persist across a reboot. The -r option recursively starts all the dependencies of the named service.

# svcadm enable -rt rpc/bind

How to Restart a Service

If a service is currently running but needs to be restarted due to a configuration change or some other reason, the service can be restarted without you having to type separate commands to stop and start the service. The only reason to specifically disable and then enable a service is if changes need to be made before the service is enabled, and after the service is disabled.

  1. Become an administrator 
  2. Restart a service.
    # svcadm restart FMRI

How to Restore a Service That Is in the Maintenance State

  1. Become an administrator 
  2. Determine why the service is in maintenance.
    # svcs -x FMRI

    Consult the log file or man page mentioned to determine what the error is.

  3. Determine if any process that are dependent to the service have not stopped.Normally, when a service instance is in a maintenance state, all processes associated with that instance have stopped. However, you should make sure before you proceed. The following command lists all of the processes that are associated with a service instance as well as the PIDs for those processes.
    # svcs -p FMRI
  4. (Optional) Kill any remaining processes.Repeat this step for all processes that are displayed by the svcs command.
    # pkill -9 process-name
  5. Restore the service.
    # svcadm clear FMRI

How to Create an SMF Profile

A profile is an XML file which lists SMF services and whether each should be enabled or disabled. Profiles are used to enable or disable many services at once. Profiles are also used to set property values, add property values, and even create a service and instances of a service. Not all services need to be listed in a profile. Each profile only needs to include those services that need to be enabled or disabled to make the profile useful.

  1. Become an administrator 
  2. Create a profile.In this example, the svccfg command is used to create a profile that represents the local customizations on the current system. Alternatively, you could make a copy of an existing profile to edit.
    # svccfg extract> profile.xml

    If you have large numbers of identical systems, or if you want to archive the system configuration for later restoration, you might want to use this procedure to create a unique version of a SMF profile.

  3. Edit the profile.xml file to make any required changes.
    1. Change the name of the profile in the service_bundle declaration.In this example the name is changed to profile.
      # cat profile.xml
        ...
      <service_bundle type=`profile` name=`profile`
          xmIns::xi='http://www.w3.org/2003/XInclude'
        ...
    2. Remove any services that should not be managed by this profile.For each service, remove the three lines that describe the service. Each service description starts with <service and ends with </service. This example shows the lines for the LDAP client service.
      # cat profile.xml
       ...
       <service name='network/ldap/client' version='1' type='service'>
               <instance  name='default' enabled='true'/>
       </service>
    3. Add any services that should be managed by this profile.Each service needs to be defined using the three line syntax shown above.
    4. If necessary, change the enabled flag for selected services.In this example, the sendmail service is disabled.
      # cat profile.xml
        ...
        <service  name='network/smtp' version='1' type='service'>
          <instance  name='sendmail' enabled='false'/>
        </service>
        ...
  4. When necessary, apply the new profile.

How to Apply an SMF Profile

  1. Become an administrator 
  2. Apply a profile.In this example, the profile.xml profile is applied.
    # svccfg apply profile.xml
Ramdev

Ramdev

I have started unixadminschool.com ( aka gurkulindia.com) in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. And the result is today's' unixadminschool.com. You can connect me at - https://www.linkedin.com/in/unixadminschool/

2 Responses

  1. September 4, 2015

    […] Solaris 11 – How to Manage Solaris SMF Services […]

  2. September 16, 2015

    […] Read – How to Manage Solaris SMF Services […]

What is in your mind, about this post ? Leave a Reply

Close
  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us