标签(空测试用例格分隔):OpenStack Train 系列


一: Horizon 环境部署

1.1 Horizon 介绍

OpenStack Dashboard 就是 Horizon,提供了基于 Web 控制台,是一个运行在 httpd 服务器上的 Web 服务

1.2 Horizon 安装

在控制节点(controller)安装 Horizon 服务
1、安装软件
# yum -y install openstack-dashboard

image.png image.png

2、修改配置文件 /etc/openstack-dashboard/local_settings

# vi /etc/openstack-dashboard/local_settings

a、配置 WEBROOT 路径和会话超时时间
WEBROOT = '/dashboard/'

# https://docs.openstack.org/horizon/ussuri/configuration/settings.html

SESSION_TIMEOUT = 86400

b、更改 OPENSTACK_HOST 值为"controller",若为 127.0.0.1 则只能在当前主机访问

OPENSTACK_HOST = "controller"

c、允许所有主机访问,注意格式,逗号后面有一个空格。
ALLOWED_HOSTS = ['*', ]

d、配置 memcached 会话存储服务,请注释掉任何其他会话存储配置,请注意格式。

SESSION_ENGINE = 'django.contrib.sessions.backends.file' 【没有手工添加】
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'controller:11211',
}}

e、配置 API 版本。【没有手工添加】

OPENSTACK_API_VERSIONS = {
"identity": 3,
"image": 2,
"volume": 3,
}

f、使用 keystone API v3 版本。
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST

g、启用对多域的支持
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True

h、配置 Default 域为通过 dashboard 创建的用户的默认域。
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"

i、配置 user 为通过 dashboard 创建的用户的默认角色。
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"

j、开启对第 3 层网络服务的支持。
OPENSTACK_NEUTRON_NETWORK = {
'enable_router': True,
'enable_quotas': True,
'enable_rbac_policy': True,
'enable_distributed_router': False,
'enable_ha_router': False,
'enable_ipv6': False,
'enable_lb': False,
'enable_firewall': False,
'enable_vpn': False,
'enable_fip_topology_check': True,
'default_dns_nameservers': [],
'supported_provider_types': ['*'],
'segmentation_id_range': {},
'extra_provider_types': {},
'supported_vnic_types': ['*'],
'physical_networks': [],
}
k、开启卷备份特性,需要后端存储类型为 swift 或 ceph 等支持分布式对象存储
【没有就添加】
OPENSTACK_CINDER_FEATURES = {
'enable_backup': True,
}

l、配置时区:上海。
TIME_ZONE = "Asia/Shanghai"
3、修改配置文件/etc/httpd/conf.d/openstack-dashboard.conf
# vi /etc/httpd/conf.d/openstack-dashboard.conf
在第 4 行添加以下内容:
WSGIApplicationGroup %{GLOBAL}
4、修改/usr/share/openstack-dashboard/ 文件夹属组、属主为 apache
# chown -R apache:apache /usr/share/openstack-dashboard/
5、重新启动 httpd 服务器和 Memcache 服务
# systemctl restart httpd.service memcached.service
6、登录 Openstack 控制台

http://controller/dashboard/
admin/openstack2022

1.3 关于dashboard 重建问题

检查dashboard是否可用
浏览器直接访问:http://172.16.10.11 地址后面不需要加dashboard。
是否需要输入域default取决于,/etc/openstack-dashboard/local_settings文件中进行OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT内容配置值
域:default;用户名:admin;密码:openstack2022

Dashboard访问问题
此时,dashboard虽可以访问,且url中不需要输入dashboard,但是在进行系统的项目管理的时候打不开页面会报错。

1.重建openstack-dashboard.conf
cd /usr/share/openstack-dashboard
python manage.py make_web_conf --apache > /etc/httpd/conf.d/openstack-dashboard.conf

ln -s /etc/openstack-dashboard /usr/share/openstack-dashboard/openstack_dashboard/conf

cp -a /usr/share/openstack-dashboard/openstack_dashboard/defaults.py{,.bak}
cp -a /usr/share/openstack-dashboard/openstack_dashboard/test/settings.py{,.bak}
cp -a /usr/share/openstack-dashboard/static/dashboard/js/9937cc9f2cae.js{,.bak}

sed -i "32c WEBROOT = '/dashboard'  # from openstack_auth" /usr/share/openstack-dashboard/openstack_dashboard/defaults.py
sed -i "32c WEBROOT = '/dashboard'" /usr/share/openstack-dashboard/openstack_dashboard/test/settings.py
sed -i '1c var STATIC_URL="/dashboard/static/";var WEBROOT="/dashboard/";/*!' /usr/share/openstack-dashboard/static/dashboard/js/9937cc9f2cae.js
cp -a  /etc/httpd/conf.d/openstack-dashboard.conf{,.bak}

#sed -in '3a WSGIApplicationGroup %{GLOBAL}' /etc/httpd/conf.d/openstack-dashboard.conf

sed -i '19c WSGIScriptAlias /dashboard /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi' /etc/httpd/conf.d/openstack-dashboard.conf
sed -i '20c WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi' /etc/httpd/conf.d/openstack-dashboard.conf
sed -i '25c Alias /dashboard/static /usr/share/openstack-dashboard/static' /etc/httpd/conf.d/openstack-dashboard.conf
之后从新启动httpd,与memcached 服务

systemctl restart httpd.service memcached.service
systemctl status httpd.service memcached.service
加载一下环境变量
source /etc/keystone/admin-openrc.sh

然后打开dashborad

http://172.16.10.11/dashborad/
域:default
用户名:admin
密码:openstack2022

image.png

1.4 使用openstack 创建实例

image.png image.png image.png image.png image.png image.png image.png image.png

为实例添加一块磁盘可以使用kvm 的方式添加,不然是无法添加的,要事先确认要添加的主机
在那个节点上面
virt-manager

image.png image.png image.png image.png

image.png

这个磁盘可以格式化并做挂载
fdisk /dev/vdb

mkdir /test

mount /dev/vdb1 /test 

cd /test/
mkdir test 

image.png