centos系统下openstack安装dashboard登录后出现server error

dashboard登录出错,提示无法进入页面,服务器错误

安装dashboard,配置文件,通过命令行web浏览器links进入http://controller/dashboard,能够正常 显示网站,但是输入admin的用户以及default的默认域后,发现无法进入页面

查看controller节点的httpd错误文件
~# vim /var/log/httpd/error_log

发现了错误报告:

[Mon Mar 27 14:20:36.204588 2017] [:error] [pid 3224] “Unable to create a new session key. ”
[Mon Mar 27 14:20:36.204588 2017] [:error] [pid 3224]RuntimeError:Unable to create a new session key. It is likely that the cache is unavailable

看起来像是缓存一样的问题
在配置dashboard的时候只有一个地方涉及到了存储

这里写图片描述

那么就可能是这里的问题
于是去找了找相关的资料,找到一个:

I was getting this error running a local, development version of a Django project, because it was periodically having trouble connecting to a non-local cache. I realized that I could change my session backend to a file-based session to address the issue .

In the settings file for this local, development version of Django, I simply set the following value:

SESSION_ENGINE = ‘django.contrib.sessions.backends.file’
This is not the solution I would use in a production environment, and not the solution I would suggest to the original poster, but it took me a few minutes to figure out what the issue was and this is one of the only results that appeared when I Googled, so I figured I’d post here possibly to help out others with a similar issue.

翻译过来就是:我在运行一个本地的开发者版本的Django项目的时候遇到了这个问题,因为他周期性的会在连接一个非本地缓存的时候遇到问题,我意识到我可以改变为基于文件的缓存来解决这件事,因此我把SESSION_ENGINE改为django.contrib.session.backends.file

于是我去试了一下,确实成功的解决了这个问题,也能够登录dashboard了,但是这样总觉得以后会出什么问题,毕竟和官方给的不一样,小白不是很懂,所以还是去查一下

Django中的Session有3种存储方式:放在数据库、缓存或者文件系统中,其中设置session在缓存中,可以使用django.contrib.session.backends.cache方法,或者django.contrib.session.backends.cache_db存放在缓存与数据库中,第一种方法不能保证session总能取到(比如缓存溢出时Session会丢失),另外一种方式就是存在文件系统上,就是将cache改为file,保存在缓存中能够获得较好的性能,但是可能会出现一些问题

所以说应该是采取了保存在文件中的方法,之前httpd中的错误提到了缓存不可用(It is likely that the cache is unavailable)

后来查到这个

要使用 Django 的缓冲区系统来保存 Session,需要将 SESSION_ENGINE 设置为 “django.contrib.sessions.backends.cache” 。您必须确保您已经配置了缓冲区,也就是memcached的缓存

也就是说,错误有可能是在memcached里面发生的,但是memcached好像没什么复杂的配置,所以查看一下日志看看

然而并没有找到memcached的日志,但是却发现了一个东西

网上通用的进入memcached的方法:
~# telnet xxx.xxx.xxx.xxx 11211
我使用了
~# telnet 10.0.0.11 11211
~# telnet controller 11211
都无法进入,后来一想,反正memcached也是装在本机上的,127.0.0.1总能进吧
~# telnet 127.0.0.1 11211
成功进入

考虑到,会不会是因为memcached没有配置允许通过本机ip来访问,才会出现的缓存不可用的错误?通过浏览器无法通过10.0.0.11:11211进入,于是搜了一下memcached的配置文件地址
~# vim /etc/sysconfig/memcached
里面有一项:OPTIONS=”-1 127.0.0.1, ::1”
将地址127.0.0.1改为10.0.0.11(即控制节点ip)后保存文件
重启memcached服务
~# systemctl restart memcached.service
通过links连接http://controller:11211,重新登录

问题成功解决

总结

问题根源在于memcached没有配置为外部可访问,而openstack的官方文档中,memcached没有进行配置,因此导致在django存session在缓存中的时候,不能通过LOACTION的controller:11211来进行访问,导致缓存不可用的问题,而解决办法则是进行memcached的配置文件修改,使其能够通过本机ip地址进行访问,就能解决问题了

发布了19 篇原创文章 · 获赞 7 · 访问量 4万+
展开阅读全文

openstack安装dashboard后访问horizon出错

11-27

如题,访问controller/horizon出错500:internal server error apache/error.log出错信息如下: [Sun Nov 27 03:35:40.350220 2016] [mpm_event:notice] [pid 3313:tid 140083000240000] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations [Sun Nov 27 03:35:40.350267 2016] [core:notice] [pid 3313:tid 140083000240000] AH00094: Command line: '/usr/sbin/apache2' [Sun Nov 27 03:43:46.458437 2016] [mpm_event:notice] [pid 3313:tid 140083000240000] AH00491: caught SIGTERM, shutting down [Sun Nov 27 05:05:03.495445 2016] [mpm_event:notice] [pid 3238:tid 139659907987328] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations [Sun Nov 27 05:05:03.555512 2016] [core:notice] [pid 3238:tid 139659907987328] AH00094: Command line: '/usr/sbin/apache2' [Sun Nov 27 05:56:53.084779 2016] [core:error] [pid 3255:tid 139659661248256] [client 192.168.157.1:6059] End of script output before headers: django.wsgi [Sun Nov 27 06:11:29.776677 2016] [mpm_event:notice] [pid 3238:tid 139659907987328] AH00493: SIGUSR1 received. Doing graceful restart [Sun Nov 27 06:11:40.334294 2016] [mpm_event:notice] [pid 3238:tid 139659907987328] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations [Sun Nov 27 06:11:40.334432 2016] [core:notice] [pid 3238:tid 139659907987328] AH00094: Command line: '/usr/sbin/apache2' [Sun Nov 27 06:17:21.963054 2016] [core:error] [pid 5214:tid 139659810662144] [client 192.168.157.1:6308] End of script output before headers: django.wsgi [Sun Nov 27 06:47:06.036727 2016] [mpm_event:notice] [pid 3238:tid 139659907987328] AH00493: SIGUSR1 received. Doing graceful restart [Sun Nov 27 06:47:11.888344 2016] [mpm_event:notice] [pid 3238:tid 139659907987328] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations [Sun Nov 27 06:47:11.888397 2016] [core:notice] [pid 3238:tid 139659907987328] AH00094: Command line: '/usr/sbin/apache2' [Sun Nov 27 06:47:39.162800 2016] [mpm_event:notice] [pid 3238:tid 139659907987328] AH00493: SIGUSR1 received. Doing graceful restart [Sun Nov 27 06:47:42.577268 2016] [core:error] [pid 5842:tid 139659703211776] [client 192.168.157.1:7524] End of script output before headers: django.wsgi [Sun Nov 27 06:47:42.636704 2016] [mpm_event:notice] [pid 3238:tid 139659907987328] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations [Sun Nov 27 06:47:42.636744 2016] [core:notice] [pid 3238:tid 139659907987328] AH00094: Command line: '/usr/sbin/apache2' [Sun Nov 27 06:53:07.710714 2016] [core:error] [pid 6066:tid 139659810662144] [client 192.168.157.1:7537] End of script output before headers: django.wsgi /etc/openstack-dashboard/local_settings.py部分如下:(按照官网配置) import os from django.utils.translation import ugettext_lazy as _ from horizon.utils import secret_key from openstack_dashboard import exceptions from openstack_dashboard.settings import HORIZON_CONFIG DEBUG = False TEMPLATE_DEBUG = DEBUG WEBROOT = '/' OPENSTACK_API_VERSIONS = { "identity": 3, "image": 2, "volume": 2, } OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "default" LOCAL_PATH = os.path.dirname(os.path.abspath(__file__)) SECRET_KEY = secret_key.generate_or_read_from_file('/var/lib/openstack-dashboard/secret_key') SESSION_ENGINE = 'django.contrib.sessions.backends.cache' CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '192.168.157.11:11211', } } EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' OPENSTACK_HOST = "controller" OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user" IMAGE_RESERVED_CUSTOM_PROPERTIES = [] API_RESULT_LIMIT = 1000 API_RESULT_PAGE_SIZE = 20 SWIFT_FILE_TRANSFER_CHUNK_SIZE = 512 * 1024 DROPDOWN_MAX_ITEMS = 30 TIME_ZONE = "UTC" ALLOWED_HOSTS = ['*', ] 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览