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:
1 |
$ tar xzf couchbase-sync-gateway-enterprise_1.3.1.1-1_x86_64.tar.gz |
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
.
1 |
$ cd ~/workspace/servers/couchbase-sync-gateway |
Start Sync Gateway running using one of the example configuration files.
1 |
$ ./bin/sync_gateway examples/basic-couchbase-bucket.json |
You should see output that looks something like this:
1 2 3 4 5 6 |
2016-09-15T15:07:13.356-07:00 Enabling logging: [*] 2016-09-15T15:07:13.356-07:00 ==== Couchbase Sync Gateway/1.3.1(16;f18e833) ==== ... 2016-09-15T15:07:13.535-07:00 Starting admin server on 127.0.0.1:4985 2016-09-15T15:07:13.539-07:00 Starting server on :4984 ... 2016-09-15T15:07:14.659-07:00 Changes+: Notifying that "default" changed (keys="{_sync:user:}") count=2 |
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
1 |
$ ./bin/sync_gateway examples/basic-walrus-bucket.json |
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:
1 |
$ curl localhost:4985 |
You should see output that looks something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
HTTP/1.1 200 OK Content-Length: 144 Content-Type: application/json Date: Thu, 15 Sep 2016 22:09:54 GMT Server: Couchbase Sync Gateway/1.3.1 { "ADMIN": true, "couchdb": "Welcome", "vendor": { "name": "Couchbase Sync Gateway", "version": 1.3 }, "version": "Couchbase Sync Gateway/1.3.1(16;f18e833)" } |
Access the administrative interface by navigating in a browser to http://localhost:4985/_admin/.
You’ll see this top level page:
If you click on db under the database list, you’ll see this page:
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.
Useful Links
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://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.
[buttongroup][button style=”btn-link btn-lg” icon=”fa fa-arrow-left” align=”left” iconcolor=”#dd3333″ type=”link” target=”false” title=”Previous: Couchbase Server via the Command Line” link=”https://www.couchbase.com/blog/getting-comfortable-couchbase-mobile-couchbase-server-command-line/” linkrel=””][button style=”btn-link btn-lg” icon=”fa fa-arrow-right” align=”left” iconcolor=”#dd3333″ type=”link” target=”false” title=”Next: Sync Gateway via the Command Line” link=”https://www.couchbase.com/blog/getting-comfortable-with-couchbase-mobile-sync-gateway-via-the-command-line/” linkrel=””][/buttongroup]
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
[…] 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 […]
[…] Previous: Installing Sync Gateway Next: TBD […]
[…] 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. […]
[…] 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 […]
[…] 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. […]