Рубрики
Uncategorized

Использование и настройка Redis Sentinel в Laravel

Автор оригинала: David Wong.

Конфигурация Ведущий-ведомый

  • Скопируйте redis файл конфигурации для открытия нескольких ведомых устройств

sudo cp/etc/redis.conf/etc/redis-6381.conf

sudo cp/etc/redis.conf/etc/redis-6382.conf

  • Отредактируйте файл конфигурации ведомого устройства, в основном измените параметры
port 6381

pidfile "/var/run/redis-6381.pid"

logfile "/var/log/redis/redis-6381.log"

slaveof 11.11.11.11 6381

Master auth "123456" # master and slave all keep the same password, and master configuration also requires this line, when executing the switch master, it seems that this line will not be added.
  • /usr/bin/redis-сервер/etc/redis.conf запускает redis через конфигурацию

Дозорный

  • Дубликат Конфигурации Часового. Откройте 3 Стража здесь

sudo cp/etc/redis-sentinel.conf/etc/redis-sentinel-26381.conf

sudo cp/etc/redis-sentinel.conf/etc/redis-sentinel-26382.conf

  • Отредактируйте файл конфигурации Sentinel. Основные параметры модификации заключаются в следующем. В зависимости от конкретной ситуации настройте файл конфигурации Sentinel.
port 26381

pidfile "/var/run/redis-sentinel-26381.pid"

logfile "/var/log/redis/redis-sentinel-26381.log"

Sentinel monitor mymaster

sentinel auth-pass mymaster 123456

Sentinel down-after-milliseconds mymaster 30000# primary node failure 30 seconds later to enable new primary node

When sentinel parallel-syncs mymaster 1# failover occurs, at most one slave node can synchronize data with the master node at the same time. The larger the number, the shorter the time, and the network and IO overhead exist.

Sentinel failover-time out mymaster 180000 # failover timeout time 180s: a if the transfer timeout fails, the next transfer time is twice as long as before; B when the slave node becomes the master node, the slave of one command from the slave node fails all the time, when the time exceeds 180S, the failover fails; C when the slave node replicates the new one; Transfer failure of primary node over 180S
  • /usr/bin/redis-sentinel/etc/redis-sentinel.conf Запускает Sentinels по конфигурации

Конфигурация Laravel Sentinel

'default' => [
            'tcp://11.11.11.11:26379',
            'tcp://11.11.11.11:26381',
            'tcp://11.11.11.11:26382', //These three are the addresses of sentinel nodes
            'options' => [
                'replication' => 'sentinel',
                'service'     => env('REDIS_SENTINEL_SERVICE', 'mymaster'),    //sentinel
                'parameters'  => [
                    'password'=> env ('REDIS_PASSWORD', null), //redis password, no time to write null
                    'database' => 0,
                ],
            ],
        ]