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 脱敏项目合作,ner需求合作
  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴