drvxclagw656708070 2015-02-03 22:06
浏览 243
已采纳

在Laravel中配置高可用性Redis群集

I'm trying to update my Laravel application so that Queue::push() pushes jobs to a redis queue cluster. The guy setting that up is communicating to me that our application needs to be configured with connection details for the primary master and several slaves. If this is the correct way to set this up I'm struggling to figure out how to configure this.

Out of the box the redis config looks something like...

'redis' => array(
    'cluster' => true,
    'default' => array(
            'host' => '127.0.0.1',
            'port' => 6379,
            'database' => 0,
        ),
    ),
);

I've been digging through the Laravel driver trying to figure out how to configure masters and slaves within Laravel and haven't been able to figure it out. How can I add slaves here?

Or is this the wrong direction?

  • 写回答

3条回答 默认 最新

  • down_load1117 2017-01-16 22:30
    关注

    As of nrk/predis v1.1.0 there is built in support for the Redis Sentinel API.

    There are slight configuration changes you will need to apply to Laravel in order to utilise this capability. The easiest way is to do this is use one of the redis sentinel packages for Laravel. These are simply wrappers for the Laravel driver and take care of the configuration. One that I personally use in a large project:

    cooperaj/laravel-redis-sentinel

    What is Redis Sentinel?

    Redis Sentinel is a seperate service that works with a Redis Cluster, monitoring its health for a highly available cluster with automatic failover.

    How do you use it?

    We run our entire application in Kubernetes, that includes a Laravel 5.2 API and React/Node websites running from that API. We have a Redis Sentinel cluster configured similar to this. We also run an Elasticsearch cluster similar to this.

    What is your hardware?

    Our entire operations / systems layer is built on a Google Container Engine cluster.

    Why is this important?

    If you rely on Redis for your Laravel caching or queues your application will fail if Redis fails for any reason.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数