本文介绍在ubuntu 16.04下单点安装Mitaka Horizon的过程。
步骤1:安装组件 apt-get install openstack-dashboard
步骤2:编辑文件 /etc/openstack-dashboard/local_settings.py,对一些参数进行如下设置:
改动1:OPENSTACK_HOST = "controller"
改动2:ALLOWED_HOSTS = ['*', ]
改动3:
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'controller:11211',
}
}
改动4:OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
改动5:OPENSTACK_API_VERSIONS = {"identity": 3,"image": 2,"volume": 2,}
改动6:OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "default"
改动7:OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
改动8:OPENSTACK_NEUTRON_NETWORK = {
'enable_router': False,
'enable_quotas': False,
'enable_ipv6': True,
'enable_distributed_router': False,
'enable_ha_router': False,
'enable_lb': False,
'enable_firewall': False,
'enable_': False,
'enable_fip_topology_check': False, ...}
改动9:TIME_ZONE = "UTC"
步骤3:重载配置 service apache2 reload
步骤4:验证,访问 http://controller/horizon/,以admin或demo用户身份登陆。此时一连串出现很多问题,列举如下:
出现问题1:访问链接http://controller/horizon/时,出现响应超时错误
解决方案:编辑配置文件 /etc/apache2/apache2.conf,修改Timeout参数值,原来为300,现在设置为600
出现问题2:再次访问链接http://controller/horizon/时,不出现超时错误了,但是出现无法访问服务的错误,
查看apache日志 (/var/log/apache2/error.log),出现错误:
"Truncated or oversized response headers received from daemon process 'horizon':
/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi"
解决方案:在文件/etc/apache2/conf-available/openstack-dashboard.conf中添加一句话:
WSGIApplicationGroup %{GLOBAL}
出现问题3:再次访问链接,还是无法访问服务,查看apache日志,出现新的错误:
[wsgi:error] [pid 3837:tid 139669550491392] Could not process panel theme_preview:
Dashboard with slug "developer" is not registered.
[wsgi:error] [pid 24416:tid 139791304124160] "Unable to create a new session key. "
[wsgi:error] [pid 24416:tid 139791304124160] RuntimeError: Unable to create a new session key.
It is likely that the cache is unavailable.
解决方案:编辑文件/etc/memcached.conf,修改参数为"-l 127.0.0.1",原来是enp3s0所绑定的IP地址,需修改
编辑文件/etc/openstack-dashboard/localsetting.py,将"controller:11211"修改成"127.0.0.1:11211"
出现问题4:再次访问链接http://controller/horizon/时,不再出现上述问题,可以进入dashborad界面,
但是界面的Layout非常难看,所有页面元素全部挤到左侧,如下所示
解决方案:编辑文件/etc/openstack-dashboard/localsetting.py,将"DEBUG = False"修改成"DEBUG = True",
否则css文件无法起作用,造成页面布局混乱。
出现问题5:用户登录时出错,日志显示错误:RuntimeError: Unable to create a new session key. It is likely that the cache is unavailable
解决方案:将/etc/openstack-dashboard/local_settings.py里面的 SESSION_ENGINE 参数设置注释掉即可
最终,我们可以看到dashboard界面如下所示: