Sync with Edge Server

      +
      edge to edge sync diagram

      Concepts

      Edge Servers can directly sync data with each other over WebSockets. This is useful when there are multiple Edge Servers that need to keep in sync at the edge, or you can set up Edge Server in a primary-backup configuration.

      You can use this configuration to allow for High Availability of your application, by switching to a synced Edge Server replica of your primary database.

      Prerequisites

      • You must have specified the host information, including the base URL and port.

      • You must have specified TLS certificate information.

      • If necessary, you must have specified an HTTP Basic username and password. The user must have the role required to carry out the API call.

      To configure Edge Server for REST-based access, see Get Started with the REST API.

      Sync Your Changes Between Edge Servers

      The following example shows a configuration for continuous bidirectional replication between two Edge Server instances. The source is the address of the remote Edge Server database. The target is the name of the local database.

      {
        databases: {
          travel: {
            path: "/opt/couchbase-edge-server/database/travel.cblite2",
            create: true,
            enable_client_sync: true
          }
        },
        interface: "0.0.0.0:59841",
        users: "/opt/couchbase-edge-server/users/users.json",
        replications: [
          {
            source: "ws://edge-server-2.example.com:59841/travel",
            target: "travel",
            bidirectional: true,
            continuous: true,
            collections: [
              "travel.airlines",
              "travel.routes",
              "travel.airports",
              "travel.landmarks",
              "travel.hotels"
            ],
            auth: {
              user: "admin_user",
              password: "s3cr3t"
            }
          }
        ]
      }

      For more information about continuous replication, see Start Replication Automatically.

      You can also start replication using the REST API. You do not need to set up replication in the configuration file to do this. Instead, you pass the replication options in the JSON request body.

      For more information, see REST API Replication.

      For information about monitoring and pushing changes, see Push Changes.