Couchbase’s Sync Gateway supports several platforms, including Linux. Unfortunately, there are a huge number of Linux distributions. It simply isn’t feasible to create and test installations for all of them.
As of this writing, Couchbase distributes two packages for Linux (expect this to increase soon). One is in Debian format, targeted to Ubuntu. The other is in rpm format, with support for RedHat Enterprise and CentOS.
So what happens if you run something else? I did a little investigating of options and did some quick tests. Here’s what I found out.
It’s helpful to know that Sync Gateway itself consists of only one binary executable,
sync_gateway. It does rely on a few dynamic libraries, but only a handful. (If you want to know how to check library dependencies, read about
ldd.) For most server-class distributions I wouldn’t expect you to have any problem running the application itself.
The difficulty comes from other aspects of a full set up. Typically, you’ll want three more things: a unique user to associate with the server, a location to install the main binary and accessory files, and a hook into the system boot sequence to automate starting and stopping the server.
It’s possible one of the current packages will work. Since Oracle Enterprise Linux (OEL) is a derivative of RedHat, I experimented with using rpm. It installed all the files in reasonable places (/home and /opt). It even started Sync Gateway running.
Unfortunately, it didn’t create the startup scripts. This is really at the core of the problem of using a package not tested for your distribution. It might not complete the installation. Worse, it may tweak something without you realizing it. Caveat emptor.
With that in mind, I’d recommend installing by hand instead. The Debian package format has a small number of files bundled in an ar archive. One of those bundles, data.tar.xz, contains the payload we want. You can pull it apart in one line.
To list the contents first, use
$ ar p couchbase-sync-gateway-enterprise_1.3.1-16_x86_64.deb data.tar.xz | tar tJ
To extract the files, use
$ ar p couchbase-sync-gateway-enterprise_1.3.1-16_x86_64.deb data.tar.xz | tar xJ
Once you’ve unpacked the archive, you’ll want to move the sync_gateway binary to your preferred directory.
For experimenting with Couchbase Mobile, this is all you really need. Be sure to check out the sample configuration files.
For production, best practices would include setting up Sync Gateway to run under its own user id (minimize privileges and isolate ability to make changes). And, of course, you’ll most likely want it to start automatically at boot, and probably restart automatically if it fails.
This post originally appeared on http://blog.couchbase.com/.