Clustered ownCloud with clustered Redis in HA environment
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.
Also required here..
00004652
@MorrisJobke
and
00005011
http://stackoverflow.com/questions/9223840/redis-fail-over
cc @MTRichards for this feature request
@cdamken are all of these file locking Redis use cases, or something else - since Redis can be used for a few things.
@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).
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 Master-Slave with Heartbeat would be my recommendation too. In the other hand, redis-sentinel provides more capabilities http://redis.io/topics/sentinel
@MorrisJobke @pako81 Anyone discuss this with the SF above? Is there a reason master/slave doesn't work for them?
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).
PR from @Xenopathic for 1) https://github.com/owncloud/core/pull/23204
@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.
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.
https://github.com/owncloud/core/issues/21448#issuecomment-196506622 I agree
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 Please test #23204, which implements Redis Cluster support - getting real-world reviews of that code is worth a hundred unit tests.
@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 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?
@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.
see https://github.com/owncloud/core/pull/23204#issuecomment-215006600 - 9.2 for my POV