Magento – Magento2 : Redis Sentinel Configuration

cm-redissessionmagento2redis

I am trying to run Magento2 with a Redis Cluster (running redis-sentinel) as cache and session backend.

I am not sure about how I should do this ? Is it even possible ?

As I see from Collin Mollenhour repository, it seems possible :

https://github.com/colinmollenhour/Cm_Cache_Backend_Redis#redis-sentinel

However, this part was written for Magento1.

But, since the library is the same in Magento2, maybe I can achieve ?

Here is my app/etc/env.php file :

'cache' => 
  array (
    'frontend' => 
    array (
      'default' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => 'magento2-redis-sentinel', // A load-balanced host where my sentinel service resides.
          'sentinel_master' => 'mymaster',
          'sentinel_master_verify' => '1',
          'port' => '26379',
          'database' => '1',
          'compress_data' => 0,
        ),
      ),
      'page_cache' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => 'magento2-redis-sentinel',
          'sentinel_master' => 'mymaster',
          'sentinel_master_verify' => '1',
          'port' => '26379',
          'database' => '2',
          'compress_data' => 0,
        ),
      ),
    ),
  ),

However, this does not work, here is what Magento says :

Unable to connect to a redis sentinel: Unknown sentinel subcommand 'setClientTimeout'

But, connecting directly via netcat is OK :

nc magento2-redis-sentinel 26379 (and then issue commands like "info" are properly showing redis-sentinel state).

Does anyone already achieve to get such setup to work?

Best Answer

From what I read in the colinmollenhour repository, I am missing this line : https://github.com/colinmollenhour/credis/blob/master/Sentinel.php#L88

This is not included in the version of colinmollenhour/credis used in Magento 2.

Will give a try to leverage the composer requirements and see if it's running better.

Related Topic