core icon indicating copy to clipboard operation
core copied to clipboard

Clustered ownCloud with clustered Redis in HA environment

Open GitHubUser4234 opened this issue 10 years ago • 22 comments

Hello,

I have an important feature request:

While ownCloud's documentation strongly recommends Redis in a distributed environment, Redis is downright unusable in a HA environment as ownCloud doesn't support a clustered Redis configuration. And that again prevents from using transactional file locking.

So ownCloud is expected to support one of the following:

(1) Support setting multiple Redis masters in config.php (similarly to setting multiple memcached_servers), and try the next one in case the first one fails and so on. This way multiple independent Redis clusters could run, with one being actively used and the others being backups.

(2) Support Redis Sentinel. Redis Sentinel is working in the background and when the current master fails, it propagates a Redis slave to master. In this option, ownCloud calls the Redis Sentinel API to ask for the address of the master.

Thanks a lot.

GitHubUser4234 avatar Jan 04 '16 17:01 GitHubUser4234

Also required here..

00004652

pako81 avatar Jan 25 '16 12:01 pako81

@MorrisJobke and
00005011

cdamken avatar Mar 10 '16 14:03 cdamken

http://stackoverflow.com/questions/9223840/redis-fail-over

MorrisJobke avatar Mar 10 '16 16:03 MorrisJobke

cc @MTRichards for this feature request

MorrisJobke avatar Mar 10 '16 16:03 MorrisJobke

@cdamken are all of these file locking Redis use cases, or something else - since Redis can be used for a few things.

MTRichards avatar Mar 10 '16 23:03 MTRichards

@cdamken are all of these file locking Redis use cases, or something else - since Redis can be used for a few things.

The cases of @pako81 and @cdamken are clearly originating in our requirement for Redis for the file locking. They are then also used for the distributed memcache (because setting up another service that mostly does the same makes no sense).

MorrisJobke avatar Mar 11 '16 08:03 MorrisJobke

Is there a reason why we don't use heartbeat between Redis servers? My understanding is that it does the same thing and is available now. In other words, set up Redis servers and connect them with heartbeat so when one fails, it fails over to another and ownCloud is none the wiser. @bboule Anything to add on that one?

MTRichards avatar Mar 11 '16 14:03 MTRichards

@MTRichards Master-Slave with Heartbeat would be my recommendation too. In the other hand, redis-sentinel provides more capabilities http://redis.io/topics/sentinel

cdamken avatar Mar 11 '16 15:03 cdamken

@MorrisJobke @pako81 Anyone discuss this with the SF above? Is there a reason master/slave doesn't work for them?

MTRichards avatar Mar 11 '16 16:03 MTRichards

Is there a reason master/slave doesn't work for them?

It's about adding complexity to the maintenance of the system. As far as I understood this they want to off-load the maintenance of the fallback to ownCloud client side code (client side here refers to the redis-client).

MorrisJobke avatar Mar 13 '16 13:03 MorrisJobke

PR from @Xenopathic for 1) https://github.com/owncloud/core/pull/23204

PVince81 avatar Mar 14 '16 14:03 PVince81

@MorrisJobke Thanks for the explanation.

While we need testing for 1), great to see the PR @Xenopathic .

@cmonteroluque When it has time to be run through its paces, we can then claim victory and roll it in to the next release that makes sense. By default, 9.1 makes the most sense I think.

MTRichards avatar Mar 14 '16 20:03 MTRichards

For 1), the best solution IMHO is to leverage existing HA solutions like Pacemaker/Heartbeat or Kubernetes, which assign an IP address that is routed to an available node, and dynamically handles node failures. This is a much more robust solution than trying to implement anything ourselves.

RobinMcCorkell avatar Mar 15 '16 12:03 RobinMcCorkell

https://github.com/owncloud/core/issues/21448#issuecomment-196506622 I agree

ghost avatar Mar 15 '16 17:03 ghost

I think one of the references concerns our setup. For the session sharing in a clustered ownCloud environment we are right now using redis-cluster as described in http://redis.io/topics/cluster-spec using phpredis 2.2.7 which works just fine. It would be nice to also use this cluster for the transactional file locking

Ethendrel avatar Mar 30 '16 12:03 Ethendrel

@Ethendrel Please test #23204, which implements Redis Cluster support - getting real-world reviews of that code is worth a hundred unit tests.

RobinMcCorkell avatar Mar 30 '16 12:03 RobinMcCorkell

@Xenopathic we are runnning 8.2.2 so I applied your changes to this version, as the checkout of the branch was giving me errors.

With 'failover_mode' => \RedisCluster::FAILOVER_DISTRIBUTE i get the following error: [Wed Mar 30 16:18:33.138068 2016] [:error] [pid 13920] [client 192.168.0.101:36320] PHP Fatal error: Undefined class constant 'OPT_FAILOVER' in /var/www/owncloud/lib/private/memcache/rediscluster.php on line 36

commenting out the 'failover_mode' to let it use the default led to a working system that survives a shutdown of half the cluster.

Ethendrel avatar Mar 30 '16 15:03 Ethendrel

@Ethendrel Brilliant, thanks for testing! Turns out there was a documentation error in phpredis, the correct constant is OPT_SLAVE_FAILOVER. I'll update the PR in a moment, could you test again without commenting out any code? Is the clustering working as expected?

RobinMcCorkell avatar Mar 30 '16 15:03 RobinMcCorkell

@Xenopathic OPT_SLAVE_FAILOVER fixed it. Yes, as far as I can see clustering is working as expected so far. Thank you for the work. I will let it run like this for a while to continue testing.

Ethendrel avatar Mar 30 '16 15:03 Ethendrel

see https://github.com/owncloud/core/pull/23204#issuecomment-215006600 - 9.2 for my POV

DeepDiver1975 avatar Apr 27 '16 08:04 DeepDiver1975