解决搭建官方openstack时遇到的服务器报错Internal Server Error 返回状态500The server encountered an internal error

Posted 抛物线.

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决搭建官方openstack时遇到的服务器报错Internal Server Error 返回状态500The server encountered an internal error相关的知识,希望对你有一定的参考价值。

这是登录dashboard时出现的报错

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

这是大致翻译:

内部服务器错误
服务器遇到内部错误或配置错误,无法完成您的请求。
请与root@localhost的服务器管理员联系,通知他们发生此错误的时间,以及您在此错误之前执行的操作。
有关此错误的更多信息可在服务器错误日志中获得。

然后我就尝试了几次还是不行,还是返回500报错
于是 我便去查看了我的httpd服务的配置文件,之前研究httpd时遇到过类似的问题,把下面这个给注释掉就可以了

[root@controller openstack-dashboard]# cd /etc/httpd/conf/
[root@controller conf]# ls
httpd.conf  magic
[root@controller conf]# pwd
/etc/httpd/conf
[root@controller conf]# 
[root@controller conf]# ls
httpd.conf  magic
[root@controller conf]# vi httpd.conf 
     LoadModule foo_module modules/mod_foo.so

但是这次注释也不行了。于是便直接查看httpd的日志文件。毕竟查看日志就能首先知道问题出在哪里。虽然有可能一时无法解决
但是我们可以明白发生错误的原因在哪里

下面开始查看我们的日志

[root@controller httpd]# ls
conf  conf.d  conf.modules.d  logs  modules  run
[root@controller httpd]# cd logs/
[root@controller logs]# ls
access_log  error_log  keystone-access.log  keystone-error.log
[root@controller logs]# pwd
/etc/httpd/logs
[root@controller logs]# cat error_log | tail -n 20
[Thu May 16 14:28:55.291742 2019] [:error] [pid 9305] [remote 192.168.217.1:228]     __import__(name)
[Thu May 16 14:28:55.291746 2019] [:error] [pid 9305] [remote 192.168.217.1:228]   File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/settings.py", line 365, in <module>
[Thu May 16 14:28:55.291757 2019] [:error] [pid 9305] [remote 192.168.217.1:228]     '.secret_key_store'))
[Thu May 16 14:28:55.291761 2019] [:error] [pid 9305] [remote 192.168.217.1:228]   File "/usr/lib/python2.7/site-packages/horizon/utils/secret_key.py", line 54, in generate_or_read_from_file
[Thu May 16 14:28:55.291768 2019] [:error] [pid 9305] [remote 192.168.217.1:228]     with lock:
[Thu May 16 14:28:55.291771 2019] [:error] [pid 9305] [remote 192.168.217.1:228]   File "/usr/lib/python2.7/site-packages/fasteners/process_lock.py", line 174, in __enter__
[Thu May 16 14:28:55.291778 2019] [:error] [pid 9305] [remote 192.168.217.1:228]     self.acquire()
[Thu May 16 14:28:55.291782 2019] [:error] [pid 9305] [remote 192.168.217.1:228]   File "/usr/lib/python2.7/site-packages/fasteners/process_lock.py", line 151, in acquire
[Thu May 16 14:28:55.291788 2019] [:error] [pid 9305] [remote 192.168.217.1:228]     self._do_open()
[Thu May 16 14:28:55.291791 2019] [:error] [pid 9305] [remote 192.168.217.1:228]   File "/usr/lib/python2.7/site-packages/fasteners/process_lock.py", line 123, in _do_open
[Thu May 16 14:28:55.291797 2019] [:error] [pid 9305] [remote 192.168.217.1:228]     self.lockfile = open(self.path, 'a')
[Thu May 16 14:28:55.291861 2019] [:error] [pid 9305] [remote 192.168.217.1:228] IOError: [Errno 13] Permission denied: '/usr/share/openstack-dashboard/openstack_dashboard/local/_usr_share_openstack-dashboard_openstack_dashboard_local_.secret_key_store.lock'

重点已经出来了
请认真查看最后一行

[Thu May 16 14:28:55.291861 2019] [:error] [pid 9305] [remote 192.168.217.1:228] IOError: [Errno 13] Permission denied: '/usr/share/openstack-dashboard/openstack_dashboard/local/_usr_share_openstack-dashboard_openstack_dashboard_local_.secret_key_store.lock'

原因就是
IOError: [Errno 13] Permission denied:
拒绝我们的 /usr/share/openstack-dashboard/openstack_dashboard/local/usr_share_openstack-dashboard_openstack_dashboard_local.secret_key_store.lock’ 这个目录

那么我们便着手解决这个问题,我们就直接给它appache的所属用户、者的权限


[root@controller logs]# chown -R apache:apache   /usr/share/openstack-dashboard/

然后再重启我们的httpd服务和我们的会话缓存服务。

[root@controller logs]# systemctl restart httpd
[root@controller logs]# systemctl restart memcached
[root@controller logs]# 


下面可以看到我们的所有服务一切正常启动

[root@controller logs]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/httpd.service.d
           └─openstack-dashboard.conf
   Active: active (running) since Thu 2019-05-16 14:38:48 EDT; 18min ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 9574 ExecStop=/bin/kill -WINCH $MAINPID (code=exited, status=0/SUCCESS)
  Process: 9610 ExecStartPre=/usr/bin/python /usr/share/openstack-dashboard/manage.py compress --force (code=exited, status=0/SUCCESS)
  Process: 9590 ExecStartPre=/usr/bin/python /usr/share/openstack-dashboard/manage.py collectstatic --noinput --clear (code=exited, status=0/SUCCESS)
 Main PID: 9633 (httpd)
   Status: "Total requests: 11; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─9633 /usr/sbin/httpd -DFOREGROUND
           ├─9635 /usr/sbin/httpd -DFOREGROUND
           ├─9636 (wsgi:keystone- -DFOREGROUND
           ├─9637 (wsgi:keystone- -DFOREGROUND
           ├─9638 (wsgi:keystone- -DFOREGROUND
           ├─9639 (wsgi:keystone- -DFOREGROUND
           ├─9640 (wsgi:keystone- -DFOREGROUND
           ├─9641 (wsgi:keystone- -DFOREGROUND
           ├─9642 (wsgi:keystone- -DFOREGROUND
           ├─9643 (wsgi:keystone- -DFOREGROUND
           ├─9644 (wsgi:keystone- -DFOREGROUND
           ├─9645 (wsgi:keystone- -DFOREGROUND
           ├─9646 /usr/sbin/httpd -DFOREGROUND
           ├─9647 /usr/sbin/httpd -DFOREGROUND
           ├─9648 /usr/sbin/httpd -DFOREGROUND
           ├─9649 /usr/sbin/httpd -DFOREGROUND
           ├─9650 /usr/sbin/httpd -DFOREGROUND
           ├─9737 /usr/sbin/httpd -DFOREGROUND
           ├─9738 /usr/sbin/httpd -DFOREGROUND
           ├─9739 /usr/sbin/httpd -DFOREGROUND
           ├─9740 /usr/sbin/httpd -DFOREGROUND
           └─9741 /usr/sbin/httpd -DFOREGROUND

May 16 14:38:33 controller python[9590]: Copying '/usr/share/javascript/jquery_ui/ui/minified/i18n/jquery.ui.datepicker-tr.min.js'
May 16 14:38:33 controller python[9590]: Copying '/usr/share/javascript/jquery_ui/ui/minified/i18n/jquery.ui.datepicker-hr.min.js'
May 16 14:38:33 controller python[9590]: Copying '/usr/share/javascript/jquery_ui/ui/minified/i18n/jquery.ui.datepicker-uk.min.js'
May 16 14:38:33 controller python[9590]: Copying '/usr/share/javascript/jquery_ui/ui/minified/i18n/jquery.ui.datepicker-hu.min.js'
May 16 14:38:33 controller python[9590]: Copying '/usr/share/javascript/jquery_ui/ui/minified/i18n/jquery.ui.datepicker-vi.min.js'
May 16 14:38:33 controller python[9590]: Copying '/usr/share/javascript/jquery_ui/ui/minified/i18n/jquery.ui.datepicker-hy.min.js'
May 16 14:38:33 controller python[9590]: Copying '/usr/share/javascript/jquery_ui/ui/minified/i18n/jquery.ui.datepicker-zh-CN.min.js'
May 16 14:38:33 controller python[9590]: Copying '/usr/share/javascript/jquery_ui/ui/minified/i18n/jquery.ui.datepicker-id.min.js'
May 16 14:38:33 controller python[9590]: Copying '/usr/share/javascript/jquery_ui/ui/minified/i18n/jquery.ui.datepicker-zh-HK.min.js'
May 16 14:38:48 controller systemd[1]: Started The Apache HTTP Server.
[root@controller logs]# 
[root@controller logs]# systemctl status memcached
● memcached.service - Memcached
   Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-05-16 14:38:57 EDT; 18min ago
 Main PID: 9706 (memcached)
   CGroup: /system.slice/memcached.service
           └─9706 /usr/bin/memcached -u memcached -p 11211 -m 64 -c 1024

May 16 14:38:57 controller systemd[1]: Started Memcached.
May 16 14:38:57 controller systemd[1]: Starting Memcached...
[root@controller logs]# 

那么我们再次刷新我们的dashboard,果然报错解决了

重点就在于把拥有者的权限给他

[root@controller logs]# chown -R apache:apache   /usr/share/openstack-dashboard/

好了 下面便可以继续我们的openstack搭建了。
搭建的时候 还有一点需要注意的就是
配置我们的dashboard文件时,一定要注意,把其他的会话给注销掉

root@controller logs]# cd /etc/openstack-dashboard/
[root@controller openstack-dashboard]# ls
ceilometer_policy.json  glance_policy.json  keystone_policy.json  local_settings.rpmsave  nova_policy.json
cinder_policy.json      heat_policy.json    local_settings        neutron_policy.json
[root@controller openstack-dashboard]# vi local_settings


把其他的会话给注释掉就可以啦。

遇到报错不可怕。要尝试查看日志,而且现在日志都比较人性化了,分类上也特别详细。

以上是关于解决搭建官方openstack时遇到的服务器报错Internal Server Error 返回状态500The server encountered an internal error的主要内容,如果未能解决你的问题,请参考以下文章

openstack R版 搭建过程遇到的种种问题

初识openstack之5——安装Keystone

关于OpenStack搭建过程中的网络问题

openstack新建实例各种报错解决

openstack horizon开发环境搭建运行run_tests报错No module named config

Rsync服务器搭建遇到的报错解决办法