Monday 13 October 2014

Couchbase Sync Gateway : Installation and Running

Sync Gateway is a sync server that syncs data to and from the mobile clients and the couchbase server. Sync Gateway can be implemented using a 100 lines of code implementing all the functionalities like network connections handling , push and pull of data between servers and devices
It makes the JSON document stored on Couchbase server available to mobile devices over the internet. 
It provide features for routing data to users, authentication, change validation and access control.

Now in this blog we will try to get the sync gateway installed and running up using the following procedure:

Running the Sync Gateway :
Since couchbase is used easily along the multiple OS. We will try to demo it on Windows. This involves a number of important steps to get couchbase running.

-> Installing of Couchbase Sync Gateway in Windows
Get the download from the following for the respective operating system.

-> Connecting Couchbase Sync gateway to Couchbase sync server
1. Open Couchbase server console and signin to the app.
      2. From the menu choose the option to create a new bucket with name sync_gateway.
      3. Accessing and modifying sync gateway : Sync Gateway is similar to an application server in that it considers itself the owner of its bucket, and stores data in the bucket using its own schema. Even though the documents in the bucket are the ones stored there by clients, the Gateway adds its own metadata to them to track their sync status and revision history.



 -> Starting Sync Gateway : There are multiple ways to start Sync Gateway in windows once it is successfully installed.

a. One option to start Sync gateway from the command line using -url option. 
You start Sync Gateway by running sync_gateway with the -url option. The argument for the -url option is the HTTP URL of the Couchbase server to which you want Sync Gateway to connect. If you do not include any additional command-line options, the default values are used.

The following command starts Sync Gateway on port 4984, connects to the default bucket named sync_gateway in the Couchbase Serving running on localhost, and starts the admin server on port 4985.

$ ./sync_gateway -url http://localhost:8091
or 
C:\Users\ravikumar>sync_gateway -url http://localhost:8091

If you used a different name for the Couchbase Server bucket or want to listen on a different port, you need to include those parameters as command-line options. For information about the available command-line options, see the Configuration options guide.

b. Other option to start sync gateway is to click start Sync Gateway exe from the Window's Startup menu.


Note : This won't run if the sync_gateway installation directory's path is not added to the environment variable.

-> Stopping Sync Gateway :
There is no specific procedure to stop the sync gateway. Use the Ctrl C to stop the running the sync gateway.

No comments:

Post a Comment