I’m looking into a way to setup Redis HA using Sentinels, and am looking into drivers that will work with laravel and laravel/horizon for job scheudling. I’ve been looking into solutions on google – there doesn’t seem to be either documentation or tutorials available, so I’m wondering if that’s even possible?
I’ve found this: https://github.com/monospice/laravel-redis-sentinel-drivers, but this seems to only support up to Laravel 8, and no more.
I’ve tried setting up a connection like this:
config/database.php
'client' => 'phpredis',
'redis-sentinel' => [
env('REDIS_SENTINEL_1'),
env('REDIS_SENTINEL_2'),
env('REDIS_SENTINEL_3'),
'options' => [
'replication' => 'sentinel',
'service' => env('REDIS_SENTINEL_SERVICE', 'mymaster'),
'parameters' => [
'password' => env('REDIS_SENTINEL_PASSWORD', null),
'database' => 0,
],
],
]
and using it, but it doesn’t quite seem to work.
Any help or resources how to set it up properly would be greatly appreciated
2
Answers
You have to install predis package
composer require predis/predis
and add this driver configuration to your config/database.php file (on the same level with connections array)
Please notice that cache cleans the database periodicaly, so you must check that it is able to specify different redis connection in the database/cache.php:
so now you can use
as app environment variables
Also, edit horizon.php to have something like
so all workers use the right queue connection.