![]()
| Change milestone | svcadm milestone -d milestone/single-user:default |
svccfg
Provides the ability to display and manipulate the contents of the service configuration repository
svccfg -v import /var/svc/manifest/application/MyApp.xml
svcprop
Retrieves property values from the service configuration repository with a output format appropriate for use in shell scripts.
svcs
| -x | explain problems |
| -xv | explain problems and show which services are dependent |
| -d | Show services, this service depends on. |
| -D | Show services that depends on this service. |
| -p | list process related to service' |
xmllint
validate the xml structure.
xmllint --valid ./tomcat.xml > /dev/null
- Any errors will be listed.
- exit code 0 zero when the structure is valid.
boot
boot -m milestone=<milestone>", to boot to the named milestone. <milestone> can be
- single-user
- multi-user
- multi-user-server
- all : the special milestones "all" (all enabled services online)
- none : (no services at all). The "none" milestone can be very useful in repairing systems that have failures early in the boot process.
- boot -m verbose: for verbose boot.
Adding new services to inetd.conf
The Internet services daemon, inetd(1M), has been rewritten as part of SMF. It stores all of its configuration data in the SMF database, rather than /etc/inet/inetd.conf, allowing the SMF tools to be used to control and observe inetd-based services. Most inetd-based services that ship with Solaris will no longer have entries in inetd.conf. To provide compatibility for services which haven't converted to SMF, entries can still be added to inetd.conf using the same syntax as always, and the new inetconv(1M) command will convert the new services to SMF services. inetconv should always be run after editing /etc/inet/inetd.conf; it can be run without any arguments.
The profile XML file
General
- **:
- **:
- **:
dependency
<dependency name='multi-user'
grouping='require_all'
restart_on='error'
type='service'>
<service_fmri value='svc:/milestone/multi-user'/>
</dependency>
- name: Name of the dependency. ??? Can you choose this arbitrarily? Probably
- Can't contain '.' (dot/full stop char)
- grouping:
- exclude_all: None of the FMRIs can be online.
- optional_any:All FMRIs must either be online, of failed to come online. So none of the can be starting.
- require_all: All FMRIs must be online.
- require_any: ??? If a single FMRI in this group is online, then we are good to go.
- restart_on: The service in this profile is restarted if the dependency encounters one of the selected situations.
- error: restarts the service if the dependency is restarted due to a fault.
- none: Service will be independent of dependency actions.
- refresh: restart service if dependency 'refresh', 'restart' or encounters an error.
- restart: restarts the service if the dependency is restarted due to a fault.
- type:
- service: another FMRI
- path: File path.
- value must start with 'file::/localhost' before the full path is written.
Dependent on file
<dependency name='my_conf_fil'
grouping='require_all'
restart_on='none'
type='path'>
<service_fmri value='file://localhost/etc/my_conf.fil'/>
</dependency>
- The file is: /etc/my_conf.fil
- There is no need to set restart_on to anything but 'none' SMF currently doesn't support onaything else on files.
Dependent on Service
Dependent on service not exist/active
The scripts
- The shell script should include /lib/svc/share/smf_include.sh to get access to the return vars.
- call smfPresent() 0 = not present, non-zero = present.
Annotated Example
Manifest
<?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> <!-- Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. ident "@(#)webmin.xml 1.1 04/11/11 SMI" Service manifest for the Webmin service. --> <service_bundle type='manifest' name='tomcat'> <service name='application/servers/tomcat' type='service' version='1'> <create_default_instance enabled='true' /> <single_instance/> <dependency name='filesystem' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/system/filesystem/local' /> </dependency> <dependency name='network' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/network/initial' /> </dependency> <dependency name='server_xml' grouping='require_all' restart_on='none' type='path'> <service_fmri value='file://localhost//opt/apache-tomcat-6.0.18/conf/server.xml'/> </dependency> <exec_method type='method' name='start' exec='/opt/apache-tomcat-6.0.18/bin/startup.sh' timeout_seconds='30' > <method_context> <method_credential user='tcat' group='bin' /> </method_context> </exec_method> <exec_method type='method' name='stop' exec='/opt/apache-tomcat-6.0.18/bin/shutdown.sh' timeout_seconds='60' /> <stability value='Unstable' /> <template> <common_name> <loctext xml:lang='C'> Tomcat </loctext> </common_name> <!-- <documentation> <manpage title='webmin' section='1M' manpath='/usr/sfw/man' /> </documentation> --> </template> </service> </service_bundle>
XML lead-in
<?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
Service_bundle
<service_bundle type='manifest' name='tomcat'> </service_bundle>
service
<service name='application/servers/tomcat' type='service' version='1'> </service>
Default creation enabled/disabled
<create_default_instance enabled='true' />
Set to 'false' to ensure the service doesn't start until explicitly enabled.
Instances single/multiple
<single_instance/>
Start command
<exec_method
type='method'
name='start'
exec='/opt/apache-tomcat-6.0.18/bin/startup.sh'
timeout_seconds='30' >
<method_context>
<method_credential user='tcat' group='bin' />
</method_context>
</exec_method>
Stop command
Stop script
<exec_method
type='method'
name='stop'
exec='/opt/apache-tomcat-6.0.18/bin/shutdown.sh'
timeout_seconds='60' />
kill command
<exec_method
type='method'
name='stop'
exec=':kill'
timeout_seconds='60' />
Stability of Manifest
<stability value='Unstable' />
man page references etc.
<template>
<common_name>
<loctext xml:lang='C'> Tomcat </loctext>
</common_name>
<!-- <documentation> <manpage title='webmin' section='1M' manpath='/usr/sfw/man' /> </documentation> -->
</template>
Start script
. /lib/svc/share/smf_include.sh /usr/local/bin/runme&
Trouble shooting
Starting
svc.startd could not set context for method: chdir: No such file or directory
- You are missing the home dir for the user you have set-up in the manifest.
- Create the home dir and the 'svcadm clear' should take care of it.
[ Apr 3 08:22:55 Executing start method ("/opt/apache-tomcat-6.0.18/bin/startup.sh") ]
svc.startd could not set context for method: chdir: No such file or directory
[ Apr 3 08:22:55 Method "start" exited with status 96 ]
See also: Securing MySQL using SMF - the Ultimate Manifest
Implementing the SMF XML
svccfg: Multiple definitions for property type in property group network.
- Dependency name was used twice
# svccfg -v import ./tomcat.xml svccfg: Multiple definitions for property type in property group network.
<dependency name='network' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/network/initial' />
</dependency>
<dependency name='network' grouping='exclude_all' restart_on='none' type='service'>
<service_fmri value='svc:/application/management/sma' />
</dependency>
Could not interpret user property
- svcsprop tomcat
- Application Mgmt
- Automation
- Availability
- Backups
- Boot Process
- Configuration
- Databases
- Desktop Envmts
- Developer
- Development Envmts
- Devices and Periphs
- [Drivers]
- [Email]
- [Environmentals]
- Fault Management
- Filesystems
- Firmware
- High Performance Computing
- [Identity Mgmt ]
- Installation
- Interoperability
- Java Deployment
- LAMP-SAMP
- [Languages]
- [Load Balancing]
- Middleware
- [Migration]
- Monitoring
- Networking
- Open Source
- Operating System
- Patches and Releases
- Performance
- Power Management
- Release Eng
- Reliability
- [Reporting]
- Servers
- Security
- Storage
- [Time]
- Tools
- Troubleshooting
- Upgrade
- Virtualization
- Volume Management
- Web Technologies
- Zones