Solaris SMF: Difference between revisions
From Lolly's Wiki
Jump to navigationJump to search
No edit summary |
m (Text replacement - "[[Kategorie:" to "[[Category:") |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[ | [[Category:Solaris|SMF]] | ||
__FORCETOC__ | |||
== Running foreground processes == | == Running foreground processes == | ||
< | <syntaxhighlight lang=xml> | ||
<?xml version='1.0'?> | <?xml version='1.0'?> | ||
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> | <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> | ||
Line 39: | Line 41: | ||
</service> | </service> | ||
</service_bundle> | </service_bundle> | ||
</ | </syntaxhighlight> | ||
==Adding dependency on another service== | ==Adding dependency on another service== | ||
For example mount NFS after ZFS: | For example mount NFS after ZFS: | ||
< | <syntaxhighlight lang=bash> | ||
svccfg -s svc:/network/nfs/client addpg filesystem-local dependency | svccfg -s svc:/network/nfs/client addpg filesystem-local dependency | ||
svccfg -s svc:/network/nfs/client setprop filesystem-local/grouping = astring: require_all | svccfg -s svc:/network/nfs/client setprop filesystem-local/grouping = astring: require_all | ||
Line 49: | Line 51: | ||
svccfg -s svc:/network/nfs/client setprop filesystem-local/restart_on = astring: none | svccfg -s svc:/network/nfs/client setprop filesystem-local/restart_on = astring: none | ||
svccfg -s svc:/network/nfs/client setprop filesystem-local/type = astring: service | svccfg -s svc:/network/nfs/client setprop filesystem-local/type = astring: service | ||
</ | </syntaxhighlight> | ||
==Setting multiple parameters to environment variables== | ==Setting multiple parameters to environment variables== | ||
The goal: | 1. The goal: | ||
Setting -Xmx from 512m to 2G | * Setting -Xmx from 512m to 2G | ||
The problem: | The problem: | ||
< | <syntaxhighlight lang=bash> | ||
# svccfg -s svc:/cms/web:tomcat setenv -m start CATALINA_OPTS '-XX:MaxPermSize=256m -Xmx2G -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.rmi.server.hostname=tomcat.server.de' | # svccfg -s svc:/cms/web:tomcat setenv -m start CATALINA_OPTS '-XX:MaxPermSize=256m -Xmx2G -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.rmi.server.hostname=tomcat.server.de' | ||
svccfg: Syntax error. | svccfg: Syntax error. | ||
</ | </syntaxhighlight> | ||
So you have to set the complete environment this way: | So you have to set the complete environment this way: | ||
< | * Get the complete environment: | ||
<syntaxhighlight lang=bash> | |||
# svccfg -s svc:/cms/web:tomcat listprop method_context/environment | # svccfg -s svc:/cms/web:tomcat listprop method_context/environment | ||
method_context/environment astring "PATH=/usr/jdk/latest/bin:/usr/sbin:/usr/bin" "LC_CTYPE=de_DE.ISO8859-15@euro" "JAVA_OPTS=-Dhttp.proxyHost=proxy.server.de -Dhttp.proxyPort=8080 -Djava.awt.headless=true" "JAVA_HOME=/usr/jdk/latest" "CATALINA_OPTS=-XX:MaxPermSize=256m -Xmx512m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.rmi.server.hostname=tomcat.server.de" | method_context/environment astring "PATH=/usr/jdk/latest/bin:/usr/sbin:/usr/bin" "LC_CTYPE=de_DE.ISO8859-15@euro" "JAVA_OPTS=-Dhttp.proxyHost=proxy.server.de -Dhttp.proxyPort=8080 -Djava.awt.headless=true" "JAVA_HOME=/usr/jdk/latest" "CATALINA_OPTS=-XX:MaxPermSize=256m -Xmx512m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.rmi.server.hostname=tomcat.server.de" | ||
</syntaxhighlight> | |||
* Set the complete (modified) environment: | |||
<syntaxhighlight lang=bash> | |||
# svccfg -s svc:/cms/web:tomcat setprop method_context/environment = astring: '("PATH=/usr/jdk/latest/bin:/usr/sbin:/usr/bin" "LC_CTYPE=de_DE.ISO8859-15@euro" "JAVA_OPTS=-Dhttp.proxyHost=proxy.server.de -Dhttp.proxyPort=8080 -Djava.awt.headless=true" "JAVA_HOME=/usr/jdk/latest" "CATALINA_OPTS=-XX:MaxPermSize=256m -Xmx2G -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.rmi.server.hostname=tomcat.server.de")' | # svccfg -s svc:/cms/web:tomcat setprop method_context/environment = astring: '("PATH=/usr/jdk/latest/bin:/usr/sbin:/usr/bin" "LC_CTYPE=de_DE.ISO8859-15@euro" "JAVA_OPTS=-Dhttp.proxyHost=proxy.server.de -Dhttp.proxyPort=8080 -Djava.awt.headless=true" "JAVA_HOME=/usr/jdk/latest" "CATALINA_OPTS=-XX:MaxPermSize=256m -Xmx2G -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.rmi.server.hostname=tomcat.server.de")' | ||
# svcadm refresh svc:/cms/web:tomcat | # svcadm refresh svc:/cms/web:tomcat | ||
</ | </syntaxhighlight> | ||
* Check it with: | |||
<syntaxhighlight lang=bash> | |||
# svccfg -s svc:/cms/web:tomcat listprop method_context/environment | |||
</syntaxhighlight> | |||
== Ignore child process coredumps == | |||
<syntaxhighlight lang=xml> | |||
<property_group name='startd' type='framework'> | |||
<!-- sub-process core dumps shouldn't restart | |||
session --> | |||
<propval name='ignore_error' type='astring' | |||
value='core,signal' /> | |||
</property_group> | |||
</syntaxhighlight> | |||
<syntaxhighlight lang=bash> | |||
< | # svccfg -s clamav | ||
# svccfg -s svc:/ | svc:/network/clamav> addpg startd framework | ||
</ | svc:/network/clamav> addpropvalue startd/ignore_error astring: core,signal | ||
svc:/network/clamav> end | |||
</syntaxhighlight> |
Latest revision as of 04:50, 26 November 2021
Running foreground processes
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='network/foreground-daemon' type='service' version='0'>
<single_instance/>
<dependency name='filesystem_minimal' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<dependency name='loopback' grouping='require_any' restart_on='error' type='service'>
<service_fmri value='svc:/network/loopback'/>
</dependency>
<dependency name='network' grouping='optional_all' restart_on='error' type='service'>
<service_fmri value='svc:/milestone/network'/>
</dependency>
<instance name='default' enabled='true'>
<exec_method name='refresh' type='method' exec=':true' timeout_seconds='60'/>
<exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'/>
<exec_method name='start' type='method' exec='/opt/foreground/bin/foreground-daemon %m' timeout_seconds='0'>
<method_context project='foreground-project' >
<method_credential user='foreground-user' group='noaccess' />
</method_context>
</exec_method>
<property_group type="framework" name="startd">
<propval type="astring" name="duration" value="child"/>
</property_group>
<template>
<common_name>
<loctext xml:lang='C'>Foreground Daemon</loctext>
</common_name>
<documentation>
<manpage title='foreground-daemon' section='1M' manpath='/opt/foreground/man'/>
</documentation>
</template>
</instance>
<stability value='Unstable'/>
</service>
</service_bundle>
Adding dependency on another service
For example mount NFS after ZFS:
svccfg -s svc:/network/nfs/client addpg filesystem-local dependency
svccfg -s svc:/network/nfs/client setprop filesystem-local/grouping = astring: require_all
svccfg -s svc:/network/nfs/client setprop filesystem-local/entities = fmri: svc:/system/filesystem/local:default
svccfg -s svc:/network/nfs/client setprop filesystem-local/restart_on = astring: none
svccfg -s svc:/network/nfs/client setprop filesystem-local/type = astring: service
Setting multiple parameters to environment variables
1. The goal:
- Setting -Xmx from 512m to 2G
The problem:
# svccfg -s svc:/cms/web:tomcat setenv -m start CATALINA_OPTS '-XX:MaxPermSize=256m -Xmx2G -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.rmi.server.hostname=tomcat.server.de'
svccfg: Syntax error.
So you have to set the complete environment this way:
- Get the complete environment:
# svccfg -s svc:/cms/web:tomcat listprop method_context/environment
method_context/environment astring "PATH=/usr/jdk/latest/bin:/usr/sbin:/usr/bin" "LC_CTYPE=de_DE.ISO8859-15@euro" "JAVA_OPTS=-Dhttp.proxyHost=proxy.server.de -Dhttp.proxyPort=8080 -Djava.awt.headless=true" "JAVA_HOME=/usr/jdk/latest" "CATALINA_OPTS=-XX:MaxPermSize=256m -Xmx512m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.rmi.server.hostname=tomcat.server.de"
- Set the complete (modified) environment:
# svccfg -s svc:/cms/web:tomcat setprop method_context/environment = astring: '("PATH=/usr/jdk/latest/bin:/usr/sbin:/usr/bin" "LC_CTYPE=de_DE.ISO8859-15@euro" "JAVA_OPTS=-Dhttp.proxyHost=proxy.server.de -Dhttp.proxyPort=8080 -Djava.awt.headless=true" "JAVA_HOME=/usr/jdk/latest" "CATALINA_OPTS=-XX:MaxPermSize=256m -Xmx2G -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.rmi.server.hostname=tomcat.server.de")'
# svcadm refresh svc:/cms/web:tomcat
- Check it with:
# svccfg -s svc:/cms/web:tomcat listprop method_context/environment
Ignore child process coredumps
<property_group name='startd' type='framework'>
<!-- sub-process core dumps shouldn't restart
session -->
<propval name='ignore_error' type='astring'
value='core,signal' />
</property_group>
# svccfg -s clamav
svc:/network/clamav> addpg startd framework
svc:/network/clamav> addpropvalue startd/ignore_error astring: core,signal
svc:/network/clamav> end