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
8.How to restore the SMF snapshot ?
You can restore complete SMF repository using below method. But you need reboot to take effect.
Caution:System may reboot immediately according to the options which you provide.
bash-3.00# /lib/svc/bin/restore_repository
See http://sun.com/msg/SMF-8000-MY for more information on the use of
this script to restore backup copies of the smf(5) repository.
If there are any problems which need human intervention, this script will
give instructions and then exit back to your shell.
Note that upon full completion of this script, the system will be rebooted
using reboot(1M), which will interrupt any active services.
The following backups of /etc/svc/repository.db exist, from
oldest to newest:
manifest_import-20120628_141735
manifest_import-20120628_150827
manifest_import-20121214_201555
boot-20130107_130944
boot-20130204_213314
boot-20130322_230722
boot-20130517_200728
The backups are named based on their type and the time what they were taken.
Backups beginning with "boot" are made before the first change is made to
the repository after system boot. Backups beginning with "manifest_import"
are made after svc:/system/manifest-import:default finishes its processing.
The time of backup is given in YYYYMMDD_HHMMSS format.
Please enter either a specific backup repository from the above list to
restore it, or one of the following choices:
CHOICE ACTION
---------------- ----------------------------------------------
boot restore the most recent post-boot backup
manifest_import restore the most recent manifest_import backup
-seed- restore the initial starting repository (All
customizations will be lost, including those
made by the install/upgrade process.)
-quit- cancel script and quit
Enter response [boot]:
After confirmation, the following steps will be taken:
svc.startd(1M) and svc.configd(1M) will be quiesced, if running.
/etc/svc/repository.db
-- renamed --> /etc/svc/repository.db_old_20130525_122228
/etc/svc/repository-boot
-- copied --> /etc/svc/repository.db
and the system will be rebooted with reboot(1M).
Proceed [yes/no]? y
Quiescing svc.startd(1M) and svc.configd(1M): done.
/etc/svc/repository.db
-- renamed --> /etc/svc/repository.db_old_20130525_122228
/etc/svc/repository-boot
-- copied --> /etc/svc/repository.db
The backup repository has been successfully restored.
Rebooting in 5 seconds.
9.How to revert specific SMF service snapshot ?
You can revert the specific service old snapshot using the following method.
bash-3.00# svccfg
svc:> select svc:/network/ipfilter:default
svc:/network/ipfilter:default> listsnap
initial
last-import
running
svc:/network/ipfilter:default> revert running
svc:/network/ipfilter:default> quit
bash-3.00# svcadm refresh svc:/network/ipfilter:default
bash-3.00# svcadm restart svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE STIME FMRI
disabled 12:24:17 svc:/network/ipfilter:default
bash-3.00# svcadm enable svc:/network/ipfilter:default
bash-3.00# svcs svc:/network/ipfilter:default
STATE STIME FMRI
online 12:32:17 svc:/network/ipfilter:default
bash-3.00#
No comments:
Post a Comment