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条)

报告相同问题?

悬赏问题

  • ¥50 swiftui @query 报错
  • ¥50 怎么解决刷卡或扫码后,点击软件输入框,win10屏幕键盘不会自动弹出的问题
  • ¥15 如何使用arcgispro的训练深度模型,发现water和nowater精度为0?(相关搜索:深度学习)
  • ¥20 matlab作业不太懂呀有问题能给个代码吗
  • ¥15 自制电路图为何无法驱动ESP01S?
  • ¥15 前端加access数据库
  • ¥15 ARCGIS 多值提取到点 ERROR 999999
  • ¥15 mysql异常断电, [MY-011971] [InnoDB]
  • ¥15 uni.onBluetoothDeviceFound熄屏不运行
  • ¥15 求PHDA糖尿病并发症数据集,有偿