AddThis Social Bookmark Button

Print

Using Solaris SMF
Pages: 1, 2, 3, 4

Boot-up and Runlevels

Because rc scripts are no longer the preferred method used to manage programs, Sun has enhanced the runlevel model with service milestones.



In Unix, runlevel one is single user mode, two is multiuser mode, and three is multiuser mode with file sharing or network services. In each runlevel, there is a core set of services that must be brought online.

For example, levels one, two, and three all require a minimum amount of local filesystems to be mounted, and network interfaces to be online. Runlevel two requires all internet services to be online, and users must be able to log on to the host. Runlevel three requires everything level two does, plus the ability to share files by NFS.

Milestones are services that don't run any applications but do have a dependent list of services. Once those services are online, the milestone is marked online. The milestone ensures an expected group of services are up and running, so you don't have to check each individual service.

Here is a list of milestones currently online. In this case, seven milestones are online because they all had their dependencies met.

$ svcs "svc:/milestone/*"
online         Sep_22   svc:/milestone/name-services:default
online         Sep_22   svc:/milestone/network:default
online         Sep_22   svc:/milestone/devices:default
online         Sep_22   svc:/milestone/single-user:default
online         Sep_22   svc:/milestone/sysconfig:default
online         Sep_22   svc:/milestone/multi-user:default
online         Sep_22   svc:/milestone/multi-user-server:default

Here is a list of milestones and their equivalant rc levels.

Milestone RC Level Description
svc:/milestone/devices:default Devices
svc:/milestone/network:default Network interfaces online
svc:/milestone/single-user:default 1 Single-user mode
svc:/milestone/sysconfig:default Basic system configuration
svc:/milestone/name-services:default Any one of the NIS, NIS+, DNS, or LDAP services
svc:/milestone/multi-user:default 2 Multiuser mode
svc:/milestone/milti-user-server:default 3 Multiuser server mode

Consider the dependencies for svc:/milestone/multi-user:default:

$ svcs -d milestone/multi-user
STATE          STIME    FMRI
disabled       Sep_22   svc:/network/smtp:sendmail
online         Sep_22   svc:/milestone/name-services:default
online         Sep_22   svc:/milestone/single-user:default
online         Sep_22   svc:/system/filesystem/local:default
online         Sep_22   svc:/network/rpc/bind:default
online         Sep_22   svc:/milestone/sysconfig:default
online         Sep_22   svc:/system/utmp:default
online         Sep_22   svc:/network/inetd:default
online         Sep_22   svc:/network/nfs/client:default
online         Sep_22   svc:/system/system-log:default

Milestones are checkpoints in the operating system. Before multiuser mode can be online, network/smtp, milestone/name-services, milestone/single-user, rpc/bind, and the other services listed must be online as well.

One of the dependent services listed is milestone/single-user, which has its own list of dependencies:

$ svcs -d milestone/single-user
STATE          STIME    FMRI
disabled       Sep_22   svc:/system/metainit:default
online         Sep_22   svc:/network/loopback:default
online         Sep_22   svc:/milestone/network:default
online         Sep_22   svc:/milestone/devices:default
online         Sep_22   svc:/system/filesystem/minimal:default
online         Sep_22   svc:/system/manifest-import:default
online         Feb_21   svc:/system/identity:node

Instead of making all milestones dependent on common services, the milestones are set up as cascading checkpoints. When you change the dependency list for milestone/single-user, you don't need to change the dependencies for milestone/multi-user-server.

To change the milestone level of the host, use the svcadm command:

$ svcadm milestone -d [milestone FMRI]

The -d option lets you set your choice as the default milestone. This option will persist across reboots.

As far as shutting down the host, the shutdown or init commands are still the preferred methods of performing a safe shutdown or reboot.

Debugging Problems with Services

Sometimes services fail due to unavoidable circumstances. For example, a bad configuration file will prevent the Apache process from starting. If the service fails, it will usually end up being marked in the maintenance state. To correct this problem, you need to know where to look for problems.

# svcs http
STATE          STIME    FMRI
maintenance    20:51:31 svc:/application/http:apache2

# svcs -x http
svc:/application/http:apache2 (Apache2 Server)
 State: maintenance since Mon Feb 20 20:51:31 2006
Reason: Method failed.
   See: http://sun.com/msg/SMF-8000-8Q
   See: httpd(8)
   See: /var/svc/log/application-http:apache2.log
Impact: This service is not running.

Each service keeps a log with the output from the method script. Most errors will appear in this file, as long as the program writes out errors to stdout or stderr.

# tail /var/svc/log/application-http\:apache2.log
Syntax error on line 23 of /etc/opt/apache2/httpd.conf:
Invalid command 'Kisten', perhaps mis-spelled or defined by a module not included in the server configuration
[ Feb 20 20:50:30 Method "stop" exited with status 0 ]
[ Feb 20 20:51:31 Method or service exit timed out.  Killing contract 957 ]
[ Feb 20 20:51:31 Rereading configuration. ]

Another option is to check the log of svc.startd, as it is the restarter process for the Apache service.

# tail /var/svc/log/svc.stard.log
Feb 20 20:51:31/3: svc:/application/http:apache2: Method or service exit timed
    out.  Killing contract 957.
Feb 20 20:51:31/520: application/http:apache2 failed

After you have corrected the error, use the svcadm command to clear the maintenance state.

# svcadm clear application/http:apache2

# svcs -x http
svc:/application/http:apache2 (Apache2 Server)
 State: online since Mon Feb 20 21:00:22 2006
   See: httpd(8)
   See: /var/svc/log/application-http:apache2.log
Impact: None.

The important thing to remember is that the Service Management Facility isn't designed to block normal access to programs or processes. If you really need to perform serious testing of Apache httpd or other programs, it's still possible to invoke these commands from the command line. If a service is in the maintenance state, then go ahead and run http -t, or sendmail -bD, or whatever command you need to run. SMF will not interfere with processes that did not initiate from its own starter.

Chris Josephes works as a system administrator for Internet Broadcasting.


Return to the Sysadmin DevCenter