適用於 Java 平台的 Service Management Facility 是 Solaris 10 的新功能之一,可為每個 Solaris 系統建立服務與服務管理所需的統一模型。
下列 svcadm 指令可協助您在 Web 伺服器上管理 Service Management Facility。
在安裝 Web 伺服器期間,您可以選擇安裝管理伺服器的服務。
svcadm enable <service-name>:<instance-name> — 啟動實例。
svcadm disable <service-name>:<instance-name>— 停止實例。
svcadm refresh <service-name>:<instance-name> — 重新啟動實例。
svcadm clear <service-name>:<instance-name> — 清除實例的狀態。您也可以在服務進入維護狀態時,使用 svcadm clear 指令將服務狀態從維護變更為停止。
您可以在建立實例時建立服務。在建立實例時,請使用下列指令建立服務:
wadm>create-instance <connect_options> --echo --no-prompt --verbose --force --config=<config_name> name --create-service (nodehost)+
使用下列指令可在現有的實例中建立服務:
wadm>create-service –config=<config-name> node host
若想了解如何透過 CLI 建立實例,請參閱create-instance(1)
服務通常由服務清單 (即 XML 檔案) 所定義,用以說明服務以及與該服務有關聯的所有實例。您可透過 svccfg import 指令將服務清單匯入儲存庫中。使用 Service Management Facility 時,服務的所有清單檔案皆必須位於下列位置:/var/svc/manifest。
使用 delete-service 指令可刪除服務。
以下是 Web 伺服器的清單檔案範例:
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!-- Copyright 2006 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms. -->
<service_bundle type='manifest' name='webserver7'>
<service name='network/http' type='service' version='1'>
<dependency name='filesystem' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<instance name='admin-server' enabled='false'>
<property_group name='start' type='method'>
<propval name='exec' type='astring' value='/var/opt/SUWwbsvr7/admin-server/bin/startserv'/>
<propval name='instanceRoot' type='astring' value='/var/opt/SUWwbsvr7'/>
<propval name='timeout' type='astring' value='300'/>
</property_group>
<property_group name='stop' type='method'>
<propval name='exec' type='astring' value='/var/opt/SUWwbsvr7/admin-server/bin/stopserv'/>
<propval name='timeout' type='astring' value='300'/>
</property_group>
<property_group name='refresh' type='method'>
<propval name='exec' type='astring' value='/var/opt/SUWwbsvr7/admin-server/bin/restartserv'/>
<propval name='timeout' type='astring' value='300'/>
</property_group>
<property_group name='startd' type='framework'>
<propval name='ignore_error' type='astring' value='core,signal'/>
</property_group>
</instance>
<instance name='https-mycompany.com' enabled='false'>
<property_group name='start' type='method'>
<propval name='exec' type='astring' value='/var/opt/SUWwbsvr7/https-mycompany.com/bin/startserv'/>
<propval name='instanceRoot' type='astring' value='/var/opt/SUWwbsvr7'/>
<propval name='timeout' type='astring' value='300'/>
</property_group>
<property_group name='stop' type='method'>
<propval name='exec' type='astring' value='/var/opt/SUWwbsvr7/https-mycompany.com/bin/stopserv'/>
<propval name='timeout' type='astring' value='300'/>
</property_group>
<property_group name='refresh' type='method'>
<propval name='exec' type='astring' value='/var/opt/SUWwbsvr7/https-mycompany.com/bin/restartserv'/>
<propval name='timeout' type='astring' value='300'/>
</property_group>
<property_group name='startd' type='framework'>
<propval name='ignore_error' type='astring' value='core,signal'/>
</property_group>
</instance>
<stability value='Evolving' />
<template>
<common_name>
<loctext xml:lang='C'>Sun Java System Web Server 7</loctext>
</common_name>
</template>
</service>
</service_bundle>
服務記錄檔位於下列目錄中:/var/svc/log 。服務記錄檔項目包含有關已嘗試的動作、動作結果,以及失敗原因等資訊。這些記錄位於下列位置:/var/svc/log/network-http:admin-server.log 。