High availability for sync_gateway to connect Couchbase cluster


#1

I am using sync_gateway 1.3.0-274 on Ubuntu 14.04.1 LTS.And I have a Couchbase cluster with 2 nodes(v 4.5.0).
And I want sync_gateway to connect the couchbase cluster for high availability.that is:
If one node in the cluster is unavailable, sync_gateway will works fine because the cluster have at least one node working.
and when the node in the cluster back,sync_gateway can auto loadbalance bewteen the nodes.
As documents mention here
Does this configuration for this purpose?
If not,How can I configure sync_gateway ?


#2

When Sync Gateway starts, it retrieves the CBS cluster topology, and monitors for changes in the cluster topology on an ongoing basis (and so can handle a CBS node going down).

However, Sync Gateway doesn’t yet allow you to define multiple Couchbase Server nodes to attempt to connect to on startup - so it requires that the node specified in the Sync Gateway config is available when SG is starting up.

There’s an open issue to improve the startup capabilities:


#3

so the configServer should be a array of available configServer node list ,and the server in databases should be a array of node list too,Am I right?


#4

I think having configServer be an array would be a distinct enhancement from #1019. There may be a use case for that, but if you’ve got an array of configServers, I think the better approach for HA would be to put them behind a load balancer.


#5

yes, add a load balancer should work, but that means I need to take care of an extra service(load balancer service),If SG can handle this will be better for me.


#6

I see - I was assuming you’d already have a load balancer in place in front of your SG cluster, to support HA from the SG perspective, and you could reuse that.


#7

ok, can you give me some configuration example for SG to connect couchbase cluster that I can test?
Do I need to proxy http://<couchbase_host>:8091/ or http://<couchbase_host>:8091/pool only?


#8

I think there’s a misunderstanding here:

  1. For SG -> Couchbase Server communication, Sync Gateway does not currently support defining multiple server endpoints in the config. That’s the issue being tracked as https://github.com/couchbase/sync_gateway/issues/1019.
  2. Also for SG -> Couchbase Server communication…on startup, Sync Gateway automatically connects to the node specified in SG’s config, and obtains the cluster topology from it. There’s no additional work required for this functionality.
  3. For SG -> ConfigServer communication (which is unrelated to Couchbase Server - it’s for loading SG configurations dynamically), I was suggesting the use of a LB.

#9

Can you give me a example for ConfigServer? Is ConfigServer a HTTP service that return the content of sync_gateway.json by HTTP GET?

I have 2 nodes in the couchbase cluster,and my sync_gateway.json look like this:

...

  "databases": {
    "sgdb": {
      "server":"http://localhost:8091",
      "bucket":"cbdb",
...

when I start my SG service,the logs show as following:

2016-08-11T12:32:18.022+06:00 Enabling logging: [*]
2016-08-11T12:32:18.023+06:00 ==== Couchbase Sync Gateway/1.3.0(274;8c3ee28) ====
2016-08-11T12:32:18.023+06:00 requestedSoftFDLimit >= currentHardFdLimit (5000 >= 4096) capping at 4096
2016-08-11T12:32:18.023+06:00 Configured process to allow 4096 open file descriptors
2016-08-11T12:32:18.023+06:00 Opening db /sgdb as bucket "cbdb", pool "default", server <http://localhost:8091>
2016-08-11T12:32:18.023+06:00 Opening Couchbase database cbdb on <http://localhost:8091>
_time=2016-08-11T12:32:18.042+06:00 _level=INFO _msg= Trying with selected node 1
_time=2016-08-11T12:32:18.042+06:00 _level=INFO _msg= Trying with http://CBNODE01:8091/pools/default/bucketsStreaming/cbdb
_time=2016-08-11T12:32:18.053+06:00 _level=INFO _msg=Got new configuration for bucket cbdb
_time=2016-08-11T12:32:18.068+06:00 _level=INFO _msg= Trying with selected node 1
2016-08-11T12:32:18.121+06:00 Cache: Initializing changes cache with options {ChannelCacheOptions:{ChannelCacheMinLength:0 ChannelCacheMaxLength:0 ChannelCacheAge:0} CachePendingSeqMaxWait:5s CachePendingSeqMaxNum:10000 CacheSkippedSeqMaxWait:1h0m0s}
2016-08-11T12:32:18.121+06:00 Feed: Using TAP feed for bucket: "cbdb" (based on feed_type specified in config file
2016-08-11T12:32:18.133+06:00     Reset guest user to config
2016-08-11T12:32:18.133+06:00 WARNING: The GUEST user is the only user defined in the 'sgdb' database, but is either disabled or has no access to any channels.  This means that you will not be able to get useful data out of the sync gateway over the standard port.  FIX: enable and/or grant access to the GUEST user to channels via the admin_channels parameter. -- rest.emitAccessRelatedWarnings() at server_context.go:895
2016-08-11T12:32:18.133+06:00 Starting admin server on 127.0.0.1:4985
2016-08-11T12:32:18.138+06:00 Starting server on :4984 ...

but my Cluster has two nodes: http://CBNODE01:8091 and http://CBNODE02:8091.How can I know that SG will obtains the cluster topology from it?


#10

The Sync Gateway config documentation includes information on the configServer property:
http://developer.couchbase.com/documentation/mobile/current/develop/guides/sync-gateway/configuring-sync-gateway/config-properties/index.html

The 'Got new configuration for bucket…" in your log excerpt happens when Sync Gateway retrieves the new server topology.


#11

why CBNODE2 don’t show here?


#12

There isn’t logging of every node that Sync Gateway establishes a connection to.