【问题标题】:I want to use django with celery (redis). Do I need to install redis on the server of my django application ? or can I have a seperate redis server?我想将 django 与芹菜(redis)一起使用。我需要在我的 django 应用程序的服务器上安装 redis 吗?或者我可以有一个单独的redis服务器吗?
【发布时间】:2021-09-12 00:49:40
【问题描述】:

我在 these guidlines 之后的 ubuntu 服务器上安装了 redis。我想将它与 celery 一起用于 Django 应用程序。我的 Django 应用程序正在另一台服务器上运行。但是现在我对如何设置 Django 设置感到困惑,因为我到处都只能找到关于 "localhost" 的文章。是否可以在另一台服务器上将 celery 和 django 与 redis 一起使用?我需要添加什么 Django settings.py ?

【问题讨论】:

    标签: django redis celery


    【解决方案1】:

    只需根据您的设置进行操作:

    CELERY_BROKER_URL = 'redis://'+REDIS_HOST+':6379/'+REDIS_DB

    REDIS_HOST是你的redis IP,REDIS_DB是你的数据库(这个是可选的)

    【讨论】:

    • @wallucas ,了解 REDIS_HOST 部分。但是我是否需要像 `CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6379/0", "选项”:{“CLIENT_CLASS”:“django_redis.client.DefaultClient”}}`
    • 我不确定你的意思
    • CELERY_BROKER_URL = 'redis://'+REDIS_HOST+':6379/0'
    • 0、1 或 2 代表什么?
    猜你喜欢
    • 2023-03-17
    • 2017-01-25
    • 1970-01-01
    • 2021-08-20
    • 2016-06-08
    • 1970-01-01
    • 2013-05-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多