/opt/couchbase/smf/couchbase.xml
:<?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> <service_bundle type="manifest" name="couchbase"> <service name="application/database/couchbase" type="service" version="1"> <single_instance/> <dependency name="multi-user-server" grouping="require_all" restart_on="none" type="service"> <service_fmri value="svc:/milestone/multi-user-server"/> </dependency> <property_group name="general" type="framework"> <propval name="action_authorization" type="astring" value="solaris.smf.manage.couchbase"/> <propval name="value_authorization" type="astring" value="solaris.smf.value.couchbase"/> </property_group> <property_group name="couchbase" type="application"> <propval name="corepattern" type="astring" value="/opt/couchbase/var/crash/core.%f.%p"/> </property_group> <instance name="couchbase" enabled="false"> <exec_method type="method" name="start" exec="/opt/couchbase/smf/couchbase start" timeout_seconds="30"> <method_context> <method_credential user="couchbase" group="couchbase"/> </method_context> </exec_method> <exec_method type="method" name="stop" exec="/opt/couchbase/smf/couchbase stop %{restarter/contract}" timeout_seconds="60"> <method_context> <method_credential user="couchbase" group="couchbase"/> </method_context> </exec_method> </instance> <stability value="Unstable"/> <template> <common_name> <loctext xml:lang="C">Couchbase database server</loctext> </common_name> </template> </service> </service_bundle>
The source bundle we built contains a script to start and stop the server, but we need to wrap it order to make it work under SMF. Let's go ahead and create
/opt/couchbase/smf/couchbase
with the following content:#!/sbin/sh . /lib/svc/share/smf_include.sh PATH=${BIN_ROOT}/bin:$PATH:/opt/local/bin:/opt/local/gnu/bin export PATH case "$1" in 'start') coreadm -p "`svcprop -p couchbase/corepattern $SMF_FMRI`" $$ /opt/couchbase/bin/couchbase-server -- -noinput -detached & ;; 'stop') /opt/couchbase/bin/couchbase-server -k & ;; *) echo "Usage: $0 {start|stop}" exit 1 ;; esac exit $SMF_EXIT_OK
The scripts above wants to run the Couchbase server as couchbase:couchbase, so the first thing we need to do is to create the user and group:
[root@cbbuilder ~] groupadd couchbase [root@cbbuilder ~] roleadd -g couchbase -d /opt/couchbase/var couchbase [root@cbbuilder ~] mkdir -p /opt/couchbase/var/crash [root@cbbuilder ~] chown -R couchbase:couchbase /opt/couchbase
Now import the the service manifest and start the service with:
[root@cbbuilder /opt/couchbase/smf] svccfg import couchbase.xml [root@cbbuilder /opt/couchbase/smf] svcadm enable couchbase
And let's look at the service:
[root@cbbuilder /opt/couchbase/smf]# svcs -xv couchbase svc:/application/database/couchbase:couchbase (Couchbase database server) State: online since 11:19:20 UTC 8. august 2013 See: /var/svc/log/application-database-couchbase:couchbase.log Impact: None.
Happy hacking :-)
No comments:
Post a Comment