OpenStack和Redis

前言: 最近開始搗鼓OpenStack了,在用RDO部署OpenStack的時候,發現裝了Redis, 遂決定看看OpenStack哪些地方(能夠)用到Redis。git


  •  Redis做爲OpenStack Dashboard的session storage backend
    目前(M版本,後面默認爲M版本) OpenStack的Dashboard支持如下三種session storage backend:
    Local memory cache
    Key-Value store(Memcached, Redis)
    Database(Mysql/Mariadb)
    其中Local memory cache是最簡單並且是最快的,可是缺點也很明顯,好比在process和worker之間不能共享,存儲隨着process結束而結束。Database做爲backend相對而言最慢的,可是能夠作到scalable,persistent. K-V storage速度上介於二者之間,也能夠salable,比較適合小規模部署的環境,一下是配置Redis做爲Session storage的backend。

    1. 安裝依賴包:redis, django-redis。
    2. 修改local_settings配置文件:/etc/openstack-dashboard/local_settings.
    SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
    CACHES = {
        "default": {
            "BACKEND": "redis_cache.cache.RedisCache",
            "LOCATION": "127.0.0.1:6379:1",
            "OPTIONS": {
                "CLIENT_CLASS": "redis_cache.client.DefaultClient",
            }
        }
    }

    若是django-redis版本是3.8.0或以上,那麼應該要這樣配置(https://niwinz.github.io/django-redis/latest/#_configure_as_cache_backend):

    github

    SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
    CACHES = {
        'default': {
            'BACKEND': 'django_redis.cache.RedisCache',
            'LOCATION': 'redis://127.0.0.1:6379/1',
            'OPTIONS': {
                'CLIENT_CLASS': 'django_redis.client.DefaultClient',
            }
        }
    }

    3. 重啓httpd/apache, 登錄Dashboard,而後查看Redis的key:
    redis

     

  •  Redis做爲OpenStack Keystone的token storage backend
    Keystone支持的Token storage backend目前有三個:
    Mysql(Mariadb)
    MemCache
    Redis

    Mysql會有token無限增加的問題,須要按期清理不須要的token, Memcache的問題是空間固定,很差擴容,相對而言Redis是一個不錯的選擇,一下是配置Redis的步驟:
    1. 安裝依賴包: Redis.
    2. 修改keystone.conf:
    [cache]
    enabled=true 
    expiration_time=600  
    backend=dogpile.cache.redis 
    backend_argument=url:redis://127.0.0.1:6379/2
    
    [token]
    caching=true  
    driver = keystone.token.persistence.backends.kvs.Token  

     

       3. 重啓keystone(httpd), 查看Redis的key:sql

       

 

  • Redis做爲OpenStack Telemetry的多個agent instances之間協做的backend

       RDO 安裝後,默認的就是Redis做爲backend, 參看/etc/ceilometer/ceilometer.conf:apache

       

[coordination]

#
# From ceilometer
#

# The backend URL to use for distributed coordination. If left empty, per-
# deployment central agent and per-host compute agent won't do workload
# partitioning and will only function correctly if a single instance of that
# service is running. (string value)
#backend_url = <None>
backend_url = redis://9.114.112.108:6379

# Number of seconds between heartbeats for distributed coordination. (floating
# point value)
#heartbeat = 1.0

# Number of seconds between checks to see if group membership has changed
# (floating point value)
#check_watchers = 10.0
相關文章
相關標籤/搜索