1

I have recently started with laravel and php and implemented redis using predis for a single node redis server ( using azure redis for cache ).

All was good until we decided to upgrade and turn clustering size to 2 and then started getting moved errors

I implemented configuration for clustering but azure only gives a single url that is made up of host name port password and ssl option.

I dont know how to use this as both phpredis and predis expect there to be a array of nodes. but i dont have that.

the errors i have gotten are moved exceptions Can't communicate with any node in the cluster Couldn't map cluster keyspace using any provided seed (phpredis)

i need help i have tried alot of different database.php configs plus client implementation.

added info using ssl port 6380

'redis' => [

        'cluster' => true,
        'client' => env('REDIS_CLIENT', 'phpredis'),

        'options' => [
            'cluster' => env('REDIS_CLUSTER', 'redis'),
            'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
            'replication' => true,
            'parameters' => [
                // Parameters provide defaults for the Connection Factory
                'password' => env('REDIS_PASSWORD', null), // Redirects need PW for the other nodes
                'scheme'   => env('REDIS_SCHEME', 'tcp'),  // Redirects also must match scheme
            ],
            'persistent' => true,
            'ssl'    => ['verify_peer' => false], // Since we dont have TLS cert to verify
        ],

        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => env('REDIS_DB', 0),
            'persistent' => true,
        ],

        'clusters' => [
            'default' => [
                [
                    'persistent' => true,
                    'scheme'   => env('REDIS_SCHEME', 'tcp'),
                    'host' => env('REDIS_HOST', 'localhost'),
                    'password' => env('REDIS_PASSWORD', null),
                    'port' => env('REDIS_PORT', 6379),
                    'database' => env('REDIS_CACHE_DB', 0),
                    'read_write_timeout' => 30,
                ],
            ],

            'options' =>[
                'cluster' =>'redis',
                'replication' => true,
                'persistent' => true,
            ]
        ],
    ],
'redis' => [

        'client' => env('REDIS_CLIENT', 'predis'),

        'options' => [
            'cluster' => env('REDIS_CLUSTER', 'redis'),
            'context' => [
                'stream' => [
                    'verify_peer' => env('REDIS_SSL_VERIFY_PEER', false),
                    'verify_peer_name' => env('REDIS_SSL_VERIFY_PEER_NAME', false),
                    'stream' => [
                        'verify_peer' => env('REDIS_SSL_VERIFY_PEER', false),
                    ]
                ],
            ],
            'scheme' => 'tls',
            'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
        ],

        'default' => [
          //  'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_DB', '0'),
            'scheme' => env('REDIS_SCHEME', 'tls'),
            'ssl' => [
                'verify_peer' => env('REDIS_SSL_VERIFY_PEER', false),
                'verify_peer_name' => env('REDIS_SSL_VERIFY_PEER_NAME', false),
            ],
        ],
   ],
'redis' => [

        'client' => 'phpredis',
        'clusters' => [
            'default' => [
                [
                    'host' => env('REDIS_HOST', 'localhost'),
                    'password' => env('REDIS_PASSWORD', null),
                    'port' => env('REDIS_PORT', 6379),
                    'database' => 0,
                ],
            ],
        ]

    ],
'redis' => [
        'cluster' => true,

        'default' => [
            'host' => env('REDIS_HOST', 'localhost'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
            'schema' => 'tls',
        ],

        'options' => [
            'cluster' => 'redis',
            'parameters' => ['password' => env('REDIS_PASSWORD', null)],
        ],
    ],*/
    'redis' => [
        'client' => env('REDIS_CLIENT', 'phpredis'), // Use 'phpredis' for the phpredis extension
        'cluster' => [
            'mode' => 'redis', // Set the mode to 'redis' for cluster support
            'seeds' => [
                env('REDIS_HOST', '127.0.0.1'), // List all nodes in your cluster
                // Add other nodes here if you have more
            ],
        ],
        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
        ],
    ],

above is the database.php redis configs i tried .

i need to connect to a cluster of 2 shards in azure redis cache with out error

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.