7
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-06-01 13:50:47 +00:00

feat: Make openedx redis db configurable.

Redis db 0 is used for celery broker and db 1 is used for cache
by default.
This commit is contained in:
liupengcheng 2021-05-14 10:33:41 +08:00 committed by Régis Behmo
parent 5658b46715
commit 028162fea4
5 changed files with 23 additions and 13 deletions

View File

@ -4,6 +4,8 @@ Note: Breaking changes between versions are indicated by "💥".
## Unreleased ## Unreleased
- [Feature] Add redis database configuration for both cache and celery.
## v11.2.10 (2021-05-17) ## v11.2.10 (2021-05-17)
- [Security] Apply Django security patches by upgrading from 2.2.20 to 2.2.23. - [Security] Apply Django security patches by upgrading from 2.2.20 to 2.2.23.

View File

@ -89,6 +89,10 @@ This defines the default version that will be pulled from all Open edX git repos
By default there are 2 `uwsgi worker processes <https://uwsgi-docs.readthedocs.io/en/latest/Options.html#processes>`__ to serve requests for the LMS and the CMS. However, each workers requires upwards of 500 Mb of RAM. You should reduce this value to 1 if your computer/server does not have enough memory. By default there are 2 `uwsgi worker processes <https://uwsgi-docs.readthedocs.io/en/latest/Options.html#processes>`__ to serve requests for the LMS and the CMS. However, each workers requires upwards of 500 Mb of RAM. You should reduce this value to 1 if your computer/server does not have enough memory.
- ``OPENEDX_CELERY_REDIS_DB`` (default: ``0``)
- ``OPENEDX_CACHE_REDIS_DB`` (default: ``1``)
These two configuration parameters define which redis database to use for Open edX cache and celery task.
Vendor services Vendor services
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~

View File

@ -22,6 +22,7 @@
"CONTACT_EMAIL": "{{ CONTACT_EMAIL }}", "CONTACT_EMAIL": "{{ CONTACT_EMAIL }}",
"CELERY_BROKER_TRANSPORT": "redis", "CELERY_BROKER_TRANSPORT": "redis",
"CELERY_BROKER_HOSTNAME": "{{ REDIS_HOST }}:{{ REDIS_PORT }}", "CELERY_BROKER_HOSTNAME": "{{ REDIS_HOST }}:{{ REDIS_PORT }}",
"CELERY_BROKER_VHOST": "{{ OPENEDX_CELERY_REDIS_DB }}",
"CELERY_BROKER_USER": "{{ REDIS_USERNAME }}", "CELERY_BROKER_USER": "{{ REDIS_USERNAME }}",
"CELERY_BROKER_PASSWORD": "{{ REDIS_PASSWORD }}", "CELERY_BROKER_PASSWORD": "{{ REDIS_PASSWORD }}",
"ALTERNATE_WORKER_QUEUES": "lms", "ALTERNATE_WORKER_QUEUES": "lms",
@ -46,18 +47,18 @@
"KEY_PREFIX": "default", "KEY_PREFIX": "default",
"VERSION": "1", "VERSION": "1",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"general": { "general": {
"KEY_PREFIX": "general", "KEY_PREFIX": "general",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"mongo_metadata_inheritance": { "mongo_metadata_inheritance": {
"KEY_PREFIX": "mongo_metadata_inheritance", "KEY_PREFIX": "mongo_metadata_inheritance",
"TIMEOUT": 300, "TIMEOUT": 300,
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"staticfiles": { "staticfiles": {
"KEY_PREFIX": "staticfiles_cms", "KEY_PREFIX": "staticfiles_cms",
@ -67,19 +68,19 @@
"configuration": { "configuration": {
"KEY_PREFIX": "configuration", "KEY_PREFIX": "configuration",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"celery": { "celery": {
"KEY_PREFIX": "celery", "KEY_PREFIX": "celery",
"TIMEOUT": "7200", "TIMEOUT": "7200",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"course_structure_cache": { "course_structure_cache": {
"KEY_PREFIX": "course_structure", "KEY_PREFIX": "course_structure",
"TIMEOUT": "7200", "TIMEOUT": "7200",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
} }
}, },
{% include "apps/openedx/config/partials/auth.json" %} {% include "apps/openedx/config/partials/auth.json" %}

View File

@ -29,6 +29,7 @@
"CONTACT_EMAIL": "{{ CONTACT_EMAIL }}", "CONTACT_EMAIL": "{{ CONTACT_EMAIL }}",
"CELERY_BROKER_TRANSPORT": "redis", "CELERY_BROKER_TRANSPORT": "redis",
"CELERY_BROKER_HOSTNAME": "{{ REDIS_HOST }}:{{ REDIS_PORT }}", "CELERY_BROKER_HOSTNAME": "{{ REDIS_HOST }}:{{ REDIS_PORT }}",
"CELERY_BROKER_VHOST": "{{ OPENEDX_CELERY_REDIS_DB }}",
"CELERY_BROKER_USER": "{{ REDIS_USERNAME }}", "CELERY_BROKER_USER": "{{ REDIS_USERNAME }}",
"CELERY_BROKER_PASSWORD": "{{ REDIS_PASSWORD }}", "CELERY_BROKER_PASSWORD": "{{ REDIS_PASSWORD }}",
"ALTERNATE_WORKER_QUEUES": "cms", "ALTERNATE_WORKER_QUEUES": "cms",
@ -55,18 +56,18 @@
"KEY_PREFIX": "default", "KEY_PREFIX": "default",
"VERSION": "1", "VERSION": "1",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"general": { "general": {
"KEY_PREFIX": "general", "KEY_PREFIX": "general",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"mongo_metadata_inheritance": { "mongo_metadata_inheritance": {
"KEY_PREFIX": "mongo_metadata_inheritance", "KEY_PREFIX": "mongo_metadata_inheritance",
"TIMEOUT": 300, "TIMEOUT": 300,
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"staticfiles": { "staticfiles": {
"KEY_PREFIX": "staticfiles_lms", "KEY_PREFIX": "staticfiles_lms",
@ -76,24 +77,24 @@
"configuration": { "configuration": {
"KEY_PREFIX": "configuration", "KEY_PREFIX": "configuration",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"celery": { "celery": {
"KEY_PREFIX": "celery", "KEY_PREFIX": "celery",
"TIMEOUT": "7200", "TIMEOUT": "7200",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"course_structure_cache": { "course_structure_cache": {
"KEY_PREFIX": "course_structure", "KEY_PREFIX": "course_structure",
"TIMEOUT": "7200", "TIMEOUT": "7200",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
}, },
"ora2-storage": { "ora2-storage": {
"KEY_PREFIX": "ora2-storage", "KEY_PREFIX": "ora2-storage",
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/1" "LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}"
} }
}, },
{% include "apps/openedx/config/partials/auth.json" %} {% include "apps/openedx/config/partials/auth.json" %}

View File

@ -63,6 +63,8 @@ OPENEDX_MYSQL_DATABASE: "openedx"
OPENEDX_CSMH_MYSQL_DATABASE: "{{ OPENEDX_MYSQL_DATABASE }}_csmh" OPENEDX_CSMH_MYSQL_DATABASE: "{{ OPENEDX_MYSQL_DATABASE }}_csmh"
OPENEDX_MYSQL_USERNAME: "openedx" OPENEDX_MYSQL_USERNAME: "openedx"
OPENEDX_COMMON_VERSION: "open-release/koa.3" OPENEDX_COMMON_VERSION: "open-release/koa.3"
OPENEDX_CELERY_REDIS_DB: 0
OPENEDX_CACHE_REDIS_DB: 1
MYSQL_HOST: "mysql" MYSQL_HOST: "mysql"
MYSQL_PORT: 3306 MYSQL_PORT: 3306
MYSQL_ROOT_USERNAME: "root" MYSQL_ROOT_USERNAME: "root"