The Couchbase Mobile Stack

Introduction

In this fourth post about the Couchbase Mobile stack, we’ll go over installing Sync Gateway.
Look for other posts in my “Getting Comfortable with Couchbase Mobile” series to learn everything you need to get the whole Couchbase Mobile stack up and running on your development machine.  (Links provided at the end.)

Background

To get comfortable with the whole stack, it’s great to install and run everything on one machine. In this series of posts, I’ll walk through the steps get to started with each component. I’ll show how to do a little extra exploring along the way, too.

I’ll only do minimal configuration. This is not intended to explain what you need for a production environment. I assume you’re familiar with some basics of NoSQL, have some understanding of Couchbase, and know how to build apps in something like Java,
Android, or iOS. If you want to read up on NoSQL databases or Couchbase, you can find lots of resources on the Couchbase site.

Couchbase is open-source. Everything I’ll use here is free to try out. See the end of the post for more resources if you need help.

Sync Gateway

Sync Gateway is a secure web gateway application with synchronization, REST, stream, batch and event APIs for accessing and synchronizing data over the web. Sync Gateway enables, among other things, secure data replication between Couchbase Server and
Couchbase Lite.

Sync Gateway has few dependencies, and can run on most Linux distributions (even on the Raspberry Pi), Windows, and OSX/macOS. The specific steps for installation vary with platform. See the downloads site for all the available packages, and the full installation guide for complete details. To install
on Linux distributions other than the supported ones, see this post.

I will walk through a simplified installation on OSX next.

OSX

Initial Installation Steps

To install Sync Gateway, first download the gzipped tar file for Mac here. You’ll get a file named something like couchbase-sync-gateway-enterprise_1.3.1.1-1_x86_64.tar.gz.

Unpack the archive, either by double-clicking on the file in Finder, or, from the command line, using the following:

This creates a number of files. We’ll only be concerned with the sync_gateway binary and the example configuration files.

Open a command line shell (e.g. Terminal). Change your working directory to the location where you unpacked the archive. In my case, I put them under my home directory in workspace/servers/couchbase-sync-gateway.

Start Sync Gateway running using one of the example configuration files.

You should see output that looks something like this:

That’s all it takes to get Sync Gateway up and going. The example configuration file I used here has the settings you need to use the other examples I will give in this and the related blogs.

This one requires you have Couchbase Server up and running at the same time.  If you want to try Sync Gateway running stand alone, use

instead.

Checking Your Installation

To verify Sync Gateway is running, you can do a couple of things.
From the command line, use curl to check the welcome message as follows:

You should see output that looks something like this:

Access the administrative interface by navigating in a browser to http://localhost:4985/_admin/.

You’ll see this top level page:

Sync Gateway Admin Interface Welcome

If you click on db under the database list, you’ll see this page:

Sync Gateway Admin Interface Database View

The links here will allow you to see quite a lot of interesting information while Sync Gateway is running. We’ll explore more when we look at the full stack operating together.

Finally, here are some other pages to explore to find out more about Sync Gateway.

https://developer.couchbase.com/documentation/mobile/current/installation/sync-gateway/index.html

https://developer.couchbase.com/documentation/mobile/current/guides/sync-gateway/index.html

https://developer.couchbase.com/documentation/mobile/current/references/sync-gateway/rest-common/index.html

https://github.com/couchbase/sync_gateway/wiki

Next Steps

In the next post in this series I’ll show some ways to work with Sync Gateway from the command line. This will help both under how Sync Gateway works, and give you some tools for diagnosing common problems and mistakes. Then we’ll look at a sample app using Couchbase Lite. Finally, we’ll use that sample app to loop back and see how everything ties together.

Postscript

Check out more resources on our developer portal and follow us on Twitter @CouchbaseDev.

You can post questions on our forums. And we actively participate on Stack Overflow.

You can follow me personally at @HodGreeley

Posted by Hod Greeley, Developer Advocate, Couchbase

Hod Greeley is a Developer Advocate for Couchbase, living in Silicon Valley. He has over two decades of experience as a software engineer and engineering manager. He has worked in a variety of software fields, including computational physics and chemistry, computer and network security, finance, and mobile. Prior to joining Couchbase in 2016, Hod led developer relations for mobile at Samsung. Hod holds a Ph.D. in chemical physics from Columbia University.

5 Comments

  1. […] Couchbase Server and Couchbase Lite and/or PouchDB. For a quick guide on installing it, check this guide. If Sync Gateway is installed, it’ll be accessible from the http://localhost:4984 when […]

  2. […] The Couchbase Mobile Stack comprises the Couchbase Server, Couchbase Sync Gateway and Couchbase Lite embedded Database. You can learn more about the server in the Getting started with Couchbase Server guide and the Sync Gateway in the Getting Started with Couchbase Sync Gateway guide. […]

  3. […] follow instructions in the blog post to install the the Sync Gateway in your Mac OS development environment. See the downloads site for all the available packages, and […]

  4. […] If you want to learn more about setting up Sync Gateway on your development machine, or how to work with it from the command line, take a look at this blog series. […]

Leave a reply