TaskRabbit is Hiring!

We’re a tight-knit team that’s passionate about building a solution that helps people by maximizing their time, talent and skills. We are actively hiring for our Engineering and Design teams. Click To Learn more

Evan Tahler

Joyent Tips and Tricks

@ 07 Feb 2013

database ops

At TaskRabbit, we use Joyent’s SmartOs as our Staging and Production operating system. There are many features that this OS has which other’s don’t including the ability resize your zones on-the-fly, a good service manager, and solid support from Joyent.

That said, SmartOS is derivation of Solaris/Illumos, and installing packages on it is not always as simple as it might be on other operating systems.

This page will serve as a collection of install notes for various application on Joyent’s SmartOS. Hopefully it helps you too!

Base Packages and General Notes

These scripts have been tested on SmartMachine base 1.8.1

For all of the following recipes, I’ll assume that you have already installed these “basic” packages:

sudo pkgin in \
  gcc47 \
  smtools \
  curl \
  gmake \
  scmgit \
  libxslt \
  ruby193-base \
  ruby193-kgio \
  ruby193-readline \
  zip \

Here is our path: PATH=/home/deploy/opt:/opt/local/gnu/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin

If you installing these packages via tool which SSH’s into the server via a non-interactive shell, remember that any settings in ~/.profile will not be used, and a similar settings file from ~/.ssh/environment will be loaded. Also, if your tool (such as capistrano) re-connected for each command, you will need to re-export and re-cd for each command.

R (The language for statistical computing)

The trick to getting R to compile is informing the make process of where to look for a few libraries, and where to save the compiled application to when complete. Unfortunately, it looks like there are some x11 issues as well, so there are certain interactive features which won’t work (and you can’t build the PDF documentation… but you didn’t need that, did you?).

We wanted R installed so we could use the rinruby R - Ruby package, and this got it working for us:

export LDFLAGS='-L/opt/local/lib -R/opt/local/lib' && export CFLAGS='-I/opt/local/include'
wget -nv http://cran.cnr.berkeley.edu/src/base/R-2/R-2.15.2.tar.gz
tar xzf R-2.15.2.tar.gz
cd R-2.15.2 && ./configure --with-x=no --prefix=/opt/local
sudo make install

Couchbase Server (the database)

As of this time we COULD NOT install couch base on SmartOs :(
We’ll keep you posted if we figure it out!

Couchbase Client (libcouchbase)

Like R, installing libcouchbase (in a way that the ruby couchbase gem could use) it was also a matter of setting proper build paths. Also, there was a slight issue with regard to the way that the couch ruby gem’s build script expected hrtime to be handled. However, this was easy to fix, and this pull request is all that is needed to get it working on SmartOS (the code already checks if there is an os-specific hrtime lib, it just needs to invoke it). Hopefully this change will be merged to core soon, but in the mean time, feel free to use our fork:

gem 'couchbase', git: 'git://github.com/taskrabbit/couchbase-ruby-client.git', branch: 'release12'

Here’s how to get libcouchbase up and running:

export LDFLAGS='-L/opt/local/lib -R/opt/local/lib' && export CFLAGS='-I/opt/local/include'
sudo pkgin -y in libevent
wget -nv http://packages.couchbase.com/clients/c/libcouchbase-2.0.2.tar.gz
tar xzf libcouchbase-2.0.2.tar.gz
./configure --prefix=/opt/local --disable-couchbasemock
sudo gmake install


Joyent does have an Nginx server you can install from the pkgin, but if you want to live on the edge, here’s what you need to do:

mkdir -p ~/src
wget -O src/nginx.tar.gz http://www.nginx.org/download/${NGINX_VERSION}.tar.gz
export LD_RUN_PATH=/opt/local/lib
export PATH=/home/deploy/opt:/opt/local/gnu/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
./configure --prefix='/home/deploy/opt/nginx' \
    --with-http_ssl_module \
    --with-cc-opt='-Wno-error -I /opt/local/include/lib' \
    --with-ld-opt='-L /opt/local/lib' \
    --with-http_realip_module \
    --with-http_stub_status_module \
make && sudo make install

This will install nginx in ~/opt/sbin. Now, you probably want to use svc to monitor and maintain Nginx, so here’s a svc manifest you can import with svccfg import nginx.xml

<?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/nginx' type='service' version='0'>
    <create_default_instance enabled='false'/>
    <dependency name='filesystem' grouping='require_all' restart_on='error' type='service'>
      <service_fmri value='svc:/system/filesystem/local'/>
    <dependency name='network' grouping='require_all' restart_on='error' type='service'>
      <service_fmri value='svc:/milestone/network:default'/>
    <dependency name='dnsclient' grouping='require_all' restart_on='error' type='service'>
      <service_fmri value='svc:/network/dns/client:default'/>
    <dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/system/filesystem/local:default'/>
    <dependency name='autofs' grouping='optional_all' restart_on='error' type='service'>
      <service_fmri value='svc:/system/filesystem/autofs:default'/>
        <envvar name='LD_PRELOAD_32' value='/usr/lib/extendedFILE.so.1'/>
    <exec_method name='start' type='method' exec='/home/deploy/opt/nginx/sbin/nginx -c %{config_file}' timeout_seconds='60'/>
    <exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'/>
    <exec_method name='refresh' type='method' exec=':kill -HUP' timeout_seconds='60'/>
    <property_group name='application' type='application'>
      <propval name='config_file' type='astring' value='/home/deploy/opt/nginx/conf/nginx.conf'/>
    <property_group name='startd' type='framework'>
      <propval name='duration' type='astring' value='contract'/>
      <propval name='ignore_error' type='astring' value='core,signal'/>
    <stability value='Evolving'/>
        <loctext xml:lang='C'>Nginx HTTP daemon</loctext>


Coments Loading...