天天看點

登入devstack:RuntimeError: Unable to create a new session key. It is likely that the cache is unavaila

登陸devstack ERROR:

[Wed Aug 30 18:59:27.742156 2017] [:error] [pid 30986] Attempted scope to domain Default failed, will attemptto scope to another domain.
[Wed Aug 30 18:59:27.935474 2017] [:error] [pid 30986] Login successful for user "admin", remote address 118.116.90.43.
[Wed Aug 30 18:59:33.461313 2017] [:error] [pid 30986] Internal Server Error: /dashboard/auth/login/
[Wed Aug 30 18:59:33.461348 2017] [:error] [pid 30986] Traceback (most recent call last):
[Wed Aug 30 18:59:33.461353 2017] [:error] [pid 30986]   File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response

...
 [Wed Aug 30 18:59:33.461520 2017] [:error] [pid 30986]     response = view_func(request, *args, **kwargs)
[Wed Aug 30 18:59:33.461522 2017] [:error] [pid 30986]   File "/usr/lib/python2.7/site-packages/django/contrib/auth/views.py", line 51, in login
[Wed Aug 30 18:59:33.461525 2017] [:error] [pid 30986]     auth_login(request, form.get_user())
[Wed Aug 30 18:59:33.461528 2017] [:error] [pid 30986]   File "/usr/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 110, in login
[Wed Aug 30 18:59:33.461531 2017] [:error] [pid 30986]     request.session.cycle_key()
[Wed Aug 30 18:59:33.461549 2017] [:error] [pid 30986]   File "/usr/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py", line 285, in cycle_key
[Wed Aug 30 18:59:33.461553 2017] [:error] [pid 30986]     self.create()
[Wed Aug 30 18:59:33.461556 2017] [:error] [pid 30986]   File "/usr/lib/python2.7/site-packages/django/contrib/sessions/backends/cache.py", line 48, in create
[Wed Aug 30 18:59:33.461559 2017] [:error] [pid 30986]     "Unable to create a new session key. "
[Wed Aug 30 18:59:33.461562 2017] [:error] [pid 30986] RuntimeError: Unable to create a new session key. It is likely that the cache is unavailable.
           

問題原因:

搭建預設session在memory cache,需要替換成file。

解決辦法:

檔案所在目錄:/opt/stack/horizon/openstack_dashboard/settings.py

源配置:

檔案位置:/usr/lib/python2.7/site-packages/django/core/cache/backends/memcached.py

SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    },
}
           

需要改配為:

檔案位置:/usr/lib/python2.7/site-packages/django/core/cache/backends/filebased.py

SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        # 'LOCATION': '127.0.0.1:11211',  # 非必選
    },
}
           

改完之後儲存重新開機httpd服務。

# systemctl restart httpd

以上操作,問題解決。

繼續閱讀