Blog Post

Running Moxi on Solaris

Trond Norbye of Couchbase Published

I have been working on getting Membase up'n'running on OpenSolaris as a side project. Most of it is already in place, but there are still some Makefile issues to sort out. I thought that while we're waiting to complete that task, I could show you how to easily run moxi as a service controlled by SMF.

I've created some scripts to make it easier for you to build and install everything, so the first we need to do is to check out (or update your clone) of my tools repository:

trond@opensolaris> git clone git://github.com/trondn/tools.git
trond@opensolaris> cd tools/membase

Next up we need to create some new ZFS datasets for our moxi installation. I've created a script that creates the zfs datasets and set up the mountpoints:

trond@opensolaris> ./smf/moxi/setup.sh -u -z rpool

The -u option tells the script to create authorizations, profiles, users and groups we need, and the -z option tells the script to create the zfs filesystems in the zfs pool named rpool.

Next up we need to compile (and install) the source code. The directory /opt/membase is not writable for us, so let's change the ownership so I can install files there...:

trond@opensolaris> pfexec chown trond:staff /opt/membase
trond@opensolaris> ./setup.sh -d /opt/membase moxi
Download commit hook - Ok.
Checking out libmemcached (Bazaar) - Ok.
Checking out bucket_engine (git) - Ok.
Checking out ep-engine (git) - Ok.
Checking out libconflate (git) - Ok.
Checking out libvbucket (git) - Ok.
Checking out memcached (git) - Ok.
Checking out moxi (git) - Ok.
Checking out vbucketmigrator (git) - Ok.
Checking out membase-cli (git) - Ok.
Checking out ns_server (git) - Ok.
Checking out memcachetest (git) - Ok.
Configure build for SunOS
trond@opensolaris> cd moxi/SunOS
trond@opensolaris> make all install

Now we've got everything installed to /opt/membase, so let's change the ownership to membase:membase and install the SMF script to manage moxi:

trond@opensolaris> chown -R membase:membase /opt/membase
trond@opensolaris> cd ../../smf/moxi
trond@opensolaris> ./setup.sh -s
moxi installed as /lib/svc/method/moxi
moxi.xml installed as /var/svc/manifest/application/moxi.xml

So let's check out the configuration options we got for our new SMF service:

trond@opensolaris> svccfg
svc:> select moxi
svc:/application/database/moxi> listprop
manifestfiles                                       framework
manifestfiles/var_svc_manifest_application_moxi_xml astring  /var/svc/manifest/application/moxi.xml
general                                             framework

general/action_authorization                        astring solaris.smf.manage.moxi
general/entity_stability                            astring  Unstable
general/single_instance                             boolean  true
general/value_authorization                         astring  solaris.smf.value.moxi
multi-user-server                                   dependency
multi-user-server/entities                          fmri svc:/milestone/multi-user-server
multi-user-server/grouping                          astring  require_all
multi-user-server/restart_on                        astring  none
multi-user-server/type                              astring  service
moxi                                                application
moxi/corepattern                                    astring /var/opt/membase/cores/core.%f.%p
moxi/downstream_max                                 astring  8
moxi/port                                           astring  11211
moxi/threads                                        astring  4
moxi/url                                            astring  http://membase:8091/pools/default/bucketStreaming/default
moxi/version                                        astring  1.6.0
tm_common_name                                      template
tm_common_name/C                                    ustring  Membase
tm_man_moxi                                         template
tm_man_moxi/manpath                                 astring  /opt/membase/share/man
tm_man_moxi/section                                 astring  1
tm_man_moxi/title                                   astring  moxi

You will most likely want to set the URL parameter to point to the bucket you want to use..

svc:/application/database/moxi> setprop moxi/url=http://myserver:8091/pools/default/bucketStreaming/default

Let's refresh the configuration and start the service:

trond@opensolaris> svccfg refresh moxi
trond@opensolaris> svcadm enable moxi
trond@opensolaris> svcs moxi
STATE          STIME    FMRI
online          9:45:41 svc:/application/database/moxi:moxi