Configure SGW

Provides an example configuration suitable for the Getting Started activity

The following steps explain how to configure Sync Gateway to connect to a Couchbase Server instance.

  1. Create a new file called sync-gateway-config.json with the following content:

    {
      "log": ["*"],
      "databases": {
        "getting-started-db": {
          "server": "http://localhost:8091",
          "bucket": "getting-started-bucket",
          "username": "sync_gateway", (1)
          "password": "password", (2)
          "enable_shared_bucket_access": true, (3)
          "import_docs": true,
          "num_index_replicas": 0, (4)
          "users": {
            "GUEST": { "disabled": false, "admin_channels": ["*"] }
          }
        }
      }
    }
    Configuration properties:
    1 The user’s username that you created on the Couchbase Server Admin Console.
    2 The user’s password that you created on the Couchbase Server Admin Console.
    3 The shared bucket access feature allows Couchbase Server SDKs to also perform operations on this bucket.
    4 num_index_replicas is the number of index replicas stored in Couchbase Server, introduced with GSI/N1QL indexing. If you’re running a single Couchbase Server node for development purposes the num_index_replicas must be set to 0.
  2. Start Sync Gateway

    Start Sync Gateway from the command line, or if Sync Gateway is running in a service replace the configuration file and restart the service.

    ~/Downloads/couchbase-sync-gateway/bin/sync_gateway ~/path/to/sync-gateway-config.json

    Run the application where Couchbase Lite is installed.

  3. To verify that documents have been replicated, you can:

    • Monitor the Sync Gateway sequence number returned by the database endpoint (GET /{db}/). The sequence number increments for every change that happens on the Sync Gateway database.

    • Query a document by ID on the Sync Gateway REST API (GET /{db}/{id}).

    • Query a document from the Query Workbench on the Couchbase Server Console.