您的位置:首页 > 运维架构 > Linux

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

2017-03-28 21:37 477 查看

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地址进行访问,就能解决问题了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dashboard openstack centos
相关文章推荐