Comparing
version 2 and
version 1 backh1. Solaris Services
Generically, a *service* is an entity that provides a list of capabilities to applications and other services, local and remote. A service is dependent on an implicitly declared list of local services. In addition, a service can include less traditional entities such as the following:
* A physical network device
* A configured IP address
* Kernel configuration information
* Milestones that correspond to system init state, such as the multiuser run level
An *instance* is a specific configuration of a service. A web server is a service. A specific web server daemon that is configured to listen on port 80 is an instance. Each instance of the web server service could have different configuration requirements.
Each service instance is named with a *Fault Management Resource Identifier* or _FMRI_. The _FMRI_ includes the service name and the instance name. For example, the _FMRI_ for the _rlogin_ service is _svc:/network/login:rlogin_, where _network/login_ identifies the service and _rlogin_ identifies the service instance.
Legacy _init.d_ scripts are also represented with FMRIs that start with *lrc* instead of svc, for example: _lrc:/etc/rcS_d/S35cacheos_sh_.
When booting a system for the first time with SMF, services listed in _/etc/inetd.conf_ are automatically converted into SMF services
A *milestone* is a special type of service. Milestone services represent high-level attributes of the system. For example, the services which constitute run levels S, 2, and 3 are each represented by milestone services.
An *SMF manifest* is an XML file that contains a complete set of properties that are associated with a service or a service instance. The files are stored in _/var/svc/manifest_.
An *SMF profile* is an XML file that lists the set of service instances that are enabled when a system is booted. The profiles are stored in _/var/svc/profile_. These are some the profiles that are included:
* _generic_open.xml_ — This profile enables most of the standard internet services that have been enabled by default in earlier Solaris releases. This is the default profile.
* _generic_limited_net.xml_ — This profile disables many of the standard internet services. The sshd service and the NFS services are started, but most of the rest of the internet services are disabled.
*svc.configd* daemon is the arbiter of all requests to the local and remote repository datastores.
*svc.startd* daemon is the master process starter and restarter for the Solaris OS. The daemon is responsible for managing service dependencies for the entire system. The daemon takes on the previous responsibility that init held of starting the appropriate _/etc/rcX_.d scripts at the appropriate run levels. First, _svc.startd_ retrieves the information in the service configuration repository. Next, the daemon starts services when their dependencies are met. The daemon is also responsible for restarting services that have failed and for shutting down services whose dependencies are no longer satisfied. The daemon keeps track of service state through an operating system view of availability through events such as process death.
h2. Service States
* _degraded_ – The service instance is enabled, but is running at a limited capacity.
* _disabled_ – The service instance is not enabled and is not running.
* _legacy_run_ – The legacy service is not managed by SMF, but the service can be observed. This state is only used by legacy services.
* _maintenance_ – The service instance has encountered an error that must be resolved by the administrator.
* _offline_ – The service instance is enabled, but the service is not yet running or available to run.
* _online_ – The service instance is enabled and has successfully started.
* _uninitialized_ – This state is the initial state for all services before their configuration has been read.
h1. Common services related tasks
h2. List the Status of a Service
svcs -l _FMRI_
% svcs -l network/login:rlogin
fmri svc:/network/login:rlogin
enabled true
...
h2. Showing the Status of Services Controlled by _inetd_
inetadm
h2. Which Services Are Dependent on a Service Instance
svcs -D _FMRI_
% svcs -D milestone/multi-user
STATE STIME FMRI
online Apr_08 svc:/milestone/multi-user-server:default
h2. Which Services a Service Is Dependent On
svcs -d _FMRI_
% svcs -d milestone/multi-user:default
STATE STIME FMRI
disabled Aug_24 svc:/platform/sun4u/sf880drd:default
online Aug_24 svc:/milestone/single-user:default
online Aug_24 svc:/system/utmp:default
...
h2. View the relationships between services and processes
svcs -p _FMRI_
svcs -pv _FMRI_
% svcs -pv system/sysevent:default
STATE NSTATE STIME CTID FMRI
online - 16:11:21 28 svc:/system/sysevent:default
16:11:21 138 syseventd
16:11:31 376 devfsadm
h2. An explanation of why a service isn't running
svcs -x _FMRI_
svcs -xv _FMRI_
% svcs -x system/zones:default
svc:/system/zones:default (Zones autoboot)
State: online since Tue Oct 31 16:11:26 2006
...
% svcs -x network/rpc/bind:default
svc:/network/rpc/bind:default (RPC bindings)
State: disabled since Wed Nov 01 12:03:11 2006
Reason: Disabled by an administrator.
...
h2. Disable a Service Instance (superuser)
svcadm disable _FMRI_
**WARNING: 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 network/login:rlogin
# svcadm disable network/login:rlogin
STATE STIME FMRI
# svcs network/login:rlogin
STATE STIME FMRI
disabled 11:17:24 svc:/network/login:rlogin
h2. Enable a Service Instance (superuser)
svcadm enable _FMRI_
Determine whether service dependencies are satisfied. If the service is enabled, then the service dependencies are satisfied. If not, use _svcadm enable -r FMRI_ to recursively enable all dependencies.
# svcs -l network/login:rlogin|grep enabled
enabled false
# svcadm enable network/login:rlogin
# svcs network/login:rlogin
STATE STIME FMRI
online 12:09:16 svc:/network/login:rlogin
h3. Enabling a Service in Single-user Mode (superuser)
The _-t_ option starts the service in temporary mode which does not change the service repository. The repository is not writable in single-user mode. The -r option recursively starts all the dependencies of the named service.
# svcadm enable -rt rpc/bind
h2. Sharing an NFS File System (restart a service - superuser)
To share a file system using the NFS service, you must define the file system in the _/etc/dfs/dfstab_ file and then restart the NFS service.
# cat /etc/dfs/dfstab
.
.
share -F nfs -o rw /export/home
# svcadm restart svc:/network/nfs/server
h2. Modify a Command-Line Argument for an _inetd_ Controlled Service (superuser)
inetadm -m _FMRI_ exec=_"command-syntax"_
Example: Adding the Connection Logging _(-l)_ Option to the _ftp_ Command
# inetadm -l svc:/network/ftp:default | grep exec
exec="/usr/sbin/in.ftpd -a"
# inetadm -m svc:/network/ftp:default exec="/usr/sbin/in.ftpd -a -l"
# inetadm -l svc:/network/ftp:default
SCOPE NAME=VALUE
name="ftp"
endpoint_type="stream"
proto="tcp6"
isrpc=FALSE
wait=FALSE
exec="/usr/sbin/in.ftpd -a -l"
.
.
h2. Convert _inetd.conf_ Entries
inetconv -i _filename_
The following procedure converts _inetd.conf_ entries into SMF service manifests. This procedure needs to be run *anytime a third-party application that depends on inetd is added to a system*. Also run this procedure, if you need to *make configuration changes to the entry in /etc/inetd.conf*.
# inetconv -i /etc/inet/inetd.conf
h2. See also
* "Managing SMF Services":http://docs.sun.com/app/docs/doc/817-1985/6mhm8o5s4?a=view
* "How to Repair a Corrupt Repository":http://docs.sun.com/app/docs/doc/817-1985/6mhm8o5t6?a=view -- _/lib/svc/bin/restore_repository_ This procedure shows how to replace a corrupt repository with a default copy of the repository. When the repository daemon, _svc.configd_, is started, it does an integrity check of the configuration repository. This repository is stored in _/etc/svc/repository.db_.
* "Start Services Interactively During Boot":http://docs.sun.com/app/docs/doc/817-1985/6mhm8o5t7?a=view -- if problems with starting services occur, sometimes a system will hang during the boot. This procedure shows how to troubleshoot this problem.