本文根据 CL210 学习笔记整理,保留概念说明、命令示例、实验步骤与自测内容。
实验版本:RHOSP 13 / RHEL 7。命令、主机名、账户、路径与软件依赖按课程环境记录;阅读其他版本时需核对对应配置。文中引用的课程镜像、脚本和课件不随本文提供。
相关阅读:CL110 · DO280 · Ceph 分布式存储管理
背景知识#
- 虚拟化:一台物理机通过 Hypervisor(虚拟机监控器)运行多台虚拟机,解决硬件复用问题。
- 云计算:在虚拟化之上增加资源池、API(Application Programming Interface,应用程序编程接口)、自助申请、多租户、配额与自动化交付。
- IaaS(Infrastructure as a Service,基础设施即服务):用户申请计算、网络和存储,并自行管理实例操作系统与应用。OpenStack 属于这一层。
- 控制平面:接收请求、认证、调度、保存状态;数据平面:承载实例流量和实际读写。
- 多租户:项目之间有资源与权限边界;相同名称、相同私有 IP 不代表同一个对象。
OpenStack#
整体结构#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| 用户 → Horizon / openstack CLI → Keystone:身份、项目、角色、Token、服务目录
↓
Nova:实例生命周期与调度
├─ Glance:取得操作系统镜像
├─ Neutron:创建端口、地址和网络连接
├─ Cinder:准备持久卷
└─ 计算节点:nova-compute → libvirt / KVM → 实例
Heat:把多个资源组织成 Stack
Ceilometer / Gnocchi / Aodh:采集、保存指标、判断告警
Swift / RGW:对象接口 Manila:共享文件系统
服务之间:API + RabbitMQ 消息通信 + 数据库状态
底层存储:可接入 Ceph,具体由各服务后端配置决定
|
核心服务#
| 服务 | 负责什么 | 不能混淆的对象 |
|---|
| Keystone | 身份认证、服务目录、角色分配 | 用户不等于项目,角色分配不等于创建用户 |
| Nova | 计算资源、调度、实例生命周期 | 实例不等于计算宿主机 |
| Glance | 镜像登记与访问 | 镜像是启动来源,不是正在运行的实例 |
| Neutron | 网络、子网、端口、路由与安全控制 | 网络不等于子网,固定 IP 不等于浮动 IP |
| Cinder | 持久块存储 | 卷附加不等于客户机完成挂载 |
| Swift | 对象容器与对象访问 | Swift Container 不等于 Docker Container |
| Heat | 按模板编排资源 | Stack 完成不等于应用初始化完成 |
| Manila | 共享文件系统服务 | 文件共享不等于块设备 |
三类身份#
1
2
3
| Linux 登录用户:student / stack / heat-admin / root
OpenStack 用户:由 RC 文件选择,关联域、项目和角色
实例内部用户:例如 cloud-user,由镜像与初始化配置决定
|
Linux root 不会自动成为 OpenStack admin。source 切换的是当前 shell 的客户端认证上下文,不会切换 Linux 登录用户。
两个云#
| 上下文 | 常用凭据 | 管理对象 |
|---|
| Undercloud / Director | director 上的 ~/stackrc | 裸机、部署网络、Overcloud 部署 |
| Overcloud | ~/overcloudrc 或项目 RC 文件 | 用户、项目、镜像、网络、卷、业务实例 |
Ceph 存储后端#
1
2
3
4
5
| Glance images → RBD 镜像后端
Cinder volumes → RBD 持久卷后端
Nova vms → 配置了 RBD 后端的实例磁盘
Manila → 课程中的 CephFS 共享
Swift API → Swift 或 RGW,需检查实际 endpoint
|
服务接口、资源生命周期、底层介质是三个不同层次。即使 Nova 临时磁盘放在 Ceph 上,它也不会因此自动变成独立保留的 Cinder 卷。
实验环境与记录方法#
适用环境#
RHOSP(Red Hat OpenStack Platform)13.0,RHEL(Red Hat Enterprise Linux)7,Linux Bash。Docker、Director 和客户端命令按这一版本使用。
<实例UUID> 等占位符需替换为实际值。demo-* 为示例资源名。命令执行前需核对所在主机、用户、项目和已存在的依赖资源。
操作上下文#
- 确认当前主机与 Linux 用户,加载目标云和项目的 RC 文件。
- 确认云、域、用户与项目;只检查必要变量,不把密码或 Token 放入截图。
- 列出已存在的资源与需要创建的资源,核对名称、UUID 和关联关系。
- 操作前确认环境起始状态,保存需要保留的数据和配置。
1
2
3
4
5
| hostname
whoami
printf '%s\n' "$OS_AUTH_URL" "$OS_USERNAME" "$OS_PROJECT_NAME"
openstack token issue
openstack catalog list
|
token issue 用于验证认证,输出包含敏感令牌;记录实验时保留作用域与有效期即可。
验证层次#
| 层次 | 示例 | 证明什么 |
|---|
| 资源状态 | 实例 ACTIVE、卷 available、栈 CREATE_COMPLETE | 控制平面记录的状态 |
| 系统功能 | 地址、挂载、服务监听、cloud-init 日志 | 实例内配置实际生效 |
| 业务结果 | SSH 成功、HTTP 正文正确、原文件可读 | 用户需要的功能可用 |
清理顺序#
先卸载正在使用的文件系统,解除资源依赖,再删除本次创建的对象。Heat 创建的资源优先通过 Stack 管理。
实验记录#
1
2
3
4
5
6
7
| 实验名称:
主机 / Linux 用户 / 云 / 项目:
关键资源 UUID 与关联关系:
操作与预期结果:
实际验证:
故障、证据与修复:
清理结果:
|
章节目录#
Undercloud 与 Overcloud#
RHOSP Director 使用 Undercloud 部署和管理 Overcloud。Undercloud 面向基础设施生命周期:发现和登记节点、准备部署网络、组织部署配置。Overcloud 面向云使用者:认证、项目、计算、网络、镜像和存储。理解这一区别,才能解释为什么同一个 CLI 在不同 RC 环境下返回不同的资源列表。
| 对象 | 主要用途 | 检查项 |
|---|
| workstation | 学员入口、浏览器与命令行 | 当前登录用户和到实验网络的连通性 |
| director / Undercloud | 部署及管理云基础设施 | 是否加载了 Undercloud 凭据 |
| 控制节点 | 运行云控制服务 | API、消息通信、数据库与高可用组件之间的依赖 |
| 计算节点 | 承载实例 | 计算服务、虚拟化和网络连接状态 |
| 存储节点 | 提供共享后端存储 | 服务健康、认证与容量 |
容器化服务检查#
RHOSP 13.0 的部分服务运行在容器内。宿主机、容器和 OpenStack 服务是三个不同的观察层:宿主机在线不代表容器健康,容器运行也不代表服务 API 或依赖可用。检查时应把容器名称、对应服务、挂载配置和日志位置联系起来。
不要只寻找传统的同名 systemd 服务。先确认容器化部署结构,再查看配置来自哪里、持久化日志在哪里,以及服务通过什么端点被访问。RHOSP 13 使用 Docker 管理相关容器,其他部署版本可能采用不同工具。
部署网络#
实验环境同时存在外部访问、部署和内部管理等网络。某个地址能 SSH 登录,只能说明这一条管理路径可用,不能证明 API、存储或实例数据网络可用。查看地址与路由时,记下接口、网段、网关和所在主机,避免把主机网络与租户网络混为一谈。
基础设施检查#
顺序浏览实验基础设施、Undercloud、容器化服务和 Overcloud。每看到一项组件,都回答“它由谁管理、依赖谁、失败时影响什么”。综合实验结束后,应能画出一张从 workstation 到 director,再到 Overcloud 节点的访问关系图,并标注不同认证环境。
管理拓扑#
1
2
3
4
5
6
7
8
| workstation:CLI / 浏览器 / 实验脚本
├─ utility:课堂身份、网络等辅助服务
├─ power:课堂节点电源模拟
└─ director:Undercloud
├─ controller:Overcloud 控制服务
├─ compute:计算节点
├─ computehci:计算 + 存储
└─ ceph:存储节点
|
Undercloud 的关键对象#
- Ironic:登记、管理裸机节点及电源接口。
- 部署网络 ctlplane:承载部署与相关管理流量,不等于业务项目网络。
- Introspection:收集节点硬件信息,为部署选择与角色分配提供依据。
- Heat 与部署配置:表达 Overcloud 角色及资源关系。
1
2
3
4
5
6
| # director,stack 用户,Undercloud
source ~/stackrc
openstack baremetal node list
openstack baremetal node show <裸机UUID>
openstack subnet show ctlplane-subnet
openstack server list
|
容器、配置、日志的对应关系#
1
2
3
| 宿主机生成配置目录 → 容器挂载 / 服务读取
容器运行进程 → 提供 API 或后台工作
宿主机持久日志目录 ← 服务日志
|
RHOSP 13 常见的宿主机路径为 /var/lib/config-data/puppet-generated/ 和 /var/log/containers/;具体服务目录以 docker inspect 的 Mounts 为准。
1
2
3
4
5
| # 对应 Overcloud 节点,sudo 权限
sudo docker ps -a
sudo docker inspect cinder_api
sudo docker logs keystone
sudo docker exec -t keystone /openstack/healthcheck
|
只改容器内部文件可能在重建后丢失;只改部署生成文件也可能在后续部署时被覆盖。实验临时诊断与由 Director 管理的持久变更要分清。
网络平面#
External、Internal API、Storage、Storage Management、Tenant、Provisioning 分别承担不同流量。这些网络可通过 VLAN 共用物理网卡;地址、接口与 VLAN 必须符合当前部署的网络规划。
实验操作#
引导练习:浏览 RHOSP 基础架构#
引导练习#
浏览 RHOSP 基础架构#
在本练习中,连接 workstation、utility、power 和 director 节点,浏览课堂基础设施。
学习目标#
能够浏览课堂基础设施。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab architecture-classroom setup 命令。脚本确认所需的节点是可以到达的。
1
| [student@workstation ~]$ lab architecture-classroom setup
|
在 workstation 上确认现有网络与路由。课堂主网络为 172.25.250.0/24。workstation 配置为课堂网络与 172.25.252.0/24 网络之间的路由器。
列出 workstation 的网络接口。eth0 将 workstation 连接到课堂网络 172.25.250.0/24;eth1 连接到 172.25.252.0/24 网络。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~]$ ip a
.. Output omitted...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default qlen 1000
link/ether 52:54:00:00:fa:fe brd ff: ff: ff: ff: ff: ff
inet 172.25.250.254/24 brd 172.25.250.255 scope global noprefixroute etho
valid_lft forever preferred_lft forever
inet6 fe80: :5054: ff: feoo: fafe/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default glen 1000
link/ether 52:54:00:01:fc:00 brd ff: ff: ff: ff: ff: fF
inet 172.25.252.250/24 brd 172.25.252.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inets6 fe8so: :5054: ff: feO1: fc@O/64 scope link
valid_lft forever preferred_lft forever
.. output omitted...
|
查看 workstation 的路由规则。
eth0 网络设备连接 RHOSP 云部署网络。eth1 提供到课堂虚拟机和其他系统的路由。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| [student@workstation ~]$ ip route
default via 172.25.252.254 dev ethi proto static metric 103
172.25.249.50 via 172.25.250.50 dev eth0 proto static metric 102
172.25.249.200 via 172.25.250.200 dev eth0 proto static metric 102
172.25.249.201 via 172.25.250.200 dev eth0 proto static metric 102
172.25.250.0/24 dev eth0 proto kernel scope link src 172.25.250.254 met
172.25.252.0/24 dev ethi proto kernel scope link src 172.25.252.250 met
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
|
249
1
2
| 50 via 172.25.250.50 dev eth0 proto static metric 102
1.200 via 172.25.250.200 dev eth0 proto static metric 102
|
249
249
250
252
1
2
3
| 1.201 via 172.25.250.200 dev etho® proto static metric 102
}.0/24 dev etho proto kernel scope link src 172.25.250.254 metric 102
0/24 dev ethi proto kernel scope link src 172.25.252.250 metric 103
|
为了适当同步 RHOSP 节点之间的服务,控制器节点必须参考更准确的 NTP 服务器。校验由课堂 VM 提供的 NTP 服务。
1
2
3
4
| [student@workstation ~]$ chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
a* classroom.example.com 8 10 377 787 -86us[ -101us] +/- 139us
|
将主机名选择性地指定给与外部提供商网络连接的实例,
DNS 服务必须配置为 RHOSP 部署使用。完全限定的主机名称在 /etc/hosts 文件中指定。文件内容由 dnsmasq 服务装入。
3.1,
核查workstation上的dnsmasq服务提供的DNS服务。
1
2
3
4
5
| [student@workstation ~]$ ps -ef | grep dnsmasq
.. output omitted...
root 1614 1613 © 09:27 ? 00:00:00 /usr/sbin/dnsmasq --conf-file=/var/
lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/
libvir t_leaseshelper
|
3.2.
查看将主机名翻译为 IP 地址并由 dnsmasq 服务装入的 /etc/hosts 文件。文件包含所有使用的虚拟机的条目
包括课堂使用的虚拟机,以及在 Overcloud 上启动的实例。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ cat /etc/hosts
.. Output omitted...
172.25.250.100 power.lab.example.com power
172.25.250.200 director.lab.example.com director
172.25.250.220 utility.lab.example.com utility
# NOTE: The following uses a 249 subnet
172.25.249.201 director-ui.lab.example.com direct«
172.25.250.254 workstation.lab.example.com worksté
|
250
1
2
3
4
| 172.25.250.220 utility.lab.example.com utility
# NOTE: The following uses a 249 subnet
172.25.249.201 director-ui.lab.example.com direc
172.25.250.254 workstation.lab.example.com works
|
249
250
1
2
3
4
5
6
7
8
9
| 172.25.249.201 director-ui.lab.example.com director -ui
172.25.250.254 workstation.lab.example.com workstation
172.25.250.1 controller0.overcloud.example.com controle
172.25.250.50 keystone.overcloud.example.com keystone
172.25.250.50 dashboard. overcloud.example.com dashboard
172.25.250.2 compute0.overcloud.example.com computed
172.25.250.3 cephO.overcloud.example.com ceph0
172.25.250.12 compute1.overcloud.example.com compute
172.25.250.6 computehci0.overcloud.example.com computet
|
25.
25.
25.
25.
25.
250.
250.
250.
250.
1
2
3
4
| 1 controller0.overcloud.example.com controllere
50 keystone.overcloud.example.com keystone
50 dashboard. overcloud.example.com dashboard
2 compute0.overcloud.example.com compute0
|
250
1
| 1.3 cephO.overcloud.example.com ceph0
|
25
. 250.
250.
1
| 12 compute1.overcloud.example.com compute
|
25.
1
| 6 computehci9.overcloud.example.com computehci0
|
172. 25. 250.
1
| 101 floati01.instance.example.com floatie1
|
操作界面、表格与配置图
1
2
3
4
| 172.25.250.102 floati02.instance.example.com float1o2
172.25.250.103 floati03.instance.example.com float1o03
172.25.250.104 floati04.instance.example.com float104
.,. Output omitted...
|
在 utility 节点上,校验组织用户和在 Red Hat IdM 服务器上存在的组。RHOSP 管理员可以配置 IdM 用户,并配置项目角色,以便他们登录到仪表板并开始工作。
使用 ssh 以 student 用户登录 utility,再执行 kinit admin 获取 Kerberos 票据。
1
2
3
| [student@workstation ~]$ ssh utility
[student@utility ~]$ kinit admin
Password for admin@LAB.EXAMPLE.NET: RedHat1234
|
执行 ipa user-find 列出用户账户。svc-ldap 是集成账户,RHOSP 身份服务使用它查询 IdM 服务器上的其他用户账户。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@utility ~]$ ipa user-find | grep User
User login: admin
User login: architect1
User login: architect2
User login: architect3
...Output omitted...
User login: developer1
User login: developer2
User login: developer3
..-output omitted...
User login: operator
User login: operator2
User login: operator3
.. output omitted...
User login: svc-ldap
|
执行 ipa group-find 列出组账户。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@utility ~]$ ipa group-find | grep Group
Group name: admins
Group name: consulting-admins
Group name: consulting-members
Group name: consulting-swiftoperators
Group name: editors
Group name: finance-admins
Group name: finance-members
Group name: finance-swiftoperators
Group name: ipausers
Group name: production-admins
Group name: production-members
Group name: production-swiftoperators
Group name: research-admins
Group name: research-members
Group name: research-swiftoperators
|
操作界面、表格与配置图
1
| Group name: trust admins
|
从 utility 中注销。
在 power 节点上确认 virshbmc 正在运行,查看虚拟 BMC 配置文件及使用 623 端口监听 IPMI 请求的地址。
使用 ssh 登录 power,然后切换为 root 用户。
1
2
3
| [student@workstation ~]$ ssh power
[student@power ~]$ sudo -i
[root@power ~]#
|
确认 virshbmc 程序正在运行。
1
2
3
4
5
6
| [root@power ~]# ps -ef | grep virshbmc
... python /usr/local/bin/virshbmc.py ... --domain controller0
... python /usr/local/bin/virshbmc.py ... --domain computed
... python /usr/local/bin/virshbmc.py ... --domain ceph0
... python /usr/local/bin/virshbmc.py ... --domain computehci0
... python /usr/local/bin/virshbmc.py ... --domain compute1
|
测试为 Overcloud 虚拟机节点提供电源管理的 IPMI 模拟软件。在 director 上使用 ipmitool 查询 compute1 的状态,其 IPMI 地址为 172.25.249.112。
使用 ssh 以 stack 用户登录 director。
1
2
| [student@workstation ~]$ ssh stack@director
(undercloud) [stack@director ~]$
|
使用 IPMI 命令行工具检查 compute1 当前的电源状态。
1
2
3
| (undercloud) [stack@director ~]$ ipmitool -I lanplus -U admin -P password \
-H 172.25.249.112 power status
Chassis Power is on
|
从 director 中注销。
本引导练习到此结束。
操作界面、表格与配置图
引导练习:查看 Undercloud 架构#
引导练习#
查看 Undercloud 架构#
本练习中,连接 Undercloud 节点 director,查看 Undercloud 的配置。
学习目标#
能够查看 Undercloud 的结构和配置。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab architecture-undercloud setup 命令。脚本确认 undercloud 节点 director 是可以到达的。
1
| [student@workstation ~]$ lab architecture-undercloud setup
|
以 stack 用户登录 director。打开 undercloud.conf 文件,检查 DHCP 配置。
从 workstation 登录 director。
1
2
| [student@workstation ~]$ ssh stack@director
(undercloud) [stack@director ~]$
|
打开 /home/stack/undercloud.conf 文件。注意 dhcp_start 和 dhcp_end 参数中的 IP 地址。
1
2
3
| (undercloud) [stack@director ~]$ grep "^dhcp*" undercloud.conf
dhcp_start = 172.25.249.51
dhcp_end = 172.25.249.59
|
在 /home/stack/undercloud.conf 文件中,搜索 undercloud_public_vip 和 undercloud_admin_vip 参数。这些 IP 地址是为 director 的公开 API 和 admin API 端点定义的。
1
2
3
| (undercloud) [stack@director ~]$ grep "^undercloud_.*vip" undercloud.conf
undercloud_public_vip = 172.25.249.201
undercloud_admin_vip = 172.25.249.202
|
在 /home/stack/undercloud.conf 文件中,搜索 undercloud_admin_password 参数。
1
2
| (undercloud) [stack@director ~]$ grep "^undercloud_.*password" undercloud.conf
undercloud_admin_password = redhat
|
操作界面、表格与配置图
确认 stackrc 环境文件自动加载了 admin 用户凭据。查看 stack 用户用于连接 Undercloud 的环境。
执行 openstack endpoint list,列出 director 上身份服务的公共 API 端点。
1
2
3
4
5
6
7
8
| (undercloud) [stack@director ~]$ openstack endpoint list \
-c 'Service Type' -c 'Interface' -c 'URL'
Seeeie
| Service Type | Interface | URL |
yes RS a SS A A eg RS IR A ee ee
.. output omitted...
| identity | public | https://172.25.249.201:13000 |
See ee ee ee a ee
|
查看在 stack 用户环境中装入的身份服务环境变量。
1
2
3
4
5
6
7
8
9
10
11
12
13
| (undercloud) [stack@director ~]$ env | grep OS_
OS_BAREMETAL_API_VERSION=1.34
OS_USER_DOMAIN_NAME=Default
OS_PROJECT_NAME=admin
OS_IDENTITY_API_VERSION=3
0S_PASSWORD=redhat
OS_AUTH_TYPE=password
PS1=${0S_CLOUDNAME:+($0S_CLOUDNAME)} [\u@\h \W]\$
OS_AUTH_URL=https://172.25.249.201:13000/
0S_USERNAME=admin
OS_NO_CACHE=True
0S_CLOUDNAME=undercloud
OS_PROJECT_DOMAIN_NAME=Default
|
注意,OS_AUTH_URL 设置为身份服务的公共 API 端点。stackrc 加载 admin 用户凭据。OS_PASSWORD 按 undercloud.conf 设置为 redhat,OS_CLOUDNAME 设置为 undercloud。
查看 director 节点配置的部署网络和外部网络接口,并列出 ctlplane-subnet 子网的详细信息。
列出 director 的部署网络和外部网络。br-ctlplane 网桥连接 172.25.249.0 部署网络;eth1 接口连接 172.25.250.0 公共网络。
1
2
3
4
5
6
7
8
| (undercloud) [stack@director ~]$ ip a | grep -E 'br-ctlplane|eth1'
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default qlen 1000
inet 172.25.250.200/24 brd 172.25.250.255 scope global noprefixroute eth1
6: br-ctlplane: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
inet 172.25.249.200/24 brd 172.25.249.255 scope global br-ctlplane
inet 172.25.249.202/32 scope global br-ctlplane
|
操作界面、表格与配置图
1
| inet 172.25.249.201/32 scope global br-ctlplane
|
使用 openstack subnet list 命令列出部署网络 172.24.249.0/24 上的 Undercloud 子网。
1
2
3
4
5
6
7
8
| (undercloud) [stack@director ~]$ openstack subnet list \
-c 'Name' -c 'Subnet'
af aoe a eeteee ee eh per ce eae Nee one eee eh ere ere eet
| Name | Subnet |
Peeence nme rn en ner e en epaecs ncn n eet
| ctlplane-subnet | 172.25.249.0/24 |
.. output omitted...
eae ee eee eee ee ee
|
执行 openstack subnet show 查看 ctlplane-subnet 的详情。注意,地址分配池与 undercloud.conf 中 dhcp_start 和 dhcp_end 的值一致。
1
2
3
4
5
6
7
8
9
| (undercloud) [stack@director ~]$ openstack subnet show ctlplane-subnet
| |allocation_pools 172.25.249.51-172.25.249.59 |
| cidr | 172.25.249.0/24 |
| created_at | 2018 -09-26T00: 38: 292 |
| description i |
| dns_nameservers | 172.25.250. 254 |
| | Trueenable_dhcp |
| | 172.25.249. 200gateway_ip |
.., output omitted...
|
列出 director 上所有已注册的裸机节点,并查看 compute1 的电源管理信息。
执行 openstack baremetal node list,列出所有已注册的裸机节点。
1
2
3
4
5
6
7
8
9
10
| (undercloud) [stack@director ~]$ openstack baremetal node list \
-c 'Name' -c 'Power State'
Speteieie aceietetacer eie Pete eceiereeierececeeceth
| Name | Power State |
Se ae
| controller0 | power on |
| compute0 | power on |
| computehci0 | power on |
| compute1 | power on |
| ceph0 | power on |
|
执行 openstack baremetal node show,查看 compute1 节点的电源管理信息。
1
2
| (undercloud) [stack@director ~]$ openstack baremetal node show \
-c 'driver' -c 'driver_info' compute1
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| | Field | Value
Seatac eat ase dTmae ean a aes ain et ae amt cees ate e aVatie ee
| driver | pxe_ipmitool
| driver_info | {u'ipmi_port': u'623', u'ipmi_username': u'admin',
| | u'deploy_kernel': u'525385d3-7f95-4911 -be6e-ea205db379a8 ',
| | u'ipmi_address': u'172.25.249.112', u'deploy_ramdisk':
| | u'246a9a84-f097 -4ce1-82d0-e8a754ef94b2', u'ipmi_password':
| | Ee
|
从 director 中注销。
本引导练习到此结束。
操作界面、表格与配置图
引导练习:查看容器化服务结构#
引导练习#
查看容器化服务结构#
本练习中,执行容器化服务的一些常见管理任务。
学习目标#
完成后,能够:
执行容器化服务的常见管理任务。
开始之前#
以 student 用户登录 workstation,密码为 student。
在workstation,运行 lab architecture-containerization setup 命令。
1
| [student@workstation ~]$ lab architecture-containerization setup
|
以 heat-admin 用户登录 compute0,执行 sudo -i 切换为 root,再用 docker ps 列出计算节点上的容器。退出 compute0,登录 controller0,同样切换为 root 并执行 docker ps。比较两个节点的差异。
以 heat-admin 用户登录 compute0,执行 docker ps 列出容器,然后退出 compute0。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~]$ ssh heat-admin@compute0
[heat-admin@compute0 ~]$ sudo -i
[root@compute0 ~]# docker ps
CONTAINER ID IMAGE
COMMAND CREATED STATUS PORTS
NAMES
5873d9d3221c 172.25.249,200:8787/rhosp13/openstack -ovn-controller: latest
"kolla_start" 3 days ago Up 26 hours
ovn_controller
f5de65054aa7 172.25. 249, 200:8787/rhosp13/openstack -neutron-metadata-agent -
ovn: latest "kolla_start" 3 days ago Up 26 hours (healthy)
ovn_me tadata_agent
.. output omitted...
[root@compute0 ~]# exit
[heat-admin@compute0 ~]$ exit
|
以 heat-admin 用户登录 controller0,执行 sudo -i 切换为 root,再执行 docker ps 列出容器。
1
| [student@workstation ~]$ ssh heat-admin@controller
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]# docker ps
CONTAINER ID IMAGE
COMMAND CREATED STATUS
PORTS NAMES
28fcdfb385fc 172.25. 249. 200:8787/rhosp13/openstack-ovn-northd: latest
"/bin/bash /usr/lo..." 26 hours ago Up 26 hours
ovn-dbs -bundle-docker -6
béd5c72ffe23 172.25. 249. 200:8787/rhosp13/openstack -manila-share:pcmklatest
"/bin/bash /usr/lo..." 26 hours ago Up 26 hours
openstack-manila-share-docker-9
37fd300bb956 172.25. 249. 200:8787/rhosp13/openstack-cinder -volume: pemklatest
"/bin/bash /usr/lo..." 26 hours ago Up 26 hours
openstack-cinder -volume-docker -0
.. Output omitted...
|
执行 docker images,列出用于创建服务容器的镜像。
1
2
3
4
5
6
7
8
9
10
| [root@controller0 ~]# docker images
REPOSITORY TAG
IMAGE ID CREATED SIZE
172.25.249.200: 8787/rhceph/rhceph -3-rhel7 latest
fa3b551f0952 2 weeks ago 592 MB
172.25.249.200: 8787/rhosp13/opens tack-neutron-server-ovn latest
80fab6coavava 5 weeks ago 867 MB
172.25.249.200: 8787/rhosp13/opens tack-cinder -api latest
1438961b75d3 5 weeks ago 992 MB
.. output omitted...
|
使用 docker inspect 检查 cinder_api 容器,并用 jq 筛选结果;可以筛选配置的任意部分
文件。
使用 docker inspect 命令检查 cinder_api 容器。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [root@controller0 ~]# docker inspect cinder_api
[
{
"Td": "15454f4111f64e319 70a38a748ba810117b218ed8a7bob5b15611 3dceda4af5d",
"Created": "2018-08-19T04:12:39.6103821352",
"Path": "kolla_start",
"args": [],
"State: 4
"Status": "running",
"Running": true,
"Paused"© "false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"pid": 14058,
"Exitcode": 6,
VERO ie
"StartedAt": "2018-08-21T05:24:24.150488874Z2",
"FinishedAt": "2018-08-21TO5: 23:55.5839841342"
t,
|
操作界面、表格与配置图
缩小查看范围。使用 jq 选择 Config 部分;.[0] 表示读取响应数组中的第一个元素。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| [root@controller0 ~]# docker inspect cinder_api | jq .[0].Config
{
"StopSignal": "SIGTERM",
"Labels": {
"version": "13.0",
"vendor": "Red Hat, Inc.",
"ves-type": "git",
"vcs-ref": "1746128fob1idf74441d30bfo0ala6902fe244a591",
"usage": "This image is very generic and does not serve a single use case. Use
it as a base to build your own images.",
"url": "https://access.redhat.com/containers/#/registry.access.redhat.com/
rhosp13/openstack-cinder -api/images/13.0-46",
"summary": "Red Hat OpenStack Platform 13.0 cinder -api",
"release": "46",
"name": "rhosp13/openstack-cinder -api",
"managed_by": "paunch",
"config_id": "tripleo_step4",
.. output omitted...
|
使用 docker logs 查看 keystone 启动日志。服务管理日志保存在 /var/log/containers/service 中。使用 less 查看 swift 日志。
使用 docker logs 查看 keystone 启动日志。
1
2
3
4
5
6
7
8
9
10
11
12
| [root@controller0 ~]# docker logs keystone
+ sudo -E kolla_set_configs
INFO:__main__:Loading config file at /var/lib/kolla/config_files/config.json
INFO:__main__:Validating config file
INFO:__main__:Kolla config strategy set to: COPY_ALWAYS
INFO:__main__:Copying service configuration files
INFO:__main__:Copying /var/lib/kolla/config_files/src/etc/ht tpd/conf.d/10-
keystone_wsgi_admin.conf to /etc/httpd/conf.d/10-keystone_wsgi_admin.conf
INFO:__main__:Copying /var/lib/kolla/config_files/src/etc/ht tpd/conf.d/10-
keystone_wsgi_main.conf to /etc/httpd/conf .d/10-keystone_wsgi_main.conf
INFO:__main__:Deleting /etc/httpd/conf.d/ssl.conf
..- Output omitted...
|
使用 less 查看 swift 日志。
1
2
3
4
5
6
7
8
9
| [root@controller0 ~]# view /var/log/containers/swift/swift.log
..-output omitted...
stead. This option will be ignored in a future release.
Aug 19 90:13:08 controller0 object-server: Starting 1
Aug 19 90:13:08 controller0 object-server: Starting object replicator in daemon
mode.
Aug 19 00:13:08 controller0 object-server: Starting object replication pass.
Aug 19 90:13:09 controller0 object-server: Nothing replicated for 0.0820679664612
seconds.
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| Aug 19 00:13:09 controller0 object-server: Object replication complete. (0.00
minutes)
Aug 19 00:13:11 controller0 account-server: Beginning replication run
Aug 19 00:13:11 controller0 account-server: Replication run OVER
Aug 19 00:13:11 controller0 account-server: Attempted to replicate 6 dbs in
@.00213 seconds (9.00000/s)
Aug 19 90:13:11 controller0 account-server: Removed © dbs
... output omitted...
|
使用 docker exec 检查 keystone 容器中的 OpenStack 服务是否健康。
1
2
3
4
5
6
7
8
9
10
11
12
| [root@controller0 ~]# docker exec -t keystone /openstack/healthcheck
{"versions": {"values": [{"status": "stable", "updated": "2018-02-28T00:00:00Z",
"media-types": [{"base": ""application/json", "type": "application/
vnd.openstack.identity-v3+json"}], "id": "v3.10", "links": [{"href":
"http://controller0.internalapi. overcloud.example.com:5000/v3/", "rel":
"self"}]}, {"status": "deprecated", "updated": "2016-08-04T00:60:00Z",
"media-types": [{"base": "application/json", "type": "application/
vnd .openstack. adentity-v2.07json"}], "id: "v2.0", "links": [{"hret*:
"http://controller0.internalapi. overcloud.example.com:5000/v2.0/", "rel":
"self"}, {"href": "https://docs.openstack.org/", "type": "text/html", "rel":
"describedby"}]}]}}
300 172.24.1.1:5000 0.006 seconds
|
执行 docker stop 停止 nova_api 容器,用 docker ps 检查状态,再执行 docker start 启动容器。重新检查状态,等待 40–50 秒后再次检查,确认状态为 healthy。
执行 docker stop 停止 nova_api 容器。
1
2
| [root@controller0 ~]# docker stop nova_api
nova_api
|
执行 docker ps 检查容器状态。
1
2
3
4
5
| [root@controller0 ~]# docker ps -a --format="{{.Names}}\t{{.Status}}" \
| grep nova_api
.. output omitted...
nova_api Exited (©) 32 seconds ago
.. output omitted...
|
执行 docker start 重新启动 nova_api 容器。
1
2
3
4
5
6
| [root@controller0 ~]# docker start nova_api
nova_api
[root@controller0 ~]# docker ps -a --format="{{.Names}}\t{{.Status}}" \
| grep nova_api
.. output omitted...
nova_api Up 2 seconds (health: starting)
|
操作界面、表格与配置图
重新检查容器状况。等待40至50秒,重新检查容器状况。确保容器状况为healthy。
1
2
3
| [root@controller0 ~]# docker ps -a --format="{{.Names}}\t{{.Status}}" \
| grep nova_api
nova_api Up About a minute (healthy)
|
退出 controller0。
1
2
| [root@controller0 ~]# logout
[student@workstation ~]$
|
在 workstation 上运行 lab architecture-containerization cleanup,清理本练习。
1
| [student@workstation ~]$ lab architecture-containerization cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:查看 Overcloud 架构#
引导练习#
查看 Overcloud 架构#
在本练习中,查看课堂系统的 Overcloud 架构,并验证 Overcloud 节点的运行状态与配置。
学习目标#
完成后,能够:
连接并观察 undercloud 虚拟机。
连接并观察 overcloud 虚拟机。
开始之前#
以 student 用户登录 workstation,密码为 student。
在workstation,运行 lab architecture-overcloud setup 命令。
1
| [student@workstation ~]$ lab architecture-overcloud setup
|
以 stack 用户登录 director,确认 stackrc 环境文件自动加载。使用 stack 用户的认证环境查询和管理 Undercloud。
以 stack 用户登录 director,无需密码。查看 stack 用户用于连接 Undercloud 的环境。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~]$ ssh stack@director
(undercloud) [stack@director ~]$ env | grep OS_
OS_BAREMETAL_API_VERSION=1.34
OS_USER_DOMAIN_NAME=Default
OS_PROJECT_NAME=admin
OS_IDENTITY_API_VERSION=3
OS_PASSWORD=redhat
OS_AUTH_TYPE=password
PS1=${0S_CLOUDNAME: +($0S_CLOUDNAME)} [\u@\h \w]\$
OS_AUTH_URL=https://172.25. 249.201:13000/
OS_USERNAME=admin
OS_NO_CACHE=True
OS_CLOUDNAME=undercloud
OS_PROJECT_DOMAIN_NAME=Default
|
查看当前 overcloud 服务器列表以找到每个节点的供给网络地址。这里显示的 IP 地址可能与您的不同。退出 director 节点。
1
| (undercloud) [stack@director ~]$ openstack server list \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| -c Name -c Status -c Networks
iete ee EE o
| Name | Status | Networks |
Se eeree
| controller0 | ACTIVE | ctlplane=172.25.249.59 |
| compute1 | ACTIVE | ctlplane=172.25.249.56 |
| cephe | ACTIVE | ctlplane=172.25.249.54 |
| compute0 | ACTIVE | ctlplane=172.25.249.53 |
| computehci0 | ACTIVE | ctlplane=172.25.249.58 |
Seee a err
(undercloud) [stack@director ~]$ exit
logout
Connection to director closed.
[student@workstation ~ ]$
|
使用 heat-admin 登录 controller0,查看该节点特有的服务。heat-admin 配置了 director 上 stack 用户的 SSH 密钥,允许免密码访问。
以 heat-admin 用户登录 controller0,执行 ip addr 列出网络配置。
1
2
| (undercloud) [stack@director ~]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$ ip addr | grep -E 'etho|vlan|br-ex'
|
2
1
2
3
4
5
6
7
8
| 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
inet 172.25.249.53/24 brd 172.25.249.255 scope global etho
inet 172.25.249.50/32 brd 172.25.249.255 scope global etho
10: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.25.250.1/24 brd 172.25.250.255 scope global br-ex
inet 172.25.250.50/32 brd 172.25.250.255 scope global br -ex
14: vlan20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.2.1/24 brd 172.24.2.255 scope global vlan20
|
15
1
2
3
| vlan40: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.4.1/24 brd 172.24.4.255 scope global vlan4o
inet 172.24.4.50/32 brd 172.24.4.255 scope global vlan4o
|
16
1
2
3
4
5
6
7
| 16: vlani0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.1.1/24 brd 172.24.1.255 scope global vlanio
inet 172.24.1.51/32 brd 172.24.1.255 scope global vlanio
inet 172.24.1.50/32 brd 172.24.1.255 scope global vlanio
17: vlan30: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.3.1/24 brd 172.24.3.255 scope global vlan30
inet 172.24.3.50/32 brd 172.24.3.255 scope global vlan30
|
18
1
2
| vlan50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.5.1/24 brd 172.24.5.255 scope global vlan5o
|
执行 ovs-vsctl 列出 controller0 上的网桥。
1
2
3
4
5
| [heat-admin@controller0 ~]$ sudo ovs-vsctl list-br
br-eth3
br-eth4
br-ex
br-int
|
操作界面、表格与配置图
执行 ovs-vsctl 列出 br-trunk 上的接口。
1
2
3
4
5
6
7
| [heat-admin@controller0 ~]$ sudo ovs-vsctl list-ifaces br-trunk
eth
vlanio
vlan20
vlan30
vlan4o
vlan50
|
执行 ovs-vsctl 列出 br-ex 上的接口。
1
2
3
| [heat-admin@controller0 ~]$ sudo ovs-vsctl list-ifaces br-ex
eth2
.. output omitted...
|
执行 docker 列出 controller0 上的容器,然后退出 controller0。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [heat-admin@controller0 ~]$ sudo docker ps \
--format="table {{.Names}}\t{{.Status}}"
NAMES STATUS
ovn-dbs-bundle-docker -0 Up 7 hours
openstack-manila-share-docker -0 Up 7 hours
openstack-cinder-volume-docker-@ Up 7 hours
haproxy-bundle-docker -9 Up 7 hours
redis-bundle-docker -0 Up 7 hours
galera-bundle-docker -0 Up 7 hours
rabbitmg-bundle-docker -9 Up 7 hours
.. output omitted...
[heat-admin@controller0 ~]$ exit
(undercloud) [stack@director ~]$
|
以 heat-admin 用户登录 compute0,列出相关服务和网络配置,然后退出。
以 heat-admin 用户登录 compute0,执行 ip addr 列出网络配置。
1
2
3
4
5
6
7
8
9
10
11
12
13
| (undercloud) [stack@director ~]$ ssh heat-admin@compute0
[heat-admin@compute0 ~]$ ip addr | grep -E 'etho|vlan|eth2'
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
inet 172.25.249.53/24 brd 172.25.249.255 scope global etho
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-
system state UP
14: vlani0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.1.2/24 brd 172.24.1.255 scope global vlanioe
15: vlan20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.2.2/24 brd 172.24.2.255 scope global vlan20
16: vlan30: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.3.2/24 brd 172.24.3.255 scope global vlan30
17: vlan50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
|
操作界面、表格与配置图
1
| inet 172.24.5.2/24 brd 172.24.5.255 scope global vlan5oe
|
执行 ovs-vsctl 列出 compute0 上的网桥。
1
2
3
4
5
6
| [heat-admin@compute0 ~]$ sudo ovs-vsctl list-br
br-eth3
br-eth4
br-ex
br-int
br- trunk
|
执行 ovs-vsctl 列出 br-trunk 上的接口。
1
2
3
4
5
6
| [heat-admin@compute0 ~]$ sudo ovs-vsctl list-ifaces br-trunk
eth1
vlanio
vlan20
vlan30
vlanb5o
|
执行 docker 列出 compute0 上的容器,然后退出。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [heat-admin@compute0 ~]$ sudo docker ps \
--format="table {{.Names}}\t{{.status}}"
NAMES STATUS
ovn_metadata_agent Up 7 hours (healthy)
ovn_controller Up 7 hours
nova_compute Up 7 hours (healthy)
logrotate_crond Up 7 hours
ceilometer_agent_compute Up 7 hours
nova_migration_target Up 7 hours
iscsid Up 7 hours
nova_libvirt Up 7 hours
nova_virtlogd Up 7 hours
[heat-admin@compute0 ~]$ exit
(undercloud) [stack@director ~]$
|
以 heat-admin 用户登录 computehci0,列出相关服务和网络配置,然后退出。
以 heat-admin 用户登录 computehci0,执行 ip addr 列出网络配置。
1
2
3
4
5
6
7
8
9
10
11
| (undercloud) [stack@director ~]$ ssh heat-admin@computehci0
[heat-admin@computehci0 ~]$ ip addr | grep -E 'etho|vlan|eth2'
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
inet 172.25.249.56/24 brd 172.25.249.255 scope global etho
4: eth2: <BROADCAST,MULTICAST,UP, LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-
system state UP
14: vlani0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.1.6/24 brd 172.24.1.255 scope global vlanio
15: vlan20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.2.6/24 brd 172.24.2.255 scope global vlan20
16: vlan30: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
|
操作界面、表格与配置图
1
2
3
4
5
| inet 172.24.3.6/24 brd 172.24.3.255 scope global vlan30
17: vlan40: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.4.6/24 brd 172.24.4.255 scope global vlan4o
18: vlan50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.5.6/24 brd 172.24.5.255 scope global vlan5e
|
执行 ovs-vsctl 列出 computehci0 上的网桥。
1
2
3
4
5
6
| [heat-admin@computehci9 ~]$ sudo ovs-vsctl list-br
br-eth3
br-eth4
br-ex
br-int
br-trunk
|
执行 ovs-vsctl 列出 br-trunk 上的接口。
1
2
3
4
5
6
7
| [heat-admin@computehci0 ~]$ sudo ovs-vsctl list-ifaces br-trunk
eth
vlanio
vlan20
vlan30
vlan4o
vilan5o
|
执行 docker 列出 computehci0 上的容器。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [heat-admin@computehci0 ~]$ sudo docker ps \
--format="table {{.Names}}\t{{.Status}}"
NAMES STATUS
ceph-osd-computehci0-vdce Up 7 hours
ceph-osd-computehci0-vdd Up 7 hours
ceph-osd-computehci0-vdb Up 7 hours
ovn_controller Up 7 hours
ovn_me tadata_agent Up 7 hours (healthy)
logrotate_crond Up 7 hours
nova_compute Up 7 hours (healthy)
nova_migration_target Up 7 hours
ceilometer_agent_compute Up 7 hours
iscsid Up 7 hours
nova_libvirt Up 7 hours
nova_virtlogd Up 7 hours
|
执行 lsblk -fs 列出指定的块设备,然后退出 computehci0。
1
2
3
4
5
6
7
8
9
| [heat-admin@computehci0 ~]$ lsblk -fs
NAME FSTYPE LABEL UUID MOUNTPOINT
sro iso9660 iPXE 2014-12-21-12-02-07-00
vda1l iso9660 config-2 2018-08-19-03-13-46-00
Uvda
vda2 xfs img-rootfs afaoé7cb-d91f-432e-b7c4-cbh46dabel1e0ec /
Uvda
vdb1 xfs 776922d3 -e888 -4a9c-9cc4 -eboOf9025dcbc
Uvdb
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| vdb2
Lvdb
vdc1 xfs 37849863 -4c0b-4495 -ab8c -Ocfbddo9 9549
Lvde
vdc2
Uvde
vdd1 xfs 9c995a6f -32C5-4138 -90da-dd4239ce37ec
Uvdd
vdd2
Uvdd
[heat-admin@computehci0 ~]$ exit
(undercloud) [stack@director ~]$
|
以 heat-admin 用户登录 ceph0,列出相关服务和网络配置,然后退出。
以 heat-admin 用户登录 ceph0,执行 ip addr 列出网络配置。
1
2
3
4
5
6
7
8
9
10
11
| (undercloud) [stack@director ~]$ ssh heat-admin@ceph0
[heat-admin@ceph0 ~]$ ip addr | grep -E 'eth0|vlan|eth2'
2: eth0: <BROADCAST,MULTICAST,UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
inet 172.25.249.56/24 brd 172.25.249.255 scope global etho
4: eth2: <BROADCAST,MULTICAST,UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
6: vlan40: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.4.3/24 brd 172.24.4.255 scope global vlan4o
7: vlan30: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.3.3/24 brd 172.24.3.255 scope global vlan30
8: vlan50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.5.3/24 brd 172.24.5.255 scope global vlan5o
|
执行 ovs-vsctl 列出 ceph0 上的网桥。
1
2
3
| [heat-admin@ceph0 ~]$ sudo ovs-vsctl list-br
br-ex
br-trunk
|
执行 docker 列出 ceph0 上的容器,然后退出。
1
2
3
4
5
6
7
| [heat-admin@ceph0 ~]$ sudo docker ps \
--format="table {{.Names}}\t{{.Status}}"
NAMES STATUS
ceph-osd-ceph0-vdb Up 7 hours
ceph-osd-ceph0-vdc Up 7 hours
ceph-osd-ceph@-vdd Up 7 hours
logrotate_crond Up 7 hours
|
执行 lsblk -fs 列出指定的块设备。
1
2
3
4
5
| [heat-admin@ceph0 ~]$ lsblk -fs
NAME FSTYPE- LABEL UUID MOUNTPOINT
sro iso9660 iPXE 2014-12-21-12-02-07-00
vdal iso9660 config-2 2018 -08-19-03-13-46-00
Lvda
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| vda2 xfs img-rootfs afa067cb-d91f-432e-b7c4-cb46dabe10ec /
Lvda
vdb1 xfs c3d437d0 -9215 -4c98 -8a40 -c5dacabf95b1
Lvdb
vdb2
Uvdb
vdc1 xfs d76e086b-db1e-4a84-9b7e-e23a51f71eee
Lvde
vdc2
Lvde
vddi xfs 1c4c6a2b -0b99 -4453-8821-caea37e78728
Uvdd
vdd2
Lydd
[heat-admin@ceph0 ~]$ exit
(undercloud) [stack@director ~]$
|
登录 controller0,使用 Ceph 命令检查集群健康状态。
登录 controller0,执行 ceph status 检查 Ceph 集群健康状态。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| (undercloud) [stack@director ~]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$ ceph status
cluster:
a6|p f9d61d02-a355-11e8 -ae2b-52540001fac8
health: HEALTH_OK
services:
mon: 1 daemons, quorum controller0
mgr: controller0(active)
mds: cephfs-1/1/1 up {0=controller0=up:active}
osd: 6 osds: 6 up, 6 in
data:
pools: 7 pools, 416 pgs
objects: 744 objects, 5617 MB
usage: 6270 MB used, 107 GB / 113 GB avail
pgs: 416 activet+clean
|
执行 ceph osd lspools 列出集群中的存储池。
1
2
| [heat-admin@controller0 ~]$ ceph osd lspools
1 images,2 metrics,3 backups,4 vms,5 volumes,6 manila_data,? manila_metadata,
|
执行 ceph osd ls 列出集群中的 OSD,然后退出 ceph0。
1
| [heat-admin@controller0 ~]$ ceph osd ls
|
9
操作界面、表格与配置图
5
1
2
| [heat-admin@controller0 ~]$ exit
(undercloud) [stack@director ~]$
|
在 director 节点上,以 Overcloud 中 admin 项目的 admin 用户身份认证。
加载 overcloudrc 认证环境文件,以 admin 用户身份访问 Overcloud。
1
| (undercloud) [stack@director ~]$ source overcloudre
|
确认 Overcloud 中存在 heat_stack_user 角色,然后退出 director。
1
2
3
4
5
6
7
8
9
10
11
| (overcloud) [stack@director ~]$ openstack role list -c Name
pee eceteeeeeeeceeet
| Name |
Se
| heat_stack_user |
| ResellerAdmin |
| _member_ |
| swif toperator |
| admin |
tenn nene ee eet
(overcloud) [stack@director ~]$ exit
|
在 workstation 上运行 lab architecture-overcloud cleanup,清理本练习。
1
| [student@workstation ~]$ lab architecture-overcloud cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:浏览 RHOSP 架构#
浏览 RHOSP 架构#
操作检查清单#
在此实验中,验证 undercloud 和 overcloud 是否正常运行,具体方式是浏览课堂基础设施、 列出网络和接口,以及部署一个带有浮动 IP 地址的服务器实例。
学习目标#
完成后,能够:
浏览课堂基础设施。
°
列出 overcloud 节点上的网络和接口。
°
使用基本命令管理容器。
列出 overcloud 节点上的 OVS 桥。
部署并核实外部实例。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab architecture-lab setup。脚本检查 default 规格、rhel7 镜像和 provider-172.25.250 网络是否存在,
测试实例部署。
1
| [student@workstation ~]$ lab architecture-lab setup
|
在director节点上,核查undercloud的网络和服务。
在 director 上查找 Overcloud 节点的 IP 地址,列出网络并查看 ctlplane 子网详情。打开 undercloud.conf,检查 DHCP 配置。
在全部四个 overcloud 节点上,使用 docker 命令显示 OpenStack 服务。
使用 docker 命令来停止 nova_api 容器。审查容器的状况并重新启动它。确保容器返回 healthy 状态。
在 controller0 和 compute0 上查看 eth0、VLAN 和 br-ex 接口,列出 OVS 网桥,以及 br-ex 和 br-trunk 上的 OVS 接口。
在 workstation 上加载 ~/operator1-production-rc Keystone 凭据文件。使用下表属性在 production 项目中创建实例,确认服务器状态为 ACTIVE。在 provider-datacentre 网络中创建浮动 IP,并将其关联到实例。
操作界面、表格与配置图
实例属性
在 workstation 上运行 lab architecture-lab grade,检查本实验是否成功。
1
| [student@workstation ~(operator1-production)]$ lab architecture-lab grade
|
清理:在 workstation 上运行 lab architecture-lab cleanup,清理本实验。
1
| [student@workstation ~(operator1-production)]$ lab architecture-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
浏览 RHOSP 架构#
操作检查清单#
在此实验中,验证 undercloud 和 overcloud 是否正常运行,具体方式是浏览课堂基础设施、 列出网络和接口,以及部署一个带有浮动 IP 地址的服务器实例。
学习目标#
完成后,能够:
浏览课堂基础设施。
列出 overcloud 节点上的网络和接口。
°
使用基本命令管理容器。
列出 overcloud 节点上的 OVS 桥。
部署并核实外部实例。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab architecture-lab setup。脚本检查 default 规格、rhel7 镜像和 provider-172.25.250 网络是否存在,以便测试实例部署。
1
| [student@workstation ~]$ lab architecture-lab setup
|
在director节点上,核查undercloud的网络和服务。
以 stack 用户登录 director,执行 openstack network list 列出 Undercloud 网络。注意外部网络、
部署网络(ctlplane)以及五个 VLAN 网络。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~]$ ssh stack@director
(undercloud) [stack@director ~]$ openstack network list
Sa I
| ID | Name | Subnets |
Sna escere
| @57a...250d | tenant | e2fc...f6co |
| Ocf6...e3d0 | management | 5800...11¢e5 |
| 3a82...e1f5 | ctlplane | a8e0...9913 |
| 3e25...7d07 | storage_mgmt | 1f31...d167 |
| 6625...62e7 | storage | S312. 3.7347 |
| 6do6...159d | external | 3720...90d6 |
| a432...0a@e | internal_api | 7c19...4549 |
|
操作界面、表格与配置图
使用 ip addr 命令来列出 director 上的接口。注意 eth1 接口,它连接到外部网络。br-ctlplane 接口链接到供给网络。
1
2
3
4
5
6
7
8
9
| (undercloud) [stack@director ~]$ ip a | grep -E 'br-ctlplane|eth1'
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default glen 1000
inet 172.25.250.200/24 brd 172.25.250.255 scope global noprefixroute eth1
6: br-ctlplane: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
inet 172.25.249.200/24 brd 172.25.249.255 scope global br-ctlplane
inet 172.25.249.202/32 scope global br-ctlplane
inet 172.25.249.201/32 scope global br-ctlplane
|
执行 openstack compute service list 列出 nova 服务。所有服务必须为 enabled 且状态为 up,环境才能正常工作。
1
2
3
4
5
6
7
8
| (undercloud) [stack@director ~]$ openstack compute service list \
-c Binary -c Host -c Status -c State
Seo ne eeeeee eee
| Binary | Host | Status | State |
Se eeer
| nova-conductor | director.lab.example.com | enabled | up |
| nova-scheduler | director.lab.example.com | enabled | up |
| nova-compute | director.lab.example.com | enabled | up
|
执行 openstack catalog list 列出 ironic 的所有端点。注意,每项服务都有三个不同的端点。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| (undercloud) [stack@director ~]$ openstack catalog list -c Name -c Endpoints
Seee ee ee
| Name | Endpoints |
SI IE aly eS ht he RE ah eae aT Ran Tn SR TENMES Rays aI Rae ee
| ironic-inspector | regionOne |
| | public: https://172.25.249.201:13050 |
| | regionone |
| | internal: http://172.25.249.202:5050 |
| | regionone |
| | admin: http://172.25,249.202:5050 |
| | |
| mistral | regionone |
| | internal: http://172.25.249.202:8989/v2|
| | regionone |
| | admin: http://172.25.249.202:8989/v2 |
| | regionone |
| | public: https://172.25.249.201:13989/v2|
|
| | | | |
1
| admin: http://172.25,249.202:5050 |
|
| |
1
2
3
4
5
6
7
| | mistral | regionone |
| | internal: http://172.25.249.202:8989/v2|
| | regionone |
| | admin: http://172.25.249.202:8989/v2 |
| | regionone |
| | public: https://172.25.249.201:13989/v2|
.. Output omitted...
|
操作界面、表格与配置图
在 director 上查找 Overcloud 节点的 IP 地址,列出网络并查看 ctlplane 子网详情。打开 undercloud.conf,检查 DHCP 配置。
使用 openstack server list 命令来列出 overcloud 节点的 IP 地址。
1
2
3
4
5
6
7
8
9
10
| (undercloud) [stack@director ~]$ openstack server list -c Name -c Networks
Be yar yee yee peep ei ye ye eyore ryote yore yee tyenen ees
| Name | Networks |
SE
| compute | ctlplane=172.25.249.57 |
| cephe | ctlplane=172.25.249.56 |
| controller0 | ctlplane=172.25.249.53 |
| compute0 | ctlplane=172.25.249.54 |
| computehci0 | ctlplane=172.25.249.58 |
ee re
|
使用 openstack network list 命令来列出 undercloud 网络。使用 openstack subnet show 命令来显示 ctlplane 子网的细节。请注意 allocation_pools 参数的内容。
1
2
3
4
5
6
7
8
9
10
11
12
| (undercloud) [stack@director ~]$ openstack network list -c Name -c Subnets
| tenant | ca617bee-fbb4 -46be- 868a-97b6384c9202
| |external d49717b4-1327 -4359 -852b-c4e600cebag7
| |internal_api | e786ca9b-5390-4197 -b4f7-d5bdb8efa309
| storage_mgmt | a2706edf-0080-44f4-b41a-ac7198a920a0
| |management 746b8a96 -3066 -4421 - 8cbb-30935754f82a
| |ctlplane 6457 f bof -2d9d -43af -93ca-foc3dcoescs2
| |storage 0b695964-76C5 -48d0-a6cO-6ac6c9d6465cC
(undercloud) [stack@director ~]$ openstack subnet show \
6457fbOF-2d9d-43af -93ca-fOc3dco0e8cs82
| allocation_pools | 172.25.249.51-172.25.249.59 |
.. output omitted...
|
在 undercloud.conf 中查找 dhcp_start 和 dhcp_end 设置的 IP 地址。
1
2
3
| (undercloud) [stack@director ~]$ grep '^dhcp_' undercloud.conf
dhcp_start = 172.25.249.51
dhcp_end = 172.25.249.59
|
注意:所有 Overcloud 节点的 IP 地址都位于 ctlplane 子网的地址分配池中。该子网在 undercloud.conf 中配置,节点从其 allocation_pools 指定的地址池获取 IP。
操作界面、表格与配置图
在全部四个 Overcloud 节点上,使用 docker 显示 OpenStack 服务。
以 heat-admin 用户登录 controller0,执行 sudo -i 获取 root 权限。使用 docker ps 列出控制器节点上的容器,然后退出 controller0。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| (undercloud) [stack@director ~]$ ssh heat-admin@controllere
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]# docker ps \
--format="table {{.Names}}\t{{.Status}}"
NAMES STATUS
ovn-dbs-bundle-docker -0 Up 7 hours
openstack -manila-share-docker -0 Up 7 hours
openstack-cinder-volume-docker-@ Up 7 hours
haproxy-bundle-docker -9 Up 7 hours
redis-bundle-docker -0 Up 7 hours
galera-bundle-docker -0 Up 7 hours
.., Output omitted...
[root@controller0 ~]# exit
[heat-admin@controller0 ~]$ exit
|
登录 compute0,执行 sudo -i 获得 root 权限,再运行 docker ps 列出容器。退出并登录 computehci0,同样切换为 root 并执行 docker ps。比较两个节点的差异,然后退出 computehci0。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| (undercloud) [stack@director ~]$ ssh heat-admin@compute0
[heat-admin@compute0 ~]$ sudo -i
[root@compute0 ~]# docker ps \
--format="table {{.Names}}\t{{.Status}}"
NAMES STATUS
ovn_me tadata_agent Up 8 hours (healthy)
ovn_controller Up 8 hours
nova_compute Up 8 hours (healthy)
logrotate_crond Up 8 hours
ceilometer_agent_compute Up 8 hours
nova_migration_target Up 8 hours
iscsid Up 8 hours
nova_libvirt Up 8 hours
nova_virtlogd Up 8 hours
[root@compute0 ~]# exit
[heat-admin@compute0 ~]$ exit
(undercloud) [stack@director ~]$ ssh heat-admin@computehci0e
[heat-admin@computehci0 ~]$ sudo -i
[root@computehci0 ~]# docker ps \
--format="table {{.Names}}\t{{.Sstatus}}"
NAMES STATUS
ceph-osd-computehci0-vde Up 8 hours
ceph-osd-computehci00-vdd Up 8 hours
ceph-osd-computehci0-vdb Up 8 hours
ovn_controller Up 8 hours
ovn_metadata_agent Up 8 hours (healthy)
logrotate_crond Up 8 hours
nova_compute Up 8 hours (healthy)
nova_migration_target Up 8 hours
|
操作界面、表格与配置图
1
2
3
4
5
6
| ceilometer_agent_compute Up 8 hours
iscsid Up 8 hours
nova_libvirt Up 8 hours
nova_virtlogd Up 8 hours
[root@computehci0 ~]# exit
[heat-admin@computehci0 ~]$ exit
|
以 heat-admin 用户登录 ceph0,执行 sudo -i 获得 root 权限,再执行 docker ps 列出容器,最后退出 ceph0。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| (undercloud) [stack@director ~]$ ssh heat-admin@ceph0
[heat-admin@ceph0 ~]$ sudo -i
[root@ceph0 ~]# docker ps \
--format="table {{.Names}}\t{{.Status}}"
NAMES STATUS
ceph-osd-ceph0-vdb Up 8 hours
ceph-osd-ceph0-vdc Up 8 hours
ceph-osd-ceph0-vdd Up 8 hours
logrotate_crond Up 8 hours
[root@ceph0 ~]# exit
[heat-admin@ceph0 ~]$ exit
logout
Connection to ceph0 closed.
(undercloud) [stack@director ~]$
|
使用 docker 命令来停止 nova_api 容器。审查容器的状况并重新启动它。确保容器返回 healthy 状态。
以 heat-admin 用户登录 controller0,执行 docker stop 停止 nova_api 容器,用 docker ps 检查状态,再执行 docker start 重新启动。根据需要等待并再次检查,直到状态为 healthy。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [student@workstation ~]$ ssh heat-admin@controller0
Last login: Mon Aug 27 12:14:20 2018 from 172.25.250.200
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]# docker stop nova_api
nova_api
[root@controller0 ~]# docker ps -a \
--format="table {{.Names}}\t{{.Status}}" | grep nova_api
.., output omitted...
nova_api Exited (©) 2 minutes ago
.. Output omitted...
[root@controller0 ~]# docker start nova_api
nova_api
[root@controller0 ~]# docker ps \
--format="table {{.Names}}\t{{.Status}}" | grep nova_api
nova_api Up 26 seconds (health: starting)
.. output omitted...
[root@controller0 ~]# docker ps \
--format="table {{.Names}}\t{{.Status}}" | grep nova_api
nova_api Up 31 seconds (healthy)
.. output omitted...
|
操作界面、表格与配置图
5. 在 controller0 和 compute0 节点上,查看 eth0、 vlan 和 br-ex 接口。列出 OVS 桥。列出 br-ex 和 br-trunk 上的 OVS 接口。
在 controller0 上列出 eth0、VLAN 和 br-ex 接口,列出 OVS 网桥及 br-ex、br-trunk 的接口,然后退出。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| (undercloud) [stack@director ~]$ ssh heat-admin@controllere
[heat-admin@controller0 ~]$ ip addr | grep -E 'etho|vlan|br-ex'
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state
inet 172.25,.249.59/24 brd 172.25.249.255 scope global etho
inet 172.25.249.50/32 brd 172.25.249.255 scope global etho
10: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.25.250.1/24 brd 172.25.250.255 scope global br-ex
inet 172.25.250.50/32 brd 172.25.250.255 scope global br -ex
14: vlan40: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.4.1/24 brd 172.24.4.255 scope global vlan4o
inet 172.24.4.50/32 brd 172.24.4.255 scope global vlan4o
15: vlan20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.2.1/24 brd 172.24.2.255 scope global vlan20
16: vlani9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.1.1/24 brd 172.24.1.255 scope global vlanio
inet 172.24,.1.51/32 brd 172.24.1.255 scope global vlanio
inet 172.24.1.50/32 brd 172.24.1.255 scope global vlanio
17: vlan30: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.3.1/24 brd 172.24.3.255 scope global vlan30
inet 172.24.3.50/32 brd 172.24.3.255 scope global vlan30
18: vlan50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24,.5.1/24 brd 172.24.5.255 scope global vlan5oe
[heat-admin@controller0 ~]$ sudo ovs-vsctl list-br
br-eth3
br-eth4
br-ex
br-int
br-trunk
[heat-admin@controller0 ~]$ sudo ovs-vsctl list-ifaces br-trunk
eth
vlani0
vlan20
vlan30
vlan4o
vlan50
[heat-admin@controller0 ~]$ sudo ovs-vsctl list-ifaces br-ex
eth2
patch-provnet-f8366a5d-9cf9 -4d38-9760-9cf9df4eceaa- to-br-int
[heat-admin@controller0 ~]$ exit
|
以 heat-admin 用户登录 compute0,列出 eth0、VLAN 和 br-ex 接口,列出 OVS 网桥及 br-ex、br-trunk 的接口,然后退出。
1
2
3
4
5
6
| (undercloud) [stack@director ~]$ ssh heat-admin@compute0
[heat-admin@compute0 ~]$ ip addr | grep -E 'etho|vlan|eth2'
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state
inet 172.25,.249.53/24 brd 172.25.249.255 scope global etho
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-
system state
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| 14: vlani0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.1.2/24 brd 172.24.1.255 scope global vlanio
15: vlan20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.2.2/24 brd 172.24.2.255 scope global vlan20
16: vlan30: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.3.2/24 brd 172.24.3.255 scope global vlan30
17: vlan50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.5.2/24 brd 172.24.5.255 scope global vlan5e
[heat-admin@compute0 ~]$ sudo ovs-vsctl list-br
br-eth3
br-eth4
br-ex
br-int
br- trunk
[heat-admin@compute0 ~]$ sudo ovs-vsctl list-ifaces br-trunk
eth
vlanio
vlan20
vlan3o
vilan50
[heat-admin@compute0 ~]$ exit
|
在 workstation 上加载 ~/operator1-production-rc Keystone 凭据文件。使用下表属性在 production 项目中创建实例,确认服务器状态为 ACTIVE。在 provider-datacentre 网络中创建浮动 IP,并将其关联到实例。
实例属性
加载 ~/operator1-production-rc 文件,以 operator1 用户启动实例,将其命名为 production-server1。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ source operator1i-production-rc
[student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--key-name example-keypair \
--nic net-id=production-network1 \
--security-group default \
--image production-rhel7 \
production-server1 --wait
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| Tee SE eg NS Et SSE PSE NRO eT SE PS NO CSE PN pe ae eS ET
| Field | Value |
RN Ne CE CT CT I
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-STS: power_state | Running |
| OS-EXT-STS: task_state | None |
| OS-EXT-STS: vm_state | active |
| OS-SRV-USG: launched_at | 2018-08-27T13:39:06.000000 |
| OS-SRV-USG: terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | production -network1=192.168.1.1 |
| adminPass | @Ck] YFEhHKH9Q |
| config_drive | |
| created | 2018 -08 -27T13:38:16Z |
| flavor | default (c620...6cOf) |
| hostiId | 8bb2...d4e4 |
| id | c82c...15ee |
| image | production-rhel7 (d4c2...7beo) |
| key_name | example-keypair |
| name | production-server1 |
| progress | 9 |
| project_id | eelb8ae964ee4ab3b2edf3 fbc7791a40 |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018 -08-27T13:39:06Z |
| user_id | 9951cbcoe9af6486c8fasdf513bess89Ff1|
| volumes_at tached | |
Tete ee SNe Sem Ne SO eT Ne Ne See ee ET
[student@workstation ~(operator1-production)]$ openstack server list \
-c Name -c Status
|
执行 openstack floating ip create,在 provider-datacentre 网络中创建浮动 IP。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~(operator1-production)]$ openstack floating ip create \
provider-datacentre
Se ee
| Field | Value |
fen nnn ne ee ee ee ee pe ee ee ee et
| created_at | 2018-08-27T13:20:58Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.N |
| floating_network_id | f836...ceaa |
| id | 9779...4ed8 |
| name | 172.25.250.113 |
| port_id | None |
| project_id | eelb...1a40 |
|
|
| | | |
|
|
1
2
| | floating_ip_address | 172.25.250.N |
| floating_network_id | f836...ceaa |
|
|
| | | |
1
2
3
4
| id | 9779...4ed8
name | Wé2.,25., 250: 113
port_id | None
project_id | eelb...1a40
|
|
|
|
操作界面、表格与配置图
1
2
3
4
5
6
7
| | qos_policy_id | None |
| revision_number | oe |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-08-27T13:20:582 |
fies eet a eeeemt mareel ee ee Nanterreent etree ee neat Nerve ea eres Narra eaten eetierte
|
将浮动 IP 地址附加到活动服务器上,并核实其响应。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-server1 172.25.250.N
[student@workstation ~(operator1-production)]$ ping -c3 172.25.250.N
PING 172. 25.250.113 (172.25.250.113) 56(84) bytes of data.
64 bytes from 172.25.250.113: icmp_seq=1 ttl=63 time=0.346 ms
64 bytes from 172.25.250.113: icmp_seq=2 ttl=63 time=0.403 ms
64 bytes from 172.25.250.113: icmp_seq=3 ttl=63 time=0.375 ms
=== 172.625.250.113 ping statistics -=--
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.346/0.374/0.403/0.032 ms
|
使用关联的浮动地址登录实例,测试外部网络访问:从 production-server1 ping 网络网关。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(operator1-production)]$ ssh cloud-user@172.25.250.
[cloud-user@production-server1 ~]$ ping -c3 172.25.250.254
PING 172.25.250.254 (172.25.250.254) 56(84) bytes of data.
64 bytes from 172.25.250.254: icmp_seq=1 ttl=63 time=0.804 ms
64 bytes from 172.25.250.254: icmp_seq=2 ttl=63 time=0.847 ms
64 bytes from 172.25.250.254: icmp_seq=3 ttl=63 time=0.862 ms
--- 172.25.250.254 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.804/0.837/0.862/0.041 ms
|
完成测试后,退出 production-server1 服务器实例。
1
2
| [cloud-user@production-server1 ~]$ exit
[student@workstation ~(operator1-production)]$
|
在 workstation 上运行 lab architecture-lab grade,检查本实验是否成功。
1
| [student@workstation ~(operator1-production)]$ lab architecture-lab grade
|
清理:在 workstation 上运行 lab architecture-lab cleanup,清理本实验。
1
| [student@workstation ~(operator1-production)]$ lab architecture-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- Undercloud 的主要职责是什么?
- 容器处于运行状态后,还需要确认什么?
自测答案#
- 部署并管理 Overcloud 基础设施 Undercloud 是 Director 管理部署基础设施的平台;租户工作负载由 Overcloud 提供。
- API、依赖服务及业务动作是否正常。容器运行只是进程层面的证据,不能证明服务依赖及业务路径正常。
C2-理解 OpenStack 控制平面#
API 是入口,消息代理负责内部协作#
客户端首先使用身份服务获得认证信息,并根据服务目录访问目标 API。API 服务接收请求后,可能通过消息代理与其他进程协作,最终由负责具体操作的服务执行。数据库保存服务所需的状态;它与消息队列承担不同职责。
| 环节 | 要回答的问题 | 典型证据 |
|---|
| 认证 | 当前身份能否获得有效令牌? | 认证结果、作用域和认证端点 |
| API 访问 | 请求是否到达正确的服务? | 端点、HTTP 响应、API 日志 |
| 内部通信 | 服务之间能否发送和处理消息? | 代理状态、连接与服务日志 |
| 状态与执行 | 状态是否更新,任务是否实际完成? | 资源状态、数据库相关错误、工作进程日志 |
API 查询与资源创建的差异#
成功取得资源列表与成功创建资源不是同一条执行路径。只读请求可能很快返回,而创建实例需要多项服务协作。排查时,应以具体失败动作和请求时间为起点,检查相应的服务链路,而不是仅测试 API 端口。
控制平面服务的关联#
控制节点集中运行多项服务,故障可能来自共同依赖。若多个服务同时异常,先比较它们是否共用消息代理、数据库、认证服务或网络路径。避免在未定位共同原因时逐个重启所有组件,否则可能丢失最有价值的现场证据。
控制平面验证#
观察消息代理时,要区分代理进程存在、连接正常、消息能够被消费。查看 Overcloud 控制平面服务时,把容器、服务配置和日志联系起来。综合实验中的每一次修复都应重新执行原先失败的业务动作,证明通信恢复确实解决了问题。
控制平面分工#
| 组件 | 职责 | 观察重点 |
|---|
| HAProxy | API 流量入口与后端转发 | VIP、监听端口、后端健康 |
| MariaDB / Galera | 数据持久化与数据库集群 | 服务连通性、同步与查询错误 |
| RabbitMQ | RPC 与消息传递 | 连接、队列、消费者、积压 |
| Memcached | 缓存 | 可达性、命中与连接状态 |
| Redis | 协调等服务依赖 | 实际配置用途、连接与状态 |
| Pacemaker / Corosync | 高可用资源管理与集群协作 | 资源归属、故障、仲裁 |
RPC 与 Notification#
- RPC:服务请求另一个组件执行工作,可以涉及请求与回复。
- Notification:发布发生了什么事件,供其他组件处理。
- 消息队列负责传递工作,数据库负责保存状态;队列有消息不代表消费者已完成操作。
实验观测命令#
1
2
3
4
5
6
7
8
| # controller,root 或 sudo
sudo ss -lntp
sudo pcs status
sudo pcs resource show
sudo docker ps --format '{{.Names}}\t{{.Status}}'
# 使用刚查到的 RabbitMQ 实际容器名
sudo docker exec <RabbitMQ容器名> rabbitmqctl cluster_status
sudo docker exec <RabbitMQ容器名> rabbitmqctl list_queues name messages consumers
|
messages 增长且无人消费时,继续查 worker 连接、认证和服务日志;仅有短暂积压不能直接断定故障。实验启用消息追踪用于解释通信,完成后需关闭。
常见监听端口#
| 默认端口 | 典型用途 |
|---|
| 5672 | RabbitMQ AMQP |
| 3306 | MariaDB |
| 11211 | Memcached |
| 6379 | Redis |
| 6080 | noVNC proxy |
这是默认用途对照;部署可能有 VIP、TLS 或不同监听配置,以实际 endpoint 和配置为准。
高可用资源的管理边界#
被 Pacemaker 管理的资源应通过对应资源管理机制操作。手工停止一个底层进程后,高可用管理器可能重新拉起它;这不等于停止命令失效。先确认 pcs resource show 与容器的映射,再开展维护。
实验操作#
引导练习:理解消息代理中的服务通信#
引导练习#
理解消息代理中的服务通信#
本练习将在 RabbitMQ 中启用消息跟踪,并在部署实例时监控指定组件。
学习目标#
完成后,能够:
在 RabbitMQ 中启用并禁用追踪。
定位与特定任务或组件有关的消息。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab controlplane-message setup 命令,这样可以确保部署实例的所有要求都存在。
1
| [student@workstation ~]$ lab controlplane-message setup
|
从 workstation 通过 SSH 连接 controller0,再执行 sudo -i 切换为 root。
1
2
3
| [student@workstation ~]$ ssh controller0
[heat-admin@controller0 ~]$ sudo -i
[root@controllere ~]#
|
使用 docker exec 和 rabbitmqctl 在 RabbitMQ 中创建 tracer 用户,密码为 redhat。
1
2
3
| [root@controller0 ~]# docker exec -t rabbitmq-bundle-docker-0 rabbitmqctl \
add_user tracer redhat
Creating user "tracer"
|
配置 tracer 用户权限,使用通配符为 configure、write 和 read 三项权限指定全部资源。
1
2
3
| [root@controller0 ~]# docker exec -t rabbitmq-bundle-docker-0 rabbitmqctl \
set_permissions tracer ".*" ".*#" ule
Setting permissions for user "tracer" in vhost "/"
|
使用 docker exec 和 rabbitmqctl trace_on 启用 RabbitMQ 跟踪。
操作界面、表格与配置图
1
2
| [root@controller0 ~]# docker exec -t rabbitmq-bundle-docker-0 rabbitmqctl trace_on
Starting tracing for vhost "/"
|
确定 RabbitMQ 正在监听的接口,默认端口为 5672。
1
2
| [root@controller0 ~]# ss -tnlp | grep :5672
LISTEN Q 128 172.24.1.1:5672 toe users: (("beam.smp", pid=12730, fd=56 ))
|
提供的 Python 脚本会消费 amq.rabbitmq.trace 交换机中的消息。使用 -u 和 -p 指定 tracer 用户及密码,用 -t 指定上一步找到的目标 IP。将输出重定向到 /tmp/rabbit.trace 以便分析。
1
2
| [root@controller0 ~]# ~/rmq_trace.py -u tracer -p redhat -t 172.24.1.1 \
> /tmp/rabbit.trace
|
在 workstation 打开第二个终端,以 finance 项目的 developer1 用户认证。使用可用的默认资源启动实例,并等待部署完成。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$ openstack server create \
--image rhel7 \
--flavor default \
--security-group default \
--key-name example-keypair \
--nic net-id=finance-network1 \
finance-server2 --wait
.. Output omitted...
|
在第一个终端中停止 rmq_trace.py,使用 docker exec 和 rabbitmqctl 禁用跟踪。
1
2
3
| [root@controller0 ~]# docker exec -t rabbitmq-bundle-docker-0 rabbitmqctl \
trace_off
Stopping tracing for vhost "/"
|
在 /tmp/rabbit.trace 跟踪日志中搜索 finance-server2。
第一个结果的路由键为 publish.nova,消息头中包含 conductor。整条消息使用 JSON 格式,可以用 echo ‘’ | jq . 将其中的片段重新格式化,以便阅读。下面的片段显示实例规格。
1
2
3
4
| "disabled": false,
"root_gb": 10,
"description": null,
"flavorid": "26df78d4-9aa7-4e57 - 9cdb-9e96503b82e2",
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| "deleted": false,
"created_at": "2018-08-20T05: 27:03Z",
"ephemeral_gb": 0,
"updated_at": null,
"memory_mb": 2048,
AVGDUS2 25
"extrasspecs": {},
"swap": 0,
"rxtx: factor: 1.0,
"is_public": true,
"deleted_at": null,
"vcpu_weight": 0,
Malfolnm: Ay
"name": "default"
I
|
在有效载荷的其他部分,单个值是可见的,例如:
您可以在此看到密钥对 :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| {
"public_key": "ssh-rsa AAAAB3NZaC1yc2EAAAADAQABAAABAQDHUTCMZG95rJkX
HZOe+7 rHMaf3me7 geAfdYAc2fuokjSVoBni4aF4mMyksm
b1UYyXjtQ++x2+i113+0sn9FJZmvdaoOmagT6DuIcpiAxl]
dVrnNJFv5LIVFGiFDbUgLThPc25Ytn/bwqgo2pFIZ4Nc
9VN+PZVETeVL8b0tMVWPQ44MRUXCCM+UaHO1mMBD2pcEn
PQLR/MZYxTzzdvj P5iBn4GAp7Kj Uw/+FvVBhINiksXxJjQ
GI6MHbCZhtgsntJz17tkKGY4SgJXZaUDOTNpPeCBLEmWN
UZ4hAOVMT11ZA4F LAmMI7yZqwRcr 4EVnqbmZcé6cf Ihvxb
1J69UHNK6 2KS6513MP3v Generated-by-Nova\\n",
"user_id": "72b24f0a94c24e34a76C7fD6F2F81637",
"name": ""example-keypair",
"deleted": false,
"created_at": "2018-08-20T05: 26:53Z",
"updated_at": null,
"Eingerprints: "aiboibbi2eraere7139 5d751256100720:8hrabico.t,
"deleted_at": null,
"type: "sshts,
Halolas v
t
|
搜索 publish.neutron,可以找到有关端口创建的消息。
1
| "event_type": "port.create. start"
|
提取 payload 的值并重新格式化,即可查看端口信息。
1
2
3
4
5
| ik
"ort: 4.
"network_id": "d67924dc-5dfo-4f17-bd4e-53a77dc9fifa",
"tenant_id": "db84762b38604849903c425e046704bf",
"device_id": "b455f85e-90f6-4591-b835-f8b885ed78d5",
|
操作界面、表格与配置图
1
2
3
4
| "security_groups": [
"1202065a-24ef-4fac-90fd -f5d9bof2aeci"
1,
"admin_state_up": true
|
搜索 PortBinding , 您可以看到该端口被绑定到实例中。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| {
"resource_list": [
{
"versioned_object.version": "1.1",
"versioned_object.name": "Port",
"versioned_object.data": {
"allowed_address_pairs": [],
"binding": {
"versioned_object.version": "1.0",
"versioned_object.name": "PortBinding",
"versioned_object.data": {
"profile": "{}",
"status": "ACTIVE",
"vif_type": "unbound",
"vif_details": null,
"vnic_type": "normal",
HOS es) tte,
"port_id": "8d9a9ac3-811e-4d32 -9055-e8e1a48764T6"
ty
"versioned_object.namespace": "versionedobjects"
},
"updated_at": "2018-08-23T01:29: 28Z",
"device_owner": "",
"revision_number": 6,
"fixed_ips": [
t
"versioned_object.version": "1.0",
"versioned_object.name": "IPAllocation",
"versioned_object.data": {
"subnet_id": "e65ea1f4-12a0-4196 -9e5a-1ce1441b661d",
"network_id": "d67924dc-5df0-4f17 -bd4e-53a77dc9 fifa",
"ip_address": "192.168.1.8",
"port_id": "8d9a9ac3 -811e-4d32-9055-e8e1a487 64f6"
b
"versioned_object.namespace": "versionedobjects"
t
1,
"id": "8d9a9ac3-811e-4d32-9055-e8e1a48764T6",
"description": "",
"name": "")
"dns": null,
"mac_address": "fa:16:3e:09:6a:bb",
"project_id": "db84762b38604849903c425e046704bf",
"dhcp_options": [],
"status": "DOWN",
"binding_levels": [],
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| "security_group_ids": [
"1202065a- 24ef -4fac-90fd-f5d9boef2aeci"
1,
"device_id": "b455f85e-90f6-4591-b835-f8b8s5ed78d5",
"qos_policy_id": null,
"admin_state_up": true,
"network_id": "d67924dc-5df0-4f17-bd4e-53a77dc9fifa",
"created_at": "2018-08-23TO1:29:28Z",
"distributed_binding": null,
"Security": {
"versioned_object.version": "1.0",
"versioned_object.name": "PortSecurity",
"versioned_object.data": {
"port_security_enabled": true,
"id": "8d9a9ac3 -811e-4d32-9055-e8e1a487 64f6"
,
"versioned_object.namespace": "versionedobjects"
}
ty
"versioned_object.namespace": "versionedobjects"
t
1,
"event_type": "updated"
t
[root@controller0 ~]# exit
[heat-admin@controller0 ~]$ exit
[student@workstation ~]$
|
消息系统提供了大量信息,可用于故障排查。
在 workstation 上执行 lab controlplane-message cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab controlplane-message cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:查看 Overcloud 控制平面服务#
引导练习#
查看 Overcloud 控制平面服务#
在本练习中,查看 Overcloud 控制平面服务。
学习目标#
完成后,能够:
列出MariaDB数据库。
停止并启动集群资源。
校验 Redis 的功能。
校验 Memcached 的功能。
从命令行连接到实例 console。
开始之前#
以 student 用户登录 workstation,密码为 student。
在workstation,运行 lab controlplane-services setup 命令。
1
| [student@workstation ~]$ lab controlplane-services setup
|
从 workstation 通过 SSH 连接 controller0,再执行 sudo -i 切换为 root。
1
2
3
| [student@workstation ~]$ ssh controllere
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
检查 Ceph Monitor 服务的状况。注意被点出的细节。
1
2
3
4
5
6
7
8
9
10
11
| [root@controller0 ~]# systemctl status ceph-mon@controller0.service -1 -n 9
e ceph-mon@controller0.service - Ceph Monitor
Loaded: loaded (/etc/systemd/system/ceph-mon@.service; @enabled; vendor
preset: disabled)
Active: active (running) since Sun 2018-08-26 22:29:21 UTC; 4h 52min ago
Process: 6051 Qexecstartpre=/usr/bin/docker rm ceph-mon-%1i (code=exited,
status=1/FAILURE)
Main PID: 6085 (docker-current)
cGroup: /system.slice/system-ceph\x2dmon.slice/ceph-mon@controller0.service
6085 O/usr/bin/docker-current run --rm --name ceph-mon-controller0o
--net=host --memory=1g --cpu-quota=100000 -v /var/lib/ceph:/var/lib/ceph:z -v /
|
操作界面、表格与配置图
1
2
3
4
| etc/ceph: /etc/ceph:z -v /var/run/ceph:/var/run/ceph:z -v /etc/localtime:/etc/
localtime:ro --net=host -e IP_VERSION=4 -e MON_IP=172.24.3.1 -e CLUSTER=ceph -e
FSID=f9d61d02-a355-11¢8 -ae2b-52540001fac8 -e CEPH_PUBLIC_NETWORK=172.24.3.0/24 -e
CEPH_DAEMON=MON 172. 25.249. 200:8787/rhceph/rhceph-3-rhel7:latest
|
0008#
服务已设为开机启用。
服务正在运行。
启动前移除所有现有实例。
进程的完整命令行。
检查 Ceph 元数据服务器服务的状况。注意被点出的细节。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [root@controller0 ~]# systemctl status ceph-mds@controller0.service -1 -n
e ceph-mds@controller0.service - Ceph MDS
Loaded: loaded (/etc/systemd/system/ceph-mds@.service; @enabled; vendor
preset: disabled)
Active: active (running) since Sun 2018-08-26 22:29:21 UTC; 5h 33min ago
Process: ©6o72 ExecStartpre=/usr/bin/docker rm ceph-mds-controller0
(code=exited, status=1/FAILURE)
Process: 6050 ExecStar tPre=/usr/bin/docker stop ceph-mds-controller0
(code=exited, status=1/FAILURE)
Main PID: 6148 (docker-current)
cGroup: /system.slice/system-ceph\x2dmds.slice/ceph-mds@controller0.service
L6148 O/usr/bin/docker-current run --rm --net=host --memory=4g
--cpu-quota=100000 -v /var/lib/ceph:/var/lib/ceph:z -v /etc/ceph: /etc/ceph: z
-v /var/run/ceph: /var/run/ceph:z -v /etc/localtime:/etc/localtime:ro -e
CLUSTER=ceph -e CEPH_DAEMON=MDS -e MDS_NAME=controller0 --name=ceph-mds-
controller0 172,.25.249. 200: 8787/rhceph/rhceph-3-rhel7: latest
|
服务为 enabled。
00080#
服务正在运行。
启动前移除并停止所有现有实例。
进程的完整命令行。
列出 MariaDB 数据库,以查看哪些组件正在关系数据库中存储数据。
在 galera-bundle-docker-0 容器中执行 mysql -u root -e “show databases;"。
1
2
3
4
5
6
7
8
9
10
11
| [root@controller0 ~]# docker exec -t \
galera-bundle-docker-0 mysql -u root -e "show databases;"
ee
| Database |
She acaceetceteraec ece
| aodh |
| cinder |
| glance |
| gnocchi |
| heat |
| information_schema |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| keys tone |
manila |
mysql |
nova |
nova_api |
nova_cello |
nova_placement |
octavia |
ovs_neutron |
panko |
performance_schema |
|
除了在 Galera 容器中执行命令,也可以从外部查询 MariaDB。
定位 root MariaDB 用户的密码。
1
2
3
4
| [root@controller0 ~]# grep ^password \
/var/lib/config-data/puppet-generated/mysq1/root/.my.cnf
pas sword="3T8pj 6NU9F"
password="3T8pj6NU9F"
|
确定 MariaDB 监听的接口。
1
2
3
| [root@controller0 ~]# ss -tnlp | grep 3306
LISTEN © 128 172.24.1.1:3306 as users: (("mysqld", pid=16796, fd=28))
LISTEN © 128 172.24.1.50:3306 ee users: (("haproxy", pid=14849, fd=26) )
|
连接 MariaDB 并列出数据库。两个接口均可使用,HAProxy 会将连接转发给 MariaDB。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| [root@controller0 ~]# mysql -uroot \
-p3TSpj]6NugF \
-h172.24.1.50 \
-e"show databases;"
EE ones eneSeyi Speen enesse
| Database |
Se et eetSete tate a ee
| aodh |
| cinder |
| glance |
| gnocchi |
| heat |
| information_schema |
| keystone |
| manila |
| mysql |
| nova |
| nova_api |
| nova_cello |
| nova_placement |
| octavia |
| ovs_neutron |
| panko |
| performance_schema |
|
操作界面、表格与配置图
查询 Redis 以确保它可用。找到 Redis 密码。
1
2
3
| [root@controller0 ~]# docker exec -t redis-bundle-docker-0 \
grep "requirepass /etc/redis.conf
requirepass q3w8WwR4GbJaBhy64t9f2kckHD
|
确定 Redis 监听的接口。
1
2
| [root@controller0 ~]# ss -tnlp | grep redis
LISTEN © 128 172.24.1.1:6379 ee users: (("redis-server",pid=17715, fd=4) )
|
使用 redis-cli 命令连接到 Redis。使用 AUTH 命令和先前获取的密码进行认证。
1
2
3
4
| [root@controller0 ~]# redis-cli -h 172.24.1.1
172.24.1.1:6379> AUTH q3W8WR4GbJaBhy64t9f2kckHD
OK
172.24.1.1:6379>
|
执行 KEYS 列出所有键,实际结果可能不同。确认 gnocchi-config 键的类型,用 HGETALL 获取其全部哈希值,然后退出 Redis CLI。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| 172.24.1.1:6379> KEYS *
1) "_tooz_beats:controller0.0.95d6c52b-bfOb-4802-89b6-bc88e9ddoee4"
2) "_tooz_group:gnocchi -processing"
3) "_tooz_group:compute-computed.overcloud.example.com"
4) "_tooz_group:central-global"
5) "_tooz_group:alarm_evaluator"
6) "_tooz_group:compute-compute1.overcloud.example.com"
7) "_tooz_beats:controller0.@.11d314d7-8b44-45c9-a98d -5838cb682f30"
8) "_tooz_beats:e/ebea7f-7 f04 -4006 -a493-a96a64CC2606"
9) "_tooz_beats:bc92a536-09CC -43¢4-867a-2C47 2e7e144c"
10) "_tooz_groups"
11) "_tooz_beats: 9c9af69a-fO9a-449f -8dbb-e1b7edb63f90"
12) "gnocchi-config"
172,.24.1.1:6379> TYPE gnocchi-config
hash
172.24.1.1:6379> HGETALL gnocchi-config
1) "sacks"
2) "128"
172.24.1.1:6379> exit
[root@controller0 ~]#
|
检查memcached
确定 Memcached 监听的接口。
1
| [root@controller0 ~]# ss -tnlp | grep memcached
|
操作界面、表格与配置图
1
| LISTEN © 128 172.24.1.1:11211 =e users: (("memcached",pid=4559, fd=16))
|
在 memcached 容器中执行 memcached-tool,默认显示 slab 类的统计信息。
1
2
3
4
| [root@controller0 ~]# docker exec -t memcached memcached-tool 172.24.1.1
# Item_Size Max_age Pages Count Full? Evicted Evict_Time OOM
6 304B 85s 1 1 yes ic} to} ic}
23 13.6K 2638S Ba 3 yes 0 0 ic}
|
上面显示两个 slab 类,实际结果可能不同。可以查看大小、存续时间及其他信息。
再次执行 memcached-tool,并使用 stats 选项。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| [root@controller0 ~]# docker exec -t memcached memcached-tool 172.24.1.1 stats
#172.24.1.1:11211 Field Value
accepting_conns ak
auth_cmds iC)
auth_errors (o)
by tes 33823
bytes_read 299122
bytes_written 3123740
cas_badval (0)
cas_hits (0)
cas_misses (o)
cmd_flush (0)
cmd_get 305
cmd_set 60
cmd_touch (0)
conn_yields (0)
connection_structures 5
crawler_items_checked (0)
crawler_reclaimed (c)
curr_connections 4
curr_items 4
decr_hits (0)
decr_misses (o)
delete_hits (0)
delete_misses (0)
evicted_unfetched (0)
evictions (0)
expired_unfetched 17
get_expired 17
get_flushed (0)
get_hits 281
get_misses 24
hash_bytes 524288
hash_is_expanding (0)
hash_power_level 16
incr_hits (0)
incr_misses (0)
libevent 2.0.21-stable
limit_maxbytes 4100980736
listen_disabled_num (0)
log_watcher_sent (o)
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| log_watcher_skipped (c)
log_worker_dropped (0)
log_worker_written (0)
lrutail_reflocked (0)
malloc_fails (o)
pid 7
pointer_size 64
reclaimed 21
reserved_fds 10
rusage_system ©. 201163
rusage_user 0.080465
threads 2
time 1535415920
time_in_listen_disabled_us (o)
total_connections 6
total_items 60
touch_hits (C)
touch_misses (o)
uptime 3052
version 1.4.39
|
这里有几条信息:
curr_items 的值应该与 slab 类输出中的计数列总数相符。
cmd_set 和 cmd_get 的值反映缓存比例。cmd_get 的值应更高;否则,缓存项可能过快过期。
get_misses 的值表示请求的缓存项不存在的次数。
使用 pcs 管理 Pacemaker 资源。
执行 pcs resource show,检查全部 Pacemaker 资源状态。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [root@controller0 ~]# pcs resource show
Docker container: rabbitmq-bundle [172.25.249.200:8787/rhosp13/openstack-
rabbitmq: pcmklatest]
rabbitmq-bundle-0 (ocf:: heartbeat: rabbitmq-cluster): Started controller0
Docker container: galera-bundle [172.25.249.200:8787/rhosp13/opens tack -
mariadb: pcmklatest ]
galera-bundle-9 (ocf::heartbeat:galera): Master controller0
Docker container: redis-bundle [172.25.249.200:8787/rhosp13/opens tack -
redis: pcmklatest]
redis-bundle-0 (ocf::heartbeat:redis): Master controller0
ip-172.25.249.50 (ocf:: heartbeat: IPaddr2): Started controller0
ip-172.25.250.50 (ocf:: heartbeat: IPaddr2): Started controller0
ip-172.24.1.51 (ocf: :heartbeat:IPaddr2): Started controller0
ip-172.24.1.50 (ocf: :heartbeat:IPaddr2): Started controllere
ip-172.24.3.50 (ocf: :heartbeat:IPaddr2): Started controller0
ip-172.24.4.50 (ocf: :heartbeat:IPaddr2): Started controller0
Docker container: haproxy-bundle [172.25.249.200:8787/rhosp13/openstack -
haproxy:pcmklatest]
haproxy-bundle-docker-0 (ocf::heartbeat:docker): Started controller0
Docker container: ovn-dbs-bundle [172.25.249.200:8787/rhosp13/openstack -ovn-
nor thd: latest]
|
操作界面、表格与配置图
1
2
3
4
5
6
7
| ovn-dbs-bundle-9 (ocf::ovn:ovndb-servers): Master controller0
Docker container: openstack-cinder-volume [172.25.249.200:8787/rhosp13/openstack-
cinder -volume: pcmklatest ]
openstack-cinder-volume-docker-0 (ocf::heartbeat:docker): Started controller0
Docker container: openstack-manila-share [172.25.249.200:8787/rhosp13/openstack-
manila-share:pcmklatest]
openstack-manila-share-docker-0 (ocf::heartbeat:docker): Started controller0
|
禁用 openstack-manila-share,再执行 pcs resource show 确认结果。
1
2
3
4
5
6
| [root@controller0 ~]# pcs resource disable openstack-manila-share
[root@controller0 ~]# pcs resource show
... Output omitted...
Docker container: openstack-manila-share [172.25.249.200:8787/rhosp13/openstack-
manila-share:pcmklatest]
openstack-manila-share-docker-@ (ocf::heartbeat:docker): Stopped (disabled)
|
启用 openstack-manila-share,执行 pcs resource show openstack-manila-share 查看详情。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| [root@controller0 ~]# pcs resource enable openstack-manila-share
[root@controller0 ~]# pcs resource show openstack-manila-share
Bundle: openstack-manila-share
Docker: image=172.25.249. 200:8787/rhosp13/openstack-manila-share:pcmklatest
network=host options="--ipc=host --privileged=true --user=root --log-
driver=journald -e KOLLA_CONFIG_STRATEGY=COPY_ALWAYS" replicas=1 run-command="/
bin/bash /usr/local/bin/kolla_start"
Storage Mapping:
options=ro source-dir=/var/lib/kolla/config_files/manila_share.json target-
dir=/var/lib/kolla/config_files/config.json (manila-share-cfg-files)
options=ro source-dir=/var/lib/config-data/puppet-generated/manila/ target-
dir=/var/lib/kolla/config_files/src (manila-share-cfg-data)
options=ro source-dir=/etc/hosts target-dir=/etc/hosts (manila-share-hosts)
options=ro source-dir=/etc/localtime target-dir=/etc/localtime (manila-share-
localtime)
options=rw source-dir=/dev target-dir=/dev (manila-share-dev)
options=rw source-dir=/run target-dir=/run (manila-share-run)
options=rw source-dir=/sys target-dir=/sys (manila-share-sys)
options=ro source-dir=/lib/modules target-dir=/lib/modules (manila-share-lib-
modules)
options=rw source-dir=/var/lib/manila target-dir=/var/lib/manila (manila-share-
var -lib-manila)
options=ro source-dir=/etc/pki/ca-trust/extracted target-dir=/etc/pki/ca-trust/
extracted (manila-share-pki-extracted)
options=ro source-dir=/etc/pki/tls/certs/ca-bundle.crt target-dir=/etc/pki/tls/
certs/ca-bundle.crt (manila-share-pki-ca-bundle-crt)
options=ro source-dir=/etc/pki/tls/certs/ca-bundle.trust.crt target-dir=/etc/
pki/tls/certs/ca-bundle. trust.crt (manila-share-pki-ca-bundle-trust-crt)
options=ro source-dir=/etc/pki/tls/cert.pem target-dir=/etc/pki/tls/cert.pem
(manila-share-pki-cert)
options=rw source-dir=/var/log/containers/manila target-dir=/var/log/manila
(manila-share-var-log)
options=ro source-dir=/etc/ceph target-dir=/etc/ceph (manila-share-ceph-cfg-
dir)
[root@controller@ ~]# logout
|
操作界面、表格与配置图
1
2
3
| [heat-admin@controller0 ~]$ logout
Connection to controller0 closed.
[student@workstation ~]$
|
连接到实例的 console。
加载 finance 项目中 developer1 用户的环境文件,获取 finance-server1 实例的控制台 URL。
1
2
3
4
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$ openstack console url show \
-c url -f value finance-server3
http://172.25. 250. 50: 6080/vnc_auto. html? token=99635dd0 -f87b-4b1b-b8cs8 -48biceé6a4afc
|
注意console URL中的端口值为6080。
登录 controller0 并切换为 root,显示监听 6080 端口的进程。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~]$ ssh controllere
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]# ss -tnlp | grep 6080
LISTEN © 128 172.25.250.50:6080 *:* users: (("haproxy",pid=15285,fd=31) )
LISTEN © 128 172.24.1.50:6080 *:* users: (("haproxy", pid=15285, fd=30) )
LISTEN © 100 172.24.1.1:6080 *:* users: (("nova-novncproxy", pid=3902, fd=4) )
[root@controller0 ~]# logout
[heat-admin@controller0 ~]$ logout
Connection to controller0 closed.
[student@workstation ~(developer1-finance)]$
|
注意:所连接的服务为 nova-novncproxy。它通过外部网络上的 HAProxy 接受连接,使用户能够访问管理网络上的实例控制台。
连接到 URL 以验证服务是否有效。
1
2
| [student@workstation ~(developeri1-finance)]$ firefox \
http://172.25.250.50:6080/vnc_auto. html?token=99635dd0 -f87b- 4b1b-b8cs-48bicoéa4afc
|
在 workstation 上运行 lab controlplane-services cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab controlplane-services cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:管理 OpenStack 内部通信#
管理 OpenStack 内部通信#
操作检查清单#
本实验将配置身份服务,使用 memcached 缓存令牌。
学习目标#
完成后,能够:
改变容器化服务的配置。
验证 Memcached 用于令牌缓存的情况。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab controlplane-review setup 命令。这样可以确保环境为这个实验配置妥当。
1
| [student@workstation ~]$ lab controlplane-review setup
|
确定 memcached 的 get_hits 参数当前的增长速率。
为 controller0 上的身份服务启用令牌缓存。使用下表设置配置 /var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf。
| 配置节 | 选项 | 值 |
|---|
| cache | enabled | true |
| cache | backend | dogpile.cache.memcached |
| cache | backend_argument | urLi172).24..1..0:11211 |
| catalog | caching | false |
| domain_config | caching | false |
| federation | caching | false |
| revoke | caching | false |
| role | caching | false |
| token | caching | true |
操作界面、表格与配置图
| 配置节 | 选项 | 值 |
|---|
| token | cache_on_issue | true |
| identity | caching | false |
使用 openstack 命令测试 memcached get_hits 参数值的急剧增长。
在 workstation 上运行 lab controlplane-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab controlplane-review grade
|
在 workstation 上运行 lab controlplane-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab controlplane-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
管理 OpenStack 内部通信#
操作检查清单#
本实验将配置身份服务,使用 memcached 缓存令牌。
学习目标#
完成后,能够:
改变容器化服务的配置。
验证 Memcached 用于令牌缓存的情况。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab controlplane-review setup 命令。这样可以确保环境为这个实验配置妥当。
1
| [student@workstation ~]$ lab controlplane-review setup
|
确定当前memcached get_hits 参数的增长率。从 workstation 登录到 controller0, 并更改为 root 用户。
1
2
3
| [student@workstation ~]$ ssh controller0
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
使用 watch 持续监视 get_hits 参数。
1
2
3
4
5
6
| [root@controller0 ~]# watch -n 5 \
""memcached-tool 172.24.1.1 stats | grep -A2 get_hits"
Every 5.0s: memcached-tool 172.24.1.1 stats | grep -A2 get_hits
get_hits 944
get_misses 88
hash_bytes 524288
|
注意,该值增长得相当缓慢。
为 controller0 上的身份服务启用令牌缓存。使用下表设置配置 /var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf。
操作界面、表格与配置图
| 配置节 | 选项 | 值 |
|---|
| cache | enabled | true |
| cache | backend | dogpile.cache.memcached |
| cache | backend_argument | url:172.24.1.1:11211 |
| catalog | caching | false |
| domain_config | caching | false |
| federation | caching | false |
| revoke | caching | false |
| role | caching | false |
| token | caching | true |
| token | cache_on_issue | true |
| identity | caching | false |
在 workstation 打开新终端,通过 SSH 连接 controller0,然后切换为 root。
1
2
3
| [student@workstation ~]$ ssh controller0
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
使用 crudini 修改相关选项。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| [root@controller0 ~]# crudini --set \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
cache enabled true
[root@controller0 ~]# crudini --set \
/var/1lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
cache backend dogpile.cache.memcached
[root@controller0 ~]# crudini --set \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
cache backend_argument url:172.24.1.1:11211
[root@controller0 ~]# crudini --set \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
catalog caching false
[root@controller0 ~]# crudini --set \
/var/1lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
domain_config caching false
[root@controller0 ~]# crudini --set \
/var/1lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
federation caching false
[root@controller0 ~]# crudini --set \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
revoke caching false
[root@controller0 ~]# crudini --set \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| /var/1lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
role caching false
[root@controller0 ~]# crudini --set \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
token caching true
[root@controller0 ~]# crudini --set \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
token cache_on_issue true
[root@controller0 ~]# crudini --set \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
identity caching false
|
重新启动 keystone 容器以生效更改。
1
2
3
4
5
| [root@controller0 ~]# docker restart keystone
keystone
[root@controller0 ~]# logout
[heat-admin@controller0 ~]$ logout
[student@workstation ~]$
|
使用 openstack 命令测试 memcached get_hits 参数值的急剧增长。
在第一个终端中,验证 get_hits 的当前值。
1
2
3
4
| Every 5.0s: memcached-tool 172.24.1.1 stats | grep -A2 get_hits
get_hits 1283
get_misses 265
hash_bytes 524288
|
在第二个终端中加载 production 项目中 operator1 用户的环境文件,并执行几条 openstack 命令。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| [student@workstation ~]$ source ~/operator1-production-rcec
[student@workstation ~(operator1-production)]$ openstack image list -f json
... output omitted...
{
"Status": "active",
"TD": "47c4a5c1-27cb-49c8-a38a-639654e8bb35",
"Name": "rhel7"
ty
... output omitted...
[student@workstation ~(operator1-production)]$ openstack flavor list -f json
.. Output omitted...
{
"Name": "default",
"RAM": 2048,
"Ephemeral": ©,
"VCPUS": 2,
"Ts Public": true,
"Disk": 10,
"TD": "4d1f2fe1-cb51-4e53 -99b9-00334eaf8c7b"
},
.. Output omitted...
[student@workstation ~(operator1-production)]$ openstack network list -f json
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| ..- Output omitted...
{
"Subnets": "deoc65db-5d75-49a3-b834-ffafb384c4c6",
"ID": "5Q060e33-2385 -45b2-8a23-7fc589a31c8a",
"Name": "production-networki"
J,
..- Output omitted...
[student@workstation ~(operator1-production)]$ openstack subnet list -f json
[
.,. output omitted...
{
"Network": "50060e33 -2385-45b2-8a23 -7fC589a31Cc8a",
"Subnet": "192.168.1.0/24",
"ID": "deecé6ésdb-5d75 -49a3-b834-ffafb384c4c6",
"Name": "production-subnet1i"
t
]
|
在第一个终端中,重新检查 get_hits 的值。
1
2
3
4
5
6
7
| Every 5.0s: memcached-tool 172.24.1.1 stats | grep -A2 get_hits
get_hits 1407
get_misses 265
hash_by tes 524288
[root@controller0 ~]# logout
[heat-admin@controller0 ~]$ logout
[student@workstation ~]$
|
请注意,get_hits值的增加速度比以前快。
在 workstation 上运行 lab controlplane-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab controlplane-review grade
|
在 workstation 上运行 lab controlplane-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab controlplane-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 消息代理与数据库的职责有什么区别?
- 资源列表查询成功,但创建实例失败,最合理的下一步是什么?
自测答案#
- 消息代理协助服务通信,数据库保存状态。内部通信与状态持久化是不同职责,排错时应分别检查。
- 检查创建操作涉及的服务链及日志。创建操作涉及调度、网络、镜像及存储等依赖,查询成功不能证明整条创建路径正常。
C3-集成身份管理#
身份认证与权限不是同一回事#
Keystone 负责身份相关能力。集成 IdM 后,用户的身份来源与 OpenStack 中的资源授权仍需分别理解:能验证密码不等于拥有项目权限;拥有某项目角色,也不等于可以访问其他项目的资源。
| 概念 | 用途 | 常见混淆 |
|---|
| Domain(域) | 组织用户、组和项目等身份对象 | 同名对象可能属于不同域 |
| User / Group | 表示身份及身份集合 | 创建用户并不会自动授予云资源权限 |
| Project(项目) | 组织和隔离资源,提供授权作用域 | 管理员看到资源,不代表普通用户也可看到 |
| Role(角色) | 参与表达授权关系 | 角色名相同仍需检查授予对象和作用域 |
| Token(令牌) | 携带认证和作用域信息 | 旧令牌可能不能反映重新认证后的上下文 |
检查集成后端#
核对 IdM 后端配置时,应确认域配置、后端连通性和身份查询结果。然后使用目标用户实际认证,再检查其项目访问。这样的验证顺序可以区分“用户查不到”“密码无法验证”和“认证成功但无权操作”。
Fernet 令牌与密钥#
令牌机制涉及签发与验证。Fernet 密钥的管理需要考虑轮换和节点间一致性。单个节点能验证令牌,不能自动证明所有身份服务节点都能验证;轮换时需保留验证未过期令牌所需的旧密钥,并同步各节点。实验中记录变更前后的状态,并使用重新获取的凭据验证结果。
项目组织的验证顺序#
先确定域,再确定用户或组,然后检查项目与角色分配,最后以目标身份访问资源。不要只用管理员账户验证授权是否生效。完成实验后,记录每个身份应当能够访问什么,以及应当看不到什么。
IdM 与 Keystone 的边界#
1
2
3
4
5
6
7
| 用户认证来源:IdM / LDAP
↓
Keystone Domain 对应后端
↓
用户 / 组 + 项目 + 角色分配
↓
带项目作用域的 Token → 服务 API 策略判断
|
LDAP 后端可能只读;不应预期 openstack user create 能修改目录中的用户。先确定用户由哪个系统管理,再选择管理入口。
域配置核对#
实验域级配置采用 keystone.<域名>.conf 形式。检查 [identity] 的后端选择与 [ldap] 的连接、用户和组映射;容器化部署中先通过挂载确定实际文件位置。
1
2
3
4
5
| # 管理员客户端
openstack domain list
openstack user list --domain Example
openstack group list --domain Example
openstack project list --domain Example
|
项目层级、组与继承#
1
2
3
4
5
6
7
8
9
10
11
| openstack domain create Lab
openstack project create --domain Lab support
openstack project create --domain Lab --parent support dev
openstack group create --domain Lab developers
openstack user create --domain Lab --password-prompt demo-user
openstack group add user --group-domain Lab --user-domain Lab developers demo-user
openstack role add --group developers --group-domain Lab \
--project support --project-domain Lab _member_
openstack role add --group developers --group-domain Lab \
--project support --project-domain Lab --inherited _member_
openstack role assignment list --project dev --project-domain Lab --names --effective
|
普通项目角色分配作用于当前项目;--inherited 用于下级项目的继承授权。需要同时覆盖父项目和子项目时,分别表达这两个意图。--effective 帮助查看组成员与继承解析后的实际授权。
Fernet Token#
- Fernet 是令牌格式与签名验证机制,不等于用户密码。
- 密钥仓库包含暂存、当前签发及保留的验证密钥;轮换时保留验证旧令牌所需密钥。
- 多个 Keystone 节点的密钥应协调一致,否则可能出现请求落到不同节点时认证结果不同。
RHOSP 13 可使用 Director 工作流协调轮换:
1
2
3
4
| # director,stack,Undercloud RC
openstack workflow execution create \
tripleo.fernet_keys.v1.rotate_fernet_keys '{"container": "overcloud"}'
openstack workflow execution show <执行UUID>
|
等待 SUCCESS 后核对各节点密钥状态和重新认证结果。不要只在一个容器中任意删除旧密钥。
实验操作#
引导练习:验证 IdM 后端配置#
引导练习#
验证 IdM 后端配置#
本练习中,为经 Red Hat IdM 认证的用户分配 OpenStack 角色。
学习目标#
完成后,能够:
创建域内的项目。
为 IdM 用户分配域中项目的角色。
使用 Red Hat IdM 后端登录 Dashboard。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab identity-idm setup 命令。此脚本确保了 OpenStack 服务正在运行,环境也为此引导练习配置得当。
1
| [student@workstation ~]$ lab identity-idm setup
|
课堂环境将 RHOSP 身份服务与 Red Hat IdM 集成,使用 IdM 作为 Example 域的外部认证后端。
列出 Example 域中的用户,验证 IdM 服务器集成。应看到 lab.example.net realm 中的用户列表。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~]$ source ~/admin-re
[student@workstation ~]$ openstack user list --domain Example
See eeeeee Se ee ee ee eS eS eeeee eS ef eee ee Sefer ee Ses coef
| ID | Name |
ee ee eee eee ee
.. Output omitted...
| 8fe31f745b4f6dd29a431045d94dc24c3dd53f28a79c1fdailaile9s8id57977d5 | architect2 |
.. output omitted...
| bécbbfb10d53eff2777a0235aeb2dd8de95 fe414 2ada32e2a803 fd3b79Cc43029 | developer2 |
| 44c56514e3c2c86274b1bd581264b3b1349fcceb336 f9457fas44deficiae225 | developer3 |
.. output omitted...
Sere eee ae nee ere eee ee ee er ere eee ee eee eee eee eee one enna erentoneers
|
在 Example 域内创建 research 项目。
1
2
| [student@workstation ~]$ openstack project create research --domain Example
Sette ee ee ee roe tee ner ee he aoe eeeene a one tne renee eons
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| | Field | Value |
cea asa ace ea at ae ne eT eaeYates
| description | |
| domain_id | 912f8a266990444da2130c6e8C68cdd1 |
| enabled | True |
| id | a6546caf46d746dfab412caofcsc8c10 |
| is_domain | False |
| name | research |
| parent_id | 012f8a266990444da2130c6e8c68cdd1 |
| tags | [] |
Bee aa a a a a ae a
|
为 IdM 的 research-members 组授予 research 项目的 member 角色。
1
2
3
4
5
6
| [student@workstation ~]$ openstack role add \
--project research \
--project-domain Example \
--group research-members \
--group-domain Example \
_tember_
|
为 IdM 的 research-admins 组授予 research 项目的 admin 角色。
1
2
3
4
5
6
| [student@workstation ~]$ openstack role add \
--project research \
--project-domain Example \
--group research-admins \
--group-domain Example \
admin
|
登录到仪表板,以验证给 developer2 IdM 用户指定的角色。
在 workstation 启动 Firefox,访问 http://dashboard.overcloud.example.com/。
Domain 填写 Example,User Name 填写 developer2,Password 填写 redhat,完成认证。
在登录到仪表板后,观察顶端导航菜单显示项目和身份标签。
退出 Dashboard。
登录 Dashboard,验证 IdM 用户 developer3 的角色。
在 workstation 启动 Firefox,访问 http://dashboard.overcloud.example.com/。
Domain 填写 Example,User Name 填写 developer3,Password 填写 redhat,完成认证。
在登录到仪表板后,观察顶端导航菜单显示项目和身份标签。
退出 Dashboard。
操作界面、表格与配置图
登录 Dashboard,验证 IdM 用户 architect3 的角色。
在 workstation 启动 Firefox,访问 http://dashboard.overcloud.example.com/。
Domain 填写 Example,User Name 填写 architect3,Password 填写 redhat,完成认证。
登录到仪表板后,观察顶部导航菜单显示项目、 管理员和身份标签,显示该用户被指定发挥 admin 角色。
退出 Dashboard。
在 workstation 上运行 lab identity-idm cleanup,清理本练习创建的资源。
在此练习中创建。
1
| [student@workstation ~]$ lab identity-idm cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理身份服务令牌#
引导练习#
管理身份服务令牌#
在此练习中,查看并轮换 Fernet 密钥。
学习目标#
完成后,能够:
启动 Fernet 密钥轮换。
验证 Fernet 密钥轮换。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab identity-tokens setup 命令。此脚本确保了 OpenStack 服务正在运行,环境也为此引导练习配置得当。
1
| [student@workstation ~]$ lab identity-tokens setup
|
使用 crudini 命令来确定 overcloud 是否使用 Fernet 令牌。
登录到 controller0 系统后成为 root 用户。
1
2
3
| [student@workstation ~]$ ssh controllere
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
查看身份服务配置文件 /var/
lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf 中 token 节的 provider 参数,确定令牌提供程序。
1
2
3
4
| [root@controller0 ~]# crudini --get \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
token provider
fernet
|
查看身份服务配置文件 /var/
lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf 中 token 节的 driver 参数,确定令牌驱动程序。
1
2
3
4
| [root@controller0 ~]# crudini --get \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
token driver
sql
|
操作界面、表格与配置图
使用 crudini 确定 Fernet 密钥库的位置以及活动密钥的最大数量。查看 fernet_tokens 节的 key_repository 参数,
该参数位于 /var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf 身份服务配置文件中,用于确定
Fernet 密钥仓库的位置。
1
2
3
4
| [root@controller0 ~]# crudini --get \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
fernet_tokens key_repository
/etc/keystone/fernet-keys
|
查看 /var/lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf 的 fernet_tokens 节中 max_active_keys 的值,确定活动 Fernet 密钥的最大数量。
1
2
3
4
| [root@controller0 ~]# crudini --get \
/var/1lib/config-data/puppet-generated/keystone/etc/keystone/keystone.conf \
fernet_tokens max_active_keys
5
|
显示活动的 Fernet 密钥列表。
1
2
3
4
5
| [root@controller0 ~]# ls -1\
/var/1lib/config-data/puppet-generated/keystone/etc/keystone/fernet -keys/
total 8
-fW-------. 1 42425 42425 44 Aug 1 15:38 0
-fW-------. 1 42425 42425 44 Aug 1 15:38 1
|
显示活动 Fernet 密钥文件的内容。文件末尾没有换行符,因此结合 cat 和 echo,便于查看
密钥文件的内容。请注意,在您的系统中,输出可能略有不同。
1
2
3
4
5
6
| [root@controller0 ~]# cat \
/var/1lib/config-data/puppet-generated/keystone/etc/keystone/fernet -keys/0; echo
dXsGBGMEbbPutvd - tASd?7 7aqVFox26 TFBPSArA3Rpb8=
[root@controller0 ~]# cat \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/fernet-keys/1; echo
HyOrUOK_WOU7 BWPTQ_rbOFLd4-ojilko_x27Cpv28zw=
|
轮换 Fernet 密钥。在新的终端会话中登录 director。
1
2
| [student@workstation ~]$ ssh director
(undercloud) [stack@director ~]$
|
执行 Mistral 工作流程以启动 Fernet 密钥轮换。
1
2
| (undercloud) [stack@director ~]$ openstack workflow execution create \
tripleo.fernet_keys.v1.rotate_fernet_keys '{"container": "overcloud"}'
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| | ID | d2fe1059-c3T0-40e3- b31a-eb83bf383711 |
| Workflow ID | 42e56b9a-b174-4626-831d -Oe66b2feOT32 |
| workflow name | tripleo.fernet_keys.v1.rotate_fernet_keys |
| workflow namespace | |
| Description | |
| Task Execution ID | <none> |
| State | RUNNING |
| State info | None |
| Created at | 2018-08-14 61:51:33 |
| Updated at | 2018-08-14 01:51:33 |
fen re ete re ee re eect
|
等待两分钟左右,然后查看工作流程执行的状态。使用前一个命令输出中显示的工作流程执行 ID。当状态显示 SUCCESS 时,继续。
1
2
3
4
5
6
7
8
9
10
11
12
| (undercloud) [stack@director ~]$ openstack workflow execution show \
d2fe1059-c3f0-40e3 -b31a-eb83bhf383711
| | |ID d2fe1059 -c3f0 -40e3 - b31a-eb83bf383711
| | |workflow ID 42e56b9a-b174 -4626 -831d-9e66b2feof 32
| | |workflow name tripleo. fernet_keys.v1.rotate_fernet_keys
| | |workflow namespace
| | |Description
| Task Execution ID | <none> |
| | |State SUCCESS
| | |State info None
| | |Created at 2018 -08-14 01:51:33
| | 2018-08-14 01:52:56 |Updated at
|
返回到 controller0 系统中,并在仓库目录中列出活动的 Fernet 密钥。
1
2
3
4
5
6
| [root@controller0 ~]# ls -1 \
/var/1lib/config-data/puppet-generated/keystone/etc/keystone/fernet -keys/
total 8
-PW-------, 1.42425 42425 44 Aug 1 15:38 0
-fW-------. 1 42425 42425 44 Aug 1 15:38 1
-fW-------. 1.42425 42425 44 Aug 1 15:38 2
|
显示活动的 Fernet 密钥文件的内容。
1
2
3
4
5
6
| [root@controller0 ~]# cat \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/fernet-keys/0; echo
V80BbRwmgwf t 2kJmPelsYFUX3Qbym15RZwNQE16 Lrok=
[root@controller0 ~]# cat \
/var/lib/config-data/puppet-generated/keystone/etc/keystone/fernet -keys/1; echo
HyOrUOK_WOU?7BWPTQ_rbOFLd4-ojilko_x27Cpv28zw=
|
操作界面、表格与配置图
1
2
3
| [root@controller0 ~]# cat \
/var/1lib/config-data/puppet-generated/keystone/etc/keystone/fernet-keys/2; echo
dXSGBGMEbbPutvd - tASd7 7aqVFox26 TFBPSArA3Rpb8=
|
注意,原暂存密钥文件 0 的内容已轮换到编号最大的文件 2,成为主密钥。原主密钥文件 1 的内容仍在编号第二大的文件 1 中,现为次密钥。文件 0 现在包含一个新的暂存密钥。
在 workstation 上运行 lab identity-tokens cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab identity-tokens cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理项目组织#
引导练习#
管理项目组织#
在此练习中,在一个域内创建嵌套项目。
学习目标#
完成后,能够:
创建域、项目和子项目。
创建组并分配组角色。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab identity-project setup 命令。此脚本确保了 OpenStack 服务正在运行,环境也为此引导练习配置得当。
1
| [student@workstation ~]$ lab identity-project setup
|
在 workstation 上加载 ~/admin-rc 文件,创建名为 Lab 的新域。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$ openstack domain create Lab
SF eK a eR Ce EE EN eK CTE EEN CE KEEHELNEN CTE EIEN EK tee
| Field | Value |
See ee eeee ce ef ee ee ce eS ee fe eeeSe cee Semench
| description | |
| enabled | True |
| id | 8f0C26484c444e3687858C47/780663d2 |
| name | Lab |
| tags | (] |
|
在 Lab 域内创建 support 项目。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~]$ openstack project create support --domain Lab
Sf eeeee ce ef eeee ee See fe Se ee Se emch
| Field | Value |
Be eeeee
| description | |
| domain_id | 8f0C26484c444e3687858C47780663d2 |
| enabled | True |
| id | 46b949d1c59740f68f11e552fd2635b7 |
| is_domain | False |
| name | support |
| parent_id | 8f0C26484c444e3687858C47780663d2 |
|
操作界面、表格与配置图
在 support 项目内创建 dev 子项目。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~]$ openstack project create dev --parent support \
--domain Lab
A dea ea eee ea ea aE cea a eee ea eenem eader een ee neatory ee ements
| Field | Value |
SP eo eg ee geee oe oe Oe gee oe test?
| description | |
| domain_id | 8f0c26484c444e3687858C47780663d2 |
| enabled | True |
| id | bagaa83cb4a04075a16bd976545f8176 |
| is_domain | False |
| name | dev |
| parent_id | 46b949d1c59740f68f11e552fd2635b7 |
| tags |] |
eT aca eTmana aaa nT ae Tae Tf
|
在 Lab 域内创建 developers 用户组。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ openstack group create developers --domain Lab
aceastaace Ta ats ae neeT eat
| Field | Value |
fin nn en en tn ne ee ne eet
| description | |
| domain_id | 8f0c26484c444e3687858C47780663d2 |
| id | 8eadf3afdda44049acbboe3229bff2fa1 |
| name | developers |
A OOO OGG IIIa Ae IEEE RG Srna me rmoereemoamair
|
为 Lab 域内的 developers 组授予 Lab 域中 support 项目的 member 角色。
1
2
| [student@workstation ~]$ openstack role add --group developers \
--group-domain Lab --project support --project-domain Lab _member_
|
为 Lab 域内的 developers 组授予 support 所有子项目的 member 角色。使用 –inherited,使 support 的子项目继承此角色。
1
2
| [student@workstation ~]$ openstack role add --group developers \
--group-domain Lab --project support --project-domain Lab --inherited _member_
|
在 Lab 域创建新用户 developer4。设置新用户的密码为 redhat。
1
2
| [student@workstation ~]$ openstack user create developer4 --domain Lab \
--password redhat
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| | Field | Value |
Sp 6sYer arcsYs es srsYarns nsVossess scaresYasar Verses sreeVosseisoseasYesarezviceVerne)
| domain_id | 8f0Cc26484c444e3687858C47780663d2 |
| enabled | True |
| id | 94ad1osffe49473bbef850123496a324 |
| name | developer4 |
| options | |
| password_expires_at | None |
Fn ne pe eet
|
将 Lab 域的 developer4 用户添加到 Lab 域的 developers 用户组。
1
2
| [student@workstation ~]$ openstack group add user --group-domain Lab \
--user-domain Lab developers developer4
|
校验 Lab 域中 support 项目的角色分配。
1
2
3
4
5
6
7
| [student@workstation ~]$ openstack role assignment list --project support \
--project-domain Lab --names --effective
Se Se ee a i et2
| Role | User | Group | Project | Domain | Inherited |
ee ee ee ee i i re regen
| _member_ | developer4@Lab | | support@Lab | | False |
Hoc ooo moe dtteqgo eam oqmomo ome ochor mere MS ey ure rye EE en ES eo eye oe
|
核查 Lab 域 dev 子项目的角色分配。
1
2
3
4
5
6
7
| [student@workstation ~]$ openstack role assignment list --project dev \
--project-domain Lab --names --effective
foes Se See pete ee ee pee ee eee ee ee eee
| Role | User | Group | Project | Domain | Inherited |
finn ee ete pe te ne ete ee ete ee eet
| _member_ | developer4@Lab | | dev@Lab | | True |
2 eene eee ie ii.
|
在 workstation 上运行 lab identity-project cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab identity-project cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:集成身份管理#
集成身份管理#
操作检查清单#
在此实验中,在域内创建嵌套项目,并在 OpenStack 中指定由 RED Hat IdM 认证的用户在 OpenStack 中的角色。您还将启动并验证 Fernet 密钥轮换。
学习目标#
完成后,能够:
在域内创建项目和次级项目。
为域中的用户组分配角色。
识别域内用户获分配的角色。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab identity-review setup 命令。这将确保
OpenStack 服务正在运行,环境已经为这个实验作了适当的配置。
1
| [student@workstation ~]$ lab identity-review setup
|
在 Example 域创建名为 consulting 的项目。
在 consulting 项目中创建名为 development 的子项目。
为 Example 域中的 consulting-members 组授予该域 consulting 项目的 member 角色。
为 Example 域中的 consulting-members 组分配该域 consulting 项目下所有子项目的 admin 角色。
校验Example 域内 consulting 项目中分配给下列用户的角色 :
operator1
architect1
核查Example域development次级项目中分配给下列用户的角色。
operatori
architect1
在 director 上启动 Overcloud Fernet 密钥轮换,并验证轮换完成。
操作界面、表格与配置图
在 workstation 上运行 lab identity-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab identity-review grade
|
在 workstation 上运行 lab identity-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab identity-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
集成身份管理#
操作检查清单#
在此实验中,在域内创建嵌套项目,并在 OpenStack 中指定由 RED Hat IdM 认证的用户在 OpenStack 中的角色。您还将启动并验证 Fernet 密钥轮换。
学习目标#
完成后,能够:
在域内创建项目和次级项目。
为域中的用户组分配角色。
识别域内用户获分配的角色。
启动并验证 Fernet 密钥轮换。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab identity-review setup 命令。这将确保
OpenStack 服务正在运行,环境已经为这个实验作了适当的配置。
1
| [student@workstation ~]$ lab identity-review setup
|
在 Example 域创建名为 consulting 的项目。
加载管理员环境文件 /home/student/admin-rc,在 Example 域中创建 consulting 项目。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~]$ source ~/admin-rce
[student@workstation ~]$ openstack project create consulting --domain Example
fence ree rnengebeconcnnecsemeeeecserecmncnsennessk
| Field | Value |
shaiajminmiei imsereim arte miminimimeimimin mimi mim mieime mime nimi mime miminsesh
| description |
| domain_id | GedOe18ad28747CcCcac32ec344e271d58 |
| enabled | True |
| id | 191dd8a9c767498ca21587c48foOld96c |
| is_domain | False |
| name | consulting |
| parent_id | GedOe18ad28747CcCcac32ec344e271d58 |
| tags | C] |
"po ero ee Sree er ee ere eer ee err ear
|
验证 consulting 项目是在 Example 域创建的。
操作界面、表格与配置图
1
2
3
4
5
6
| [student@workstation ~]$ openstack project list --domain Example
SI ae a ne a eg aT eS aT ee a
| ID | Name |
Poem enn nnn nen e wn ewneen en een fe wn we nen wet
| 191dd8a9c767498ca21587c48fold96c | consulting |
Se ee eeee a
|
在 consulting 项目中创建名为 development 的子项目。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~]$ openstack project create development \
--parent consulting --domain Example
Pee eee eee ee ef eee ee ee ee eee ee eee eee eee ee e+
| Field | Value |
Sf htc ceo eoceeceeceecet cateceoceoceoce eth cee cc che
| description | |
| domain_id | GedOe18ad28747CCcac32eCc344e271d58 |
| enabled | True |
| id | 547e84f2efeb431ea77c48aed5al4a68 |
| is_domain | False |
| name | development |
| parent_id | 191dd8a9c767498ca21587Cc48fO1d96c |
| tags | (] |
ptsassYassYaseasVosea epoca Vasc essnesVasesVasesVssreaies sre sree sores)asncavsasrea esreeps
|
为 Example 域中的 consulting-members 组分配该域 consulting 项目的 member 角色。
1
2
3
| [student@workstation ~]$ openstack role add \
--group consulting-members --group-domain Example \
--project consulting --project-domain Example _member_
|
为 Example 域中的 consulting-members 组分配该域 consulting 项目下所有子项目的 admin 角色。
1
2
3
| [student@workstation ~]$ openstack role add \
--group consulting-members --group-domain Example \
--project consulting --project-domain Example --inherited admin
|
校验Example 域内 consulting 项目中分配给下列用户的角色 :
operatori
architect1
验证 Example 域 consulting 项目中的 operator1 用户已获得 member 角色。
1
2
3
| [student@workstation ~]$ openstack role assignment list \
--user operator1 --user-domain Example \
--project consulting --names --effective
|
操作界面、表格与配置图
1
| ee ee eter eater eter hee eresme enc terete ere ere ett eer es ere eeteren =tere erteret terreVere sheetrefer =verereterehateets
|
验证 Example 域 consulting 项目中的 architect1 用户已获得 member 角色。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ openstack role assignment list \
--user architect1 --user-domain Example \
--project consulting --names --effective
Bee(SCT SCT SC a IO (SCT SCT ET (CTT Sg SSC TSS1 RSET SCT CSET OCTNOT NSC Oe OCT NCE OCT Oe OeT Oe e
| Role | User | sae | Project |... | Inherited |
Se ee ee ee ee ee See Se
| _member_ | architect1@Example | | consulting@Example | | False |
Se aoe ee ee ee ee ce ee ee a eae
|
核查Example域development次级项目中分配给下列用户的角色。
operator1
architect1
验证 Example 域 development 子项目中的 operator1 用户已获得 admin 角色。
1
2
3
| [student@workstation ~]$ openstack role assignment list \
--user operator1 --user-domain Example \
--project development --names --effective
|
核实admin的角色是否分配给Example域development次级项目中的architect1用户。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ openstack role assignment list \
--user architect1 --user-domain Example \
--project development --names --effective
es ee eeee
| Role | User |... | Project | ... | Inherited |
2 ee eeeeies
| admin | architect1@Example | | development@Example | | True |
Se a a ee ee
|
在 director 上启动 Overcloud Fernet 密钥轮换,并验证轮换完成。
登录到 director 系统。
1
2
| [student@workstation ~]$ ssh director
(undercloud) [stack@director ~]$
|
执行 Mistral 工作流程以启动 Fernet 密钥轮换。
1
2
| (undercloud) [stack@director ~]$ openstack workflow execution create \
tripleo.fernet_keys.v1.rotate_fernet_keys '{"container": "overcloud"}'
|
操作界面、表格与配置图
1
2
3
4
5
| | b41be9b9-f9ad -4924- 9b6d-b9b11bd613f6ID
| Q1bd8112-405d -4f Od - 9aca-83C642d82946workflow ID
| tripleo. fernet_keys.v1.rotate_fernet_keysworkflow name
| Workflow namespace
| Description
|
|
1
2
3
4
5
6
| Task Execution ID <none>
State RUNNING
State info None
Created at 2018-09-06 11:49:41
Updated at 2018-09-06 11:49:41
Been (ltion leone ineerartientennet nel ar NCE SRC Ko NCO TENET CHE SSCS XC HX TEL HE INCE RCE XH +
|
|
|
|
|
通过引用上一个命令输出中的 ID 显示的 ID 来验证工作流程执行的状态。如果需要,将重新运行命令,并等待状态设定为 SUCCESS。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| (undercloud) [stack@director ~]$ openstack workflow execution show \
641be09b9 - F9ad-4924 -9b6d-b9b11bd613f6
finn te ne ee ee nee ee et
| Field | Value |
a ee eee ee ey en en ee Oe een eee
| ID | b41be9b9-f9ad -4924-9b6d-b9b11bd613f6 |
| Workflow ID | 91bd8112-405d-4fOd - 9aea-830642d82946 |
| Workflow name | tripleo. fernet_keys.vi.rotate_fernet_keys |
| workflow namespace | |
| Description | |
| Task Execution ID | <none> |
| State | SUCCESS |
| State info | None |
| Created at | 2018-09-06 11:49:41 |
| Updated at | 2018-09-06 11:50:44 |
|
从 director 中注销。
在 workstation 上运行 lab identity-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab identity-review grade
|
在 workstation 上运行 lab identity-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab identity-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 用户可以认证,但无法访问目标项目,首先应检查什么?
- 验证普通用户授权时,哪种方式最可靠?
自测答案#
- 项目作用域及角色分配。身份认证成功与目标项目授权生效是两件事。
- 以目标用户重新认证并执行实际访问。应从目标用户的作用域和权限验证访问结果。
C4-执行镜像操作#
镜像格式与镜像属性#
镜像是实例启动的基础输入。磁盘格式决定镜像文件的组织方式,镜像服务中的属性描述它应如何被使用;两者都应与预期的虚拟化环境匹配。上传成功只证明镜像服务接收了文件,是否可启动还需要实际实例验证。
构建、修改、初始化#
| 操作阶段 | 主要目标 | 验证方式 |
|---|
| 构建镜像 | 生成包含所需系统和软件的磁盘镜像 | 检查构建结果与镜像内容 |
| 离线定制 | 在未启动实例时修改磁盘中的文件和配置 | 检查目标路径、权限与配置 |
| 首次启动初始化 | 为每次部署提供实例特定配置 | 检查 cloud-init 执行状态及实例内部结果 |
通用软件适合放入可重复构建的镜像;实例名称、用户数据和部署相关参数通常在启动阶段注入。将这两个阶段分开,可以减少为每个实例复制一份镜像的维护负担。
cloud-init 的观察方式#
提供 user-data 后,不要仅看实例是否处于 ACTIVE。应登录实例,检查初始化日志、目标文件、账户或服务是否符合要求。配置内容、数据源获取和实际执行是不同阶段,排错时要确认在哪一阶段失败。
镜像实验的完整闭环#
先构建或修改镜像,再上传并核对属性,然后启动测试实例,验证服务和持久化结果。最后清理测试资源。保留镜像构建命令及输入文件,使下一次构建可以复现,而不是只保存最终生成的大文件。
镜像构建工具#
| 工具 | 作用 | 输入与输出 |
|---|
| diskimage-builder | 通过 elements 组合构建镜像 | 基础镜像、软件源、脚本 → 新镜像 |
| guestfish | 离线查看或修改客户机文件系统 | 镜像文件中的路径与内容 |
| virt-customize | 批量离线定制 | 安装包、修改配置、运行命令 |
| cloud-init | 实例启动时初始化 | user-data / metadata → 实例特定配置 |
diskimage-builder 的实验参数#
1
2
3
4
5
| export DIB_LOCAL_IMAGE=/home/student/osp-small.qcow2
export DIB_YUM_REPO_CONF=/etc/yum.repos.d/openstack.repo
export ELEMENTS_PATH=/home/student/elements
export DIB_NO_TMPFS=1
disk-image-create vm rhel7 -t qcow2 -p bind,bind-utils -o demo-rhel-dns.qcow2
|
前提是相应基础镜像、软件源和 elements 已准备。post-install.d 中脚本要有正确解释器、顺序和执行权限;构建完成仍需测试实际服务。
离线定制#
保留基础镜像,修改工作副本,不对正在被虚拟机写入的磁盘执行离线修改。
1
2
3
4
| cp osp-small.qcow2 demo-web.qcow2
virt-customize -a demo-web.qcow2 --install httpd \
--run-command 'systemctl enable httpd'
guestfish --ro -i -a demo-web.qcow2 cat /etc/os-release
|
离线安装依赖软件源与网络配置;镜像可能还需 repository / registration 设置。
上传并启动验证#
1
2
3
| openstack image create --disk-format qcow2 --container-format bare \
--min-disk 10 --min-ram 2048 --file demo-web.qcow2 demo-web
openstack image show demo-web
|
随后选择至少满足 min-disk / min-ram 的规格启动,检查软件包、配置、服务启用与网络访问。上传 active 只证明镜像已登记可用,不证明镜像内应用正确。
镜像构建与初始化分工#
通用软件、固定配置进入可重复构建的镜像;每台实例的用户、密钥、业务参数交给 cloud-init。不要把不应共享的私钥或固定主机身份复制进所有实例。
实验操作#
引导练习:构建镜像#
引导练习#
建立镜像#
在此练习中,使用 diskimage-builder 构建并定制磁盘镜像。
学习目标#
完成后,能够:
使用 diskimage-builder 构建和自定义镜像。
上传镜像到 OpenStack 镜像服务。
使用定制镜像启动实例。
开始之前#
以 student 用户登录 workstation,密码为 student。
在workstation,运行 lab customization-img-building setup 命令。
这会确保 workstation 已安装所需软件包,并为环境准备公共网络、私有网络、密钥对及访问实例的安全规则。
1
| [student@workstation ~]$ lab customization-img-building setup
|
在 workstation 下载 http://materials.example.com/osp-small.qcow2 磁盘镜像,保存到 /home/student/。
1
| [student@workstation ~]$ wget http://materials.example.com/osp-small.qcow2
|
将 /usr/share/diskimage-builder/elements 复制到 /home/student/ 下作为工作副本。
1
2
| [student@workstation ~]$ cp -a /usr/share/diskimage-builder/elements \
/home/student/
|
在 rhel7 元素的工作副本下创建 post-install.d 目录。
1
| [student@workstation ~]$ mkdir -p /home/student/elements/rhel7/post-install.d
|
在 rhel7 元素的 post-install.d 目录下添加两个脚本:启用 named 服务,并在 /etc/named.conf 中添加 forwarders 选项。
1
2
3
4
| [student@workstation ~]$ cd /home/student/elements/rhel7/post-install.d/
[student@workstation post-install.d]$ cat <<EOF > 01-enable-services
#!/bin/bash
systemctl enable named
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| EOF
[student@workstation post-install.d]$ cat <<EOF > 02-configure-named
#!/bin/bash
# add forwarders
sed -i 's|\(.*\)\(recursion yes;\)|\1\2\n\1forwarders {172.25.250.254;};|' \
/etc/named.conf
# allow queries from the local subnet
sed -i 's|\(.*allow-query\).*|\1 { localhost; 192.168.1.0/24; };|' \
7etc/named.conf
# disable dnssec validation
sed -i 's|\(.*dnssec-validation\).*|\1 no;|' /etc/named.conf
EOF
|
切换到 /home/student 目录,并设置脚本上的可执行权限。
1
2
| [student@workstation post-install.d]$ cd
[student@workstation ~]$ chmod +x /home/student/elements/rhel7/post-install.d/*
|
导出diskimage-builder所要求的下列环境变量。DIB_NO_TMPFS变量只是因为workstation有一个小硬盘,在多数情况下不需要。
环境变量
| 变量 | 内容 |
|---|
| DIB_LOCAL_IMAGE | /home/student/osp-small1.qcow2 |
| DIB_YUM_REPO_CONF | /etc/yum. repos.d/openstack.repo |
| ELEMENTS_PATH | /home/student/elements |
| DIB_NO_TMPFS | 1 |
1
2
3
4
| [student@workstation ~]$ export DIB_LOCAL_IMAGE=/home/student/osp-small.qcow2
[student@workstation ~]$ export DIB_YUM_REPO_CONF=/etc/yum.repos.d/openstack.repo
[student@workstation ~]$ export ELEMENTS_PATH=/home/student/elements
[student@workstation ~]$ export DIB_NO_TMPFS=1
|
构建 finance-rhel-dns.qcow2 磁盘镜像,包含 bind 和 bind-utils 软件包。之前创建的脚本会自动集成。出现提示时输入 student 用户的密码。
1
2
3
4
5
| [student@workstation ~]$ disk-image-create vm rhel7 \
-t qcow2 \
-p bind,bind-utils \
-o finance-rhel-dns.qcow2
.. Output omitted...
|
操作界面、表格与配置图
以 OpenStack 用户 developer1 上传 finance-rhel-dns.qcow2 到镜像服务,命名为 finance-rhel-dns,要求最小磁盘 10 GiB、最小内存 2 GiB。
加载 developer1-finance-rc 凭据文件。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
使用 openstack 将 finance-rhel-dns.qcow2 上传到镜像服务。
1
2
3
4
5
6
7
| [student@workstation ~(developeri1-finance)]$ openstack image create \
--disk-format qcow2 \
--min-disk 10 \
--min-ram 2048 \
--file ~/finance-rhel-dns.qcow2 \
finance-rhel-dns
.. output omitted...
|
使用以下属性在环境中启动实例。
实例属性
| 属性 | 值 |
|---|
| 规格 | default |
| 密钥对 | example -keypair |
| 网络 | finance-network1 |
| 镜像 | finance-rhel-dns |
| 安全组 | finance-dns |
| 名称 | finance-dns1 |
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
--key-name example-keypair \
--nic net-id=finance-network1 \
--image finance-rhel-dns \
--security-group finance-dns \
--wait finance-dnsi
.. Output omitted...
|
列出可用浮动 IP,并将其中一个分配给 finance-dns1。
列出可用的浮动 IP。您系统中可用的浮动 IP 可能与下面显示的有所不同。
1
2
| [student@workstation ~(developeri1-finance)]$ openstack floating ip list \
-c "Floating IP Address" -c Port
|
操作界面、表格与配置图
1
2
3
4
5
6
| BAe a a Sig NO ON nePON et oe
| Floating IP Address | Port |
fn ne ee neeepe et
| 172.25. 250.110 | None |
| 172.25. 250.107 | None |
fan enn enn eee eee ee pe ee et
|
将一个可用浮动 IP 关联到 finance-dns1。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add floating \
ip finance-dnsi 172.25.250.110
|
如果镜像构建成功,生成的 DNS 服务器应该接受查询,并将其转发到运行在 workstation 上的域名服务处。
使用 ssh 以 cloud-user 登录 finance-dns1。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh cloud-user@172.25.250.110
Warning: Permanently added '172.25.250.110' (ECDSA) to the list of known hosts.
[cloud-user@finance-dns1 ~]$
|
确认 named 正在监听 53 端口。
1
2
3
4
| [cloud-user@finance-dns1 ~]$ sudo ss -4nlp | grep named
udp UNCONN © O 127.0.0.1:53 i users: (("named", pid=860, fd=513),...
tcp LISTEN © 10 127.0.0,.1:53 Se users: (("named", pid=860, fd=21) )
tcp LISTEN © 128 127.0.0.1:953 ae users: (("named",pid=860, fd=23) )
|
使用 dig 查询本地 named 服务,查询 example.com 域的 NS 记录。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [cloud-user@finance-dns1 ~]$ dig @localhost example.com NS
; <<>> DIG 9.9.4-RedHat-9.9.4-61.e17 <<>> @localhost example.com NS
; (2 servers found)
;; Global options: +cmd
;; Got answer:
}; 7->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43472
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: ©, ADDITIONAL: 2
}, OPT PSEUDOSECTION:
; EDNS: version: ©, flags:; udp: 4096
}; QUESTION SECTION:
;example.com. IN NS
;; ANSWER SECTION:
example.com. 85612 IN NS classroom.example.com.
;; ADDITIONAL SECTION:
classroom.example.com. 85612 IN A 172.25.254.254
3; Query time: 1 msec
j; SERVER: ::1#53(::1)
;; WHEN: Thu Sep 20 04:41:28 EDT 2018
3}; MSG SIZE rcvd: 80
|
操作界面、表格与配置图
1
2
| [cloud-user@finance-dns1 ~]$ logout
[student@workstation ~(developer1-finance)]$
|
注意,输出的 flags 中没有 aa 标志,说明所查询服务器不是 example.com 的权威服务器。因此,查询由上游名称服务器应答,finance-dns1
按设计工作。
在 workstation 上运行 lab customization-img-building cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab customization-img-building cleanup
|
操作界面、表格与配置图
引导练习:定制镜像#
引导练习#
自定义镜像#
本练习使用 guestfish 和 virt-customize 定制磁盘镜像。
学习目标#
完成后,能够:
.
使用 guestfish 定制镜像。
使用 virt-customize 自定义镜像。
上传镜像到 Glance。
使用定制镜像生成实例。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上,运行 lab customization-img-customizing setup 命令,这样可以确保所需的软件包安装在 workstation 上,并为环境提供公共网络、 私人网络、 私人密钥、 安全规则。
1
| [student@workstation ~]$ lab customization-img-customizing setup
|
在 workstation 下载 http://materials.example.com/osp-small.qcow2,保存为 /home/student/finance-rhel-db.qcow2。
1
2
| [student@workstation ~]$ wget http://materials.example.com/osp-small.qcow2 \
-O ~/finance-rhel-db.qcow2
|
使用 guestfish 修改镜像,使其能够访问网络。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ guestfish -i --network -a ~/finance-rhel-db.qcow2
welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
Type: 'help' for help on commands
'man' to read the manual
"quit' to quit the shell
Operating system: Red Hat Enterprise Linux Server 7.5 (Maipo)
/dev/sdail mounted on /
><fs>
|
操作界面、表格与配置图
安装 mariadb 和 mariadb-server 软件包。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| ><fs> command "yum -y install mariadb mariadb-server"
.. output omitted...
Installed:
mariadb.x86_64 3:10.1.20-2.el7ost mariadb-server.x86_64 3:10.1.20-2.el7ost
Dependency Installed:
libaio. x86_64 0:0.3.109-13.e17
lsof.x86_64 0:4.87-5.e17
mariadb-errmsg.x86_64 3:10.1.20-2.el7ost
perl-Compress -Raw-Bzip2.x86_64 0:2.061-3.e17
perl-Compress -Raw-Zlib.x86_64 1:2.061-4.el17
per1-DBD-MySQL.x86_64 0:4.023-6.e17
perl-DBI.x86_64 0:1.627-4.e17
perl-Data-Dumper .x86_64 0:2.145-3.e17
perl-I0-Compress.noarch 0:2.061-2.e17
perl-Net-Daemon.noarch 0:0.48-5.e17
perl-PLRPC.noarch 0:0. 2020-14.e17
socat.x86_64 0:1.7.3.2-2.e17
complete!
|
启用 mariadb 服务。
1
| ><fs> command "systemctl enable mariadb"
|
因为没有输出,所以确保mariadb服务为enabled。
1
2
| ><fs> command "systemctl is-enabled mariadb"
enabled
|
确保所有受影响文件的 SELinux 上下文正确。
重要:此时不要忘记修复 SELinux 文件上下文。
1
| ><fs> selinux-relabel /etc/selinux/targeted/contexts/files/file_contexts /
|
退出 guestfish shell。
1
2
| ><fs> exit
[student@workstation ~]$
|
操作界面、表格与配置图
以 OpenStack 用户 developer1 将 finance-rhel-db.qcow2 上传到镜像服务,命名为 finance-rhel-db,要求最小磁盘 10 GiB、最小内存 2 GiB。
加载 /home/student/developer1-finance-rc 凭据文件。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
以 OpenStack 用户 developer1 将 finance-rhel-db.qcow2 上传到镜像服务,命名为 finance-rhel-db。
1
2
3
4
5
6
7
| [student@workstation ~(developeri1-finance)]$ openstack image create \
--disk-format qcow2 \
--min-disk 10 \
--min-ram 2048 \
--file ~/finance-rhel-db.qcow2 \
finance-rhel-db
.. output omitted...
|
使用以下属性在环境中启动实例 :
实例属性
| 属性 | 值 |
|---|
| 规格 | default |
| 密钥对 | example -keypair |
| 网络 | finance-network1 |
| 镜像 | finance-rhel-db |
| 安全组 | finance-db |
| 名称 | finance-db1 |
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
--key-name example-keypair \
--nic net-id=finance-network1 \
--security-group finance-db \
--image finance-rhel-db \
--wait finance-db1
.. Output omitted...
|
列出可用的浮动 IP 地址,然后分配给 finance-db1。
列出浮动 IP;未分配地址的 Port 值为 None。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack floating ip list \
-c "Floating IP Address" -c Port
SEmimeimi mim mmm em mmimimmmiat eimmamioeet
|
操作界面、表格与配置图
1
2
3
4
| | Floating IP Address | Port |
NhRENNNees et
| 172.25.250.110 | None |
| 172.25. 250.107 | None |
|
在 finance-db1 实例中附加一个未分配的浮动 IP。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add floating \
ip finance-db1 172.25.250.110
|
使用 ssh 连接到 finance-db1 实例。确保安装 mariadb-server 软件包,并确保 mariadb 服务为 enabled 并运行中。
使用 ssh 命令将 finance-db1 登录为 cloud-user 用户。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh cloud-user@172 .25.250.110
warning: Permanently added '172.25.250.110' (ECDSA) to the list of known hosts.
[cloud-user@finance-db1 ~]$
|
确认已安装 mariadb-server 软件包。
1
2
| [cloud-user@finance-db1 ~]$ rpm -q mariadb-server
mariadb-server-10.1.20-2.el70st.x86_64
|
确认 mariadb 服务已启用且正在运行,然后退出登录。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [cloud-user@finance-db1 ~]$ systemctl status mariadb
.. output omitted...
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor
preset: disabled)
Active: active (running) since Wed 2018-09-19 04:21:31 EDT; 1h 38min ago
Process: 1033 ExecStar tPost=/usr/libexec/mariadb-wait-ready $MAINPID
(code=exited, status=0/SUCCESS)
Process: 815 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited,
status=0/SUCCESS)
Main PID: 1031 (mysqld_safe)
..-output omitted...
[cloud-user@finance-db1 ~]$ logout
Connection to 172.25.250.110 closed.
[student@workstation ~(developer1-finance)]$
|
在 workstation 下载 osp-small.qcow2 镜像,地址为 http://
materials.example.com/osp-small.qcow2,保存为 /home/student/finance-rhel-mail.qcow2。
1
2
| [student@workstation ~(developer1-finance)]$ wget \
http://materials.example.com/osp-small.qcow2 -0 ~/finance-rhel-mail.qcow2
|
使用 virt-customize 定制 ~/finance-rhel-mail.qcow2 镜像。启用 postfix 服务,将其配置为监听所有接口,并中继
操作界面、表格与配置图
全部邮件到 workstation.lab.example.com。安装 mailx 以便发送测试邮件,并恢复 SELinux 上下文。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(developer1-finance)]$ virt-customize \
-a ~/finance-rhel-mail.qcow2 \
--run-command 'systemctl enable postfix' \
--run-command 'postconf -e "relayhost = [workstation.lab.example.com]"' \
--run-command 'postconf -e "inet_interfaces = all"' \
--run-command 'yum -y install mailx' \
--selinux-relabel
[ @.0] Examining the guest ...
[ 26.8] Setting a random seed
[ 26.9] Running: systemctl enable postfix
[ 27.9] Running: postconf -e "relayhost = [workstation.lab.example.com]"
[ 28.8] Running: postconf -e ""inet_interfaces = all"
[ 29.7] Running: yum -y install mailx
[ 54.5] SELinux relabelling
[ 187.8] Finishing off
|
以 OpenStack 用户 developer1 将 finance-rhel-mail.qcow2 上传到镜像服务,命名为 finance-rhel-mail,要求最小磁盘 10 GiB、最小内存 2 GiB。
使用 openstack 将 finance-rhel-mail.qcow2 上传到镜像服务。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack image create \
--disk-format qcow2 \
--min-disk 10 \
--min-ram 2048 \
--file ~/finance-rhel-mail.qcow2 \
finance-rhel-mail
.. output omitted...
|
使用以下属性在环境中启动实例 :
实例属性
| 属性 | 值 |
|---|
| 规格 | default |
| 密钥对 | example-keypair |
| 网络 | finance-network1 |
| 镜像 | finance-rhel-mail |
| 安全组 | finance-mail |
| 名称 | finance-mail1 |
1
2
| [student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
|
操作界面、表格与配置图
1
2
3
4
5
6
| --key-name example-keypair \
--nic net-id=finance-network1 \
--security-group finance-mail \
--image finance-rhel-mail \
--wait finance-mail1
.. output omitted...
|
列出可用的浮动 IP 地址,并分配一个给 finance-mail1。
列出可用的浮动 IP 地址。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack floating ip list \
-c "Floating IP Address" -c Port
Sf erosYossieassessYar beVossmss tesYasar anes YaraneVoss ts snesYasar VoreatsYasar beVoss steosVossresiseVor eaesYosatezveeVossen
| Floating IP Address | Port |
Seee ee ret
| 172.25.250.110 | 1Ice9ffa5-b52b-4581-a696-52f464912500 |
| 172.25.250.107 | None |
pSV ES ST Sa VSVS Se SR Se Se ae ee
|
将可用的浮动 IP 附加到 finance-mail1 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add floating \
ip finance-mail1 172.25.250.107
|
使用 ssh 连接到 finance-mail1 实例。确保 postfix 服务正在运行,postfix 正在监听所有接口,relay_host 选项是正确的。
使用 ssh 以 cloud-user 登录 finance-mail1。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh cloud-user@172.25.250.107
Warning: Permanently added '172.25.250.107' (ECDSA) to the list of known hosts.
[cloud-user@finance-mail1 ~]$
|
确保正在运行 postfix 服务。
1
2
3
4
5
6
7
8
9
10
11
12
| [cloud-user@finance-maili ~]$ systemctl status postfix
...output omitted...
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor
preset: disabled)
Active: active (running) since Wed 2018-09-19 06:12:00 EDT; 8min ago
Process: 1064 ExecStar t=/usr/sbin/postfix start (code=exited, status=@/SUCCESS)
Process: 1061 ExecStar tPre=/usr/libexec/postfix/chroot-update (code=exited,
status=0/SUCCESS)
Process: 1058 ExecStar tPre=/usr/libexec/postfix/aliasesdb (code=exited,
status=0/SUCCESS)
Main PID: 1136 (master)
.. Output omitted...
|
确保 postfix 监听所有接口。
1
2
| [cloud-user@finance-mail1 ~]$ sudo ss -tnlp | grep master
LISTEN (o) 100 SPA ehat users: (("master", pid=1136, fd=13))
|
操作界面、表格与配置图
1
| LISTEN (o) 100 s2e25 cos users: (("master", pid=1136, fd=14))
|
确认 relayhost 选项配置正确。
1
2
| [cloud-user@finance-mail1 ~]$ postconf relayhost
relayhost = [workstation.lab.example.com]
|
向 student@workstation.lab.example.com 发送一封测试邮件。
1
2
3
| [cloud-user@finance-mail1 ~]$ mail -s "Test" student@workstation.lab.example.com
Hello world!
EOT
|
返回 workstation,使用 mail 确认已收到测试邮件。
1
2
3
4
5
6
7
8
9
10
11
| [cloud-user@finance-mail1 ~]$ logout
Connection to 172.25.250.107 closed.
You have new mail in /var/spool/mail/student
[student@workstation ~]$ mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/student": 1 message 1 new
>N 1 Cloud User Wed Sep 19 10:21 21/938 "Test"
&q
Held 1 message in /var/spool/mail/student
You have mail in /var/spool/mail/student
[student@workstation ~]$
|
在 workstation 上运行 lab customization-img-customizing cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab customization-img-customizing cleanup
|
操作界面、表格与配置图
引导练习:部署期间初始化实例#
引导练习#
部署期间初始化实例#
本练习使用 cloud-init,在部署期间定制启动的实例。
学习目标#
完成后,能够:
以云配置格式创建 user-data 文件。
启动实例并验证 user-data 已生效。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab customization-img-cloudinit setup 命令,这确保了在 workstation 上安装所需的软件包,并为环境提供启动实例所需的资源。
1
| [student@workstation ~]$ lab customization-img-cloudinit setup
|
以 cloud-config 格式创建 /home/student/user-data。
编辑 /home/student/user-data,添加创建 cloud-admin 的指令,将 /home/student/.ssh/example-keypair.pub 的内容写入 /home/cloud-admin/.ssh/authorized_keys。允许 cloud-admin 免密码使用 sudo,并确保包含 #cloud-config 文件头。
注意:下面的输出为便于阅读进行了换行;实际 SSH 公钥数据不能包含换行符。
1
2
3
4
5
6
7
8
9
10
| #cloud -config
users:
- name: cloud-admin
sudo: ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- ssh-rsa AAAAB3NzZaClyc2EAAAADAQABAAABAQDHUTCMmzG95r JKXHZ0e+7 rHMaf3me7geA
fdYAc2fuokj SVoBni4aF 4MYkSmb1U YyX j tQ++x2+113+0sn9FJZmvdaOmaqT6D
ulcpiAxldVrnNJFV5LAVFGiFDbUg1ThPc25Ytn7bwqgO2pF JZ4NC9VN+PZVETe
VL8b0tMvWPQ44MRUXCCM+UAHO1MBD2pcEnpQ1R/Mz YxTzZzdv jP5iBn4GAp7kKjU
w/+FVBh1NiksXJjQG16MHbCZhtgsntJz17tKGY4Sg JXZaUDOTnpPeCBLEmWNUZ
|
操作界面、表格与配置图
1
2
| 4hAOVMTLIZA4FLAmI7yZqwRer4EvngbmZcé6cflhvxb1J69UHhK62KS6513MP3V
Generated-by-Nova
|
确保安装 aide、nmap、socat 和 wireshark 软件包。
1
2
3
4
5
| packages:
- aide
- nmap
- socat
- wireshark
|
加载 /home/student/.bashrc 以启用 yv 别名。验证 /home/student/user-data 符合 YAML 格式,并修正报告的错误。
1
2
| [student@workstation ~]$ source ~/.bashrc
[student@workstation ~]$ yv ~/user-data
|
加载 /home/student/developer1-finance-rc 环境文件,使用以下属性启动实例:
实例属性
| 属性 | 值 |
|---|
| 规格 | default |
| 密钥对 | example-keypair |
| 网络 | finance-network1 |
| 镜像 | rhe17 |
| 安全组 | default |
| user-data | /home/student /user-data |
| 名称 | finance-admin1 |
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
--key-name example-keypair \
--nic net-id=finance-network1 \
--security-group default \
--image rhel7 \
--user-data ~/user-data \
--wait finance-admin1
.. output omitted...
|
操作界面、表格与配置图
列出可用的浮动 IP 地址,然后分配给 finance-admin1。
列出浮动 IP;未分配地址的 Port 值为 None。实际可用地址及数量可能与下面的输出不同。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack floating ip list \
-c "Floating IP Address" -c Port
Seee
| Floating IP Address | Port |
Ceeeee
| 172.25. 250.110 | None |
| 172.25. 250.107 | None |
2ee
|
将一个未分配浮动 IP 关联到 finance-admin1。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add floating \
ip finance-admin1 172.25.250.110
|
验证 cloud-init 定制是否生效;如有失败,查看 /var/log/cloud-init.log 排查。
使用 ssh 命令试图登录到 finance-admin1 实例,作为 cloud-admin 用户。/home/student /.ssh/example-keypair 私人密钥在课堂中自动使用。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh cloud-admin@172.25.250.110
warning: Permanently added '172.25.250.110' (ECDSA) to the list of known hosts.
[cloud-admin@finance-admin1 ~]$
|
确认已安装 aide、nmap、socat 和 wireshark 软件包。
1
2
3
4
5
6
7
8
9
| [cloud-admin@finance-admin1 ~]$ rpm -qa | egrep 'aide|nmap|socat|wireshark'
socat-1.7.3.2-2.e17.x86_64
wireshark-1.10.14-14.e17.x86_64
aide-0.15.1-13.e17.x86_64
nmap-ncat -6.40-13.e17.x86_64
nmap-6.40-13.e17.x86_64
[cloud-admin@finance-admin1 ~]$ logout
Connection to 172.25.250.110 closed.
[student@workstation ~(developer1-finance)]$
|
在 workstation 上运行 lab customization-img-cloudinit cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab customization-img-cloudinit cleanup
|
操作界面、表格与配置图
实验:执行镜像操作#
执行镜像操作#
操作检查清单#
在此实验中,使用 diskimage-builder 建立一个磁盘镜像,用 guestfish 修改它,上传到镜像服务,然后使用新镜像启动一个实例。
学习目标#
完成后,能够:
使用 diskimage-builder 构建镜像。
使用 post-install 脚本自定义镜像。
使用 guestfish 定制镜像。
上传镜像到 OpenStack 镜像服务。
°
使用定制镜像启动实例。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab customization-review setup 命令,这样可以确保所需的软件包安装在 workstation 上,并为环境提供启动实例所需的资源。
1
| [student@workstation ~]$ lab customization-review setup
|
在 workstation 下载 http://materials.example.com/osp-small.qcow2,保存到 /home/student/。
创建要在 /home/student/. 下工作的 /usr/share/diskimage-builder/elements 目录副本
在 rhel7 目录的工作副本下创建 post-install.d 目录。
在 rhel7/post-install.d 目录下添加脚本,以启用 httpd 服务。
导出diskimage-builder所要求的下列环境变量。DIB_NO_TMPFS变量只是因为workstation有小硬盘,在大多数情况下不需要。
环境变量
| 变量 | 内容 |
|---|
| DIB_LOCAL_IMAGE | /home/student /osp-small.qcow2 |
| DIB_YUM_REPO_CONF | “/etc/yum.repos.d/openstack.repo” |
操作界面、表格与配置图
| 变量 | 内容 |
|---|
| ELEMENTS_PATH | /home/student/elements |
| DIB_NO_TMPFS | 1 |
使用先前配置的 diskimage-builder 元素构建 production-rhel-web.qcow2(RHEL 7),在镜像中包含 httpd 软件包。出现提示时输入 student 的密码。
使用 guestfish 向 production-rhel-web.qcow2 添加自定义网页。在 index.html 中写入 production-rhel-web,确认 /var/www/html/index.html 的 SELinux 上下文正确。
以 operator1 用户使用 production-rhel-web.qcow2 创建名为 production-rhel-web 的镜像,要求最小磁盘 10 GiB、最小内存 2 GiB。
以 operator1 用户使用以下属性启动实例:
实例属性
| 属性 | 值 |
|---|
| 规格 | default |
| 密钥对 | example-keypair |
| 网络 | product ion-network1 |
| 镜像 | product ion-rhel-web |
| 安全组 | default |
| 名称 | product ion-web1 |
列出可用的浮动 IP 地址,然后分配给 production-web1。
使用 ssh 登录 production-web1,确认已安装 httpd 软件包,且 httpd 服务已启用并正在运行。
从 workstation 验证 production-web1 提供的自定义网页包含 production-rhel-web。
在 workstation 上运行 lab customization-review grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
1
| [student@workstation ~]$ lab customization-review grade
|
在 workstation 上运行 lab customization-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab customization-review cleanup
|
操作界面、表格与配置图
执行镜像操作#
操作检查清单#
在此实验中,使用 diskimage-builder 建立一个磁盘镜像,用 guestfish 修改它,上传到镜像服务,然后使用新镜像启动一个实例。
学习目标#
完成后,能够:
使用 diskimage-builder 构建镜像。
°
使用 post-install 脚本自定义镜像。
使用 guestfish 定制镜像。
上传镜像到 OpenStack 镜像服务。
使用定制镜像启动实例。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab customization-review setup 命令,这样可以确保所需的软件包安装在 workstation 上,并为环境提供启动实例所需的资源。
1
| [student@workstation ~]$ lab customization-review setup
|
在 workstation 下载 http://materials.example.com/osp-small.qcow2,保存到 /home/student/
目录。
1
2
| [student@workstation ~]$ wget http://materials.example.com/osp-small.qcow2 \
-O0 /home/student/osp-small.qcow2
|
创建要在 /home/student/. 下工作的 /usr/share/diskimage-builder/elements 目录副本
1
2
| [student@workstation ~]$ cp -a /usr/share/diskimage-builder/elements \
/home/student/
|
在 rhel7 工作目录下创建 post-install.d。
1
| [student@workstation ~]$ mkdir -p /home/student/elements/rhel7/post-install.d
|
在 rhel7/post-install.d 下添加一个脚本,用于启用 httpd 服务。
操作界面、表格与配置图
1
2
3
4
5
| [student@workstation ~]$ cd /home/student/elements/rhel7/post-install.d/
[student@workstation post-install.d]$ cat <<EOF > 01-enable-services
#!/bin/bash
systemctl enable httpd
EOF
|
设置脚本上的可执行权限。
1
| [student@workstation post-install.d]$ chmod +x 01-enable-services
|
换回主目录。
1
2
| [student@workstation post-install.d]$ cd
[student@workstation ~]$
|
导出 diskimage-builder 所需的以下环境变量。
DIB_NO_TMPFS变量之所以需要,只是因为workstation有一个小硬盘,在大多数情况下不需要。
环境变量
| 变量 | 内容 |
|---|
| DIB_LOCAL_IMAGE | /home/student /osp-small.qcow2 |
| DIB_YUM_REPO_CONF | “/etc/yum.repos.d/openstack. repo” |
| ELEMENTS_PATH | /elements /home/student |
| DIB_NO_TMPFS | 1 |
1
2
3
4
| [student@workstation ~]$ export DIB_LOCAL_IMAGE=/home/student/osp-small.qcow2
[student@workstation ~]$ export DIB_YUM_REPO_CONF=/etc/yum.repos.d/openstack.repo
[student@workstation ~]$ export ELEMENTS_PATH=/home/student/elements
[student@workstation ~]$ export DIB_NO_TMPFS=1
|
使用先前配置的 diskimage-builder 元素构建 production-rhel-web.qcow2(RHEL 7),在镜像中包含 httpd 软件包。出现提示时输入 student 的密码。
1
2
3
4
| [student@workstation ~]$ disk-image-create vm rhel7 \
-t qcow2 \
-p httpd \
-O production-rhel-web.qcow2
|
使用 guestfish 向 production-rhel-web.qcow2 添加自定义网页,在 index.html 中写入 production-rhel-web,并确认 /var/www/html/index.html 的 SELinux 上下文正确。
打开 guestfish shell,操作 production-rhel-web.qcow2 镜像。
1
2
| [student@workstation ~]$ guestfish -i -a production-rhel-web.qcow2
.. Output omitted...
|
操作界面、表格与配置图
创建 /var/www/html/index.html 文件。
1
| ><fs> touch /var/www/htm1/index.html
|
编辑 /var/www/html/index.html,写入要求的文字。
1
2
| ><fs> edit /var/www/html/index.html
This instance uses the production-rhel-web image.
|
恢复 /var/www/ 目录(包括 index.html)的 SELinux 上下文,确保强制模式下新网页可用。
1
| ><fs> selinux-relabel /etc/selinux/targeted/contexts/files/file_contexts /var/www/
|
退出 guestfish shell。
1
2
| ><fs> exit
[student@workstation ~]$
|
以 operator1 用户使用 production-rhel-web.qcow2 创建名为 production-rhel-web 的镜像,要求最小磁盘 10 GiB、最小内存 2 GiB。
加载 /home/student/operator1-production-rc 环境文件。
1
2
| [student@workstation ~]$ source ~/operator1-production-re
[student@workstation ~(operator1i-production)]$
|
将 production-rhel-web.qcow2 上传到 OpenStack 镜像服务。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack image create \
--disk-format qcow2 \
--min-disk 10 \
--min-ram 2048 \
--file ~/production-rhel-web.qcow2 \
production-rhel-web
.. Output omitted...
|
以 operator1 用户使用以下属性启动实例:
实例属性
| 属性 | 值 |
|---|
| 规格 | default |
| 密钥对 | example-keypair |
| 网络 | product ion-network1 |
| 镜像 | production-rhel-web |
操作界面、表格与配置图
| 属性 | 值 |
|---|
| 安全组 | default |
| 名称 | product ion-web1 |
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--key-name example-keypair \
--nic net-id=production-network1 \
--image production-rhel-web \
--security-group default \
--wait production-web1
.. Output omitted...
|
列出可用浮动 IP,将其中一个分配给 production-web1。可用地址的 Port 属性为 None。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack floating ip list \
-c "Floating IP Address" -c Port
Deee
| Floating IP Address | Port |
Foal toa tron tc on(eltoneters eters elconocer entenderfe
| 172.25.250.104 | None |
Seeee
|
将可用浮动 IP 关联到 production-web1。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-web1 172.25.250.104
|
使用 ssh 登录 production-web1,确认 httpd 软件包已安装,服务已启用且正在运行。
使用 SSH 登录到 production-web1 实例。
1
2
3
| [student@workstation ~(operator1-production)]$ ssh cloud-user@172.25.250.104
Warning: Permanently added '172.25.250.104' (ECDSA) to the list of known hosts.
[cloud-user@production-web1 ~]$
|
验证是否安装了 httpd 软件包。
1
2
| [cloud-user@production-web1 ~]$ rpm -q httpd
httpd-2.4.6-45.e17.x86_64
|
确认 httpd 服务正在运行,然后退出登录。
1
2
3
4
5
6
7
| [cloud-user@production-web1 ~]$ systemctl status httpd
.. output omitted...
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset:
disabled)
Active: active (running) since Wed 2017-05-24 23:55:42 EDT; 8min ago
Docs: man: httpd(8)
man: apachect1(8)
|
操作界面、表格与配置图
1
2
3
4
| Main PID: 833 (httpd)
... output omitted...
[cloud-user@production-web1 ~]$ logout
[student@workstation ~(operator1-production)]$
|
从 workstation 验证 production-web1 提供的自定义网页包含 production-rhel-web。
1
2
3
| [student@workstation ~(operator1-production)]$ curl http://172.25.250.104/
index. html
This instance uses the production-rhel-web image.
|
在 workstation 上运行 lab customization-review grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
1
| [student@workstation ~]$ lab customization-review grade
|
在 workstation 上运行 lab customization-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab customization-review cleanup
|
操作界面、表格与配置图
自测问题#
- 镜像上传成功能否证明它能正常启动?
- 验证 user-data 是否生效,应检查什么?
自测答案#
- 不能,还需启动实例并验证。上传验证的是文件接收,启动与初始化还取决于内容及属性。
- cloud-init 日志及实例内的目标结果。初始化执行与实例虚拟化状态不同,应检查实例内的结果。
C5-管理存储#
四类存储的差异#
| 类型 | 使用方式 | 关键问题 |
|---|
| 实例临时存储 | 作为实例运行环境的一部分 | 生命周期是否随实例结束? |
| Cinder 块存储 | 向实例提供块设备 | 卷是否附加、客户机是否识别并挂载? |
| Swift / 对象存储接口 | 通过 API 操作对象 | 容器、对象、认证及访问路径是否正确? |
| Manila 共享文件系统 | 提供共享文件访问 | 共享后端、协议及访问规则是否满足要求? |
共享后端可能使用同一种存储技术,但客户端看到的接口和生命周期仍然不同。例如,“后端是 Ceph”不能替代对块设备、对象接口和文件共享的选择。
块存储要验证两端#
OpenStack 中的卷状态与实例内部使用情况需要分别检查。卷成功附加后,客户机仍可能需要识别设备、创建文件系统并挂载。验证时记录卷 UUID、实例 UUID、客户机设备及挂载点;不要只依赖可能变化的设备顺序。
对象与文件不是同一种操作#
对象存储通过对象名和 API 管理数据;文件共享通过文件系统协议提供访问。不能用“能否像本地目录一样挂载”来评价对象存储是否正常。比较存储服务时,应核对访问接口、认证方式、命名规则和数据读取路径。
临时与持久存储的生命周期#
删除实例前,明确哪些数据位于实例临时磁盘、哪些位于独立卷,以及删除动作是否会连带删除卷。快照、镜像与卷也具有不同用途。实验中通过实际创建、附加、写入、卸载和重新访问来证明持久性,避免仅凭资源名推断。
排错时分清层次#
从服务资源状态检查到附加关系,再检查客户机内部,最后沿后端日志定位异常。共享文件系统还需检查访问规则及网络连通性;对象存储需确认认证和目标容器。清理前卸载正在使用的文件系统,并按依赖关系释放资源。
从 OpenStack 资源追到 Ceph#
1
2
3
4
5
| Glance Image → images Pool → RBD
Cinder Volume → volumes Pool → RBD
Nova 临时磁盘 → vms Pool → RBD(按实际后端配置)
Manila Share → CephFS → MDS 元数据 + RADOS 数据
Object API → Swift 后端或 Ceph RGW
|
检查服务和后端#
1
2
3
4
5
6
7
8
9
| # 管理员客户端
openstack volume service list
openstack volume type list
openstack volume show <卷UUID>
# 具备 Ceph 管理配置的课堂节点
ceph -s
ceph osd lspools
rbd ls images
rbd ls volumes
|
从资源 UUID 关联 RBD 名称,避免只凭相似名称判断。客户端能创建卷、实例能附加卷、Ceph 中能定位后端是不同层次的证据。
Cephx 与 libvirt#
Cinder / Nova 访问 RBD 需要正确的 Ceph 配置和最小权限凭据。libvirt secret 提供虚拟机访问 RBD 所需密钥;Nova 配置中的 secret UUID 与宿主机注册项要一致。卷 available 但附加失败时,应继续查计算节点而非只重建卷。
Manila 与 CephFS#
1
2
3
4
5
6
7
| # 使用课程提供的 manila 客户端与共享类型
manila type-list
manila create --name demo-share --share-type cephfstype cephfs 1
manila list
manila show demo-share
manila access-allow demo-share cephx demo-client
manila access-list demo-share
|
需确认实验后端支持此协议和访问类型。创建后等待 available;授权后依据实际 export location 与访问凭据挂载。不要从其他共享复制密钥。
文件共享验收#
实例 A 具备存储网络和客户端 → 按返回的 export 与 Cephx 凭据挂载 → 写入文件 → 实例 B 使用同一共享读取。这里验证的是多客户端共享文件系统,不能用两台实例各挂一块独立卷替代。
生命周期与备份#
卷快照不是异地备份;共享文件与块存储恢复需要不同流程。删除实例前检查临时盘、根卷、数据卷和 Heat 删除策略,实际写入并在生命周期操作后读取才足以证明数据保留。
实验操作#
引导练习:实现块存储#
引导练习#
实现块存储#
在此练习中,校验 Ceph 集群的健康状况。您还将校验和测试使用 Ceph 集作为 OpenStack 镜像服务和 OpenStack 块存储服务的后端的设置。
学习目标#
完成后,能够:
从 controller 检查 Ceph 健康状态和配置。
创建镜像并在 Ceph 中定位它。
创建卷并在 Ceph 中定位它。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab storage-backend setup,确保本引导练习需要的规格、网络、子网、安全组和用户环境文件已准备好。
1
| [student@workstation ~]$ lab storage-backend setup
|
以 root 用户在 controller0 上验证 ceph-mon 服务正在运行。
打开 SSH 会话至 controller0 作为 root。
1
| [student@workstation ~]$ ssh root@controller0
|
使用 systemctl 查看 ceph-mon 状态。
1
2
3
4
5
6
7
8
9
10
| [root@controller0 ~]# systemctl list-units -t service ceph\*
UNIT LOAD ACTIVE SUB DESCRIPTION
ceph-mds@controller0.service loaded active running Ceph MDS
ceph-mgr@controller0.service loaded active running Ceph Manager
ceph-mon@controller0.service loaded active running Ceph Monitor
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
3 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
|
在课堂环境中运行 ceph -s,查看 Ceph 集群状态。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [root@controller0 ~]# ceph -s
cluster:
id: 817893a8 -b2f5-1168-8087 -52540001fac8
health: HEALTH_OK
services:
mon: 1 daemons, quorum controller0
mgr: controller@(active)
mds: cephfs-1/1/1 up {09=controller0=up:active}
osd: 3 osds: 3 up, 3 in
data:
pools: 7 pools, 416 pgs
objects: 603 objects, 4498 MB
usage: 4830 MB used, 53504 MB / 58334 MB avail
pgs: 416 activet+clean
|
当前集群健康状态为 HEALTH_OK,说明 Ceph 集群正常运行。
校验Ceph 设置是否以正确的池名适当定义,例如 OpenStack 镜像服务使用 Ceph 存储作为后端存储供应商以容纳镜像。
从 OpenStack 镜像服务 API 容器的配置文件获取 Ceph 设置。
1
2
3
4
5
6
7
8
| [root@controller0 ~]# docker \
exec -it glance_api grep -Ei 'rbd|ceph' \
/etc/glance/glance-api.conf | grep -v "#
stores=http,rbd
default_store=rbd
rbd_store_pool=images
rbd_store_user=openstack
rbd_store_ceph_conf=/etc/ceph/ceph.conf
|
确认 images 存储池和 cephx 用户 client.openstack 存在,以便将 Ceph 配置为 OpenStack 镜像服务的后端。
在 controller0 执行 ceph osd lspools,确认 images 存储池存在。
1
2
| [root@controller0 ~]# ceph osd lspools
1 images,2 metrics,3 backups,4 vms,5 volumes,6 manila_data,7 manila_metadata,
|
注意:本引导练习后续步骤还会使用 volumes 存储池。
执行 ceph auth list,确认 cephx 用户 client.openstack 存在。
1
| [root@controller0 ~]# ceph auth list
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| .. Output omitted...
client.openstack
key: AQA+CZNDAAAAABAAXPUXXZqYw3mwT 7VZ2 TQ8 jQ==
caps: [mds]
caps: [mgr] allow *
caps: [mon] profile rbd
caps: [osd] profile rbd pool=volumes, profile rbd pool=backups, profile rbd
pool=vms, profile rbd pool=images, profile rbd pool=metrics
.. output omitted...
|
注意,client.openstack 对 images 存储池拥有由 rbd 能力配置定义的块存储访问权限。
从 controller0 中注销。
1
2
| [root@controller0 ~]# logout
[student@workstation ~]$
|
在 workstation 以 finance 项目的 developer1 用户创建 Glance 镜像。镜像文件位于 http://materials.example.com/osp-
small.qcow2。加载 developer1 的凭据文件。
1
2
| [student@workstation ~]$ source developer1-finance-rc
[student@workstation ~(developeri1-finance)]$
|
注意:developer1 的凭据文件已在实验初始化步骤中创建。
下载 http://materials.example.com/osp-small.qcow2。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ wget \
http://mater ials.example.com/osp- small. qcow2
..- output omitted...
Saving to: ''osp-small.qcow2'
100% [ =====$$$55 SSS S55 S3555555555555555=5====>] 1,528,233,984 58.2MB/S in 26s
.. Output omitted...
|
使用下载的 /home/student/osp-small.qcow2 创建 Glance 镜像,命名为 finance-image。
1
2
3
4
5
| [student@workstation ~(developer1-finance)]$ openstack image create \
--disk-format qcow2 \
--file osp-small.qcow2 \
finance-image
.. output omitted...
|
确认 finance-image 的状态为 active。
1
| [student@workstation ~(developer1-finance)]$ openstack image list
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| HEE BERET KEE SEKone Ran San Sekar kere oka een aeeoaes eae ene CaeRane aR ea ante eemnecenesea
| ID | Name | Status |
NNR a ECE Br ak
| d0712086-6594-4620-b936-e58573e9c451 | finance-image | active |
| 988c81e7 -bfd7 -45eb-8d51-c429be83315b | rhel7 | active |
| bv6aef5f-3bc2-4297-a448-cff9bsocsé6cf | rhel7-db | active |
| dbe819bc-a82e-4462-9711-8005760fOc90 | rhel7-web | active |
NR a SCE Ber ae
|
查看 Ceph 的 images 存储池,确认其中的镜像 ID 与 OpenStack 镜像服务显示的一致。
打开 SSH 会话到 controller0 成为 root。
1
2
| [student@workstation ~(developer1-finance)]$ ssh root@controller0
[root@controller0 ~]#
|
查看 Ceph 的 images 存储池内容,核对镜像 ID。
镜像 ID 在您的环境中可能有所不同,您需要在前一个命令中使用您环境的镜像 ID。
1
2
3
| [root@controller0 ~]# rados -p images ls | grep \
d0712086 - 6594-4620 -b936-e58573e9C451
rbd_id.d0712086 -6594-4620-b936 -e58573e9C451
|
从 controller0 注销。
1
2
| [root@controller0 ~]# logout
[student@workstation ~(developer1-finance)]$
|
以 finance 项目的 developer1 用户使用以下属性启动实例:
镜像:finance-image
网络: finance-network1安全组: default 服务器名称: finance-server1
执行以下命令启动新实例。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server \
create --flavor default \
--image finance-image \
--nic net-id=finance-network1 \
--security-group default \
finance-server1
.. Output omitted...
|
确认 finance-server1 的状态为 ACTIVE。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server \
list -c Name -c Status
|
操作界面、表格与配置图
1
2
3
| | Name | Status |
Spore ate aera ateve tere aera peretanera oneal
| finance-server1 | ACTIVE |
|
以 developer1 在 finance 项目创建 1 GB 的 finance-volume1,并附加到 finance-server1。
运行以下命令以创建卷。
1
2
3
4
| [student@workstation ~(developeri1-finance)]$ openstack volume \
create --size 1 \
finance-volume1
.. Output omitted...
|
确认新建 finance-volume1 已可用。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack volume list
ta ninennenengebaeinennrcnecsensheecnerncose heecsectessccsccncosnct#
| ID | Name | Status | Size | Attached to |
cH afm fem rmsartes fem nme pee em mre fen pei meme pennies epi imc
| 92ef...4f4f | finance-volume1 | available | 1 | |
peti rp pp
|
将 finance-volume1 附加到 finance-server1 上。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack server \
add volume \
finance-server1 finance-volume1
|
在浏览器中打开 finance-server1 的控制台 URL,以 root 登录,密码为 redhat。确认新卷出现在客户机磁盘列表中,可以使用 lsblk
命令查看磁盘。
注意:使用 openstack console url show 获取实例的控制台 URL。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack console url show \
finance-server1 -f json
{
"url": "http: //172. 25. 250.50: 6080/vnc_auto. html? token=0081acd7 -
be8b-4eef-83a9 -3c79a47adbc7",
"type": "novnc"
|
确认 finance-volume1 以对象形式存在于 Ceph 的 volumes 存储池。
在 workstation 上通过 SSH 以 root 用户登录 controller0。
1
| [student@workstation ~(developer1-finance)]$ ssh root@controller0
|
操作界面、表格与配置图
使用 rados 查看 volumes 存储池的内容。
1
2
3
4
5
6
| [root@controller0 ~]# rados -p volumes ls
rbd_header .101fe33e645f4
rbd_object_map.101fe33e645T4
rbd_directory
rbd_info
rbd_id. volume-92ef6080-60ec-4017- b5ca-5e44485f4f4F
|
确认上述命令输出的卷 ID 与步骤 8.2 中 openstack volume list 显示的块存储卷 ID 一致。你所在环境中的卷 ID 可能
环境。
核对 Ceph 配置及存储池名称,确保 OpenStack 块存储服务使用 Ceph 作为后端存储
后端提供程序,以容纳卷。
运行以下命令以从配置文件获取 Ceph 设置
中读取设置,该文件属于 OpenStack 块存储服务 API 容器。
1
2
3
4
5
6
7
8
9
10
11
| [root@controller0 ~]# docker \
exec -it cinder_api \
grep -Ei 'rbd|ceph' \
/etc/cinder/cinder.conf | grep -v A#
enabled_backends=tripleo_ceph
[tripleo_ceph]
volume_backend_name=tripleo_ceph
volume_driver=cinder.volume.drivers.rbd.RBDDriver
rbd_ceph_conf=/etc/ceph/ceph.conf
rbd_user=openstack
rbd_pool=volumes
|
从 controller0 中注销。
1
2
| [root@controller0 ~]# logout
[student@workstation ~(developeri1-finance)]$
|
在 workstation 上运行 lab storage-backend cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab storage-backend cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:比较对象存储#
引导练习#
比较对象存储#
在此练习中,会在 OpenStack 对象存储处中添加第二个磁盘。您还将创建一个含有文件对象的物件容器,并在后端磁盘中找到对象的结构。
学习目标#
完成后,能够:
在 OpenStack 对象存储中创建对象,并在磁盘上找到实际存储的数据。
开始之前#
以 student 密码作为 student 登录到 workstation。
在 workstation 上运行 lab storage-swift setup,确认 OpenStack 服务正在运行,实验环境已准备就绪。
1
| [student@workstation ~]$ lab storage-swift setup
|
验证 OpenStack 对象存储相关 Docker 容器的健康状态。以 root 通过 SSH 登录 controller0。
1
2
| [student@workstation ~]$ ssh root@controller0
[root@controller0 ~]#
|
验证 OpenStack 对象存储相关容器的健康状态。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [root@controller0 ~]# docker ps --format="{{.Names}}\t{{.Status}}" | grep swift
swift_proxy Up About an hour (healthy)
swift_container_auditor Up About an hour
swift_object_expirer Up About an hour
swift_object_updater Up About an hour
swift_container_replicator Up About an hour
swift_account_auditor Up About an hour
swift_account_server Up About an hour (healthy)
swift_object_replicator Up About an hour
swift_container_server Up About an hour (healthy)
swift_rsync Restarting (11) 49 minutes ago
swift_account_reaper Up About an hour
swift_account_replicator Up About an hour
swift_object_auditor Up About an hour
swift_object_server Up About an hour (healthy)
swift_container_updater Up About an hour
|
操作界面、表格与配置图
注意:可以忽略上述输出中 swift_rsync 容器的 Restarting 状态。
将 /srv/node/d2 作为额外设备添加到 OpenStack 对象存储,并更新 ring 文件,确保每个存储设备都保存
同一对象的一个副本。
注意:受课堂环境限制,使用 /srv/node/d2 目录代替磁盘设备。实际环境应使用真实磁盘,通常格式化为 XFS 等文件系统。
校验当前OpenStack 对象环文件所知道的单一设备。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [root@controller0 ~]# cd /var/lib/config-data/puppet-generated/swift/etc/swift/
[root@controller0 swift]# swift-ring-builder account.ring.gz
Note: using account.builder instead of account.ring.gz as builder file
account.builder, build version 2, id 5ef67cb074a0430ebc5d25fice51f329
1024 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance,
@.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00
remaining)
The overload factor is 9.00% (0.900000)
Ring file account.ring.gz is up-to-date
Devices: id region zone ip address:port replication ip:port name weight
partitions balance flags meta
[0] ay 1 172.24.4.1:6002 172.24.4.1: 6002 d1 100.00
|
1024 0.00
1
2
3
4
5
6
7
8
9
10
11
12
| [root@controller0 swift]# swift-ring-builder container.ring.gz
Note: using container.builder instead of container.ring.gz as builder file
container.builder, build version 2, id 66dcd204b5f44375b5d4e1dd677a962b
1024 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance,
©.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00
remaining)
The overload factor is 9.00% (0.000000)
Ring file container.ring.gz is up-to-date
Devices: id region zone ip address:port replication ip:port name weight
partitions balance flags meta
[o] 1 1 172.24.4.1:6001 172.24.4.1: 6001 d1 100.00
|
1024 6.00
1
2
3
4
5
6
7
8
| [root@controller0 swift]# swift-ring-builder object.ring.gz
Note: using object.builder instead of object.ring.gz as builder file
object.builder, build version 2, id 8a94f604449f4d83aeb2c18boebd47f79
1024 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance,
@.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00
remaining)
The overload factor is 9.00% (0.900000)
|
操作界面、表格与配置图
1
2
3
4
5
| Ring file object.ring.gz is up-to-date
Devices: id region zone ip address:port replication ip:port name weight
partitions balance flags meta
10] 1 1 172.24.4.1: 6000 172.24.4.1: 6000 d1 100.00
1024 0.00
|
更新 OpenStack 对象存储的 ring builder 文件,将 /srv/node/d2 添加为额外设备,权重设为 100。
1
2
3
4
5
6
7
8
9
10
11
12
| [root@controller0 swift]# swift-ring-builder account.builder \
add z1-172.24.4.1:6002/d2 100
WARNING: No region specified for z21-172.24.4.1:6002/d2. Defaulting to region 1.
Device d1ir1z1-172.24.4.1:6002R172.24.4.1:6002/d2_"" with 100.90 weight got id 1
[root@controller0 swift]# swift-ring-builder container.builder \
add 21-172.24.4.1:6001/d2 100
WARNING: No region specified for z1-172.24.4.1:6001/d2. Defaulting to region 1.
Device d1r1z1-172. 24.4.1: 6001R172.24.4.1:6001/d2_"" with 100.0 weight got id 1
[root@controller0 swift]# swift-ring-builder object.builder \
add z1-172.24.4.1:6000/d2 100
WARNING: No region specified for z1-172.24.4.1:6000/d2. Defaulting to region 1.
Device d1r1z1-172. 24.4.1: 6000R172.24.4.1:6000/d2_"" with 100.0 weight got id 1
|
在 ring builder 文件中将副本数设为 2。
1
2
3
4
5
6
7
8
9
| [root@controller0 swift]# swift-ring-builder account.builder set_replicas 2
The replica count is now 2.000000.
The change will take effect after the next rebalance.
[root@controller0 swift]# swift-ring-builder container.builder set_replicas 2
The replica count is now 2.900000.
The change will take effect after the next rebalance.
[root@controller0 swift]# swift-ring-builder object.builder set_replicas 2
The replica count is now 2.900000.
The change will take effect after the next rebalance.
|
校验新设备以及环状构建器文件中的复制数。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| [root@controller0 swift]# swift-ring-builder account.builder
account.builder, build version 3, id 5ef67cb074a0430ebc5d25fice51f329
1024 partitions, 2.900000 replicas, 1 regions, 1 zones, 2 devices, 100.00 balance,
©.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:90
remaining)
The overload factor is 0.00% (0.900000)
Ring file account.ring.gz is obsolete
Devices: id region zone ip address:port replication ip:port name weight
partitions balance flags meta
0 1 1 172.24.4.1:6002 172.24.4.1: 6002 d1 100.90
1024 0.00
na a 1 172.24.4.1:6002 172.24.4.1: 6002 d2 100.090
0 -100.00
[root@controller0 swift]# swift-ring-builder container.builder
container.builder, build version 3, id 66dcd204b5f44375b5d4e1dd677a962b
1024 partitions, 2.900000 replicas, 1 regions, 1 zones, 2 devices, 100.00 balance,
©.00 dispersion
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| The minimum number of hours before a partition can be reassigned is 1 (0:00:00
remaining)
The overload factor is 9.00% (0.900000)
Ring file container.ring.gz is obsolete
Devices: id region zone ip address:port replication ip:port name weight
partitions balance flags meta
10] 1 1 172.24.4.1:6001 172.24.4.1: 6001 d1 100.00
1024 0.00
1 1 1 172.24.4.1:6001 172.24.4.1:6001 d2 100.00
0 -100.00
[root@controller0 swift]# swift-ring-builder object.builder
object.builder, build version 3, id 8a94f604449f4d83aeb2c18bebd47f79
1024 partitions, 2.900000 replicas, 1 regions, 1 zones, 2 devices, 100.00 balance,
©.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00
remaining)
The overload factor is 9.00% (0.900000)
Ring file object.ring.gz is obsolete
Devices: id region zone ip address:port replication ip:port name weight
partitions balance flags meta
0 1 1 172.24.4.1: 6000 172.24.4.1: 6000 di 100.90
1024 0.00
1 1 1 172.24.4.1:6000 172.24.4.1: 6000 d2 100.00
0 -100.00
|
重新平衡 OpenStack 对象存储环文件。
1
2
3
4
5
6
| [root@controller0 swift]# swift-ring-builder account.builder rebalance
Reassigned 1024 (100.00%) partitions. Balance is now 9.00. Dispersion is now 9.00
[root@controller0 swift]# swift-ring-builder container.builder rebalance
Reassigned 1024 (100.00%) partitions. Balance is now ©.00. Dispersion is now 0.00
[root@controller0 swift]# swift-ring-builder object.builder rebalance
Reassigned 1024 (100.00%) partitions. Balance is now ©.00. Dispersion is now 0.090
|
重新启动swift_proxy、swift_account_server、swift_container_server和swift_object_server容器。
1
2
3
4
5
6
7
| [root@controller0 swift]# docker restart \
swift_proxy swift_account_server \
swift_container_server swift_object_server
swift_proxy
swift_account_server
swift_container_server
swift_object_server
|
从 controller0 注销。
1
2
3
| [root@controller0 swift]# logout
Connection to controller0 closed.
[student@workstation ~]$
|
在 finance 项目中创建对象容器 finance-container1。上传 /home/student/finance-object1 到 finance-container1 作为 finance-
操作界面、表格与配置图
object1 对象。定位 finance-object1 对象在 OpenStack 对象仓库后端存储设备中的文件。
以 developer1 创建对象容器 finance-container1。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$ openstack container create \
finance-container1
Ee C Ta(CCTaCe Ce CCT SgiC (CTC Tia SeTaN oeTateTin a Si SeTis SeTae TCT eT e
| account | container | x-trans-id |
a ea ISeeen
| AUTH_3c00...953c | finance-container1 | txe@cé6b...30a9 |
Seer ee Se re
|
上传 /home/student/finance-object1 到 finance-container1。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack object create \
finance-container1 finance-object1
See eee ee ee ee ee en
| object | container | etag |
SS. eee i
| finance-objecti | finance-container1 | 740580d95587be0197cf16e2d96f4931 |
te eee ee tbe en i tn i ee i ee ee ee eet
|
在对象存储后端设备中定位 finance-object1。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ ssh root@controllere \
find /srv/node -iname *.data
/srv/node/di/objects/211/7d6/34cd...b7d6/1541157229 .63432.data
/srv/node/d2/objects/211/7d6/34cd...b7d6/1541157229.63432.data
|
注意:/srv/node/d1 与 /srv/node/d2 目录下各有一份数据文件副本,这两个目录在课堂环境中作为
对象存储设备。这些数据文件存放 finance-container1 容器中的 finance-object1 对象。
确认上述数据文件的内容与 finance-object1 一致。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ cat finance-object1
This is to test the OpenStack Object Store service
[student@workstation ~(developer1-finance)]$ ssh root@controller0 \
'find /srv/node -iname *.data -exec cat {} \;'
This is to test the OpenStack Object Store service
This is to test the OpenStack Object Store service
|
将 /home/student/finance-object2 上传到 finance-container1,命名为 finance-object2。追踪后端数据文件,验证对象副本,并识别每个对象对应的副本。
将 /home/student/finance-object2 上传到 finance-container1。
1
2
| [student@workstation ~(developer1-finance)]$ openstack object create \
finance-container1 finance-object2
|
操作界面、表格与配置图
追踪后端数据文件,确认每个 /srv/node/d1 和 / srv/node/d2 存储装置都含有这些物体的副本。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ ssh root@controller0 \
find /srv/node -iname *.data
/srv/node/di/objects/211/7d6/34cd. ..b7d6/1541494418 .07269 data
/srv/node/d1/objects/150/f97/25ac...0f97/1541494485.92954.data
/srv/node/d2/objects/211/7d6/34cd. ..b7d6/1541494418 .07269 data
/srv/node/d2/objects/150/f97/25ac...f97/1541494485.92954.data
|
注意每对数据文档的等级结构的相似性,
它们分别位于两个存储设备中。这种相似性有助于确定数据文件
属于同一对象。例如,/srv/node/d1/ 与 /srv/node/d2/ 的 objects/211/7d6/34cd…b7d6/ 层次中均有 1541494418.07269.data,说明这些数据文件是同一对象的副本。
在 workstation 上运行 lab storage-swift cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab storage-swift cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理共享文件系统#
引导练习#
管理共享文件系统#
在此练习中,创建一个共享的文件系统,并从一个实例中访问它。
学习目标#
能够创建和使用以 Red Hat Ceph Storage 为后端的共享文件系统。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 运行 lab storage-manila setup,准备实验环境。该命令创建后续步骤中将使用的附加资源,
练习的不同步骤。
1
| [student@workstation ~]$ lab storage-manila setup
|
从 workstation 以 root 通过 SSH 登录 controller0。
1
2
| [student@workstation ~]$ ssh root@controller0
[root@controller0 ~]#
|
校验 OpenStack 共享文件系统服务的状态和配置设置。
在 controller0,核查与共享文件系统服务有关的容器是否有效。
1
2
3
4
| [root@controller0 ~]# docker ps --format="{{.Names}}\t{{.Status}}" | grep manila
openstack-manila-share-docker-0 Up 25 minutes
manila_api Up 28 minutes
manila_scheduler Up 28 minutes (healthy)
|
在 controller0 检查共享文件系统服务的配置;课堂环境使用 Red Hat Ceph Storage
作为存储提供者。
1
2
3
4
5
6
7
8
9
| [root@controller0 ~]# crudini --get \
/var/lib/config-data/puppet-generated/manila/etc/manila/manila.conf \
DEFAULT enabled_share_backends
cephfs
[root@controller0 ~]# crudini --get \
/var/lib/config-data/puppet-generated/manila/etc/manila/manila.conf \
DEFAULT enabled_share_protocols
CEPHFS
[root@controller0 ~]# tail \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
| /var/1lib/config-data/puppet-generated/manila/etc/manila/manila.conf
[cephfs]
driver_handles_share_servers=False
share_backend_name=cephfs
share_driver=manila.share.drivers.cephfs.driver.CephFSDriver
cephfs_conf_path=/etc/ceph/ceph.conf
cephfs_auth_id=manila
cephfs_cluster_name=ceph
cephfs_enable_snapshots=False
cephfs_protocol_helper_type=CEPHFS
|
注意:共享文件系统服务的配置文件通常是 /etc/manila/manila.conf。但在容器化 Overcloud 中,服务配置文件位于 /var/lib/config-data/puppet-generated//etc// 目录。请修改
在此目录下更改文件以调整容器化服务设置。要执行更改,重新启动或重新装入容器。
从 controller0 中注销。
1
2
3
| [root@controller0 ~]# logout
Connection to controller0 closed.
[student@workstation ~]$
|
以 Overcloud 用户 architect1 验证共享文件系统服务实例的状态;该操作需要管理员权限。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ source ~/architect1-finance-rc
[student@workstation ~(architect1i-finance)]$ manila service-list \
--columns Binary,Status,State
2 eee TeNaeTaeTa eka Naetee aera oeTeeas
| Binary | Status | State |
SP Fe et Feoe et et eeetet eet re
| manila-scheduler | enabled | up |
| manila-share | enabled | up |
|
在 finance 项目中创建容量为 1 GB 的 finance-share1 共享。创建 cephfstype 共享类型,并将其用于 finance-share1。
以 architect1 创建 cephfstype 共享类型,将 driver_handles_share_servers 设为 false。
1
2
| [student@workstation ~(architect1-finance) ]$ manila type-create cephfstype false
required_extra_specs | driver_handles_share_servers : False
|
|
1
2
3
4
| | Name | cephfstype
| Visibility | public |
| is_default | - |
| ID | bd3ae330-2170-4e57 -a54f -865faacde5fi
|
操作界面、表格与配置图
1
2
3
| | optional_extra_specs | |
| Description | None |
Fin epnn ee et
|
重要:若要动态扩展共享节点,将 driver_handles_share_servers 设为 true。
管理共享类型需要管理员权限。执行 source /home/student/architect1-finance-rc 加载 architect1 凭据。
命令。
以 developer1 用户创建新共享 finance-share1。
1
2
3
4
| [student@workstation ~(architect1-finance)]$ source developer1-finance-rc
[student@workstation ~(developer1-finance)]$ manila create \
--name finance-share1 --share-type cephfstype cephfs 1
.. output omitted...
|
确认新共享处于 available 状态。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ manila list \
--columns Name, 'Share Proto',Status, 'Share Type Name'
Se ee ee ee
| Name | Share Proto | Status | Share Type Name |
SeSe Se eer
| finance-share1 | CEPHFS | available | cephfstype |
SieSe ee aE Err
|
使用两个网络接口启动 finance-server1:第一个连接租户网络 finance-network1,第二个连接存储提供商网络 provider-storage,使实例能够直接访问共享文件系统的数据网络。
以 developer1 使用以下参数启动实例。
1
2
| ¢ Name: finance-server
¢ Flavor: default
|
镜像:rhel7
SSH 密钥对:example-keypair
第一块网卡的网络:finance-network1
第二块网卡的网络:provider-storage
用户数据文件: /home/student/manila/user-data.file
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]]$ openstack server create \
--flavor default \
--image rhel7 \
--key-name example-keypair \
--nic net-id=finance-network1 \
--nic net-id=provider-storage \
--user-data /home/student/manila/user-data.file \
finance-server1 --wait
|
操作界面、表格与配置图
在实例中添加可用的浮动 IP 地址。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(developer1-finance)]$ openstack floating \
ip list -c 'Floating IP Address'
Se ee
| Floating IP Address |
poe Se eee
| 172.25.250.107 |
fae e eimaiaime eee mie meme eet
[student@workstation ~(developeri1-finance)]$ openstack server \
add floating ip finance-server1 172.25.250.107
|
确认从 workstation 可以访问该实例。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ ping -c 3 172.25.250.207
PING 172.25. 250.107 (172.25.250.107) 56(84) bytes of data.
64 bytes from 172.25.250.107: icmp_seq=1 ttl=63 time=1.76 ms
64 bytes from 172.25.250.107: icmp_seq=2 ttl=63 time=1.04 ms
64 bytes from 172.25.250.107: icmp_seq=3 ttl=63 time=0.587 ms
--- 172.25.250.107 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 0.587/1.132/1.763/0.483 ms
|
创建专用 cephx 用户 client.cloud-user,授予其对 Ceph 后端共享 finance-share1 的读写权限。共享文件系统服务使用 client.manila 与 Ceph 集群通信,但该账户权限高于最终用户访问共享所需的权限。本步骤通过 cephx 认证机制控制 finance-share1 的访问。
打开 SSH 会话作为 root 到 controller0。
1
2
| [student@workstation ~(developer1-finance)]$ ssh root@controllere
[root@controller0 ~]#
|
创建 cephx 用户 client.cloud-user,将密钥环保存到 /root/cloud-user.keyring。
1
2
3
| [root@controller0 ~]# ceph --name=client.manila \
--keyring=/etc/ceph/ceph.client.manila. keyring \
auth get-or-create client.cloud-user > /root/cloud-user.keyring
|
从 controller0 中注销。
1
2
| [root@controller0 ~]# logout
Connection to controller0 closed.
|
操作界面、表格与配置图
1
| [student@workstation ~(developer1-finance)]$
|
将 ceph.conf 和 cloud-user.keyring 复制到先前创建的 finance-server1。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ cd manila
[student@workstation manila(developer1-finance)]$ scp \
root@controller0o: {cloud-user.keyring, /etc/ceph/ceph.conf} .
cloud-user. keyring 100% 68 36.3KB/S 00:00
ceph.conf 100% 797 805.3KB/S 00:00
[student@workstation manila(developer1-finance)]$ scp \
{cloud-user.keyring,ceph.conf} cloud-user@172 .25.250.107:
|
添加并验证 client.cloud-user 对 finance-share1 的访问权限。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~(developeri1-finance)]$ manila access-allow \
finance-share1 cephx cloud-user
ee ee
| Property | Value |
Pee ieee eee eee ee eee eee eee eee eee eee eee eee eee eee eee ey
| access_key | None |
| share_id | €28b9123-ae9a-4951-a6d1-5b856c83a600 |
| created_at | 2018 -10-11T10:15:22.000000 |
| updated_at | None |
| access_type | cephx |
| access_to | cloud-user |
| access_level | rw |
| state | queued_to_apply |
| id | c4665a6b-7570-4221-b3cb-623d0bbef87d |
fee epeet
[student@workstation ~(developer1-finance)]$ manila access-list \
finance-share1 --columns access_to,access_level,state
|
若省略 –access-level,默认访问级别为 rw。
从 finance-server1 访问 finance-share1。
打开 SSH 会话至finance-server1,作为cloud-user。
1
2
| [student@workstation ~(developer1-finance)]$ ssh cloud-user@172.25.250.107
[cloud-user@finance-server1 ~]$
|
创建共享的挂载点 /mnt/ceph。
1
2
| [cloud-user@finance-server1 ~]$ su -
Password: redhat
|
操作界面、表格与配置图
1
| [root@finance-server1 ~]# mkdir /mnt/ceph
|
在 workstation 以 student 打开另一个终端,再以 developer1 租户身份查询 finance-share1 的导出位置。
1
2
3
| [student@workstation ~]$ source developer1-finance-rc
[student@workstation ~(developer1-finance)]$ manila share-export-location-list \
finance-share1 --columns Path
|
记下导出路径,挂载共享时需要使用。
启用 finance-server1 上的 Ceph 仓库,并安装 ceph-fuse 软件包。
1
2
3
4
5
6
7
| [root@finance-server1 ~]# curl -s -f \
-o /etc/yum.repos.d/ceph.repo http://materials.example.com/ceph.repo
[root@finance-server1 ~]# yum install ceph-fuse
.. output omitted...
Is this ok [y/d/N]: y
.. Output omitted...
Complete!
|
在 finance-server1 将共享挂载到 /mnt/ceph,使用上一步记录的导出路径,确认挂载成功。
1
2
3
4
5
6
7
8
9
10
11
12
| [root@finance-server1 ~]# ceph-fuse /mnt/ceph/ \
--id=cloud-user --conf=/home/cloud-user/ceph.conf \
--keyr ing=/home/cloud-user/cloud-user.keyring \
--client-mountpoint=/volumes/_nogroup/cead22a9-ceé@c -4003-b6f3-8feaza4obd5f
2018-10-26 60:20:28.786368 7fa7Oael40cO -1 init, newargv = 0x55e83fad2d80
newar gc=9
ceph-fuse[1487]: starting ceph client
ceph-fuse[1487]: starting fuse
[root@finance-server1 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
.. output omitted...
ceph-fuse fuse.ceph-fuse 1.06 Q@ 1.06 06% /mnt/ceph
|
在 /mnt/ceph 目录中创建文本文件。
1
2
3
| [root@finance-server1 ~]# cd /mnt/ceph
[root@finance-server1 ceph]# echo hello > hello.txt
[root@finance-server1 ceph]# cat hello.txt
|
操作界面、表格与配置图
前述命令确认,finance-share1共享的可读性和可写性基于先前步骤之一中规定的访问权。
从 finance-server1 中注销。
1
2
3
| [root@finance-server1 ceph]# logout
[cloud-user@finance-serveri1 ~]$ logout
[student@workstation ~(developer1-finance)]$
|
终止 finance-server1 实例并删除 finance-share1 共享。
终止 finance-server1。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server \
delete finance-server1
|
删除 finance-share1。
1
| [student@workstation ~(developeri1-finance)]]$ manila delete finance-share1
|
删除 cephfstype 共享类型。
1
2
| [student@workstation ~(developer1-finance)]$ source architect1-finance-re
[student@workstation ~(architect1-finance)]$ manila type-delete cephfstype
|
在 workstation 上运行 lab storage-manila cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab storage-manila cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理临时与持久存储#
引导练习#
管理临时与持久存储#
本练习使用临时和持久根磁盘启动实例,附加其他磁盘,并在后端存储中追踪这些磁盘对应的对象。
学习目标#
完成后,能够:
使用临时和持久根磁盘创建实例,并添加额外磁盘。
比较和对比这些不同磁盘的存储结构和位置。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 运行 lab storage-compare setup,准备环境和本练习各阶段使用的附加资源。
1
| [student@workstation ~]$ lab storage-compare setup
|
在 workstation 上启动 finance 项目中的 finance-server1 实例,并追踪其存储对应的后端对象。
以 architect1 使用以下参数启动实例。
1
2
| * name: finance-server1
¢ flavor: default
|
镜像: rhel7
1
2
3
4
5
6
7
8
9
10
11
12
| * key-name: example-keypair
* nic: net -id=finance-network1
* availability-zone: nova:compute1.overcloud.example.com
[student@workstation ~]$ source architect1-finance-rc
[student@workstation ~(architect1-finance)]$ openstack server create \
--flavor default \
--image rhel7 \
--key-name example-keypair \
--nic net-id=finance-network1 \
--availability-zone nova:compute1.overcloud.example.com \
finance-server1 --wait
.. Output omitted...
|
以 developer1 查找并记录 finance-server1 的唯一 ID,下一步会用到它。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| [student@workstation ~(architect1-finance)]$ source developer1-finance-rc
[student@workstation ~(developer1-finance)]$ openstack server list \
-c ID -c Name
Sf ee eeeee ee ee eeeee eetee web ee ee eee tenet
| ID | Name |
eae ee ee ee ee pe ee et
| 2c¢477594-d47a-4f44-9974-17aleeo0f266d | finance-server1 |
Pee ere erence eee ere eco rs eco ecoecoerceosteccccecc ccceccoot
|
将上一步记录的实例 UUID 与 Ceph 的 vms 存储池中的后端对象进行匹配。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ ssh root@controllere \
rados -p vms \
ls | grep 2¢477594-d47a-4f44-9974-17alee0f266d
rbd_id. 2c477594-d47a-4f44-9974-17aleeof266d_disk
|
删除 finance-server1,并确认其根磁盘已不再存在于 Ceph 的 vms 存储池中。
删除 finance-server1 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server1
|
确认 Ceph 的 vms 存储池中已没有代表 finance-server1 根磁盘的对象,使用上一步记录的实例 ID。
步骤。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh root@controller0 \
rados -p vms \
ls | grep 2¢477594-d47a-4f44-9974-17alee0f266d
|
查看计算服务将实例磁盘保存在 Ceph 中的配置。以 Ceph 为后端可以避免计算节点本地磁盘耗尽及扩展性问题;实例磁盘保存在 vms 存储池中,
利用 Ceph 提供更好的扩展性。以 root 通过 SSH 登录 compute1。
1
2
| [student@workstation ~(developer1-finance)]$ ssh root@compute1
[root@compute1 ~]#
|
查看启用 Ceph 存储为 OpenStack 计算服务的后端存储提供者的设置。
1
2
3
4
5
6
| [root@compute1 ~]# grep rbd \
/var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf
rbd_user=openstack
rbd_secret_uuid=945a02d4-c931-118 -b4cd -52540001 fac8
images_type=rbd
images_rbd_pool=vms
|
操作界面、表格与配置图
1
| images_rbd_ceph_conf=/etc/ceph/ceph.conf
|
调整 OpenStack 计算服务的配置设置,以便使用 default 方法将实例磁盘储存在本地计算节点而不是 Ceph 存储上。启动一个实例并验证实例的根磁盘存在于本地计算节点上。删除此实例并验证实例的根磁盘在计算节点上已不复存在。
在 /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf 的 [libvirt] 节中,注释 images_type=rbd 这一行。
1
2
3
4
| [libvirt]
... output omitted...
#images_type=rbd
..- Output omitted...
|
重新启动 nova_compute 容器以使配置变化生效。
1
2
| [root@compute1 ~]# docker restart nova_compute
nova_compute
|
等30秒核实nova_compute容器的状况
1
2
3
4
5
6
| [root@compute1 ~]# sleep 30; docker ps \
--format="{{.Names}}\t{{.Status}}" | grep nova
nova_compute Up 31 seconds (healthy)
nova_migration_target Up 4 hours
nova_libvirt Up 4 hours
nova_virtlogd Up 4 hours
|
从 compute1 中注销。
1
2
| [root@compute1 ~]# logout
[student@workstation ~(developer1-finance)]$
|
以 architect1 使用以下参数启动实例。
1
2
| * name: finance-server1
¢ flavor: default
|
镜像: rhel7
1
2
3
4
5
6
7
8
9
10
11
| * key-name: example-keypair
* nic: net -id=finance-network1
* availability-zone: nova:compute1.overcloud.example.com
[student@workstation ~(developer1-finance)]$ source architect1-finance-re
[student@workstation ~(architect1-finance)]$ openstack server create \
--flavor default \
--image rhel7 \
--key-name example-keypair \
--nic net-id=finance-network1 \
--availability-zone nova:compute1.overcloud.example.com \
finance-server1 --wait
|
操作界面、表格与配置图
以 developer1 查找并记录 finance-server1 的唯一 ID,下一步会用到它。
1
2
3
4
5
6
7
8
| [student@workstation ~(architect1-finance)]$ source developer1-finance-rc
[student@workstation ~(developer1-finance)]$ openstack server list \
-c ID -c Name
SF ae a Kee ON IEE at EK Co ELONCIES BEN EK ASHENCa EON EEN EEN HEN a HK EEE
| ID | Name |
Fern ne teee eeeeeet
| 54ec33d2-961c-4cc1-91b5-5d336fcb336a | finance-server1 |
fan nnn ene nnn nn ee ee ee ee ee pe ee ee ee eet
|
将上一步记录的实例唯一 ID 与 compute1 上 /var/lib/nova/instances 下的目录名进行匹配。确认
显示目录包含 finance-server1 实例的根磁盘镜像文件。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developeri1-finance)]$ ssh root@compute1 \
ls /var/lib/nova/instances
54ec33d2-961c-4cc1-91b5-5d336fcb336a
_base
compute_nodes
locks
[student@workstation ~(developer1-finance)]$ ssh root@compute1 \
ls /var/lib/nova/instances/54ec33d2-961¢-4cC1-91b5-5d336fch336a
console. log
disk
disk. info
|
disk 文件代表 finance-server1 的根磁盘。
删除 finance-server1 实例,并核实此实例的根磁盘在计算节点上已不复存在。
删除 finance-server1 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server1
|
确认 finance-server1 实例的根磁盘镜像文件在计算节点中已不复存在。
1
2
3
4
5
| [student@workstation ~(developer1-finance)]$ ssh root@compute1 \
ls /var/1lib/nova/instances
_base
compute_nodes
locks
|
前面的步骤使用了实例的临时根磁盘。接下来学习持久根磁盘。在 controller0 查看块存储服务的配置,
确认其使用 Ceph 保存持久卷。使用
操作界面、表格与配置图
rhel7 镜像创建持久卷,确认它位于 Ceph 的 volumes 存储池中,再以新卷作为根磁盘启动实例。
查看 OpenStack 块块存储服务的后端存储提供者。
1
2
3
4
5
| [student@workstation ~(developer1-finance)]]$ ssh root@controller0 \
crudini --get \
/var/1lib/config-data/puppet-generated/cinder/etc/cinder/cinder.conf \
DEFAULT enabled_backends
tripleo_ceph
|
开放SSH 会话到 controller0。
1
| [student@workstation ~(developer1-finance)]$ ssh root@controller0
|
查看OpenStack块存储服务配置文件 tripleo_ceph INI 部分下的设置。
1
2
3
4
5
6
7
8
9
10
| [root@controller0 ~]# grep -A 6 \
'a\[tripleo_ceph\]$ ' \
/var/lib/config-data/puppet-generated/cinder/etc/cinder/cinder.conf
[tripleo_ceph]
backend_host=hostgroup
volume_backend_name=tripleo_ceph
volume_driver=cinder.volume.drivers.rbd.RBDDriver
rbd_ceph_conf=/etc/ceph/ceph.conf
rbd_user=openstack
rbd_pool=volumes
|
注意,保存卷的 Ceph 存储池设置为 volumes,然后退出 controller0。
1
2
| [root@controller0 ~]# logout
[student@workstation ~(developer1-finance)]$
|
以 developer1 使用 rhel7 镜像创建卷,并确认创建成功。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(developer1-finance)]$ openstack volume create \
--size 10 \
--image rhel7 \
finance-vol1
.. Output omitted...
[student@workstation ~(developer1-finance)]$ openstack volume list
RE a re age a ena eet ea Hea ead fa
| ID | Name | Status | Size | Attached to |
Se eee ea ee ee ee
| 1972...34cf | finance-voli1 | available | 190 | |
|
操作界面、表格与配置图
注意:执行 openstack volume create 后,最多等待两
分钟,让 rhel7 镜像内容写入 finance-vol1。也可以执行 watch openstack volume list 实时监控卷状态。
复制上一步 openstack volume list 输出中的卷 UUID,与 Ceph 的 volumes 存储池对象比较,以确定存储池中的对应卷。
使用上一步记录的卷 UUID,确认 Ceph 的 volumes 存储池中存在 finance-vol1 对应的对象。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ ssh root@controller0 \
rados -p volumes \
ls | grep 19723579-a453-4412-bfic-377d647e34cf
rbd_id. volume-19723579-a453-4412-bf1c-377d647e34cf
|
以 developer1 使用以下参数启动实例。
1
2
| name: finance-server2
flavor: default
|
密钥名称:example-keypair
1
2
3
4
5
6
7
8
9
| * nic: net -id=finance-network1
¢ volume: finance-vol1
[student@workstation ~(developeri1-finance)]]$ openstack server create \
--flavor default \
--volume finance-vol1 \
--key-name example-keypair \
--nic net-id=finance-network1 \
finance-server2 --wait
.. output omitted...
|
使用任何可用的浮动 IP 地址访问新实例 finance-server2。创建一个文本文件,文件中含有任意文本。删除此实例。
查看可用的浮动 IP 地址。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack floating ip list\
-c "Floating IP Address"
Se rete es meth ee eee cere emo ee
| Floating IP Address |
SA es en ep a Re a ET eS
| 172.25. 250.109 |
Hos onoems sesame sss see
|
将浮动 IP 地址与 finance-server2 实例相联系。
1
| [student@workstation ~(developer1-finance)]$ openstack server add \
|
操作界面、表格与配置图
1
| floating ip finance-server2 172.25.250.109
|
通过 SSH 登录 finance-server2,以 root 创建一个包含任意文本的文件。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ ssh 172.25.250.209
[cloud-user@finance-server2 ~]$ sudo -i
[root@finance-server2 ~]# echo Testing >> /test.txt
[root@finance-server2 ~]# sync
|
重要
sync 将 Linux 缓冲区缓存的内容写入磁盘。跳过此命令可能丢失刚创建的文本文件内容。
退出并删除 finance-server2,验证卷仍存在于 Ceph 的 volumes 池中。使用前面步骤中相同的卷 UUID。
1
2
3
4
5
6
7
8
| [root@finance-server2 ~]# logout
[cloud-user@finance-server2 ~]$ logout
[student@workstation ~(developer1-finance)]$ openstack server \
delete finance-server2
[student@workstation ~(developer1-finance)]$ ssh root@controller0 \
rados -p volumes \
ls | grep 19723579-a453-4412-bfic-377d647e34cf
rbd_id. volume-19723579-a453-4412- bf1c-377d647e34cf
|
注意,实例终止后卷仍然存在,因此可作为实例的持久存储。
以同一个 finance-vol1 作为启动盘创建新实例,确认先前创建的文本文件及其内容仍然存在。
以 developer1 使用以下参数启动实例。
1
2
| name: finance-server2
flavor: default
|
密钥名称:example-keypair
1
2
3
4
5
6
7
8
9
| * nic: net -id=finance-network1
* volume: finance-vol1
[student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
--volume finance-voli \
--key-name example-keypair \
--nic net-id=finance-networki \
finance-server2 --wait
.. Output omitted...
|
将可用的浮动 IP 地址与 finance-server1 实例连在一起。
1
2
| [student@workstation ~(developer1-finance)]]$ openstack floating ip list \
-c "Floating IP Address"
|
操作界面、表格与配置图
1
2
3
4
5
6
7
| BANG a St eat Ste ee
| Floating IP Address |
fen ene nee nee eet
| 172.25.250.109 |
fan enn ene enn eee eet
[student@workstation ~(developer1-finance)]$ openstack server add \
floating ip finance-server2 172.25.250.109
|
打开 SSH 会话到 finance-server1 实例,并验证 /test.txt 文件的内容。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh 172.25.250.109
[cloud-user@finance-server2 ~]$ cat /test.txt
Testing
|
从 finance-server2 中注销。
1
2
| [cloud-user@finance-server2 ~]$ logout
[student@workstation ~(developer1-finance)]$
|
创建一个 1 GB 的新卷,并附加到 finance-server2。
以 developer1 用户创建名为 finance-vol2 的 1 GB 空卷。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack volume create \
--size 1 finance-vol2
.. output omitted...
|
将 finance-vol2 卷附于 finance-server2 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add \
volume finance-server2 finance-vol2
|
校验 finance-server2 实例的新磁盘。
1
2
3
4
5
| [student@workstation ~(developer1-finance)]$ ssh 172.25.250.109 1lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 © 10G © disk
Lydal 253:1 © 10G © part /
vdb 253:16 fo] 1G © disk
|
确认 Ceph 的 volumes 存储池中出现 finance-vol2 对应的新卷对象。
查找并记录 finance-vol2 的 UUID,用它与 Ceph 的 volumes 存储池对象比较。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack volume list \
-c ID -c Name
Sa eg ae ena eg ee an ay OG ee aaa eR ION
| ID | Name |
eeeee ee Se een &
| 93b29d6b-59dd -4903-a0a0-42773ee02b89 | finance-vol2 |
| 19723579-a453-4412-bf1c-377d647e34cf | finance-vol1 |
|
操作界面、表格与配置图
1
| ee erence eet errenter eteVer eter tereteVereenneeeeh terre erprerenterehterre vere etere once
|
确认 finance-vol2 的 UUID 与 volumes 存储池中的一个卷对象匹配。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ ssh root@controller0 \
rados -p volumes \
ls | grep 92b29d6hb-59dd-4903-a0a0-42773ee02b89
rbd_id. volume-93b29d6b-59dd - 4903 -a0a0-42773ee02b89
|
删除 finance-server2 实例,以及 finance-vol1 和 finance-vol2 卷。确认这些卷已从 Ceph 的 volumes 池中移除。
删除 finance-server2 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server2
|
删除 finance-vol1 和 finance-vol2 卷。
1
2
| [student@workstation ~(developer1-finance)]$ openstack volume delete \
finance-vol1 finance-vol2
|
确认这些卷已不在 Ceph 的 volumes 池中。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ ssh root@controller0 \
rados -p volumes ls
rbd_directory
rbd_info
|
在 workstation 上运行 lab storage-compare cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab storage-compare cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:管理存储#
储存管理#
操作检查清单#
本实验将管理 OpenStack 计算实例的持久卷,管理共享文件系统,并从实例中使用这些共享。
学习目标#
完成后,能够:
管理 OpenStack 块存储。
管理 OpenStack 共享文件系统
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 运行 lab storage-review setup,检查 OpenStack 服务和已有资源,并准备本实验需要的资源。
1
| [student@workstation ~]$ lab storage-review setup
|
以 operator1 在 production 项目中使用 rhel7 镜像创建 10 GB 的可启动卷 production-volume1。
以 operator1 在 production 项目创建 1 GB 空卷 production-volume2。
确认新卷以对象形式存在于 Ceph 的 volumes 存储池。
注意:课堂环境中的 OpenStack 块存储服务使用 Red Hat Ceph Storage 作为后端存储。
以 operator1 在 production 项目中使用 production-volume1 启动卷,按以下参数启动实例。
1
2
| * name: product ion-server1
¢ flavor: default
|
密钥名称:operator1-keypair
1
2
| nic: net-id=production-network1
volume: production-volume1
|
将空的 production-volume2 卷附加到 production-server1 实例。
访问 production-server1,确认空卷 production-volume2 已成功挂接到该实例。
操作界面、表格与配置图
6. 在 production-volume2 中创建一个 1 GB 分区;该卷在 production-server1 的分区表中显示为 vdb。将分区格式化为 XFS,并临时挂载到 /mnt。创建 /mnt/hello.txt,写入 hello。由于 /mnt 是该卷的挂载点,此文件保存在 production-volume2 中。另创建 /hello2.txt,写入 hello2。该文件保存在 production-volume1 中,因为 production-server1 使用这个卷作为根文件系统。
删除现有的 production-server1,并按以下参数创建新实例,使用 production-volume1 作为启动卷。
1
2
| name: production-server1
flavor: default
|
密钥名称:operator1-keypair
1
2
| nic: net-id=production-network1
volume: production-volume1
|
将 production-volume2 卷附于新的 production-server1 实例。
确认您先前创建的文本文件一直存在,且所有内容都在 production-server1 实例中。
以 operator1 用户在 production 项目中创建 1 GB 共享文件系统,名称为 production-share1,类型为 cephfstype。创建时使用
cephfs 协议。管理共享文件系统类型等操作需要使用 architect1 租户用户。
注意:课堂环境中预安装的 Red Hat Ceph Storage 为
production-share1 共享文件系统提供后端。OpenStack 共享文件系统服务使用相应的 Ceph 驱动与 Red Hat Ceph Storage 协调。
10. 为 production-server1 添加来自 provider-storage 的网卡,使其能够访问 production-share1 的网络。将新增网卡配置为使用 DHCP。
11. 创建 cephx 用户 client.cloud-user,将密钥环保存为 cloud-
user.keyring。创建用户时,使用 /etc/ceph/ceph.client.manila.keyring 以 client.manila 认证。
将 Ceph 配置和 cloud-user.keyring 复制到 production-server1。使用 http://materials.example.com/ceph.repo 配置软件源,并安装访问 Ceph 共享文件系统所需的工具。
12. 授予 client.cloud-user 对 production-share1 的读写权限。
13. 从 production-server1 访问 production-share1。使用 /home/cloud-user/cloud-user.keyring 以 client.cloud-user 认证,集群配置位于 /home/cloud-user/ceph.conf。在共享中创建 hello.txt,写入 hello。
操作界面、表格与配置图
删除 production-server1 实例,并创建一个具有以下参数的新实例:
1
2
3
4
5
6
7
| * name: production-server2
¢ flavor: default
¢ key-name: operator1-keypair
* nic: net -id=production-network1
* nic: net -id=provider -storage
* volume: production-volume1
* user-data: /home/student/manila/user -data. file
|
注意:/home/student/manila/user-data.file 用于配置实例的第二块网卡。
从新的 production-server2 实例访问 production-share1 共享文件系统以确认您在共享文件系统中创建的文本文件在先前一步中仍然有效。
在 workstation 上运行 lab storage-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab storage-review grade
|
在 workstation 上运行 lab storage-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab storage-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
储存管理#
操作检查清单#
本实验将管理 OpenStack 计算实例的持久卷,管理共享文件系统,并从实例中使用这些共享。
学习目标#
完成后,能够:
管理 OpenStack 块存储。
管理 OpenStack 共享文件系统
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 运行 lab storage-review setup,检查 OpenStack 服务和已有资源,并准备本实验需要的资源。
1
| [student@workstation ~]$ lab storage-review setup
|
以 operator1 在 production 项目中使用 rhel7 镜像创建 10 GB 的可启动卷 production-volume1。
加载 operator1 的凭据。
1
2
| [student@workstation ~]$ source operator1-production-re
[student@workstation ~(operator1-production)]$
|
使用 rhel7 镜像创建 10 GB 可启动卷 production-volume1。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ openstack volume create \
--image rhel7 \
--Size 10 \
production-volume1
.. output omitted...
|
执行 openstack volume create 后,最多等待两分钟,将 rhel7 镜像内容写入 production-vol1。也可执行 watch openstack volume list 实时监控状态。
核查 production-volume1 卷是否可用。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name \
-c Status
Spee eeeeee eee cee eee Se ee ene
| Name | Status |
Reee ea
| production-volume1 | available |
SE careretea etreriee trent eleanor note eiele eel aeunreeumrarcrt
|
以 operator1 在 production 项目创建 1 GB 空卷 production-volume2。
创建名为 production-volume2 的空的 1 GB 卷。
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack volume create \
--size 1 \
production-volume2
.. Output omitted...
|
核查 production-volume2 卷是否可用。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name \
-c Status
ef ee ateetmeh eee eth pee tea neh eteee eee
| Name | Status |
Pee n enn nen nena pen een een en at
| production-volume2 | available |
| production-volume1 | available |
Reee ee
|
确认新卷以对象形式存在于 Ceph 的 volumes 存储池。
注意:课堂环境中的 OpenStack 块存储服务使用 Red Hat Ceph Storage 作为后端存储。
查找 production-volume1 和 production-volume2 的 UUID,与 Ceph 的 volumes 存储池对象比较。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name \
-c ID
CE Ma a er rere resCen eee ee
| ID | Name |
foo aS OWS RAS RSS FRIIS RSS PRES ee Rastlas epee se sas eves se rast
| ©b4944e7-6939 -4350-86a4-71746c6fe4F3 | production-volume2 |
| 03c4ebcd-1829-4f08-8bdd-9d8esdcf1i4ff | production-volume1 |
|
操作界面、表格与配置图
1
| ee eee ere te ee eee eee nr een eee ere teerehevecare ere terete een ee erereter ateren eh
|
使用前面记录的 production-volume1 UUID,确认它以对象形式存在于 volumes 存储池。
1
2
3
4
| [student@workstation ~(operator1-production)]$ ssh root@controller0 \
rados -p volumes \
ls | grep 03c4ebcd-1829-4f08-8hdd-9d8e8sdcf14ff
rbd_id. volume-@3c4ebcd-1829-4f08-8bdd-9d8esdcfL4tf
|
使用前面记录的 production-volume2 UUID,确认它以对象形式存在于 volumes 存储池。
1
2
3
4
| [student@workstation ~(operator1-production)]$ ssh root@controllere \
rados -p volumes \
ls | grep 0b4944e7-6939-4350-86a4-71746c6fe4f3
rbd_id. volume-0b4944e7-6939 -4350-86a4-71746c6fe4f3
|
以 operator1 在 production 项目中使用 production-volume1 启动卷,按以下参数启动实例。
1
2
| name: production-server1
flavor: default
|
密钥名称:operator1-keypair
1
2
| nic: net-id=production-network1
volume: production-volume1
|
将空的 production-volume2 卷附加到 production-server1 实例中。
使用上述参数启动 production-server1 实例。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--volume production-volume1 \
--key-name operator1-keypair \
--nic net-id=production-network1 \
production-server1 --wait
.. Output omitted...
|
将空的 production-volume2 卷附加到 production-server1 实例中。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
volume production-server1 production-volume2
|
访问 production-server1 实例,并验证空的 production-volume2 卷已成功连接到 production-server1 实例。
将浮动 IP 172.25.250.151 关联到 production-server1。
1
| [student@workstation ~(operator1-production)]$ openstack server add \
|
操作界面、表格与配置图
1
| floating ip production-server1 172.25.250.151
|
浮动 IP 地址 172.25.250.151 已在实验初始化过程中准备好。
核查production-server1 实例中现有磁盘中是否还有代表production-volume2的1 GB 盘。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151 lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 © 10G © disk
Lydal 253:1 © 10G © part /
vdb 253:16 Lo] 1G © disk
|
在 production-volume2 中创建一个 1 GB 分区;该卷在 production-server1 的分区表中显示为 vdb。将分区格式化为 XFS,并临时挂载到 /mnt。创建 /mnt/hello.txt,写入 hello。由于 /mnt 是该卷的挂载点,此文件保存在 production-volume2 中。另创建 /hello2.txt,写入 hello2。该文件保存在 production-volume1 中,因为 production-server1 使用这个卷作为根文件系统。
在 production-volume2 中创建 1 GB 的主分区,该分区作为设备 vdb 出现在 production-server1 实例的分区表格中。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151 \
sudo /usr/sbin/parted /dev/vdb \
mklabel msdos \
mkpart primary © 1G
Warning: The resulting partition is not properly aligned for best performance.
Information: You may need to update /etc/fstab.
|
注意:可以忽略前一条命令输出中的警告。
在 /dev/vdb1 分区中创建类型 xfs 的文件系统。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(operatori1-production)]$ ssh 172.25.250.151 \
sudo /usr/sbin/mkfs \
-t xfs /dev/vdb1
meta-data=/dev/vdb1 isize=512 agcount=4, agsize=65536 blks
= sectsz=512 attr=2, projid32bit=1
= crce=1 finobt=0, sparse=0
data = bsize=4096 blocks=262143, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
|
将 /dev/vdb1 临时挂载到 /mnt。
1
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151 \
|
操作界面、表格与配置图
1
2
| sudo /usr/bin/mount \
/dev/vdb1 /mnt
|
创建 /mnt/hello.txt 和 /hello2.txt,分别写入 hello 和 hello2。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151
[cloud-user@production-server1 ~]$ sudo -i
[root@production-server1 ~]# echo hello > /mnt/hello.txt
[root@production-server1 ~]# echo hello2 > /hello2.txt
[root@production-server1 ~]# sync
|
重要
sync 将 Linux 缓冲区缓存的内容写入磁盘。跳过此命令可能丢失刚创建的文本文件内容。
从 production-server1 中注销。
1
2
3
4
| [root@production-server1 ~]# logout
[cloud-user@production-server1 ~]$ logout
Connection to 172.25.250.151 closed.
[student@workstation ~(operator1-production)]$
|
删除现有的 production-server1 实例,并用以下参数创建以production-volume1为可启动量的新实例。
1
2
| name: production-server1
flavor: default
|
密钥名称:operator1-keypair
1
2
| nic: net-id=production-network1
volume: production-volume1
|
将 production-volume2 卷附于新的 production-server1 实例。
删除现有的 production-server1 实例。
1
2
| [student@workstation ~(operator1-production)]$ openstack server delete \
production-server1
|
使用上述参数创建新实例。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--volume production-volumel \
--key-name operator1-keypair \
--nic net-id=production-network1 \
production-server1 --wait
.. Output omitted...
|
将 production-volume2 附加到 production-server1。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
volume production-server1 production-volume2
|
操作界面、表格与配置图
确认您先前创建的文本文件一直存在,且所有内容都在 production-server1 实例中。
关联 172.25.250.151 作为production-server1 实例的浮动 IP 地址。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-server1 172.25.250.151
|
将 /dev/vdb1 临时挂载到 /mnt。
1
2
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151 \
sudo /usr/bin/mount /dev/vdb1 /mnt
|
核查 /mnt/hello.txt 和 /hello2.txt 文件的内容。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151 \
cat /mnt/hello.txt
hello
[student@workstation ~(operator1-production)]$ ssh 172.25.250.151 \
cat /hello2.txt
hello2
|
以 operator1 用户在 production 项目中创建 1 GB 共享文件系统,名称为 production-share1,类型为 cephfstype,协议为 cephfs。管理共享文件系统类型等操作使用 architect1 租户用户。
在课堂环境中预先安装的Red Hat Ceph 存储支持 production-share1 共享文件系统。OpenStack 共享文件系统服务使用适当的 Ceph 驱动程序与Red Hat Ceph 存储协调。
加载 architect1 的凭据。
1
2
| [student@workstation ~(operator1-production)]$ source architect1-production-re
[student@workstation ~(architect1-production)]$
|
验证 OpenStack 共享文件系统服务的状况。
1
2
3
4
5
6
7
8
| [student@workstation ~(architect1-production)]$ manila service-list \
--columns Binary,Status,State
Jiao ono eS ease We See Seas seserhieonsessch
| Binary | Status | State |
Sea ee
| manila-scheduler | enabled | up |
| manila-share | enabled | up |
SNtasSto ene a
|
创建 cephfstype 共享类型,将 driver_handles_share_servers 设为 false。
1
| [student@workstation ~(architect1-production)]$ manila type-create \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| cephfstype false
SOC Ie Ie ie i ie Bee I I OC OC OC OC OCIOCIC ee ite
| Property | Value |
ferent nie eter iether eter nie ete ie se eee es ie see eee eh
| required_extra_specs | driver_handles_share_servers : False |
| Name | cephfstype |
| Visibility | public |
| is_default | - |
| ID | 384aca36 -841a-4344-a75b-421e1d096e47 |
| optional_extra_specs |
| Description | None |
tan nn nn pnnn ne ee ee ee et
|
若要动态扩展共享节点,将 driver_handles_share_servers 设为 true。
以 operator1 用户创建名为 production-share1 的 1 GB 共享文件系统。
1
2
3
4
| [student@workstation ~(architect1-production)]$ source operator1-production-re
[student@workstation ~(operator1-production)]$ manila create \
--name production-share1 --share-type cephfstype cephfs 1
.. output omitted...
|
验证 production-share1 成功创建。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ manila list \
--columns Name,Size, Share Proto',Status, 'Share Type Name'
See Se ee eee ee ee Se en
| Name | Size | Share Proto | Status | Share Type Name |
| production-share1 | 1 | CEPHFS | available | cephfstype |
SS eee ee. ee er
|
为 production-server1 添加来自 provider-storage 的网卡,使其能够访问 production-share1 的网络。将新增网卡配置为使用 DHCP。
为 production-server1 添加连接 production-network1 的额外网卡。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
network production-server1 provider-storage
|
通过 SSH 登录 production-server1,确认实例中存在新增网卡。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151
[cloud-user@production-server1 ~]$ ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
qlen 1000
link/loopback 00:00:00:00:00:600 brd 06:60:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1442 qdisc pfifo_fast state UP
group default qlen 1000
link/ether fa:16:3e:b1:87:d9 brd ff: ff: ff: ff: ff: ff
inet 192.168.1.11/24 brd 192.168.1.255 scope global noprefixroute dynamic etho
valid_lft 42295sec preferred_lft 42295sec
inet6 feso::f816: 3eff:feb1:87d9/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default qlen 1000
link/ether fa:16:3e:2e:e2:2d brd ff: ff: ff: ff: ff: ff
|
注意您在前一步添加的 eth1 网络接口。
创建 /etc/sysconfig/network-scripts/ifcfg-eth1,将 eth1 配置为使用 DHCP。创建文件时使用 sudo,因为该操作需要 root 权限。
1
2
3
| DEVICE=ethi
ONBOOT=yes
BOOTPROTO=dhcp
|
启用 eth1 接口。
1
| [cloud-user@production-server1 ~]$ sudo ifup ethi
|
核查 eth1 的设置。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [cloud-user@production-server1 ~]$ ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
qlen 1000
link/loopback 00:00: 090:60: 00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1442 qdisc pfifo_fast state UP
group default glen 1000
link/ether fa:16:3e:b1:87:d9 brd ff: ff: ff: ff: ff: ff
inet 192.168.1.11/24 brd 192.168.1.255 scope global noprefixroute dynamic etho
valid_lft 41615sec preferred_lft 41615sec
inet6 fe8o::f816:3eff: feb1:87d9/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default glen 1000
link/ether fa:16:3e:2e:e2:2d brd ff: ff: ff: ff: ff: ff
inet 172.24.3.205/24 brd 172.24.3.255 scope global noprefixroute dynamic eth1
valid_lft 43100sec preferred_lft 43100sec
inet6 fe8so: :f816: 3eff: fe2e:e22d/64 scope link
|
操作界面、表格与配置图
1
| valid_lft forever preferred_lft forever
|
注意,eth1 的 IP 地址为 172.24.3.205,该地址允许实例访问 production-share1 共享文件系统的网络,
production-server1 实例。
退出 production-server1。
1
2
3
| [cloud-user@production-server1 ~]$ logout
Connection to 172.25.250.151 closed.
[student@workstation ~(operator1-production)]$
|
创建 cephx 用户 client.cloud-user,将密钥环保存为 cloud-user.keyring。创建用户时,使用 /etc/ceph/ceph.client.manila.keyring 以 client.manila 认证。将 Ceph 配置与密钥环复制到 production-server1,并使用 http://materials.example.com/ceph.repo 配置软件源,安装访问 Ceph 共享所需的工具。
通过 SSH 登录 controller0;该节点运行 Ceph Monitor,并安装了所需的管理工具。
1
2
| [student@workstation ~(operator1-production)]$ ssh root@controller0
[root@controller0 ~]#
|
使用 /etc/ceph/ceph.client.manila.keyring 以 client.manila 认证,创建 cephx 用户 client.cloud-user,将密钥环保存到 /root/cloud-user.keyring。
1
2
3
| [root@controller0 ~]# ceph --name=client.manila \
--keyring=/etc/ceph/ceph.client.manila. keyring \
auth get-or-create client.cloud-user > /root/cloud-user.keyring
|
从 controller0 中注销。
1
2
3
| [root@controller0 ~]# logout
Connection to controller0 closed.
[student@workstation ~(operator1-production)]$
|
将 Ceph 配置和 cloud-user.keyring 复制到 production-server1。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ scp \
root@controller0o:{/etc/ceph/ceph.conf,/root/cloud-user .keyring} manila/
ceph.conf 100% 797 870.4KB/s 60:90
cloud-user. keyring 100% 68 75.9KB/S 00: BO
[student@workstation ~(operator1-production)]$ scp \
manila/{ceph.conf, cloud-user. keyring} cloud-user@172.25.250.151:
ceph.conf 100% 797 670.0KB/s 00:00
cloud-user. keyring 100% 68 80.6KB/$ 00: BO
|
在 production-server1 安装 ceph-fuse,软件源配置从 http://materials.example.com/ceph.repo 下载。
1
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| [cloud-user@production-server1 ~]$ sudo curl -s -f -o \
7etc/yum.repos.d/ceph.repo http://materials.example.com/ceph.repo
[cloud-user@production-server1 ~]$ sudo yum install ceph-fuse
... Output omitted...
Total download size: 3.3 M
Installed size: 11M
Is this ok [y/d/N]: y
.. Output omitted...
Complete!
|
从 production-server1 中注销。
1
2
| [cloud-user@production-server1 ~]$ logout
[student@workstation ~(operator1-production)]$
|
授予 client.cloud-user 对 production-share1 的读写权限。
授予 client.cloud-user 对 production-share1 的读写权限。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(operator1-production)]$ manila access-allow \
--access-level rw \
production-share1 cephx cloud-user
| | |access_key None
| share_id | 84ce9714-2093 -436b-ae70-4bd7fe48faoo |
| created_at | 2018 -10-31T19: 27:40. 000000 |
| updated_at | None |
| access_type | cephx
| access_to | cloud-user
| access_level | rw
| | |state queued_to_apply
| | |id €a602cdc-b303 -4966 -9a23-8 fad7aad9969
|
验证 production-share1 上的访问权限。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ manila access-list \
--columns access_type,access_to,access_level, state \
production-share1
DS ee ee ee a
| Access_Type | Access_To | Access_Level | State |
Seeeeeneen ete econo eeemeee ee me me et a ee a ee a eaten aote
| cephx | cloud-user | rw | active |
Ce en ee Se eee Seo
|
从 production-server1 访问 production-share1,使用 /home/cloud-user/cloud-user.keyring 以 client.cloud-user 认证。相应的
操作界面、表格与配置图
Ceph 集群配置位于 /home/cloud-user/ceph.conf。在共享中创建 hello.txt,写入 hello。
打开 SSH 会话到 production-server1 并切换到 root。
1
2
3
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151
[cloud-user@production-serveril ~]$ sudo -i
[root@production-server1 ~]#
|
创建 /manila 作为 production-share1 的挂载点。
1
| [root@production-server1 ~]# mkdir /manila
|
在 workstation 以 student 打开新终端,再以 operator1 租户身份查询 production-share1 的导出位置。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ source operator1-production-re
[student@workstation ~(operator1-production)]$ manila share-export-location-list \
production-share1 --columns Path
Efe tt a telme ete ee te fe tele et fe fete efee etele etee et fete ter te tee ete fete etre tei
| Path |
{See er er rer er errr eee rer rere
| 172.24.3.1:6789: /volumes/_nogroup/45306T38-73c9-44b3-a794-ag4bdbob25e3 |
SP ee et Dm Ft ee Ft et Fe Fe ce Ve Fe et et ef
|
记下导出位置,下一步挂载 production-share1 共享文件系统时需要使用。
返回第一个终端,在 production-server1 将 production-share1 挂载到 /manila。使用 /home/cloud-user/cloud-user.keyring 认证,使用 /home/cloud-user/ceph.conf 提供集群配置,导出位置沿用上一步结果。
1
2
3
4
5
6
7
8
| [root@production-server1 ~]# ceph-fuse /manila \
--id=cloud-user --conf=/home/cloud-user/ceph.conf \
--keyr ing=/home/cloud-user/cloud-user.keyring \
--client-mountpoint=/volumes/_nogroup/45306f38-73c9-44b3-a794-a84bdb0bh25e3
2018-10-31 16:30:39.637732 7f8163dc00cO -1 init, newargv = 0x55855fcead8o
newar gc=9
ceph-fuse[1877]: starting ceph client
ceph-fuse[1877]: starting fuse
|
验证 production-share1 已成功挂载。
1
2
3
4
5
6
7
8
| [root@production-server1 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/vdal xfs 10G 1.66 8.5G 16% /
devtmpfs dev tmpfs 898M @ 898M 0% /dev
tmpfs tmpfs 920M @ 920M 0% /dev/shm
tmpfs tmpfs 920M 17M 903M 2% /run
tmpfs tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs tmpfs 184M 0 184M 6% /run/user/1001
|
操作界面、表格与配置图
1
| ceph-fuse fuse.ceph-fuse 1.06 © 1.06 0% /manila
|
创建 /manila/hello.txt,写入 hello。
1
| [root@production-server1 ~]# echo hello > /manila/hello.txt
|
从 /manila. 卸载 production-share1
1
| [root@production-server1 ~]# umount /manila
|
从 production-server1 中注销。
1
2
3
4
| [root@production-server1 ~]# logout
[cloud-user@production-server1 ~]$ logout
Connection to 172.25.250.151 closed.
[student@workstation ~(operator1-production)]$
|
删除 production-server1 实例,并创建一个具有以下参数的新实例:
1
2
3
4
5
6
7
| * name: production-server2
¢ flavor: default
¢ key-name: operator1-keypair
* nic: net -id=production-network1
* nic: net -id=provider -storage
* volume: production-volume1
* user-data: /home/student/manila/user - data. file
|
注意:/home/student/manila/user-data.file 用于配置实例的第二块网卡。
从新的 production-server2 实例访问 production-share1,确认先前在共享文件系统中创建的文本文件仍然存在。
删除 production-server1。
1
2
| [student@workstation ~(operator1-production)]$ openstack server delete \
production-server1
|
创建带有上述参数的新 production-server2 实例。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--volume production-volume1 \
--key-name operator1-keypair \
--nic net-id=production-network1 \
--nic net-id=provider-storage \
--user-data /home/student/manila/user-data.file \
production-server2 --wait
|
操作界面、表格与配置图
将浮动 IP 172.25.250.151 关联到 production-server2。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-server2 172.25.250.151
|
打开 SSH 会话到 production-server2 并切换到 root。
1
2
3
| [student@workstation ~(operator1-production)]$ ssh 172.25.250.151
[cloud-user@production-server2 ~]$ sudo -i
[root@production-server2 ~]#
|
在 production-server2 将 production-share1 挂载到 /manila。使用 /home/cloud-user/cloud-user.keyring 认证,使用 /home/cloud-user/ceph.conf 提供集群配置,导出位置沿用前面步骤的结果。
1
2
3
4
5
6
7
8
| [root@production-server2 ~]# ceph-fuse /manila \
--id=cloud-user --conf=/home/cloud-user/ceph.conf \
--keyring=/home/cloud-user/cloud-user.keyring \
--client-mountpoint=/volumes/_nogroup/45306f38-73c9-44bh3-a794-a84hdhob25e3
ph-fuse[1377]: starting ceph client
2018-11-01 02:18:25.304052 7f59130e70cO -1 init, newargv = 0x55c9235b6d80
newar gc=9
ceph-fuse[1377]: starting fuse
|
验证 production-share1 已成功挂载。
1
2
3
4
5
6
7
8
9
| [root@production-server2 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/vdat xfs 106 1.66 8.5G 16% /
devtmpfs devtmpfs 898M 0 898M 0% /dev
tmpfs tmpfs 920M QO 920M 0% /dev/shm
tmpfs tmpfs 920M 17M 903M 2% /run
tmpfs tmpfs 920M 6 920M 0% /sys/fs/cgroup
tmpfs tmpfs 184M QO 184M 0% /run/user/1001
ceph-fuse fuse.ceph-fuse 1.06 © 1.06 0% /manila
|
确认您在production-share1共享文件系统中早期步骤中创建的文本文件仍然保留其所有内容。
1
2
| [root@production-server2 ~]# cat /manila/hello.txt
hello
|
从 production-server2 中注销并删除实例。
1
2
3
4
5
| [root@production-server2 ~]# logout
[cloud-user@production-server2 ~]$ logout
Connection to 172.25.250.151 closed.
[student@workstation ~(operator1-production)]$ openstack server delete \
production-server2
|
操作界面、表格与配置图
在 workstation 上运行 lab storage-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab storage-review grade
|
在 workstation 上运行 lab storage-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab storage-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 卷成功附加后,还应检查什么?
- 哪项最能证明数据持久性?
自测答案#
- 客户机设备识别、文件系统和挂载情况。块设备附加并不自动完成客户机内的文件系统配置。
- 写入数据并按实验要求重新挂载或重新访问验证。持久性应通过实际生命周期操作与数据读取验证。
C6-管理 OpenStack 网络#
从逻辑对象到实际连接#
网络定义连接范围,子网提供地址配置,端口将实例等资源接入网络,路由器连接不同网络。浮动 IP 提供一种外部访问映射,但它的存在并不能证明实例中的服务已监听或安全规则已允许访问。
| 对象或机制 | 主要作用 | 检查重点 |
|---|
| Network / Subnet | 组织二层连接和 IP 配置 | 网络类型、地址段、网关及 DHCP |
| Port | 表示资源的网络接入点 | 绑定对象、MAC、固定 IP 与状态 |
| Router | 连接内部网络与外部网络 | 接口、网关和路由关系 |
| Security Group | 控制端口相关流量 | 方向、协议、端口与来源 |
| Floating IP | 提供外部地址映射 | 关联端口、路由路径与可达性 |
网络协议与供应方式#
网络配置包含逻辑隔离、物理承载和节点可达性三个层次。网络资源创建成功,只证明控制面接受配置,数据面能否转发还需验证。
OVN 的学习重点#
OVN 将逻辑网络模型转换为实际转发行为。理解它时,从 Neutron 创建的网络、端口和路由入手,再查看相应的逻辑配置和运行状态。不要把其他网络后端的排查路径直接套到 OVN 环境;先确认当前环境实际部署了哪个后端。
按路径排查连通性#
从实例内部地址和路由开始,检查端口与安全组,再检查同网段通信、跨网段路由和外部访问。逐段验证比反复更换浮动 IP 更容易定位问题。ICMP 成功也不能代替目标应用端口验证;最终应使用应用本身的访问方式检查。
实验完成标准#
记录网络、子网、端口、路由器、浮动 IP 之间的关系。网络诊断需定位报文经过的逻辑对象,并区分配置、端口绑定和实际转发故障。
网络类型对照#
| 类型 | 隔离机制 | 底层要求 |
|---|
| flat | 直接使用指定物理二层网络 | 正确的物理网映射 |
| VLAN | 802.1Q 标签 | 交换机允许对应 VLAN、端口配置一致 |
| VXLAN | 基于 UDP 的覆盖网络 | 节点隧道端点互通、MTU 适配 |
| Geneve | 可扩展封装的覆盖网络 | OVN 的隧道承载与 MTU 适配 |
Provider 网络描述与物理承载的关系;Self-service 网络由项目创建并通过网络后端实现。两者与“是否 external”不是同一维度。
OVN 的控制链#
1
2
3
4
5
6
7
| Neutron API / ML2 OVN 驱动
↓
OVN Northbound DB:逻辑交换机、路由器、ACL 等意图
↓ ovn-northd
OVN Southbound DB:逻辑流、绑定、Chassis 信息
↓ 各节点 ovn-controller
Open vSwitch:实际流表与数据包转发
|
观测命令#
先使用当前 OVN 数据库地址设置 OVN_NB_DB、OVN_SB_DB,再在具备工具和访问权限的节点执行。不要将示例 VIP 当成固定地址。
1
2
3
4
5
6
7
| sudo ovs-vsctl show
sudo ovs-vsctl get Open_vSwitch . external_ids
ovn-nbctl show
ovn-nbctl ls-list
ovn-nbctl lr-list
ovn-sbctl show
ovn-sbctl lflow-list
|
把逻辑端口关联到实例#
1
2
3
4
5
6
| # 项目客户端
openstack server show <实例UUID>
openstack port list --server <实例UUID>
openstack port show <端口UUID>
openstack network show <网络UUID>
openstack subnet show <子网UUID>
|
记下 Port UUID、MAC、固定 IP、宿主机绑定,然后对照 OVN Logical Switch Port 与 Southbound 绑定。仅看到 Northbound 对象存在,还不能证明绑定和转发已成功。
Provider 网络的配置要点#
物理网络名 → ovn-bridge-mappings → OVS Bridge → 物理接口 → 交换机 VLAN / 二层网络,必须一一对应。VLAN ID 是外部交换网络要求,不是随便填写的标签。
按范围排错#
同宿主机同网段 → 跨宿主机同网段 → 跨子网 → 浮动 IP → 应用端口。前两者结果不同,重点看隧道和物理承载;小包成功而大包失败,进一步检查 MTU 与路径发现。OVN 使用逻辑流与 ACL 的检查路径,不照搬 CL110 的 DHCP / L3 agent namespace 结构。
实验操作#
引导练习:识别网络协议类型#
引导练习#
识别网络协议类型#
在此过程中,部署两个实例,并查看从一个实例到另一个实例的路径的各个组成部分。
学习目标#
完成后,能够:
查看控制器节点的组件。
查看计算节点的组件。
查看 Geneve 网络包。
开始之前#
以 student 用户登录 workstation,密码为 student。
运行 lab networking-protocols setup 命令。此脚本确保 OpenStack 服务正在运行,环境为此练习配置妥当。
1
| [student@workstation ~]$ lab networking-protocols setup
|
在 workstation 加载 architect1-finance-rc;只有管理员才能指定可用区。以 architect1 使用 rhel7 镜像、default 规格和 finance-network1,分别在 compute0 创建 finance-server3、在 compute1 创建 finance-server4。记录 IP 地址,后续步骤会用到。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| [student@workstation ~]$ source /home/student/architect1-finance-rc
[student@workstation ~(architect1-finance) ]$ openstack server create \
--flavor default \
--image rhel7 \
--nic net-id=finance-network1 \
--availability-zone nova:compute0@.overcloud.example.com \
--wait finance-server3
rf
|
+
| |OS-DCF: diskconfig | MANUAL
| |OS-EXT-AZ: availability_zone | nova
| |OS-EXT-SRV-ATTR: host | compute0.overcloud.example.com
| OS-EXT-SRV-ATTR: hypervisor_hostname | compute0.overcloud.example.com ||
| OS-EXT-SRV-ATTR: ins tance_name instance -90000007 ||
| |OS-EXT-STS: power_state Running|
| |OS-EXT-STS: task_state None|
| |OS-EXT-STS: vm_state active|
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| | | |OS-SRV-USG: launched_at 2018 -10-04T09: 06: 51. 990000
| OS-SRV-USG: terminated_at | None
| accessIPv4 | |
| accessIPv6 |
| addresses | finance-network1=192 .168.1.11 |
| adminPass | PZgvw7cp287V
| config_drive |
| created | 2018-10-04T09: 05: 442 |
| flavor | default (7acO...0a9e) |
| hostid | 7f59...4ca01 |
| id | brad .c532, |
| image | rhel7 (dd3d...do2e) |
| key_name | None
| name | finance-server3 |
| progress | 9
| project_id | f8594af5ef6 246888ed31df520fccf30 |
| properties |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-10-04T09: 06: 51Z |
| user_id | 8eb50062824b468b9b205c538d57 F46F |
| |volumes_at tached
[student@workstation ~(architect1-finance) ]$ openstack server create \
--flavor default \
--image rhel7 \
--nic net-id=finance-network1 \
--availability-zone nova:compute1.overcloud.example.com \
--wait finance-server4
| OS-DCF: diskConfig | |MANUAL
| OS-EXT-AZ: availability_zone | |nova
OS-EXT-SRV-ATTR: host | |compute1.overcloud.example.com
| OS-EXT-SRV-ATTR: hypervisor_hostname | |compu tel. overcloud.example.com
| OS-EXT-SRV-ATTR: ins tance_name ins tance -90000008| |
OS-EXT-STS: power_state | Running
| OS-EXT-STS: task_state | None
| OS-EXT-STS: vm_state | active
OS-SRV-USG : launched_at | 2018-10-04T09:12:11. 900000 |
| OS-SRV-USG: terminated_at | None
| accessIPv4 | |
accessIPv6 |
| addresses | finance-network1=192.168.1.8 |
| adminPass | UBzit2gsuGKe |
| config_drive |
| created | 2018-10-04T09:11: 432
| flavor | default (7acO...9a9e) |
| hostid | eeac...f6a7 |
| id | 3f0c...e004 |
| image | rhel7 (dd3d...d02e) |
| key_name | None
| name | finance-server4 |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| | progress | 9 |
| project_id | fe594af5ef6246888ed31df520fccf30|
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-10-04T09:12:12Z |
| user_id | 8eb50062824b468b9b205c538d57F46F |
| volumes_at tached |
Fn pn ee et
|
使用 ovs-ofctl 和 ovs-vsctl 查看 Overcloud 节点上的组件。
打开另一终端,从 workstation 以 heat-admin 用户登录 controller0,再执行 sudo -i 获取 root 权限。
1
2
3
| [student@workstation ~]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
在 controller0 执行 ovs-vsctl show 列出网桥配置,注意 br-ex。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [root@controller0 ~]# ovs-vsctl show
.. Output omitted...
Bridge br -ex
fail_mode: standalone
Port "eth2"
Interface "eth2"
Port br-ex
Interface br-ex
type: internal
Port "patch-provnet-ef9b4ad2 -36c0-4ed4-8547-d78s46f7dofooe-to-br-int"
Interface "patch-provnet -ef9b4ad2 -36c0- 4ed4-8547 -d7s46f7dofoe-to-br-int"
type: patch
options: {peer="patch-br -int-to-provnet -ef9b4ad2 -36c0- 4ed4-8547 -
d7s46f7defoo"}
.. output omitted...
|
在 workstation 上,使用 openstack network list 命令来列出 OpenStack 网络。请注意 provider-datacentre 的 ID 与 br-ex 上的一个端口匹配。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(architect1-finance)]$ openstack network list -c ID -c Name
Se a ee ee Oe a ee
| ID | Name |
fan nee eee eee ee ee ee ee ee pe ee ee ee ee ee et
| 1¢458a95-a00f -411e-8a73-d88ba18ddeao | finance-network1 |
| 772fe396 -a9dc -4243 -80bc-682664829e00 | lb-mgmt-net |
| b5522075-961a-40f3-b7b4-ce5236a3f73c | production-network1 |
| e8d43fea-ad78 -4165-913f-ad74288d0e51 | demo-network1 |
| ef9b4ad2-36c0-4ed4-8547-d7s46f7defee | provider-datacentre |
|
操作界面、表格与配置图
在 controller0 执行 ovs-vsctl show 列出网桥配置,注意 br-int。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| [root@controller0 ~]# ovs-vsctl show
.., output omitted...
Bridge br-int
fail_mode: secure
Port "ovn-849e32-0"
Interface "ovn-840e32-6"
type: geneve
options: {csum="true", key=flow, remote_ip="172.24.2.2"}
Port "ovn-14c844-0"
Interface "ovn-14c844-6"
type: geneve
options: {csum="true", key=flow, remote_ip="172.24.2.12"}
Port "o-hmo"
Interface "o-hmo"
type: internal
Port "ovn-263d95-0"
Interface "ovn-263d95-6"
type: geneve
options: {csum="true", key=flow, remote_ip="172.24.2.6"}
Port br-int
Interface br-int
type: internal
Port "patch-br -int-to-provnet -ef9b4ad2 -36c0- 4ed4-8547 -d7846f7dofoo"
Interface "patch-br-int-to-provnet-ef9b4ad2 -36c0 -4ed4-8547 -d7846f7dofoo"
type: patch
options: {peer="patch-provnet -ef9b4ad2-36c0-4ed4 -8547 -d7846f 7doToo-to-br -
int"}
ovs_version: "2.9.0"
.. output omitted...
|
在 workstation 上,使用 openstack hypervisor list 命令来列出计算节点。请注意,接口 ovn-840e32-0 相当于 compute0 、 ovn-14c844-0 对应 compute1 、 ovn-263d95-0 对应 computehci0。请注意,所有这些接口都属于 Geneve 类型。provider-datacentre 网络接口还有一个端口。
1
2
3
4
5
6
7
8
| [student@workstation ~(architect1-finance)]$ openstack hypervisor list \
-c "Hypervisor Hostname" -c "Host IP"
RRre ar a a eae ee a
| Hypervisor Hostname | Host IP |
2 eye Sei eT OeTa erate Oe Setetn OckeOeienreneia Ooo Coneoene
| computehci0.overcloud.example.com | 172.24.1.6 |
| compute1.overcloud.example.com | 172.24.1.12 |
| compute. overcloud.example.com | 172.24.1.2 |
|
在 controller0 执行 ovs-ofctl show 列出 br-trunk 的接口,注意五个 VLAN 接口。
1
| >[root@controller0 ~]# ovs-ofctl show br-trunk
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| OFPT_FEATURES_REPLY (xid=0x2): dpid:0000525400010001
n_tables: 254, n_buffers:0
capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst
mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
1(eth1): addr:52:54: 00:01:00: 01
config: (0)
state: (0)
speed: © Mbps now, © Mbps max
2(vlan1e): addr:7a:cf:bb:f5:83:cc
config: (0)
state: (0)
speed: © Mbps now, © Mbps max
3(vlan20): addr:22:0c:51:bd:2e:bd
config: (0)
state: (0)
speed: © Mbps now, © Mbps max
4(vlan30): addr:92:b5:04:bce:23:82
config: (0)
state: (0)
speed: © Mbps now, © Mbps max
5(vlan40): addr:52:ff:78:53:14:ea
config: (0)
state: ()
speed: © Mbps now, © Mbps max
6(vlan50): addr:7e:6b:6e:17:74:59
config: (o)
state: ()
speed: © Mbps now, © Mbps max
LOCAL (br-trunk): addr:52:54:00:01:00:01
config: (0)
state: (0)
speed: © Mbps now, © Mbps max
OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0
|
打开另一个终端窗口。从 workstation 登录到 compute0 的 heat-admin 用户。使用 ip link 命令列出接口。注意
VLAN接口。VLAN20是租户VLAN。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~]$ ssh heat-admin@compute0
[heat-admin@compute0 ~]$ ip link
.. output omitted...
14: vlani1@: <BROADCAST,MULTICAST,UP, LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
mode DEFAULT group default glen 1000
link/ether 1a:e5:09:ff:90:a3 brd ff: ff: ff: ff: ff: ff
15: vlan20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
mode DEFAULT group default glen 1000
link/ether 8e:43:4c:8b:d8:cf brd ff: ff: ff: ff: ff: ff
16: vlan30: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
mode DEFAULT group default glen 1000
link/ether ca:ca:f9:af:53:0e brd ff: ff: ff: ff: ff: ff
17: vlan50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
mode DEFAULT group default glen 1000
link/ether ca:85:82:a1:f3:45 brd ff: ff: ff: ff: ff: ff
|
操作界面、表格与配置图
接口 VLAN20 上的抓取包显示 finance-server3 和 finance-server4 之间的流量。
在 compute0 上执行 sudo -i 获取 root 权限,使用 tcpdump 捕获 VLAN20 租户网络上的数据包。
1
2
3
| [heat-admin@compute0 ~]$ sudo -i
[root@compute0 ~]# tcpdump -ten -i vlan20 | grep ICMP
tcpdump: listening on ethi, link-type EN10MB (Ethernet), capture size 262144 bytes
|
在 workstation 上,使用 openstack console url show 命令获取 console URL 用于 finance-server3. 在 Firefox 中打开 URL, 然后登录到 finance-server3, 使用 root 作为用户名和 redhat 作为密码。Ping finance-server4。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~(architect1-finance)]$ openstack console url show \
finance-server3 --max-width=80
SOOO ern Soe mei ete ie ie I ee tO COCO ee ee ie ie ion
| Field | Value |
Fe cece ee Gee Gee eee ee ene Goa cece ee Ce eed
| type | novne |
| url | http: //172. 25. 250.50: 6080/vnc_auto. html?token=201¢4763-7f10-4¢55 |
| | -a3fb-a4fdo45a5f32 |
SOs See ieee ie I ee OOO OO ee ie eit ieraion
[student@workstation ~(architect1-finance)]]$ firefox \
http://172.25.250.50:6080/vnc_auto. html?token=201c4763-7f10-4c55-a3Tb-a4fd045a5f32
[root@finance-server3 ~]$ ping -c3 192.168.1.8
64 bytes from 192.168.1.8: icmp_seq=1 ttl=64 time=0.450 ms
64 bytes from 192.168.1.8: icmp_seq=1 ttl=64 time=0.350 ms
64 bytes from 192.168.1.8: icmp_seq=1 ttl=64 time=0.430 ms
...output omitted...
|
在 compute0 上分析 tcpdump 输出,查找 finance-server3 与 finance-server4 之间的 ICMP echo request 和 echo reply 数据包。注意,数据包在 compute0 和 compute1 之间传输。隧道类型为 Geneve,vni 参数保存该数据包的网络标识。
1
2
3
4
5
6
7
8
9
10
| 8e:43:4c:8b:d8:cf > 76:3a:02:69:82:1e, ethertype IPv4 (0x9800), length
156: 172.24.2.2.35614 > 172.24.2.12.6081: Geneve, Flags [C], vni 0x3, proto TEB
(9x6558), options [8 bytes]: fa:16:3e:b5:fd:da > fa:16:3e:ec:5f:e0, ethertype
IPv4 (90x9800), length 98: 192.168.1.11 > 192.168.1.8: ICMP echo request, id 1211,
seq 1, length 64
76: 3a:02:69:82:1e > 8e:43:4c:8b:d8:cf, ethertype IPv4 (0xo@800), length
156: 172.24.2.12.23252 > 172.24.2.2.6081: Geneve, Flags [C], vni 0x3, proto TEB
(9x6558), options [8 bytes]: fa:16:3e:ec:5f:eO > fa:16:3e:b5:fd:da, ethertype
IPv4 (0x9800), length 98: 192.168.1.8 > 192.168.1.11: ICMP echo reply, id 1211,
seq 1, length 64
|
打开另一终端,从 workstation 以 heat-admin 用户登录 compute1,再执行 sudo -i 获取 root 权限。
1
| [student@workstation ~]$ ssh heat-admin@compute1
|
操作界面、表格与配置图
1
2
| [heat-admin@compute1 ~]$ sudo -i
[root@compute1 ~]#
|
在 compute0 执行 ovs-vsctl list open,查找 OVN 南向与北向数据库的 IP(ovn-remote 参数)。在 compute0 和 compute1 上配置数据库环境变量,北向数据库端口为 6641。
1
2
3
4
5
6
7
8
9
| [root@compute0 ~]# ovs-vsctl list open
.. Output omitted...
external_ids : {hostname="compute0.overcloud.example.com", ovn-bridge=br-
int, ovn-bridge-mappings="datacentre:br-ex,provider_vlan:br-eth3", ovn-encap-
ip="172.24.2.2", ovn-encap-type=geneve, ovn-remote="tcp:172.24.1.50:6642",
rundir="/var/run/openvswitch", system-id="840e32d5 -21¢3-4760-b6e8 -8bfd063b50a1"}
.. Output omitted...
[root@compute0 ~]# export OVN_SB_DB=tcp:172.24.1.50:6642
[root@compute0 ~]# export OVN_NB_DB=tcp:172.24.1.50:6641
|
在 workstation 上,使用 openstack port list 命令为 finance-server3 和 finance-server4 寻找端口 ID。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(architect1-finance)]$ openstack port list \
-c ID -c "Fixed IP Addresses"
Jiao ONS ORS 9 SSA TSS PASSES PSR DSR SE PSR BEF OS RS RRS FTE TSF PS Re eRe seems
2n5 | Fixed IP Addresses |
Finn nn nn npn en nn nn en en ee ee ee et
| f13c...9107 | ip_address='192.168.1.11', subnet_id='1479...6a78' |
.. Output omitted...
| 9b27...78d7 | ip_address='192.168.1.8', subnet_id='1479...6a78' |
.. output omitted...
|
执行 ovn-sbctl lflow-list,列出南向数据库中的流表。
在 compute0 执行 ovn-sbctl lflow-list,将输出重定向到 flow.txt。
1
| [root@compute0 ~]# ovn-sbctl 1flow-list > flow.txt
|
在文件中搜索 finance-server3 的 ID,查找允许 finance-server3 和 finance-server4 流量的流表。
1
2
3
4
5
6
7
8
9
| [root@compute0 ~]# view flow.txt
..,output omitted...
table=o (ls_in_port_sec_l2 ), priority=50 , match=(inport
== "f1i3cebbd-32ca-4fc8-9a65-4293f4fe9107" && eth.srce ==
{fa:16:3e:bc:bb:d9}), action=(next;)
.. output omitted...
table=13(1ls_in_dhcp_response), priority=100 , match=(inport ==
"f1i3cebbd-32ca-4fc8-9a65-4293f4fe9107" && eth.src == fa:16:3e:bc:bb:d9 && ip4 &&
udp.src == 68 && udp.dst == 67 && reg®[3]), action=(eth.dst = eth.src; eth.sre =
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| fa:16:3e:f8:63:f0; ip4.dst = 192.168.1.11; ip4.src = 192.168.1.1; udp.sre = 67;
udp.dst = 68; outport = inport; flags. loopback = 1; output;)
table=13(1s_in_dhcp_response), priority=0 , match=(1), action=(next;)
table=14(1s_in_dns_lookup ), priority=0 , mMatch=(1), action=(next;)
table=15(ls_in_dns_response ), priority=0 , match=(1), action=(next;)
table=16(1s_in_12_lkup ), priority=100 , match=(eth.mcast),
action=(outport = "_MC_flood"; output;)
table=16(1s_in_12_lkup ), priority=50 , wtatch=(eth.dst ==
fa:16:3e:18:e6:f6), action=(outport = "9b272b18-1b7c-47a9-9d9Tf -d431d31278d7";
output;)
.. output omitted...
|
在 compute1 重复上述步骤,查找 finance-server4 的流表。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| [root@compute1 ~]# ovn-sbctl 1lflow-list > flow.txt
[root@compute1 ~]# view flow.txt
... output omitted...
table=o (ls_in_port_sec_l12 ), priority=50 , match=(inport
== "9b272b18-1b7c-47a9-9d9f-d431d31278d7" && eth.src ==
{fa:16:3e:18:e6:f6}), action=(next;)
... Output omitted...
table=13(1s_in_dhcp_response), priority=100 , match=(inport ==
"9b272b18-1b7c -47a9-9d9f-d431d31278d7" && eth.src == fa:16:3e:18:e6:f6 && ip4 &&
udp.src == 68 && udp.dst == 67 && reg®[3]), action=(eth.dst = eth.src; eth.sre
= fa:16:3e:f8:63:f0; ip4.dst = 192.168.1.8; ip4.srce = 192.168.1.1; udp.src = 67;
udp.dst = 68; outport = inport; flags.loopback = 1; output;)
table=13(1s_in_dhcp_response), priority=100 , match=(inport ==
"f13cebbd-32ca-4fc8-9a65-4293f4fe9107" && eth.src == fa:16:3e:bc:bb:d9 && ip4 &&
udp.src == 68 && udp.dst == 67 && regO[3]), action=(eth.dst = eth.src; eth.sre =
fa:16:3e:f8:63:f0; ip4.dst = 192.168.1.11; ip4.srce = 192.168.1.1; udp.sre = 67;
udp.dst = 68; outport = inport; flags.loopback = 1; output;)
table=13(ls_in_dhcp_response), priority=0 , match=(1), action=(next;)
table=14(1s_in_dns_lookup ), priority=0 , match=(1), action=(next;)
table=15(1s_in_dns_response ), priority=0 , WMatch=(1), action=(next;)
table=16(1s_in_12_lkup ), priority=100 , match=(eth.mcast),
action=(outport = "_MC_flood"; output;)
table=16(1s_in_12_lkup ), priority=50 , Match=(eth.dst ==
fa:16:3e:18:e6:f6), action=(outport = "9b272b18-1b7c-47a9-9d9f -d431d31278d7" ;
output;)
.. Output omitted...
|
在每个计算节点上使用相同的文件,找到DHCP、SSH和ICMP的安全组流。
1
2
3
4
5
6
7
| [root@compute0 ~]# view flow.txt
.. output omitted...
table=6 (ls_in_acl ), priority=2002 , match=(!ct.new
&& ct.est && !ct.rpl && ct_label.blocked == © && (inport ==
"fi3cebbd-32ca-4fc8-9a65-4293f4fe9107" && ip4 && ip4.dst == {255.255.255.255,
192.168.1.0/24} && udp && udp.src == 68 && udp.dst == 67)), action=(next;)
.. output omitted...
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| table=4 (ls_out_acl ), priority=2002 , match=(!ct.new ct.est && !ct.rpl
&& ct_label.blocked == © && (outport == "f13cebbd-32ca-4fc8-9a65- 4293f4fe9107"
&& ip4 && ip4.src == 0.0.0.0/0 && icmp4)), action=(next;)
table=4 (ls_out_acl ), priority=2002 , match=(!ct.new
&& ct.est && !ct.rpl && ct_label.blocked == © && (outport ==
"f13cebbd-32ca-4fc8-9a65-4293f4fe9107" && ip4 && ip4.src == 0.0.0.0/0 && tcp &&
tcep.dst == 22)), action=(next;)
.. output omitted...
table=6 (1s_in_acl ), priority=2002 , match=(!ct.new && ct.est && !ct.rpl
&& ct_label.blocked == © && (inport == "9b272b18-1b7c-47a9-9d9f-d431d31278d7" &&
ip4 && ip4.dst == {255.255.255.255, 192.168.1.0/24} && udp && udp.src == 68 &&
udp.dst == 67)), action=(next;)
.. output omitted...
table=4 (ls_out_acl ), priority=2002 , match=(!ct.new && ct.est
&& !ct.rpl && ct_label. blocked == © && (outport == "9b272b18-1b7c -47a9-9d9Ff -
d431d31278d7" && ip4 && ip4.src == 0.0.0.0/0 && icmp4)), action=(next;)
table=4 (1ls_out_acl ), priority=2002 , match=(!ct.new && ct.est
&& !ct.rpl && ct_label. blocked == © && (outport == "9b272b18-1b7c-47a9-9d9f-
d431d31278d7" && ip4 && ip4.src == 0.0.0.0/0 tcp && tcp.dst == 22)),
action=(next;)
.. Output omitted...
|
在 compute0 执行 ovn-nbctl show,查看北向数据库并找到 finance-network1 的 lrp(逻辑路由器端口)。在 compute1 的 flow.txt 中查找该端口的流表。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [root@compute0@ ~]# ovn-nbctl show
.. Output omitted...
switch 3bc3a1b0-2a6f-4b91-853e-b2d143871066 (neutron-1c458a95-a00f -411e-8a73-
ds8ba1sdd0a0) (aka finance-network1)
port 9b272b18-1b7c-47a9-9d9f-d431d31278d7
addresses: ["fa:16:3e:18:e6:f6 192.168.1.8"]
port f13cebbd-32ca-4fc8-9a65-4293f4fe9107
addresses: ["fa:16:3e:bc:bb:d9 192.168.1.11"]
port 25263397 -e€320-4b99 -ae82-ee3a2e91d565
type: router
router-port: lrp-252e3397 -e320-4b99-ae82 -ee3a2e91d565
port 3d58e426-a8sd7-4ea3 -a974-Oabd48b5b1d3
type: localport
addresses: ["fa:16:3e:54:e9:70 192.168.1.2"]
...output omitted...
table=8 (lr_in_arp_resolve ), priority=100 , match=(outport == "lrp-252e3397-
e320-4b99 -ae82-ee3aze91d565" && rego == 192.168.1.8), action=(eth.dst =
fa:16:3e:18:e6:f6; next;)
... Output omitted...
table=s (lr_in_arp_resolve ), priority=100 , match=(outport == "lrp-252e3397-
e320-4b99 -ae82-ee3a2e91d565" && rego == 192.168.1.11), action=(eth.dst =
fa:16:3e:bce:bb:d9; next;)
.. output omitted...
|
关闭此练习期间打开的所有终端窗口。
操作界面、表格与配置图
在 workstation 上运行 lab networking-protocols cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab networking-protocols cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:实现开放虚拟网络 OVN#
引导练习#
实现开放虚拟网络 OVN#
在此练习中,管理 OVN 和安全组,查看 OpenFlow 流,并审查 DHCP 配置和路由表。
学习目标#
完成后,能够:
部署一个可从公共网络访问的实例。
创建安全组规则,并检查安全策略对应的 OpenFlow 流表。
审查 DHCP 的 OpenFlow 规则。
°
查看 OpenFlow 中的路由表。
开始之前#
以 student 用户登录 workstation,密码为 student。
运行 lab networking-ovn setup 命令。此脚本确保 OpenStack 服务正在运行,环境为练习配置得当。
1
| [student@workstation ~]$ lab networking-ovn setup
|
以 developer1 用户确认 finance-network1 存在,并查看该网络的安全组规则。
在 workstation 加载 /home/student/developer1-rc 身份环境文件,以 developer1 访问 OpenStack 服务。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
使用 openstack network list 命令列出可用的网络。注意 finance-network1 中的 ID。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack network list -c ID -c Name
ea ea Ye ae ne ee ce ee nih
| ID | Name |
Seee eS
| 7ad21970-5986 -42e0-9b48-64ab414bb0b1 | finance-network1 |
| d55fé6die-c29e-4825-8de4-01dd95f8a220 | provider-storage |
| f8366a5d-9cf9 -4d38-9760-9cf9df4eceaa | provider-datacentre |
BROT SC NCSC CCMe CSC CSCC ICI eC eI Tea eT Te TC TC TC Te sa
|
打开另一终端,从 workstation 以 heat-admin 用户登录 controller0,再执行 sudo -i 获取 root 权限。
操作界面、表格与配置图
1
2
3
| [student@workstation ~]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
在 controller0 执行 ovs-vsctl list open,从 ovn-remote 参数找到南向与北向数据库 IP,并设置 OVN 数据库环境变量。
1
2
3
4
5
6
7
8
9
10
| [root@controller0 ~]# ovs-vsctl list open
.. Output omitted...
external_ids : {hostname="controller0.overcloud.example.com", ovn-
bridge=br-int, ovn-bridge-mappings="datacentre:br-ex", ovn-cms-options=enable-
chassis-as-gw, ovn-encap-ip="172.24.2.1", ovn-encap-type=geneve, ovn-
remote="tcp:172.24.1.50:6642", rundir="/var/run/openvswitch", system-id="698c1e91-
b2c0-455a-becb-O@baa27d275ad"}
.. output omitted...
[root@controller0 ~]# export OVN_SB_DB=tcp:172.24.1.50:6642
[root@controller0 ~]# export OVN_NB_DB=tcp:172.24.1.50:6641
|
执行 ovn-nbctl ls-list 列出所有交换机,再用 ovn-nbctl acl-list neutron-switch_ID 查看网络交换机的安全规则。switch_ID 对应 finance-network1 的 ID。注意,目前尚未为该交换机分配安全规则。
1
2
3
4
5
6
7
| [root@controller0 ~]# ovn-nbctl 1ls-list
.. Output omitted...
bedo...4def (neutron-7ad21970-5986-42e0-9b48-64ab414bbob1)
.. output omitted...
[root@controller0 ~]# ovn-nbctl acl-list \
neu tron-7ad21970-5986 -42e0-9b48-64ab414bb0b1
[root@controller0 ~]#
|
在 workstation 终端以 developer1 用户创建 finance-server1。使用 rhel7 镜像、default 规格、default 安全组和 finance-network1 网络。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(developer1-finance)]$ openstack server create \
--image rhel7 \
--flavor default \
--nic net-id=finance-network1 \
--security-group default \
--wait finance-server1
Se rT
| Field | Value |
IES aty ost t ey tee m mce em a y ae mmye eaem p
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ: availability_zone | nova |
| OS-EXT-STS: power_state | Running |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| OS-EXT-STS: task_state | None |
OS-EXT-STS:vm_state | active |
OS-SRV-USG: launched_at | 2018-09-26T13:33:49,000000 |
OS-SRV-USG: terminated_at | None |
accessIPv4 | |
accessIPv6 | |
addresses | finance-network1=192.168.1.10 |
adminPass | hyP4Dn3Dvse6 |
config_drive | |
created | 2018-09-267T13:33:14Z |
flavor | default (71eb...a769) |
hostId | debs....932T. |
id | €417...5720 |
image | rhel7 (ec201...e840) |
key_name | None |
name | finance-server1 |
progress | 9 |
project_id | Obaease7fc5b4720bc418c0172ee6ae5 |
properties | |
security_groups | name='default' |
status | ACTIVE |
updated | 2018-09-26113:33:49Z |
user_id | 92f5297388884088b72fO1b0T2787127 |
volumes_at tached | |
|
在 controller0 上重新检查 finance-network1 交换机的安全策略。在 workstation 上列出 default 安全组的规则,将 OpenFlow 流表与安全组规则对应起来,并将 inport 和 outport 参数对应到相应的 OpenStack 实体。
3.1.
在 controller0 执行 ovn-nbctl acl-list neutron-switch_ID,重新检查 finance-network1 交换机的安全组策略。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [root@controller0 ~]# ovn-nbctl acl-list \
neutron-7ad221970-5986-42e0-9b48-64ab414bb0b1
from-lport 1002 (inport == "a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4) allow-
related
from-lport 1062 (inport == "abd57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.dst == {255.255. 255.255, 192.168.1.0/24} && udp && udp.src == 68 && udp.dst
== 67) allow
from-lport 1002 (inport == "ab57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip6) allow-
related
from-lport 1001 (inport == "aS57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip) drop
to-lport 1002 (outport == "ab57dbb8-3dib-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.sre == $as_ip4_feef8ea8s_b579_4e8f_bda3_b880afia468e) allow-related
to-lport 1002 (outport == "ab5/7dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4d &&
ip4.src == 0.0.0.0/0 && icmp4) allow-related
to-lport 1002 (outport == "ab57dbb8 -3dib-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 22) allow-related
to-lport 1002 (outport == "ab57dbb8 -3dib-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 443) allow-related
to-lport 1002 (outport == "a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 80) allow-related
|
操作界面、表格与配置图
1
2
3
| to-lport 1002 (outport == "ab57dbb8-3d1b-4780-9ca7-d343d3d1106a" && 1p6 &&
ip6.srce == $as_ip6_feef8eas8_b579_4e8f_bda3_b880afia468e) allow-related
to-lport 1001 (outport == "a557dbb8 -3d1b-4780-9ca7-d343d3d1106a" && ip) drop
|
在 workstation 执行 openstack security group show default,查看 default 安全组。注意,上一步的流表与 OpenStack 安全组规则对应,最后的动作为 drop(丢弃)。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| [student@workstation ~(developer1-finance)]$ openstack security group \
rule list default --long -f json
L
t
"IP Range": "@.0.0.0/0",
"Direction": "ingress",
"Ethertype": "IPv4",
"Port Range": "22:22",
MIP Protocol': Step;
"Remote Security Group": null,
"ID": "b67C8063-28ac -4dc2-a734-3cb6b2de2e42"
ty
{
"IP Range": null,
"Direction": "egress",
"Ethertype": "Ipv4",
"Port Range": "",
"IP Protocol": null,
"Remote Security Group": null,
"ID": "bbc6 8ba4-89ea -4b34 - 8ca7 -8e8cd5cc2a4f"
ty
t
"IP Range": null,
"Direction": "ingress",
"Ethertype": "IPv4",
"Port Range": "",
"IP Protocol": null,
"Remote Security Group": "feef8eas-b579-4e8f -bda3-b880afi1a468e",
"TD": "717925c3-fb1f-4e87 -b8f2-4b6a0127d648"
ty
t
"IP Range": "0.0.0.0/0",
"Direction": "ingress",
"Ethertype": "Ipv4",
"Port Range": "443:443",
"IP Protocol": "tcp",
"Remote Security Group": null,
"ID": "6b8aa744-cd3a-449f -bdca-dc75d70b16 21"
ty
t
"IP Range": "0.0.0.0/0",
"Direction": "ingress",
"Ethertype": "IPv4",
"Port Range": "80:80",
"IP Protocol": "tcp",
"Remote Security Group": null,
"Ip": "6deb5bdd1-dc72-4c1c-afo7 -cd9eec96ffas"
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| ty
t
"IP Range": null,
"Direction": "ingress",
"Ethertype": "IPv6",
HPort Ranges: sh,
"TP Protocol": null,
"Remote Security Group": "feef8eas-b579-4e8f -bda3-b88oafia468e",
"Tp": "361e6de4-c1b7 -47e3-887d-0ff475464c05"
ty
t
"IP Range": null,
'Direction: "egress,
Nethertype: ""IPye'
"Port Ranges "5,
"IP Protocol": null,
"Remote Security Group": null,
"TD": "8659559d-4024-4083 -8cda-38acf9d3f97e"
ty
a
"IP Range": "0.0.0.0/0",
"Direction": "ingress",
"Ethertype": "IPv4",
-Port Ranges: sh,
"TP Pretoced': "sLenpt,
"Remote Security Group": null,
"TD": "cdf56956-a6f2-4ba5 -8974-eb5c60afd82f"
t
|
在 workstation 执行 openstack port list。注意,finance-server1 的端口与流表中的 inport 和 outport 参数对应。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~(developer1-finance)]]$ openstack port list \
-c ID -c "Fixed IP Addresses"
spaeeta eee eee ere eee ere reree erereee eee eee eee eee ee ree ee eee
| ID | Fixed IP Addresses |
poe oe eee ereeererr ere
| 12c7...00d5 | ip_address='192.168.1.1', subnet_id='849b...9ab9' |
| a557...1106a| ip_address='192.168.1.10', subnet_id='849...79ab9' |
| eb6f...2b89 | ip_address='192.168.1.2', subnet_id='849b...9ab9' |
eb es as eneserosessoem tions icons enesm yan eens ationsweyieaus ens yon eenens nti eeyioansane iors enoneitionsuey
from-lport 1002 (inport == "a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4) allow-
related
from-lport 1002 (inport == "a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.dst == {255.255.255.255, 192.168.1.0/24} && udp && udp.src == 68 && udp.dst
== 67) allow
.. output omitted...
to-lport 1002 (outport == "a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcep.dst == 22) allow-related
|
操作界面、表格与配置图
在 finance-network1 创建第二个实例,然后在 controller0 列出安全规则流表。
在 workstation 以 developer1 用户创建 finance-server2,使用 rhel7 镜像、default 规格和 finance-network1 网络。注意:即使没有指定安全组,实例仍会被分配到 default 安全组。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| [student@workstation ~(developer1-finance)]$ openstack server create \
--image rhel7 \
--flavor default \
--nic net-id=finance-network1 \
--wait finance-server2
Tete Se SO SE ee eT Ne eNO Ce ee ET
| Field | Value |
fstrasYasar Yano stra asVases sensYasar PeVs saosin starsYasar sessYaraneVasesestenrosYasar eat
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ: availability_zone | nova |
| OS-EXT-STS: power_state | Running |
| OS-EXT-STS: task_state | None |
| OS-EXT-STS: vm_state | active |
| OS-SRV-USG: launched_at | 2018 -09-26T17:15:05.900000 |
| OS-SRV-USG: terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | finance-network1=192.168.1.12 |
| adminPass | KJ6jneM5sxew |
| config_drive | |
| created | 2018 -09-26T17:14:18Z |
| flavor | default (71eb...a769) |
| hostId | 445c. .81cc |
| id | 4dfa...e4b9 |
| image | rhel7 (ec20...e840) |
| key_name | None |
| name | finance-server2 |
| progress | 9 |
| project_id | Obaease7fc5b4720bc418c0172ee6aed |
| properties |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-09-26T17:15:052 |
| user_id | 92f5297388884088b72folbof 2787127 |
| volumes_at tached | |
|
在 controller0 检查 finance-network1 交换机的安全策略,注意新出现的流表。每个实例的最后一条规则都是 drop。
1
2
3
4
5
6
7
| [root@controller0 ~]# ovn-nbctl acl-list \
neu tron-7ad21970-5986 -42e0-9b48-64ab414bb0b1
from-lport 1002 (inport == "a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4) allow-
related
from-lport 1002 (inport == "ab57dbb8-3d1b -4780-9ca7-d343d3d1106a" && i1p4 &&
ip4.dst == {255.255.255.255, 192.168.1.0/24} && udp && udp.src == 68 && udp.dst
== 67) allow
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| from-lport 1002 (inport == "ab57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip6) allow-
related
from-lport 1002 (inport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip4) allow-
related
from-lport 1002 (inport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip4 &&
ip4.dst == {255.255.255.255, 192.168.1.0/24} && udp && udp.src == 68 && udp.dst
== 67) allow
from-lport 1002 (inport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip6) allow-
related
from-lport 1001 (inport == "a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip) drop
from-lport 10601 (inport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip) drop
to-lport 1002 (outport == "ab57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == $as_ip4_feef8ea8_b579_4e8f_bda3_b88o0afia468e) allow-related
to-lport 1002 (outport == "ab57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == 0.0.0.0/0 && icmp4) allow-related
to-lport 1002 (outport == "ab57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 22) allow-related
to-lport 1002 (outport == "ab57dbb8 -3dib-4780-9ca7-d343d3d1106a" && 1p4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 443) allow-related
to-lport 1002 (outport == "ab57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 80) allow-related
to-lport 1002 (outport == "ab57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip6 &&
ip6.src == $as_ip6_feef8ea8_b579_4e8f_bda3_b88oafia468e) allow-related
to-lport 1002 (outport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && i1p4 &&
ip4.sre == $as_ip4_feef8ea8s_b579_4e8f_bda3_b88eafia468e) allow-related
to-lport 1002 (outport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip4 &&
ip4.src == 0.0.0.0/0 && icmp4) allow-related
to-lport 1002 (outport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 22) allow-related
to-lport 1002 (outport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 443) allow-related
to-lport 1002 (outport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 80) allow-related
to-lport 1002 (outport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip6 &&
ip6.src == $as_ip6_feef8ea8s_b579_4e8f_bda3_b88oeafia468e) allow-related
to-lport 1001 (outport == "ab57dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip) drop
to-lport 1001 (outport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip) drop
|
在 workstation 上列出 OpenStack 端口。看看安全组 OpenFlow
流表,注意允许实例之间通信的规则。在此示例中,inport 是新建的 finance-server2,outport 是先前的 finance-server1,两条规则分别对应 ICMP 和 TCP。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack port list \
-c ID -c "Fixed IP Addresses"
| ID | Fixed IP Addresses
pose eeeeeeoues Peow eee eeeceee
| 12c7...00d5 | ip_address='192.168.1.1', subnet_id='849b...9ab9
| a557...106a | ip_address='192,168.1.10', subnet_id='849b...9ab9'
| b3e3...7702 | ip_address='192.168.1.12', subnet_id='849b...9ab9'
| eb6f...2b89 | ip_address='192.168.1.2', subnet_id='849b...9ab9
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| BAe SE ee SON Oe SE NS Oat PEF OS Sg NO OE OS OSH aN ea Cte EP
from-lport 16001 (inport == "b3e37780-7fe3-471a-bcdd-73bdcb957702" && ip) drop
to-lport 1002 (outport == "a557dbb8-3d1b-4780-9ca7-
d343d3d1106a" && ip4 && ip4.src ==
$as_ip4_feef8eas_b579_4e8f_bda3_b880afia468e) allow-related
to-lport 1002 (outport == "a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == 0.0.0.0/0 && icmp4) allow-related
to-lport 1002 (outport == "a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && ip4 &&
ip4.src == 0.0.0.0/0 && tcp && tcp.dst == 22) allow-related
|
在 workstation 上,在 provider-datacentre 外部网络上创建一个浮动 IP 地址。将浮动 IP 附加到 finance-server1。使用 openstack server list 命令来核查是否添加了浮动 IP 地址。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| [student@workstation ~(developer1-finance)]$ openstack floating ip create \
provider-datacentre
SY yy ayy ay yayaa ary engence mee rey rvterymere een ery ey raya araenn
| Field | Value |
ee tin ee ee ee ee ee ee ee ee ee eee et
| created_at | 2018-09-27T08:22:32Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.108 |
| floating_network_id | f8366a5d-9cf9-4d38-9760-9cf9df4eceaa |
| id | c4416eaa-35a3-47e6 -9546-€8256981Cc069 |
| name | 172.25.250.110 |
| port_id | None |
| project_id | Obaease7fc5b4720bc418c0172ee6ae5 |
| qos_policy_id | None |
| revision_number | 9 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-09-27T08:22:32Z |
Se ie
[student@workstation ~(developer1-finance)]$ openstack server add \
floating ip finance-server1 172.25.250.108
[student@workstation ~(developer1-finance)]$ openstack server list \
-c ID -c Name -c Networks
|
操作界面、表格与配置图
在 controller0 列出路由流表并查看 finance-network1 的路由表。执行 ovn-nbctl show,概览北向数据库内容。
在 controller0 执行 ovn-sbctl lflow-list,找到 finance-server1 的 SNAT 和 DNAT 流。将输出写入文件再搜索更方便。注意,浮动 IP 和内部 IP 都有对应规则。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| [root@controller0 ~]# ovn-sbctl 1lflow-list > flow.txt
[root@controller0 ~]# view flow.txt
.. Output omitted...
table=3 (1r_in_unsnat )}, priority=100 , match=(ip && ip4.dst
== 172.25.250.108 && inport == "Irp-8905aec6-0db1-475f-8e38-edfd4b4fe4fc"),
action=(ct_snat;)
... output omitted...
table=3 (1r_in_unsnat ), priority=50 , tatch=(ip && ip4.dst
== 172.25.250.108), action=(reg9[O] = 1; next;)
.. output omitted
table=1 (lr_out_snat ), priority=33 , mMatch=(ip && ip4.src
== 192.168.1.10 && outport == "lrp-8905aec6-0db1-475f -8e38-odfd4b4fe4fc"),
action=(eth.sre = fa:16:3e:76:a8:89; ct_snat(172.25.250.108);)
.. Output omitted...
table=4 (1r_in_dnat ), priority=100 , match=(ip && ip4.dst
== 172.25.250.108 && inport == "Irp-8s905aec6-0db1-475f-8e38-odfd4b4fe4fc"),
action=(ct_dnat(192.168.1.10);)
table=4 (1r_in_dnat ), priority=50 , match=(ip && ip4.dst
== 172.25.250.108), action=(reg9[O] = 1; next;)
table=4 (lr_in_dnat ), priority=0 , mMatch=(1), action=(next;)
.. output omitted...
table=0 (1r_out_undnat ), priority=100 , match=(ip && ip4.sre
== 192.168.1.10 && outport == "l1rp-s905aec6-0db1-475f -8e38-odfd4b4fe4fc"),
action=(eth.sre = fa:16:3e:76:a8:89; ct_dnat;)
.. output omitted...
|
从上一步 SNAT 或 DNAT 片段记录 finance-server1 使用的 lrp inport 和 outport。在 controller0 执行 ovn-nbctl show,查看北向数据库。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [root@controller0 ~]# ovn-nbctl show
.. Output omitted...
switch ce4e7293 -9bed-4504-9272-1fc698393048 (neutron-
f8366a5d-9cT9-4d38-9760-9cT9df4eceaa) (aka provider-datacentre)
port provnet-f8366a5d-9cf9-4d38 -9760-9cf9df4eceaa
type: localnet
addresses: ["unknown"]
port ©59d906d -fbid-4120-8c74-5cd9de12f832
type: localport
addresses: ["faslbsdsereos57+14."|
port 8905aec6-0db1-475f-8e38-odfd4b4fe4fc
type: router
router-port: lrp-8905aec6-0db1-475f-8e38-edfd4b4fe4fc
port 8e0a4263 -3b98-49cc-81a9 -499fec769040
|
操作界面、表格与配置图
1
2
3
| type: router
router-port: Irp-8e0a4263 -3b98-49cC-81a9 -499feCc769040
.. Output omitted...
|
注意,这些 lrp inport 和 outport 是 provider-datacentre 外部网络的路由器端口。
显示 finance-router1 的路由表。
在 workstation 上,使用 openstack router list 命令来列出 OpenStack 路由器。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack router list -c ID -c Name
ee eee
| ID | Name |
fan nnn ne ee ee pe ee ee et
| 54a04000-17ea-44df-8c79-d18164e6a1f2 | finance-router1 |
peeccence rene secre roster ss rcesres se ccetecccecseccecceccct
|
在 controller0 执行 ovn-nbctl lr-list,列出所有逻辑路由器。
1
2
3
4
5
| [root@controller0 ~]# ovn-nbctl lr-list
df2df96e-d19f-48e9 -8204-391e22b35efd (neutron-54a04000-17ea- 44df-8c79-
d18164e6a1f2 )
ibaf78f6-b8cc-468c-bd7e-4f01d363c5b5 (neutron-6e39ddfe-1a26-46f7 -
b602-15373b615al1e)
|
在 controller0 执行 ovn-nbctl lr-nat-list,查看 finance-router1 的 NAT 表。
1
2
3
4
5
| [root@controller0 ~]# ovn-nbctl 1r-nat-list \
neutron-54a04000-17ea-44df -8c79-d18164e6a1f2
TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
dnat_and_snat 172.25.250.108 192.168.1.10 fa:16:3e:76:a8:89 a557...106a
snat 172.25.250.102 192.168.1.0/24
|
在 workstation 上,使用 openstack port list 命令列出 OpenStack 端口。
查看上一步的路由表。IP 192.168.1.10 对应的 OpenStack 端口 ID 与 OVN 的 Logical Port 相同。finance-server2 未关联浮动 IP,因此没有对应的 SNAT、DNAT 和路由流。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(developer1-finance)]$ openstack port list \
-c ID -c "Fixed IP Addresses"
ee ee ee ee ee ee ee een eee
| ID | Fixed IP Addresses |
Be ee a ee a
| 12c7...0@d5 | ip_address='192.168.1.1', subnet_id='849b...9ab9' |
| a557...106a | ip_address='192.168.1.10', subnet_id='849b...9ab9' |
| b3e3...7702 | ip_address='192.168.1.12', subnet_id='849b...9ab9' |
| eb6f...2b89 | ip_address='192.168.1.2', subnet_id='849b...9ab9' |
|
操作界面、表格与配置图
在 controller0 使用 ovn-sbctl 列出逻辑流,重定向到 dhcp.txt。在文件中查找 finance-server1 的 ls_in_dhcp_options、ls_in_dhcp_response 和 put_dhcp_opts。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [root@controller0 ~]# ovn-sbctl 1flow-list > dhcp.txt
[root@controller0 ~]# view dhcp.txt
table=12(1s_in_dhcp_options ), priority=100 , match=(inport ==
"a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && eth.src == fa:16:3e:eb:a3:bc && ip4.sre
== 0.0.0.0 && ip4.dst == 255.255.255.255 && udp.src == 68 && udp.dst == 67),
action=(reg0[3] = put_dhcp_opts(offerip = 192.168.1.10, classless_static_route
= {169.254.169.254/32,192.168.1.2, 0.0.0.0/0,192.168.1.1}, dns_server =
{172.25.250.254}, lease_time = 43200, mtu = 1442, netmask = 255.255.255.0, router
= 192.168.1.1, server_id = 192.168.1.1); next;)
table=13(1s_in_dhcp_response), priority=100 , match=(inport ==
"a557dbb8-3d1b-4780-9ca7-d343d3d1106a" && eth.src == fa:16:3e:eb:a3:bce && ip4 &&
udp.src == 68 && udp.dst == 67 && reg®[3]), action=(eth.dst = eth.src; eth.sre =
faii6:3e'd0:10:a8; ip4.dst = 192.168.1.16; ip4.sre = 192.168.1.1; udp.sre = 67;
udp.dst = 68; outport = inport; flags. loopback = 1; output;)
|
关闭此练习中使用的终端窗口。
在 workstation 上运行 lab networking-ovn cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab networking-ovn cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:选择网络配置选项#
引导练习#
选择网络配置选项#
在此过程中,创建一个提供商网络,然后核实所涉及的组件。
学习目标#
完成后,能够:
创建 VLAN 提供者网络。
描述支持 VLAN 提供者网络所需的组件和配置。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab networking-provisioning setup 命令。此脚本创建执行该练习所需的任何资源。
1
| [student@workstation ~]$ lab networking-provisioning setup
|
登录 controller0,确认哪些物理网络可用于创建提供商网络。
从 workstation 登录 controller0,然后切换为 root。
1
2
3
| [student@workstation ~]$ ssh controllere
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
执行 ovs-vsctl 查看 ovn-bridge-mappings,确认哪些网桥映射到物理接口,可用于提供商网络。
1
2
| [root@controller0 ~]# ovs-vsctl get open . external-ids:ovn-bridge-mappings
"datacentre: br-ex, vlanprovider1:br-eth3,vlanprovider2: br-eth4,storage: br -trunk"
|
datacentre 映射已用于 flat 外部网络,storage 映射供实例挂载 CephFS。剩下 vlanprovider1 和 vlanprovider2 可用于提供商网络。
使用 ovs-vsctl 命令显示 br-eth3 和 br-eth4 桥。
1
2
3
4
5
6
| [root@controller0 ~]# ovs-vsctl show
.. output omitted...
Bridge "br-eth4"
fail_mode: standalone
Port "eth4"
Interface "eth4"
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| Port "br-eth4"
Interface "br-eth4"
type: internal
Bridge "br-eth3"
fail_mode: standalone
Port "eths"
Interface "eth3"
Port "br-eth3"
Interface "br-eth3"
type: internal
... output omitted...
|
请注意,这些桥梁除了物理接口之外,没有其它连接。
确定是否为网桥映射配置了 VLAN ID 范围,然后退出 controller0。
1
2
3
4
5
6
7
| [root@controller0 ~]# grep Anetwork_vlan_ranges \
/var/1lib/config-data/puppet-generated/neutron/etc/neutron/plugins/m12/m12_conf .ini
network_vlan_ranges=datacentre:1:1000, vlanprovider1:101:104, vlanprovider 2:101:104,
storage: 30:30
[root@controller0 ~]# logout
[heat-admin@controller0 ~]$ logout
[student@workstation ~]$
|
这意味着可以利用VLANID101至104(含)建立提供商网络。
使用下表创建名为 provider1-103 的匹配子网 subnet1-103 的 VLAN 供应商网络。
| 选项 | 值 |
|---|
| –external | |
| –share | |
| provider -network- type | vlan |
| provider physical network | vlanprovider1 |
| provider segment | 103 |
| –dhep | |
| subnet -range | 10.0.103.0/24 |
操作界面、表格与配置图
| 选项 | 值 |
|---|
| –allocation- pool | start=10.0.103.100, end=10.0.103.149 |
在 workstation 加载 /home/student/admin-rc 用户环境文件。
1
| [student@workstation ~]$ source ~/admin-re
|
创建 provider1-103 提供者网络。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [student@workstation ~]$ openstack network create \
--external \
--share \
--provider-network-type vlan \
--provider-physical-network vlanprovider1 \
--provider-segment 103 \
provider1-103
.. output omitted...
| mtu | 1500 |
| name | provider1-103 |
| port_security_enabled | True |
| project_id | 42eecbfbafé6s4f909abfe5304434fc77 |
| provider :network_type | vlan |
| provider: physical_network | vlanprovider1 |
| provider:segmentation_id | 103 |
| qos_policy_id | None |
| revision_number | 6 |
| router:external | External |
.. Output omitted...
|
创建 subnet1-103 子网。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~]$ openstack subnet create \
--dhep \
--subnet-range=10.0.103.0/24 \
--allocat ion-pool=start=10.0.103.100, end=10.0.103.149 \
--network provider1-103 \
subnet1-103
ee ee mm ee re CP nn nme
| Field | Value
Spee endear amet eee eer Nerd Seta amt eet ee eeeNeedles eee aera ee eel ee eea Nerv ea eeeeer
| allocation_pools | 10.6.103.100-10.0.103.149
| cidr | 10.60.103.0/24
| created_at | 2018-10-25703:19:212
| description |
| dns_nameservers |
| enable_dhcp | True
| gateway_ip | 160.6.103.1
|
| | |
1
2
3
4
| cidr 10.0.103,0/24
created_at 2018 -10-257T03:19: 212
| description
dns_nameservers
|
| | |
1
2
3
| enable_dhcp True
gateway_ip
., Output omitted...
|
操作界面、表格与配置图
部署provider1-103网络的一个实例。
加载 /home/student/developer1-finance-rc 用户环境文件。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
使用以下值创建名为 finance-server1 的实例。
| 选项 | 值 |
|---|
| –flavor | default |
| 镜像 | rhel7 |
| –key-name | example-keypair |
| –network | provider1-103 |
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
--image rhel7 \
--key-name example-keypair \
--network provider1-103 \
--wait \
finance-server1
.. Output omitted...
| addresses | provider1-103=10.0.103.109 |
... Output omitted...
|
从 utility 执行 ping,验证能从 OpenStack 外部通过 provider1-103 访问 finance-server1。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ ssh utility ping -c3 10.0.103.209
PING 10.0.103.109 (10.0.103.109) 56(84) bytes of data.
64 bytes from 10.0.103.109: icmp_seq=1 ttl=64 time=1.31 ms
64 bytes from 10.0.103.109: icmp_seq=2 ttl=64 time=0.920 ms
64 bytes from 10.0.103.109: icmp_seq=3 ttl=64 time=0.545 ms
--- 10.0.103.109 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.545/0.926/1.313/0.313 ms
|
在 workstation 上运行 lab networking-provisioning cleanup 脚本以清除此练习中创建的资源。
1
| [student@workstation ~]$ lab networking-provisioning cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:管理 OpenStack 网络#
管理 OpenStack 网络#
操作检查清单#
在这个实验里,你会创建并测试VLAN供应商网络。
学习目标#
完成后,能够:
创建 VLAN 提供者网络。
启动连接到提供者网络的实例。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab networking-review setup 命令。此脚本创建执行该练习所需的任何资源。
1
| [student@workstation ~]$ lab networking-review setup
|
查看 utility 的网络接口。它在 VLAN 101–104 中各配置了一个子接口,用于测试离开 OpenStack 的 VLAN 流量。
加载 /home/student/admin-rc 环境文件,创建 VLAN 提供者网络 provider1-104 及子网 subnet1-104。根据前一练习,该网络流量经过 br-eth3 网桥。使用下表中的选项和值。
| 选项 | 值 |
|---|
| –share | |
| provider -network- type | vlan |
| provider physical- network | vianprovider1 |
| provider segment | 104 |
| –dhcp | |
| subnet range | 10.0.104.0/24 |
| –allocation- pool | start=10.0.104.100, end=10.0.104.149 |
加载 /home/student/admin-rc 环境文件,创建 VLAN 提供者网络 provider2-104 及子网 subnet2-104。根据前一
练习中,您知道这个网络的流量会穿过 br-eth4 桥。使用下表的选项和值。
操作界面、表格与配置图
| 选项 | 值 |
|---|
| –share | |
| -network- type –provider | vlan |
| provider physical- network | vilanprovider2 |
| provider segment | 104 |
| –dhep | |
| subnet range | 10.0.104.0/24 |
| –allocation- pool | start=10.0.104.150, end=10.0.104.199 |
启动一个连接到 provider1-104 网络的实例。命名production-server1 并使用以下值。
| 选项 | 值 |
|---|
| –flavor | default |
| 镜像 | rhel7 |
| –key-name | example-keypair |
| –network | provider1-104 |
启动一个连接到 provider2-104 网络的实例。命名production-server2 并使用以下值。
| 选项 | 值 |
|---|
| –flavor | default |
| 镜像 | rhel7 |
| –key-name | example-keypair |
| –network | provider2-104 |
从 utility 执行 ping,验证能从 OpenStack 外部访问 production-server1 和 production-server2。
在 workstation 打开新终端,登录 utility 并运行 tcpdump,验证使用的 VLAN 是否正确。
从 production-server1 执行 ping,测试与 production-server2 和 utility 的通信。
在 utility 停止 tcpdump,确认捕获的 ICMP 流量属于 VLAN 104。
在 workstation 上运行 lab networking-review grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
操作界面、表格与配置图
1
| [student@workstation ~]$ lab networking-review grade
|
在 workstation 上运行 lab networking-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab networking-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
管理 OpenStack 网络#
操作检查清单#
在这个实验里,你会创建并测试VLAN供应商网络。
学习目标#
完成后,能够:
创建 VLAN 提供者网络。
启动连接到提供者网络的实例。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 运行 lab networking-review setup 命令。此脚本
创造进行这项工作所需的任何资源。
1
| [student@workstation ~]$ lab networking-review setup
|
查看 utility 的网络接口。它在 VLAN 101–104 中各配置了一个子接口,用于测试离开 OpenStack 的 VLAN 流量。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| [student@workstation ~]$ ssh root@utility ip a
.. output omitted...
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group
default qlen 1000
link/ether 52:54:00:03:00:dce brd ff: ff: ff: ff: ff: ff
inet6 fe80: :5054: ff: fe@3:dc/64 scope link
valid_lft forever preferred_lft forever
4: eth1.102@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UP group default glen 1000
link/ether 52:54:00:03:00:dce brd ff: ff: ff: ff: ff: ff
inet 10.0.102.1/24 brd 10.0.102.255 scope global noprefixroute eth1.102
valid_lft forever preferred_lft forever
ineté6 fe8so: :5054: ff: fe@3:dc/64 scope link
valid_lft forever preferred_lft forever
5: eth1.104@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UP group default qlen 1000
link/ether 52:54:00:03:00:dce brd ff: ff: ff: ff: ff: ff
inet 10.0,.104.1/24 brd 10.0.104.255 scope global noprefixroute eth1.104
valid_lft forever preferred_lft forever
ineté6 fes8o: :5054: ff: feO3:dc/64 scope link
valid_lft forever preferred_lft forever
6: eth1.103@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UP group default qlen 1000
link/ether 52:54:00:03:00:dce brd ff: ff: ff: ff: ff: ff
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| inet 10.0.103.1/24 brd 10.0.103.255 scope global noprefixroute eth1.103
valid_lft forever preferred_lft forever
inet6 fe80: :5054: ff: fee3:dc/64 scope link
valid_lft forever preferred_lft forever
7: eth1.101@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UP group default glen 1900
link/ether 52:54:00:03:00:dce brd ff: ff: ff: ff: ff: ff
inet 10.0.101.1/24 brd 10.0.101.255 scope global noprefixroute eth1.101
valid_lft forever preferred_lft forever
inet6 fes8o: :5054: ff: feO3:dc/64 scope link
valid_lft forever preferred_lft forever
|
加载 /home/student/admin-rc 环境文件,创建 VLAN 提供者网络 provider1-104 及子网 subnet1-104。根据前一练习,该网络流量经过 br-eth3 网桥。使用下表中的选项和值。
| 选项 | 值 |
|---|
| –share | |
| –provider -network- type | vlan |
| –provider physical network | vlanprovider1 |
| provider segment | 104 |
| –dhcp | |
| subnet range | 10.0.104.0/24 |
| –allocation- pool | end=10.0.164.149 start=10.6.104.100, |
在 workstation 加载 /home/student/admin-rc 环境文件。
1
| [student@workstation ~]$ source ~/admin-rce
|
创建 provider1-104 提供者网络。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~]$ openstack network create \
--Share \
--provider-network-type vlan \
--provider-physical-network vlanprovider1 \
--provider-segment 104 \
provider1-104
.. Output omitted...
| mtu | 1500 |
| name | provider1-104 |
| port_security_enabled | True |
| project_id | 42eecbTbaf6s4f9o9abfe5304434fc77 |
| provider :network_type | vlan |
| provider: physical_network | vlanprovider1 |
| provider:segmentation_id | 104 |
| qos_policy_id | None |
| revision_number | 6 |
|
操作界面、表格与配置图
1
2
| | router: external | External
.. Output omitted...
|
创建 subnet1-104 子网。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~]$ openstack subnet create \
--dhep \
--subnet-range=10.0.104.0/24 \
--allocation-pool=start=10.0.104.100, end=10.0.104.149 \
--network provider1-104 \
subnet1-104
SS eee eee
| Field | Value |
Semen tention menagesehen een ey men an en nm en men em in genefe
| allocation_pools | 10.0.104.100-10.0.104.149 |
| cidr | 10.0.104.0/24 |
| created_at | 2018-10-30T03:29: 46Z |
| description |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 10.0.104.1 |
.., output omitted...
|
加载 /home/student/admin-rc 环境文件,创建 VLAN 提供者网络 provider2-104 及子网 subnet2-104。根据前一练习,该网络流量经过 br-eth4 网桥。使用下表中的选项和值。
| 选项 | 值 |
|---|
| –share | |
| provider -network- type | vian |
| –provider physical network | vlanprovider2 |
| provider segment | 104 |
| –dhep | |
| subnet range | 10.0.104.0/24 |
| –allocation-pool | start=10.0.104.150, end=10.0.104.199 |
创建 provider2-104 提供者网络。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ openstack network create \
--share \
--provider-network-type vlan \
--provider-physical-network vlanprovider2 \
--provider-segment 104 \
provider2-104
.. output omitted...
| mtu | 1500 |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| | port_security_enabled | True |
| project_id | 42eecbTfbaf6s4f9o9abfeb304434fc77 |
| provider :network_type | vlan |
| provider:physical_network | vlanprovider2 |
| provider:segmentation_id | 104 |
| qos_policy_id | None |
| revision_number | 6 |
| router: external | External |
.. Output omitted...
|
创建 subnet2-104 子网。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~]$ openstack subnet create \
--dhep \
--subnet-range=10.0.104.0/24 \
--allocation-pool=start=10.0.104.150,end=10.0.104.199 \
--network provider2-104 \
subnet2-104
Bee aCe (CSC eC aC MCSETOSiq RIC CSC eC Te ITS TICTOCTICTOC TSC TCT CSC CCia
| Field | Value |
2. ee
| allocation_pools | 10.0.104.150-10.0.104.199 |
| cidr | 10.0.104,0/24 |
| created_at | 2018-10-30TO3:33:06Z |
| description |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 10.0.104.1 |
.. output omitted...
|
连接 provider1-104 网络的启动实例。命名为 production-server1, 并使用以下值。
| 选项 | 值 |
|---|
| –flavor | default |
| 镜像 | rhel7 |
| –key-name | example-keypair |
| –network | provider1-104 |
加载 /home/student/operator1-production-rc 用户环境文件。
1
2
| [student@workstation ~]$ source ~/operator1i-production-re
[student@workstation ~(operator1-production)]$
|
启动实例。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--image rhel7 \
--key-name example-keypair \
--network provider1-104 \
|
操作界面、表格与配置图
1
2
3
4
5
| --wait \
production-server1
.. Output omitted...
| addresses | provider1-104=10.0.104.102 |
.. output omitted...
|
启动一个连接到 provider2-104 网络的实例。命名production-server2 并使用以下值。
| 选项 | 值 |
|---|
| –flavor | default |
| 镜像 | rhel7 |
| –key-name | example-keypair |
| –network | provider2-104 |
启动实例。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--image rhel7 \
--key-name example-keypair \
--network provider2-104 \
--wait \
production-server2
.. Output omitted...
| addresses | provider2 -104=10.0.104.153 |
.. output omitted...
|
从 utility 执行 ping,测试 production-server1 和
production-server2可在OpenStack之外获取。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~(operator1-production)]$ ssh utility ping -c3 10.0.104.102
PING 10.0.104.102 (10.0.104.102) 56(84) bytes of data.
64 bytes from 10.0.104.102: icmp_seq=1 ttl=64 time=1.50 ms
64 bytes from 10.0.104.102: icmp_seq=2 ttl=64 time=0.797 ms
64 bytes from 10.0.104.102: icmp_seq=3 ttl=64 time=0.565 ms
--- 10.0.104.1602 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.565/0.954/1.502/0.400 ms
[student@workstation ~(operator1-production)]$ ssh utility ping -c3 10.0.104.153
PING 10.0.104.153 (10.0.104.153) 56(84) bytes of data.
64 bytes from 10.0.104.153: icmp_seq=1 ttl=64 time=1.23 ms
64 bytes from 10.0.104.153: icmp_seq=2 ttl=64 time=0.625 ms
64 bytes from 10.0.104.153: icmp_seq=3 ttl=64 time=0.565 ms
--- 10.0.104.153 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = ©.565/0.809/1.238/0.304 ms
|
操作界面、表格与配置图
在 workstation 打开新终端,登录 utility 并运行 tcpdump,验证使用的 VLAN 是否正确。
1
2
| [student@workstation ~]$ ssh root@utility
[root@utility ~]# tcpdump -nnei eth1 -vvv
|
从 production-server1 执行 ping,测试与 production-server2 和 utility 的通信。
从workstation获得production-server1的consoleURL。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(operator1-production)]$ openstack console url show \
production-server1
fe eet ie ie ie ie ie ie ie nie nie nie nen rien rie ee i ie re ee ee ie ee eee eet
| Field | Value |
Nt eR aR TR NR OR eo eR ae a ae re a a RR RR
| type | novne |
| url | http: //172. 25. 250.50; 6680/vnc_auto. html?token=84f2c5ae- |
| | 11b9-4297-be63-327fcc7152f4 |
fe eee ie ie ie ie ie nie nie ein nie nie nie nin sie ee es ti ee ee ee ee eee eet
|
在 Firefox 中打开链接,然后以 redhat 密码登录为 root。
使用 ping 命令测试与 production-server2 和 utility 的连接。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [root@production-server1 ~]# ping -c3 10.0.104.153
PING 10.0.104.153 (10.0.104.153) 56(84) bytes of data.
64 bytes from 10.0.104.153: icmp_seq=1 ttl=64 time=3.23 ms
64 bytes from 10.0.104.153: icmp_seq=2 ttl=64 time=1.22 ms
64 bytes from 10.0.104.153: icmp_seq=3 ttl=64 time=0.863 ms
--- 10.0.104.153 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.863/1.774/3.234/1.043 ms
[root@production-server1 ~]# ping -c3 10.0.104.1
PING 10.0.104.1 (10.0.104.1) 56(84) bytes of data.
64 bytes from 10.0.104.1: icmp_seq=1 ttl=64 time=3.23 ms
64 bytes from 10.0.104.1: icmp_seq=2 ttl=64 time=1.22 ms
64 bytes from 10.0.104.1: icmp_seq=3 ttl=64 time=0.863 ms
--- 160.0.104.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = ©.863/1.774/3.234/1.043 ms
|
在 utility 停止 tcpdump,确认捕获的 ICMP 流量属于 VLAN 104。
1
2
3
4
5
6
7
8
9
| ... output omitted...
05:41:39.550482 fa:16:3e:b7:86:40 > 52:54:00:03:00:dc, ethertype 802.1Q (0x8100),
length 102: vlan 104, p 9, ethertype IPv4, (tos oxo, ttl 64, id 11745, offset 0,
flags [DF], proto ICMP (1), length 84)
10.0.104.102 > 10.60.104.1: ICMP echo request, id 1339, seq 1, length 64
05:41:39.550564 52:54:00:03:00:dc > fa:16:3e:b7:86:40, ethertype 802.19 (0x8100),
length 102: vlan 104, p 0, ethertype IPv4, (tos 0x0, ttl 64, id 46758, offset 0,
flags [none], proto ICMP (1), length 84)
10.0.104.1 > 10.60.104.102: ICMP echo reply, id 1339, seq 1, length 64
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| 05:41:40.552250 fa:16:3e:b7:86:40 > 52:54:00:03:00:dc, ethertype 802.1Q (0x8100),
length 102: vlan 104, p 0, ethertype IPv4, (tos ox0, ttl 64, id 12450, offset 0,
flags [DF], proto ICMP (1), length 84)
10.0.104.102 > 10.0.104.1: ICMP echo request, id 1339, seq 2, length 64
05:41:40.552308 52:54:00:03:00:dc > fa:16:3e:b7:86:40, ethertype 802.1Q (0x8100),
length 102: vlan 104, p 0, ethertype IPv4, (tos 0x0, ttl 64, id 47597, offset 9,
flags [none], proto ICMP (1), length 84)
10.0.104.1 > 10.0.104.102: ICMP echo reply, id 1339, seq 2, length 64
05:41:41.553772 fa:16:3e:b7:86:40 > 52:54:00:03:00:dc, ethertype 802.1Q (0x8100),
length 102: vlan 104, p 9, ethertype IPv4, (tos 0x0, ttl 64, id 12729, offset 0,
flags [DF], proto IcmP (1), length 84)
10.0.104.102 > 10.60.104.1: ICMP echo request, id 1339, seq 3, length 64
05:41:41.553837 52:54:00:03:00:dc > fa:16:3e:b7:86:40, ethertype 802.19 (0x8100),
length 102: vlan 104, p 9, ethertype IPv4, (tos 0x0, ttl 64, id 48352, offset 0,
flags [none], proto ICMP (1), length 84)
10.0.104.1 > 10.0.104.102: ICMP echo reply, id 1339, seq 3, length 64
.. Output omitted...
|
在 workstation 上运行 lab networking-review grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
1
| [student@workstation ~]$ lab networking-review grade
|
在 workstation 上运行 lab networking-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab networking-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 浮动 IP 已关联,应用仍无法访问,应该如何处理?
- 排查 OVN 网络前应首先确认什么?
自测答案#
- 检查端口、安全规则、路由和应用监听。浮动 IP 映射只是访问路径中的一环。
- 实际部署的网络后端与当前拓扑。不同后端对应不同组件和数据路径,应以当前部署为依据。
C7-管理计算资源#
实例启动的依赖链#
实例请求包含镜像、规格、网络和存储等输入。计算服务需要完成调度与资源准备,并与镜像、网络、存储和虚拟化组件协作。失败可能发生在不同阶段;应结合实例故障信息、服务日志和相关资源状态,而不是只看到 ERROR 就重新创建。
计算节点与工作负载#
节点可用性、容量和已运行工作负载需要同时考虑。准备维护计算节点时,应先确认服务状态和实例分布,再执行相应的迁移或维护操作。禁用新的调度与处理已经运行的实例不是同一个动作。
超融合基础设施#
超融合将计算与存储角色部署在相同节点上,因此 CPU、内存、网络和磁盘资源需要统筹。超融合实例部署需同时核对实例状态与实际宿主机。资源规格与选择条件应符合目标节点的能力和调度策略。
迁移操作的前提#
迁移涉及源节点、目标节点、网络、存储和实例状态。操作名称相似,不代表前提条件相同。执行前记录实例所在主机及持久化数据的位置,操作后检查新的主机位置、实例状态和业务连续性;迁移命令返回成功不能取代业务验证。
计算资源验证#
保留实例 UUID、创建参数、调度结果、计算服务状态以及实例内部验证结果。若操作失败,检查请求是否已部分完成,避免留下重复实例、端口或卷。综合实验应形成“准备资源—启动—确认位置—管理节点—验证业务”的闭环。
实例创建的责任链#
1
2
3
4
5
6
7
| nova-api:校验与受理
→ conductor / scheduler:协调、选宿主机
→ nova-compute:执行计算侧操作
├─ Glance:镜像
├─ Neutron:端口与绑定
├─ Cinder / Ceph:磁盘
└─ libvirt / KVM:创建并启动虚拟机
|
这是职责图,实际调用会异步交错。排错时同时记录 request ID、实例 UUID、项目与时间。
调度与超融合#
Host Aggregate 用于组织主机及元数据;Flavor extra specs 表达实例要求;对应 scheduler filters 需要正确启用。写了属性不等于所有部署都会按该属性调度。
示例采用 computehci=true 元数据,需配合能够读取该属性的调度过滤器:
1
2
3
4
5
6
7
| openstack aggregate create demo-hci
openstack aggregate add host demo-hci <超融合宿主机名>
openstack aggregate set --property computehci=true demo-hci
openstack flavor create --vcpus 2 --ram 1024 --disk 10 demo-hci
openstack flavor set --property computehci=true demo-hci
openstack aggregate show demo-hci
openstack flavor show demo-hci
|
超融合节点上的 Nova 和 Ceph 会竞争 CPU、内存、磁盘及网络。要预留存储服务资源,不能将全部物理容量计入实例可分配量。
维护与迁移#
1
2
3
4
5
6
| # Overcloud 管理员;宿主机名称以列表为准
openstack compute service list
openstack server list --all-projects --host <源宿主机名>
openstack compute service set --disable <源宿主机名> nova-compute
openstack server migrate --live <目标宿主机名> <实例UUID>
openstack server show <实例UUID>
|
迁移前确认 CPU 兼容、目标容量、存储可达和迁移网络;示例采用 RHOSP 13的客户端语法。
| 操作 | 使用场景 | 关键区别 |
|---|
| 冷迁移 | 允许停机的移动 | 要核对 VERIFY_RESIZE 后的确认或回退 |
| Live Migration | 源节点仍可协作的在线迁移 | 验证目标主机与应用连续性 |
| Evacuation | 源计算节点故障后的恢复 | 先确认源端不会继续运行相同实例 |
| 禁用 nova-compute 调度 | 阻止新实例分配 | 不会自动迁走现有实例 |
nova host-evacuate-live 是批量在线迁出工具,不等于故障源节点无法参与时的 evacuation。维护完成后核对服务健康,再恢复调度。
实验操作#
引导练习:理解实例启动过程#
引导练习#
理解实例启动过程#
在此练习中,查看 placement 服务器的日志文件和数据,并观察调度器消息。
学习目标#
能够查看 Placement 服务日志,并观察实例创建成功和失败时的调度器消息。
开始之前#
以 student 用户登录 workstation,密码为 student。
运行 lab computeresources-launch setup 命令。此脚本确保 OpenStack 服务正在运行,环境为导引练习配置得当。
1
| [student@workstation ~]$ lab computeresources-launch setup
|
从 workstation 登录 controller0 并切换为 root,启用计算服务调试,重启容器并确认状态。
从 workstation 登录到 controller0 作为 heat-admin 用户,并更改为 root 用户。
1
2
3
| [student@workstation ~]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
编辑 /var/lib/config-data/puppet-generated/nova/etc/nova/nova.conf,将 debug 设为 true。重启 nova_scheduler 和 nova_api,等待 45 秒后执行 docker ps,确认容器运行且健康。
1
2
3
4
5
6
7
8
9
10
11
12
| [root@controller0 ~]# crudini --set \
/var/1lib/config-data/puppet-generated/nova/etc/nova/nova.conf \
DEFAULT debug True
[root@controller0 ~]# docker restart nova_api
nova_api
[root@controller0 ~]# docker restart nova_scheduler
nova_scheduler
[root@controller0 ~]# docker ps \
--format="{{.Names}}\t{{.Status}}" | grep nova
.. output omitted...
nova_api Up About 31 seconds (healthy)
nova_scheduler Up About 46 seconds (healthy)
|
操作界面、表格与配置图
再打开三个终端,分别从 workstation 登录 compute0、controller0、controller0。每个终端执行 sudo -i 获得 root 权限,并切换到 /var/log/containers/nova。
这些额外的终端窗口将用于检查计算服务日志文件。
打开新终端,以 heat-admin 用户登录计算节点,执行 sudo -i 获取 root 权限,然后进入日志目录。
1
2
3
4
| [student@workstation ~]$ ssh heat -admin@compute0
[heat-admin@compute0 ~]$ sudo -i
[root@compute0O ~]# cd /var/log/containers/nova
[root@compute0 nova]#
|
打开新终端,以 heat-admin 用户登录 controller0,执行 sudo -i 获取 root 权限,然后进入日志目录。
1
2
3
4
| [student@workstation ~]$ ssh heat-admin@controller0e
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]# cd /var/log/containers/nova
[root@controller0 nova]#
|
打开新终端,以 heat-admin 用户登录 controller0,执行 sudo -i 获取 root 权限,然后进入日志目录。
1
2
3
4
| [student@workstation ~]$ ssh heat-admin@controller0e
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]# cd /var/log/containers/nova
[root@controller0 nova]#
|
在 workstation 上,作为 architect1 的用户,创建一个名为 finance-server1 的新实例。
加载 /home/student/architect1-finance-rc 身份环境文件。
1
2
| [student@workstation ~]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
执行 openstack server create 创建 finance-server1,使用 rhel7 镜像、default 规格、default 安全组、finance-network1,并指定 compute0。记录实例 UUID,用于检查
nova 日志文件。
1
2
3
4
5
| [student@workstation ~(architect1-finance)]$ openstack server create \
--image rhel7 \
--flavor default \
--nic net-id=finance-network1 \
--security-group finance-web \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| --availability-zone nova:compute0.overcloud.example.com \
--wait finance-server1
Deeee reo
| Field | Value |
Popesee era eae ee 2 ye Eee Eee Ea ea Soa Soe ere Ne eehet aa Eee se E2828 Ena Ea ae en a a eeeA
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ: availability_zone | nova |
| OS-EXT-SRV-ATTR:host | compute0.overcloud.example.com |
| OS-EXT-SRV-ATTR: hypervisor_hostname | compute0.overcloud.example.com |
.. output omitted...
| id | 1dd346b7 -8b39-4bof-988b-90fic3d4ef3b |
.. Output omitted...
|
在 compute0 查看 nova-compute.log,用 grep 查找 finance-server1 UUID 对应的条目。
1
| [root@compute0 nova]# grep 1dd346b7-8b39-4b0f-988b-90fiIc3d4ef3b nova-compute.log
|
nova-compute.log 包含 finance-server1 创建过程的多个条目。注意申请 compute0 资源的记录,以及所需内存、磁盘和 vCPU。
1
2
3
4
5
6
| 2018-11-01 09:34:08.050 1 INFO nova.compute.claims
[req-c41919ad-a82e-43b0-89ea-6b268a64d15b
69fb452af3dcicib54fb342df19d898fe39 28e50cc930ebb8 f112b1a59e917 26
3c003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9 default]
[instance: 1dd346b7-8b39-4bof -988b-90f1c3d4ef3b]| Attempting claim on node
compute0.overcloud.example.com: memory 2048 MB, disk 10 GB, vcpus 2 CPU
|
下一个条目告知用户compute0上可用的内存、磁盘和 vCPU。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| 2018-11-01 09:34:08.050 1 INFO nova. compute.claims
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69 fb452af3dcicib54fb342df19d898fe39 28e50cc930ebb8f112b1a59e917 26
3c003f65d8d64914a053f178fbbf953c - 8dd2d3i6acc74f54bs890baeb19ea75b9 default]
[instance: 1dd346b7-8b39-4bef -988b-90Tfic3d4ef3b| Total memory: 6143 MB, used:
4096.00 MB
2018-11-91 09:34:08.050 1 INFO nova.compute.claims
[req-c41919ad -a82e-43b0-89ea-6b268a64d15b
69fb452af3dc1c1b54fb342df19d898fe39 28e50cc930ebb8f112b1a59e917 26
30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9 default|
[instance: 1dd346b7-8b39-4bof -988b-90fic3d4ef3b]| memory limit not specified,
defaulting to unlimited
2018-11-01 09:34:08.050 1 INFO nova. compute.claims
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dcicib54fb342df19d898fe39 28e50cc930ebb8 f112b1a59e917 26
30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890baeb19ea75b9 default]
[instance: 1dd346b7-8b39-4b0f-988b-90fic3d4ef3b]| Total disk: 113 GB, used: 0.00
GB
2018-11-01 09:34:08.051 1 INFO nova.compute.claims
[req-c41919ad-a82e-43b0-89ea-6b268a64d15b
69fb452af3dc1c1b54fb342df19d898fe39 28e50cc930ebb8f112b1a59e917 26
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| 30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890baeb19ea75b9 default]
[instance: 1dd346b7-8b39-4bof -988b-90f1c3d4ef3b] disk limit not specified,
defaulting to unlimited
2018-11-01 09:34:08.051 1 INFO nova.compute.claims
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dc1c1b54fb342df19d898fe39 28e50cc930ebb8f112b1a59e917 26
30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9 default]
[instance: 1dd346b7-8b39-4b0f-988b-90fic3d4ef3b] Total vcpu: 4 VCPU, used: 0.00
VCPU
2018-11-01 09:34:08.051 1 INFO nova.compute.claims
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dcicib54fb342df19d898fe39 28e50cc930ebb8f112b1a59e917 26
30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9 default]
[instance: 1dd346b7-8b39-4b0Tf -988b-90f1ic3d4ef3b] vcpu limit not specified,
defaulting to unlimited
|
下一个条目表示 nova-compute 资源申请成功。
1
2
3
4
5
6
| 2018-11-01 09:34:08.051 1 INFO nova.compute.claims
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dcic1b54fb342df19d898fe3928e50cc93 0ebb8f112b1a59e917 26
3c003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9 default]
[instance: 1dd346b7-8b39-4bof -988b-90f1c3d4ef3b]| Claim successful on node
compute0.overcloud.example.com
|
其余条目告诉用户正在创建实例。最后条目告诉用户构建实例需要多长时间
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| 2018-11-01 09:34:09.621 1 INFO nova. virt.libvirt.driver
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dc1c1b54fb342df19d898fe39 28e50cc930ebb8f112b1a59e91726
30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9 default]
[instance: 1dd346b7-8b39-4bof -988b-90T1ic3d4ef3b] Creating image
2018-11-01 09:34:29,110 1 INFO nova.compute.manager [req-92997d21-381c-4cba-9d97-
c83d5d51cee8 d5ea3é6lacid44b3fa6aa289cd0a52756 d8f5ide4ie7e4f4b8c71ed7dfc226c97
- default default] [instance: 1dd346b7-8b39-4bof-988b-90fic3d4ef3b] VM Started
(Lifecycle Event)
... Output omitted...
2018-11-01 09:34:34,016 1 INFO nova.compute.manager [req-bd300177 -3613-4ec6 -8bd7 -
da20a7857a6b d5ea36lacid44b3fas6aa289cd0ab2756 déf5ide4ie7e4f4b8c71ed/dfc226c97
- default default] [instance: 1dd346b7 -8b39-4bo0f-988b-90fic3d4ef3b] Took 25.98
seconds to build instance.
|
注意:在 Life-cycle Event 开始之前的日志条目中,都包含相同的 ID,位于 finance-server1 的 ID 之前。下一步将使用此 ID 来
检查 nova-scheduler.log。
1
2
3
4
5
6
| 2018-11-01 09:34:08.051 1 INFO nova.compute.claims [req-
c41919ad -a82e-43b0-89eai -6b268a64d15b
69fb452af3dc1c1b54fb342df19d898fe3928e50cc930ebb8f112b1a59e91726
30003f65d8d64914a053f178fbbf953c - Sdd2d316acc74f54bs9ebae519ea75b9 default]
[instance: 1dd346b7-8b39-4bof -988b-90fic3d4ef3b] vcpu limit not specified,
defaulting to unlimited
|
操作界面、表格与配置图
在一个 controller0 终端中,用 grep 和 finance-server1 的 UUID 查找 nova-placement 日志。每次创建实例有三个条目:两个 GET 和一个 PUT。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [root@controller0 nova]# grep 1dd346b7-8b39-4bof -988b-90f1c3d4ef3b \
nova-placement.log
2018-11-01 09:34:07.772 12 INFO nova.api.openstack.placement.requestlog
[req-7980d973-6aac-49bf-b58c-d44e1f90ae84 a4sdc9ff61c54efb8104440971e1Fffdd
dsf5ide41e7e4f4bsc71ed7dfc226c97 - default default] 172.24.1.1 "GET /
placement/allocations/1dd346b7-8b39- 4bof-988b-90f1c3d4ef3b" status: 200 len: 19
microversion: 1.0
2018-11-01 09:34:07.811 12 INFO nova.api.openstack.placement.requestlog
[req-cbbb796e-5d99 -4e04-a2c0-ed62ec389cd9 a4sdc9ff6ich4efb8104440971e1ffdd
dsf5ide41e7e4f4bsc7ied7dfc226c97 - default default] 172.24.1.1 "PUT /placement/
allocations/1dd346b7-8b39-4bof -988b-90fic3d4ef3b" status: 204 len: © microversion:
Arcee
2018-11-01 69:34:08.956 12 INFO nova.api.openstack.placement.requestlog
[req-c7076539-5929-457c-bbde-8069e990ea9b a4sdc9ff6ich4efb8104440971e1ffdd
d8f5ide41e7e4f4b8c71ed7dfc226c97 - default default] 172.24.1.1 "GET /placement/
allocations/1dd346b7-8b39-4bef -988b-90fic3d4ef3b" status: 200 len: 136
microversion: 1.0
|
在一个 controller0 终端中,使用从 nova-compute.log 复制的请求 ID,通过 grep 查找 nova-scheduler 日志。
1
| [root@controller0 nova]# grep 8dd2d316acc74f54b89ebae519ea75b9 nova-scheduler.log
|
最初的条目是一系列 nova_scheduler 获取和释放主机锁的操作。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| 2018-11-01 69:33:54.461 1 DEBUG oslo_concurrency.lockutils
[req-58612dbf-305f-4a13 -b1e1-638a65324c0a
69fb452af3dc1c1b54fb342df19d898fe39 28e50cc930ebb8f112b1a59e917 26
3c003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9 default] Lock
"host_instance" acquired by "nova.scheduler.host_manager .delete_instance_info" ::
waited ©.000s inner /usr/lib/python2.7/site-packages/oslo_concurrency/
lockutils.py:273
2018-11-01 09:33:54.461 1 DEBUG oslo_concurrency. lockutils
[req-58612dbf-305f-4a13 -b1e1-638a65324c0a
69fb452af3dcicib54fb342df19d898fe3928e50cc930ebb8f112b1a59e917 26
30003F65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b89Obae519ea75b9 default] Lock
"host_instance" released by "nova.scheduler.host_manager .delete_instance_info" ::
held ©.000s inner /usr/lib/python2. 7/site-packages/oslo_concurrency/
lockutils.py:285
|
这里第一个条目显示 nova_scheduler 开始调度 finance-server1,下一个条目显示它获取计算节点和服务,以创建实例。
1
2
3
4
| 2018-11-01 09:34:06.397 1 DEBUG nova.scheduler.manager
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dcicib54fb342df19d898fe39 28e50cc930ebb8 f112b1a59e917 26
3c003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b8 90bae519ea75b9
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
| default] Starting to schedule for instances:
[u'1dd346b7-8b39- 4bof-98sb-90f1ic3d4ef3b'| select_destinations /usr/lib/python2.7/
site-packages/nova/scheduler/manager. py:110
2018-11-01 09:34:06.934 1 DEBUG nova. scheduler .host_manager
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dc1c1b54fb342df19d8 98fe3928e50cc930ebb8f112b1a59e91726
3c003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9
default] Getting compute nodes and services for cell
QOOOOOOO - OOOO - OOH - OOOO -OOOOHOOOOOOOO(Ccell1O) _get_computes_for_cells /usr/lib/
python2.7/site-packages/nova/scheduler/host_manager . py:623
|
随后 nova_scheduler 检查主机聚合。
1
2
3
4
5
6
| 2018-11-01 09:34:06.958 1 DEBUG nova.scheduler.host_manager
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dc1cib54fb342df19d898fe39 28e50cc930ebb8f112b1a59e917 26
30003F65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890baeb519ea75b9
default] Update host state with aggregates: [] _locked_update /usr/lib/python2.7/
site-packages/nova/scheduler/host_manager. py: 175
|
在同一控制器节点上,并使用相同的 grep 命令,搜索 finance-server1 的 ID。
1
2
| [root@controller0 nova]# grep 1dd346b7-8b39-4bof-988b-90fic3d4ef3b nova-
scheduler .log
|
创建每个实例有三个条目。第一个条目显示 nova_scheduler 排程。第二个条目显示 nova_scheduler 请求资源。第三个条目是创建实例。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| 2018-11-01 09:34:06.397 1 DEBUG nova.scheduler.manager
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dcicib54fb342df19d898fe3928e50cc930ebb8f112b1a59e917 26
30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b89Obaed519ea75b9
default] Starting to schedule for instances:
[u'1dd346b7-8b39- 4bof-988b-90f1c3d4ef3b'| select_destinations /usr/lib/python2.7/
site-packages/nova/scheduler/manager. py:110
2018-11-01 69:34:06.961 1 DEBUG nova.scheduler.utils
[req-c41919ad-a82e-43b0 -89ea-6b268a64d15b
69fb452af3dcicib54fb342df19d898fe39 28e50cc930ebb8f112b1a59e91726
30003F65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b89Obaeb19ea75b9
default] Attempting to claim resources in the placement API for instance
1dd346b7 -8b39-4bof-988b-90fic3d4ef3b claim_resources /usr/lib/python2.7/site-
packages/nova/scheduler/utils.py: 786
2018-11-01 10:10:29.698 1 DEBUG nova.scheduler.host_manager
[req-a56f6380-23a3-4ba4 -9296 -69075401800d
69fb452af3dc1c1b54fb342df19d898fe3928e50cc930ebb8f112b1a59e91726
30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9
default] Update host state with instances:
{u'1dd346b7 -8b39-4bof-988b-90f1c3d4ef3b' :
Instance(access_ip_v4=None,access_ip_v6=None,architecture=None,
au to_disk_config=False, availability_zone='nova' ,cell_name=None,
cleaned=False, config_drive='',created_at=2018 -11-01T09:34:06Z,
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| default_ephemeral_device=None,default_swap_device=None,
deleted=False, deleted_at=None,device_metadata=None,
disable_terminate=False, display_description=' finance-
server1',display_name='Tinance-server1',
ec2_ids=EC2Ids, ephemeral_gb=0, ephemeral_key_uuid=None,fault=
.. Output omitted...
flavor=Flavor(2),host='compute0.overcloud.example.com', hostname='finance-
server1' , id=4, image_ref='6b0128a9 -4481-4ceb-b34e-
ffe92eedcfdd' , info_cache=Ins tanceInfocache,instance_type_id=2,kernel_id='',
key_data=None, key_name=None, keypair s=KeyPair List, launch_index=0,
launched_at=2018-11-01T09:34:33Z, launched_on='compute0. overcloud.example.com',
locked=False, locked_by=None, memory_mb=2048, metadata={},migration_context=
.. Output omitted...
image_container_format='bare', image_cpu_arch='x86_64', image_disk_format='qcow2',
image_min_disk='10', image_min_ram='2048', image_owner_specified. shade. md5=
"9300685C8287e30b967Cca4cb71057b3b', image_owner_specified. shade. object='images/
rhel7' ,image_owner_specified.shade.sha256=
'e5855605 fdce3 754c3d600f6d3b8a9bd58e93371b376fc7cébbsafs8dc9c16d952',
owner_project_name='finance',owner_user_name='architect1'},
tags=TagList, task_state=None, terminated_at=None, updated_at=2018 -11-01T09 :34:09Z,
user_data=None, user_id=
'69fb452af3dcicib54fb342df19d898fe39 28e50cc930ebb8f112b1a59e91726',
uuid=1dd346b7-8b39- 4bof -988b-90f1c3d4ef3b, vcpu_model=Vir tCPUModel,
vcpus=2,vm_mode=None, vm_state='active')} _locked_update /usr/lib/python2.7/site-
packages/nova/scheduler/host_manager . py:181
|
执行 openstack server create 创建 finance-server2,使用 rhel7 镜像、launch 规格、finance-web 安全组和 finance-network1,指定 compute0。
1
2
3
4
5
6
7
| [student@workstation ~(architect1-finance)]$ openstack server create \
--image rhel7 \
--flavor launch \
--nic net-id=finance-network1 \
--security-group finance-web \
--availability-zone nova:compute0.overcloud.example.com \
--wait finance-server2
|
实例启动将失败,因为规格的内存小于镜像要求。
1
2
| Flavor's memory is too small for requested image. (HTTP 400) (Request-
ID: req-5f1ca5b7-94ee -4a62-9703-3cbe78e6c513 )
|
在 controller0 检查 nova-api.log,使用创建实例失败时错误信息中的请求 ID。
1
2
| [root@controller0 nova]# grep req-5fica5b7 -94ee-4a62-9703-3cbe78e6c513 \
nova-api. log
|
第一个条目显示在 compute0 上创建服务器的尝试。
1
2
| 2018-11-01 10:52:46.193 14 DEBUG nova.api.openstack.wsgi
[req-5f1ca5b7-94ee-4a62-9703-3cbe78e6c513
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
| 69fb452af3dc1c1b54fb342df19d898fe3928e50cc930ebb8f112b1a59e91726
3c003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9
default] Action: 'create', calling method: <bound method Serverscontroller.create
of <nova.api.openstack. compute.servers.Serverscontroller object
at 0x7f42cbiefd50>>, body: {"server": {"name": "finance-server2",
"imageRef": "6b0128a9-4481 -4ceb-b34e-ffe92e0dcfdd", ""availability_zone":
"nova:computed.overcloud.example.com", "flavorRef": "10b69784-0ed5-4394-982c-
b6239e663a9c", "max_count": 1, "min_count": 1, "networks": [{"uuid":
"7a6556ab-6083 -403e-acfc-79caf3873660"}]}} _process_stack /usr/lib/python2.7/
site-packages/nova/api/openstack/wsgi.py:604
|
下一个条目显示 nova_scheduler 服务获得的锁。
1
2
3
4
5
6
7
| 2018-11-01 10:52:46.214 14 DEBUG oslo_concurrency. lockutils
[req-5f1ca5b7-94ee-4a62 -9703-3cbe78e6c513
69fb452af3dc1c1b54fb342df19d898fe3928e50cc930ebb8f112b1a59e91726
30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b89Obaeb19ea75b9
default] Lock "Q00O00OO - 0000 - 0900-9H00 -9OO0OO009000" acquired by
"nova.context.get_or_set_cached_cell_and_set_connections" :: waited 0.900@s
inner /usr/lib/python2.7/site-packages/oslo_concurrency/lockutils.py:273
|
后来,nova_scheduler服务获得项目配额。
1
2
3
4
5
6
| 2018-11-01 10:52:46.740 14 DEBUG nova.quota
[req-5f1ca5b7-94ee-4a62-9703-3cbe78e6c513
69fb452af3dcicib54fb342df19d898fe39 28e50cc930ebb8f112b1a59e917 26
30003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b89Obae519ea75b9
default] Getting quotas for project 3c003f65d8d64914a053f178fbbf953c. Resources:
['injected_files'] _get_quotas /usr/lib/python2.7/site-packages/nova/quota.py:409
|
有些条目后来注意到错误信息,告知用户规格的内存太小。
1
2
3
4
5
6
7
8
9
10
11
| 2018-11-01 10:52:46.762 14 INFO nova.api.openstack.wsgi
[req-5f1ca5b7-94ee-4a62 -9703-3cbe78e6c513
69fb452af3dcicib54fb342df19d898fe3928e50cc930ebb8f112b1a59e91726
3c003f65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b89ebae519ea75b9 default] HTTP
exception thrown: Flavor's memory is too small for requested image.
2018-11-01 10:52:46.763 14 DEBUG nova.api.openstack.wsgi
[req-5f1ca5b7-94ee-4a62 -9703-3cbe78e6c513
69fb452af3dc1icib54fb342df19d898fe3928e50cc930ebb8f112b1a59e91726
30003F65d8d64914a053f178fbbf953c - 8dd2d316acc74f54b890bae519ea75b9
default] Returning 400 to user: Flavor's memory is too small for requested image.
_call_ /usr/lib/python2.7/site-packages/nova/api/openstack/wsgi. py:1064
|
关闭此引导练习中使用的所有终端窗口。
清理:在 workstation 上运行 lab computeresources-launch cleanup,清理
本练习创建的资源。
1
| [student@workstation ~]$ lab computeresources-launch cleanup
|
操作界面、表格与配置图
本引导练习到此结束。
操作界面、表格与配置图
引导练习:将实例部署到超融合计算节点#
引导练习#
将实例部署到超融合计算节点#
本练习创建主机聚合和规格,使特定实例必须部署到 HCI 节点。
学习目标#
能够利用主机聚合和元数据创建控制实例放置的规格,并观察 nova_scheduler 日志。
开始之前#
以 student 用户登录 workstation,密码为 student。
运行 lab computeresources-hci setup 命令。此脚本确保 OpenStack 服务正在运行,环境为导引练习配置得当。
1
| [student@workstation ~]$ lab computeresources-hci setup
|
以 architect1 创建 hci-aggregate 主机聚合,将 computehci0 加入其中。
在 workstation 加载 /home/student/architect1-finance-rc,以管理员权限访问 OpenStack。
1
| [student@workstation ~]$ source architect1-finance-rc
|
使用 openstack aggregate create 创建名为 hci-aggregate 的主机聚合。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~(architect1-finance)]$ openstack aggregate create \
hci-aggregate
Se eeee
| Field | Value |
Beene TeNee Nee oeNaoceCe nee e TeeNao TenCe eee ts
| availability_zone | None |
| created_at | 2018-10-16T08: 21:28.625185 |
| deleted | False |
| deleted_at | None |
| id | 4 |
| name | hei-aggregate |
| updated_at | None |
Se ee ee er
|
执行 openstack aggregate add host,将 computehci0 加入 hci-aggregate。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(architect1-finance)]$ openstack aggregate add host \
hci-aggregate computehci0.overcloud.example.com
| |availability_zone | None
| created_at | 2018-10-16T08: 21: 28. 000000 |
| deleted | False |
| deleted_at | None |
| hosts | [u'computehci0.overcloud.example.com'] |
| id Heal |
| name | hci-aggregate |
| updated_at | None |
tenes cee Heese eerste seers reese cee +
|
设置 hci-aggregate 的元数据。
执行 openstack aggregate set,设置 hci-aggregate 的元数据。
1
2
| [student@workstation ~(architect1-finance)]$ openstack aggregate set \
--property computehci=true hci-aggregate
|
执行 openstack aggregate show,查看 hci-aggregate 详情。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(architect1-finance)]$ openstack aggregate show \
hci-aggregate
San ee ra
| Field | Value |
ee ee ee ee ee a a a ne
| availability_zone | None |
| created_at | 2018-10-16T08:21: 28. 990000 |
| deleted | False |
| deleted_at | None |
| hosts | [u'computehci0.overcloud.example.com'] |
| id | 4 |
| name | hci-aggregate |
| properties | computehci='true' |
| updated_at | None |
ee ee ee ee re
|
创建新规格并配置 computehci 属性。
执行 openstack flavor create,创建 default-hci 规格,配置 1024 MB 内存、10 GB 磁盘,
以及两个 vCPU,并将规格设为公开。
1
2
| [student@workstation ~(architect1-finance)]$ openstack flavor create \
--ram 1024 --disk 10 --vcpus 2 --public default-hci
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| | OS-FLV-DISABLED: disabled | False |
| OS-FLV-EXT-DATA: ephemeral | 0 |
| disk | 10 |
| id | d159f88a-ccab-4dca-8a91-de16e416792b |
| name | default-hei |
| os-flavor-access:is_public | True |
| properties | |
| ram | 1024 |
| rxtx_factor | 1.9 |
| swap | |
| vepus | 2 |
SOOM OSS eee tee ie eee oe aC oe ee Ie
|
使用 openstack flavor set 命令配置 default-hci 规格以使用 computehci 属性。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [student@workstation ~(architect1-finance)]$ openstack flavor set \
default-hci --property computehci=true
[student@workstation ~(architect1-finance)]$ openstack flavor show default-hci
2 eee eNotes Oct Oeta Oca einen Meta Oe ocia Se i Oe a Oot oei cr Oeiaoers ocmeoerecens
| Field | Value |
SP Fe em ee Ft et Vee Ft eV cet et Vm et Feet of
| OS-FLV-DISABLED: disabled | False |
| OS-FLV-EXT-DATA: ephemeral | 0 |
| access_project_ids | None |
| disk | 10 |
| id | di59f88a-ccab-4dca-8a91-de16e416792b |
| name | default-hci |
| os-flavor-access:is_public | True |
| properties | computehci='true' |
| ram | 1024 |
| rxtx_factor | 1.9 |
| swap | |
| vcpus | 2 |
SNne care rt
|
使用 openstack image list 命令确保 hci-image 镜像存在。使用 openstack image show 命令确认镜像大小。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(architect1-finance)]$ openstack image list
a at a) aT a YS a en a at ene Sees ae
| ID | Name | Status |
Bee eT ea ee ote eta Seineta ote ha neicera eta oein cha Seen renereoeien tr
| eObaic8f -0aa2 -4599-a487-abo6974b4cb7 | hci-image | active |
... output omitted...
[student@workstation ~(architect1-finance)]$ openstack image show \
hci-image --max-width=se
Pewee rp
| Field | Value |
ee
| checksum | cbe377ed77279c4a136e05e713db3a50 |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| | container_format | bare |
| created_at | 2018-10-16T08:06:51Z |
| disk_format | qcow2 |
| file | /v2/images/e0baicsf -Oaa2 -4599-a487 -a506974b4cb7/ file |
| id | eObaicsf -9aa2-4599-a487 -ab06974b4cb7 |
| min_disk | 10 |
| min_ram | 1024 |
| name | hci-image
| owner | 3bc7526a7d44471d8cad16a7 3e2d5871 |
| properties | direct_url='rbd://945a02d4-c931-11e8-b4cd- |
| | 52540001fac8/images/eObaicéf - |
| | Oaa2-4599 -a487-a506974b4cb7/snap', locations='[{u'url': |
| | u'rbd: //945a02d4-Cc931-11e8-b4cd-52540001fac8/images |
| | /eObaicéf -Oaa2-4599-a487 -a506974b4cb7/snap', u'metadata':
| protected | True
| schema | /v2/schemas/image
| size | 1621950464 |
| status | active
| tags | |
| updated_at | 2018-10-16T08:07:102Z
| virtual_size | None |
| visibility | public
Ss ae a cP NS a lO a a i oa i es a ees cd
|
在 workstation 上打开新终端。从 workstation 登录到 controller0 节点。在 controller0 上配置 nova 进行调试。重新启动容器并检查 nova_scheduler 日志文件。
在 workstation 的新终端中,以 heat-admin 用户登录 controller0。
1
2
3
4
| [student@workstation ~]$ ssh heat-admin@controller0
Warning: Permanently added 'controller@®,172.25.250.1' (ECDSA) to the list of known
hosts.
[heat-admin@controller0 ~]$
|
执行 sudo -i 获得 root 权限,编辑 nova.conf 将 debug 设为 true。重启 nova_scheduler 和 nova_api,等待 45 秒,再用 docker ps 确认容器运行且健康。
1
2
3
4
5
6
7
8
9
10
11
| [heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]# crudini --set \
/var/1lib/config-data/puppet-generated/nova/etc/nova/nova.conf \
DEFAULT debug True
[root@controller0 ~]# docker restart nova_api
nova_api
[root@controller0 ~]# docker restart nova_scheduler
nova_scheduler
[heat-admin@controller0 ~]$ docker ps \
--format="{{.Names}}\t{{.Status}}" | grep nova
...output omitted...
|
操作界面、表格与配置图
1
2
3
| nova_api Up About 31 seconds (healthy)
nova_scheduler Up About 46 seconds (healthy)
.. Output omitted...
|
使用 default-hci 规格创建实例,确认它部署在 computehci0,并检查 nova-scheduler.log。
在最初的 workstation 终端中,使用 openstack server create 命令创建一个名为 hci-server1 的新实例。使用 default-hci 规格、 hci-image 镜像和 finance-network1 网络。
1
2
3
4
5
| [student@workstation ~(architect1-finance)]$ openstack server create \
--flavor default-hci \
--image hci-image \
--nic net-id=finance-network1 \
--wait hci-server1
|
创建 hci-server1 时返回 controller0,对 nova-scheduler.log 执行 tail -f,将输出重定向到 hci.txt。
1
2
| [root@controller0 nova]# tail -f \
/var/log/container s/nova/nova-scheduler .log > hci.txt
|
在 workstation 确认 hci-server1 部署在 computehci0,记录实例 UUID,与 hci.txt 中的调试记录比较。
1
2
| [student@workstation ~(architect1-finance)]$ openstack server show \
hei-server1 --max-width=80
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| +
| | |OS-DCF: diskConfig MANUAL
| | |OS-EXT-AZ: availability_zone nova
| | |OS-EXT-SRV-ATTR: host compu tehcio. overcloud.example.com
| | |OS-EXT-SRV-ATTR: hypervisor_hostname computehcie.overcloud.example.com
| | |OS-EXT-SRV-ATTR: ins tance_name ins tance -99000002
| OS-EXT-STS: power_state | Running |
| OS-EXT-STS: task_state | None |
| OS-EXT-STS: vm_state | active
| OS-SRV-USG: launched_at | 2018-10-16T09: 06: 00. 990000 |
| OS-SRV-USG: terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | finance-network1=192 .168.1.5 |
| config_drive | |
| created | 2018-10-16T09: 05: 31Z
| flavor | default-hei (d159f88a-ccab-4dca- |
| | 8a91-de16e416792b) |
| hostId | 9bfo95a2180a28d194225768846ba007161890 |
| | 1cc37be32d9d44a1be |
| id | 9cc87d2c-efd3-45ae-940c-a3fescs9eace |
| image | hei-image (eObaicsf-
| | Oaa2-4599-a487 -a506974b4cb7 ) |
| key_name | None |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
| | name | hei-server1 |
| progress | 9
| project_id | 7adc3822ee5447 2b85b2d34cc835803 |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-10-16T09:06: O0Z |
| user_id | 62dc592686267444e8065dd49673d5cfe7868b |
| | 4735edffo2bea576d220c938fb |
| volumes_at tached |
|
在 controller0 用 view 打开 hci.txt,搜索 hci-server1 的 UUID,并记录请求 ID。相同请求 ID 的条目属于同一次请求。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| [root@controller0 nova]# view hci.txt
.. Output omitted...
2018-10-16 12:20:27.240 1 DEBUG nova.scheduler.filter_scheduler
[req-5406d5ea- 432a-46dc-9b19-042fa769esbo
62dc592686267444e8065dd496 73d5cfe7868b4735ed fFO2bead7 6d220c938fb
7adc3822ee5447 2b85b2d34cc83f5803 - 04c2c4feabbb4a839101a89ef9134e2c
default] Weighed [(computehci0. overcloud.example.com,
computehci®.overcloud.example.com) ram: 2047MB disk: 106496MB
io_ops: © instances: ©, (compute1.overcloud.example.com,
compute1.overcloud.example.com) ram: 2047MB disk: 108544MB io_ops: © instances:
©, (compute0.overcloud.example.com, compute0.overcloud.example.com) ram: 2047MB
disk: 108544MB io_ops: © instances: ©] _get_sorted_hosts /usr/lib/python2.7/site-
packages/nova/scheduler/filter_scheduler.py:424
2018-10-16 12:20:27.241 1 DEBUG nova.scheduler.utils
[req-5406d5ea-432a-46dc -9b19-042fa769es8bo
62dc592686267444e8065dd496 73d5cfe7868b4735ed f fO2beas7 6d220c938fb
7adc3822ee5447 2b85b2d34cc83f5803 - 04c2c4feabbb4a839101a89ef9134e2c
default] Attempting to claim resources in the placement API for
instance 9cc87d2c-efd3-45ae-940c-a3foesc59eace claim_resources /usr/lib/python2.7/
site-packages/nova/scheduler/utils.py:786
2018-10-16 12:20:27.283 1 DEBUG nova.scheduler.filter_scheduler
[req-5406d5ea-432a-46dc -9b19-042fa769esbo
62dC592686267444e8065dd496 73d5cfe7868b4735ed f fO2bead7 6d220c938Tb
7adc3822ee5447 2b85b2d34cc83f5803 - 04c2c4feabbb4a839101a89ef9134e2c
default] Selected host: (computehci@.overcloud.example.com,
computehci9.overcloud.example.com) ram: 2047MB disk: 106496MB io_ops: 0
instances: © _consume_selected_host /usr/lib/python2.7/site-packages/nova/
scheduler/filter_scheduler.py:325
2018-10-16 12:20:27.283 1 DEBUG oslo_concurrency.lockutils
[req -5406d5ea- 432a-46dc -9b19- 042 fa769es8be
62dc592686267444e8065dd496 73d5cfe7868b4735ed f FO2beah7 6d220C938 Fb
7adc3822ee54472b85b2d34cc83f5803 - 04c2c4feadbb4a839101a89ef9134e2c default] Lock
"Cu'computehci0. overcloud.example.com', u'computehci@.overcloud.example.com')"
acquired by "nova.scheduler.host_manager.locked" :: waited ©.000s inner /usr/
lib/python2. 7/site-packages/oslo_concurrency/lockutils.py:273
.. Output omitted...
|
操作界面、表格与配置图
在 workstation 上运行 lab computeresources-hci cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab computeresources-hci cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理计算节点#
引导练习#
管理计算节点#
在此练习中,迁移一个实例,禁用和启用计算节点,并疏散一个计算节点。
学习目标#
能够启用并禁用计算节点、 迁移实例和疏散整个计算节点。
开始之前#
以 student 用户登录 workstation,密码为 student。
运行 lab computeresources-migrate setup 命令。此脚本确保 OpenStack 服务正在运行,环境为导引练习配置得当。
1
| [student@workstation ~]$ lab computeresources-migrate setup
|
在 workstation 加载 /home/student/architect1-finance-rc,然后列出计算服务。
加载 /home/student/architect1-finance-rc。
1
2
| [student@workstation ~]$ source ~/architect1-finance-re
[student@workstation ~(architect1-finance)]$
|
1: 使用 openstack compute service list 命令列出每个服务节点的主机、 区和状态列。确保计算节点的状态为 enabled。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(architect1-finance)]$ openstack compute service list \
-c Host -c Zone -c Status
hree eee
| Host | Zone | Status
Seee ee ee
| controller0.overcloud.example.com | internal | enabled |
| controller0.overcloud.example.com | internal | enabled |
| controller0.overcloud.example.com | internal | enabled |
| computehci0.overcloud.example.com | nova | enabled |
| computed. overcloud.example.com | nova | enabled |
| compute1.overcloud.example.com | nova | enabled |
Finn etece er teeeee eet
|
执行 openstack server list,列出 compute0 和 compute1 上的实例。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~(architect1-finance)]$ openstack server list \
--host compute0.overcloud.example.com --all-projects \
-c ID -c Name
Sf tee eeeeee ee eeeee ee etee fe web ee eet ees at ene of
| ID | Name |
eae eee ee ee ee ee et
| €1060cd2-154b-48fc-930e-36ac92ad00ae | finance-server3 |
| d70a2397-77f3-4fa4-8af4-1404ac4f2bod | finance-server2 |
| a181bb99-e8b1 -4d74-8e46-37d46a7d5024 | finance-server1 |
Sf eee eeee ee eS eeeee ee eee fenhe eee ees te nee mf
[student@workstation ~(architect1-finance)]$ openstack server list \
--host computel.overcloud.example.com --all-projects \
-c ID -c Name
[student@workstation ~(architect1-finance)]$
|
注意,三个实例都运行在 compute0 上。
将 finance-server1 从 compute0 迁移到 compute1,并验证结果。
使用 openstack server migrate 命令迁移 finance-server1。在上一步骤的输出中可以看到 finance-server1 的 ID。
1
2
3
| [student@workstation ~(architect1-finance)]$ openstack server migrate \
a181bb99-e8b1-4d74-8e46-37d46a7d5024 \
--live computel.overcloud.example.com
|
执行 openstack server list,确认 finance-server1 现在运行在 compute1。迁移可能需要约一分钟,必要时重试。
需要。
1
2
3
4
5
6
7
8
| [student@workstation ~(architect1-finance)]$ openstack server list \
--host compute1.overcloud.example.com --all-projects \
-c ID -c Name
Rete tate these ace eh pm te ate thee neither ace tse ne else tee thse
| ID | Name |
ene
| al81bb99-e8b1-4d74-8e46-37d46a7d5024 | finance-server1 |
Fir we teee neeeeet
|
禁用 compute0 的 nova-compute,将剩余实例疏散到 compute1,并验证结果。最后重新启用 compute0 的 nova-
compute 服务。先执行 openstack compute service set,禁用 compute0 的 nova-compute。
1
| [student@workstation ~(architect1-finance)]$ openstack compute service set \
|
操作界面、表格与配置图
1
| compute0.overcloud.example.com nova-compute --disable
|
执行 openstack compute service list,确认 compute0 已禁用。
1
2
3
4
5
6
7
| [student@workstation ~(architect1-finance)]$ openstack compute service list \
-c Binary -c Host -c Status
... output omitted...
| nova-compute | computehci0. overcloud.example.com | enabled |
| nova-compute | compute0. overcloud.example.com | disabled |
| nova-compute | compute1. overcloud.example.com | enabled |
Seee a ee a a.
|
使用 nova host-evacuate-live 命令从 compute0 撤出其余服务器。
1
2
3
4
5
6
7
| [student@workstation ~(architect1-finance)]$ nova host-evacuate-live \
compute0
foe e ee ee i ee ee ee
| Server UUID | Live Migration Accepted | Error Message |
A. 2 IRAE RG ER meSe nanan seeneeresneac te meses meena Sit aos nesneereecdi
| d70a2397-77f3-4fa4-8af4-1404ac4f2bod | True | |
| €1060cd2-154b-48fc-930e-36ac92ado0ae | True | |
|
执行 openstack server list,确认实例已迁移到 compute1。迁移可能需要约一分钟,请重复执行
命令,直到所有服务器迁移。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(architect1-finance)]$ openstack server list \
--host compute1.overcloud.example.com --all-projects \
-c ID -c Name
SSee ee
| ID | Name |
fee ete eeeeetete tee eetee tees te tetera ete teeter tere free tater tetet tater tetera eresach
| €1060cd2-154b-48 fc-930e-36ac92ad00ae | Finance-server3 |
| d70a2397-77f3-4fa4-8af4-1404ac4f2bod | finance-server2 |
| al8ibb99-e8b1-4d74-8e46-37d46a7d5024 | finance-server1 |
|
执行 openstack compute service set,启用 compute0 的 nova-compute,再执行 openstack compute service list
命令来验证服务状态。
1
2
3
4
5
6
| [student@workstation ~(architect1-finance)]$ openstack compute service set \
compute0.overcloud.example.com nova-compute --enable
[student@workstation ~(architect1-finance)]$ openstack compute service list \
-c Host -c Status
.. Output omitted...
| computehci0.overcloud.example.com | enabled |
|
|
1
2
| | compute0.overcloud.example.com | enabled |
| compute1.overcloud.example.com | enabled |
|
操作界面、表格与配置图
在 workstation 上运行 lab computeresources-migrate cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab computeresources-migrate cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:管理计算资源#
管理计算资源#
操作检查清单#
本实验中,管理计算资源。
学习目标#
完成后,能够:
向 HCI 节点部署实例。
执行实例疏散(evacuation)。
执行块迁移(block migration)。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab computeresources-review setup 命令。此脚本创建了进行练习所需要的资源。
1
| [student@workstation ~]$ lab computeresources-review setup
|
一个计算节点当前已关机。找出该节点,将其上的实例疏散到其他节点,然后启动该计算节点。
以 architect1 创建 hci-aggregate,添加 computehci0 并设置聚合元数据。创建 default-hci 规格,配置 computehci 属性。使用该规格、hci-image 和 production-network1 启动 hci-server1,确认实例部署在 computehci0。
配置 nova 使用块存储,在 compute0 和 compute1 重启 nova_compute 并检查健康状态。以 architect1 在 compute0 使用 default 规格、rhel7 镜像和 production-network1 创建实例,再通过块迁移将其迁往 compute1。
在 workstation 上运行 lab computeresources-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab computeresources-review grade
|
在 workstation 上运行 lab computeresources-review cleanup,清理本练习创建的资源。
操作界面、表格与配置图
1
| [student@workstation ~]$ lab computeresources-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
管理计算资源#
操作检查清单#
本实验中,管理计算资源。
学习目标#
完成后,能够:
向 HCI 节点部署实例。
执行实例疏散(evacuation)。
执行块迁移(block migration)。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab computeresources-review setup 命令。此脚本创建了进行练习所需要的资源。
1
| [student@workstation ~]$ lab computeresources-review setup
|
一个计算节点当前已关机。找出该节点,将其上的实例疏散到其他节点,然后启动该计算节点。
从 workstation 以 stack 登录 director,执行 openstack baremetal node list,查找哪个
节点已断电。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ ssh stack@director
(undercloud) [stack@director ~]$ openstack baremetal node list \
-c Name -c "Power State"
| |controller0 | power on
| compute0 | power off |
| computehci0 | power on |
| compute1 | power on |
| ceph0 | power on |
cfs ey ete avert bao pce at ea oer a ar +
|
加载 /home/stack/overcloudrc,执行 openstack server list 列出已关机计算节点上的实例,再用 nova host-evacuate 疏散这些实例。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| (undercloud) [stack@director ~]$ source ~/overcloudrc
(overcloud) [stack@director ~]$ openstack server list \
--host compute0.overcloud.example.com --all-projects \
-c ID -c Name
ee See ee ee ee ee pe ee ee et
| ID | Name |
Eeea a ao
| 966bf13c-219c-45c6-9525-676befbdd50f | production-server3 |
| dog4a3d6 -95fa-4d75-a027-e04f1f37dc60 | production-server2 |
| 382f9Tf07 -dcb2-4b26-82f2-e38ae46de8a4 | production-server1 |
Be eeeSee eee
(overcloud) [stack@director ~]$ nova host-evacuate compute0e
Ee Ne en es ee eee ee eesSe ee
| Server UUID | Evacuate Accepted | Error Message |
fi en pe epee ee ee eee eet
| 382f9f07-dcb2-4b26-82f2-e38a046de8a4 | True | |
| de94a3d6-95fa-4d75-a027-eO4f1if37dc60 | True | |
| @66bf13c-219c-45c6-9525-676befbdd5of | True | |
|
确认实例已疏散到其他计算节点,过程可能需要一至两分钟。
1
2
3
4
5
6
7
8
9
10
11
12
| (overcloud) [stack@director ~]$ openstack server list \
--host compute0.overcloud.example.com --all-projects \
-c ID -c Name
(overcloud) [stack@director ~]$ openstack server list \
--host compute1.overcloud.example.com --all-projects \
-c ID -c Name -c Status
Pee eine ee eee MCMC eee CeCe eee CeCe ee eeeeee CeCe eCeeCe C+eck Cee
tb | Name | |
eee eth ee ch cee mF eh Fete eee Fete eh ce eee Pano cea
| O66bf13C-219c -45c6-9525-676befbdd50f | production-server3 | ACTIVE |
| do94a3d6-95fa-4d75-a027-e04f1f37dc60 | production-server2 | ACTIVE |
| 382f9f07-dcb2 -4b26-82f2-e38a046de8a4 | production-server1 | ACTIVE |
|
加载 /home/stack/stackrc,用 openstack baremetal node 启动计算节点,确认 compute0 裸机节点已开机。
1
2
3
4
5
6
7
8
9
10
| (overcloud) [stack@director ~]$ source ~/stackre
(undercloud) [stack@director ~]$ openstack baremetal node power on compute0
(undercloud) [stack@director ~]$ openstack baremetal node list \
-c Name -c "Power State"
Peeie
| Name | Power State |
Se aa
| controller0 | power on |
| compute0 | power on |
| computehci0 | power on |
|
操作界面、表格与配置图
1
2
| | compute | power on |
| ceph0 | power on |
|
在课堂等虚拟环境中,Undercloud 计算服务可能无法感知节点电源变化。因此使用 openstack baremetal 开机后,计算服务与裸机服务的状态可能不一致。执行 openstack server start 使两者一致,确保 compute0 可以接收实例调度。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| (undercloud) [stack@director ~]$ openstack server list -c Name -c Status
Se se
| Name | Status |
Bee eT Nae Tea eae TeTey
| compute1 | ACTIVE |
| computed | SHUTOFF |
| computehci0 | ACTIVE |
| controller0 | ACTIVE |
| ceph0 | ACTIVE |
SE
(undercloud) [stack@director ~]$ openstack server start computed
(undercloud) [stack@director ~]$ openstack server list -c Name -c Status
ee aera ee oe ce pp ee op
| Name | Status |
Se CG
| compute | ACTIVE |
| compute0 | ACTIVE |
| computehci0 | ACTIVE |
| controller0 | ACTIVE |
| ceph0 | ACTIVE |
Seehere here igre teretiarastere eteret
|
加载 /home/stack/overcloudrc,执行 openstack compute service list,确认 compute0 的 nova_compute 为 up,然后退出 director。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| (undercloud) [stack@director ~]$ source ~/overcloudrec
(overcloud) [stack@director ~]$ openstack compute service \
list -c Binary -c Host -c State
See a eneeee
| Binary | Host | State |
ees
| nova-conductor | controller0.overcloud.example.com | up |
| nova-compute | compute1. overcloud.example.com | up |
| nova-compute | computehci0.overcloud.example.com | up |
| nova-compute | computed. overcloud.example. com | up |
| nova-consoleauth | controller0.overcloud.example.com | up |
| nova-scheduler | controller0.overcloud.example.com | up |
SE aT a Ee ro a ae eee ao ete
(overcloud) [stack@director ~]$ exit
logout
Connection to director closed.
[student@workstation ~]$
|
操作界面、表格与配置图
2. 以 architect1 创建 hci-aggregate 主机聚合,将
computehci0 加入聚合并设置元数据。创建 default-hci 规格,配置
computehci 属性。使用 default-hci、hci-image 和 production-network1 启动 hci-server1,确认它部署在 computehci0。
在 workstation 加载 /home/student/architect1-production-rc,以管理员权限访问 OpenStack。
1
2
| [student@workstation ~]$ source ~/architect1-production-re
[student@workstation ~(architect1-production)]$
|
使用 openstack aggregate create 创建名为 hci-aggregate 的主机聚合。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~(architect1-production)]$ openstack aggregate create \
hci-aggregate
Stee ee ee ce cee ce oc Fee et ceo ee eee mr ceed
| Field | Value |
Tce Oe OS ee ee ee a ee CN EE
| availability_zone | None |
| created_at | 2018-11-19T15:07:51.605242 |
| deleted | False |
| deleted_at | None |
| id | 1 |
| name | hci-aggregate |
| updated_at | None |
Hos ono RS BSR Re See athens 22S RPS RRs 2S ee eee eseese st
|
执行 openstack aggregate add host,将 computehci0 加入 hci-aggregate。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(architect1-production)]$ openstack aggregate add host \
hci-aggregate computehciO.overcloud.example.com
| |availability_zone | None
| | |created_at 2018-11-19T15: 07:51. E2000
| deleted | False |
| deleted_at | None |
| hosts | [u'computehci0.overcloud.example.com'] |
| id Ja |
| metadata | {} |
| name | hci-aggregate |
| updated_at | None |
Fenn n eee e ee eee eee ee fee nnn ee ee een ee ee eee eee eee eee +:
|
执行 openstack aggregate set,设置 hci-aggregate 的元数据。
1
| [student@workstation ~(architect1-production)]$ openstack aggregate set \
|
操作界面、表格与配置图
1
| --property computehci=true hci-aggregate
|
执行 openstack aggregate show,查看 hci-aggregate 详情。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(architect1-production)]$ openstack aggregate show \
hci-aggregate
eaene re ne ee eee nd
| Field | Value |
Pe er er ereeFe aeFe eee FF Veer er eee eer eer ee
| availability_zone | None |
| created_at | 2018-11-19T15:07:51. 900000 |
| deleted | False |
| deleted_at | None |
| hosts | [u'computehci9.,overcloud.example.com'] |
| id | 2 |
| name | hci-aggregate |
| properties | computehci='true' |
| updated_at | None |
Beene Te NICS Nao Manea eseNate TeeNano NeneTneMae CeMato NeneNeMee TeNatae
|
使用 openstack flavor create 命令创建一种叫做 default-hci 的新规格。配置规格以使用 RAM 的 1024 MB, 拥有 10 GB 盘,并拥有两个 vCPU。配置规格以公开。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~(architect1-production)]$ openstack flavor create \
--ram 1024 --disk 10 --vcpus 2 --public default-hci
pe erm irenesere niece eter rere erere hiere ete eter sie nie ies siete eee es eie see eeh
| Field | Value |
Spe enter eeeer etree ee ees Nantes eeamen aretee ene Nantel seeNeer matetel ee aea Nantes ee eseer aed eatera Nervesester de
| OS-FLV-DISABLED: disabled | False |
| OS-FLV-EXT-DATA: ephemeral | 0 |
| disk | 10 |
| id | 47919950-d803-4da4-8a9cC-857144498bb7 |
| name | default-hei |
| os-flavor-access:is_public | True |
| properties |
| ram | 1024 |
| rxtx_factor | 1.9 |
| swap | |
| vepus | 2 |
SOC ieieee ie ioe ie See te CC Oo oe ee ee
|
使用 openstack flavor set 命令配置 default-hci 规格以使用 computehci 属性。
1
2
3
4
5
6
7
8
| [student@workstation ~(architect1-production)]$ openstack flavor set \
default-hci --property computehci=true
[student@workstation ~(architect1-production)]$ openstack flavor show default-hci
2 ele eT ea eT Oets ot Oe Ocracine Moet erecta Ooi Oct Oeiaoc rere ocmoeracens
| Field | Value |
Se ee ee ee ee ee
| OS-FLV-DISABLED: disabled | False |
| OS-FLV-EXT-DATA: ephemeral | © |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| | access_project_ids | None |
| disk | 10 |
| id | 47919950-d803-4da4-8a9c-857144498bb7 |
| name | default-hci |
| os-flavor-access:is_public | True |
| properties | computehci='true' |
| ram | 1024 |
| rxtx_factor | 1.9 |
| swap | |
| vcpus | 2 |
Finn en nn nn nn nn np nn nn nn en nn ne ee ee nt
|
使用 default-hci 规格创建实例,确认其部署在 computehci0。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~(architect1-production)]$ openstack server create \
--flavor default-hci \
--image hci-image \
--nic net-id=production-network1 \
--wait hci-server1
Finn te ee ee eet
| Field | Value |
{HS
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ: availability_zone | nova |
| OS-EXT-SRV-ATTR:host | computehci0.overcloud.example.com |
| OS-EXT-SRV-ATTR: hypervisor_hostname | computehci0.overcloud.example.com |
| OS-EXT-SRV-ATTR:ins tance_name | instance -99ee000d |
.. output omitted...
|
配置 nova 使用块存储,在 compute0 和 compute1 重启 nova_compute 并确认健康状态。以 architect1 使用 default 规格、rhel7 镜像及 production-network1 在 compute0 创建实例,通过块迁移将其迁移到 compute1。
在 compute0 和 compute1 配置 nova 使用块存储,执行 sudo -i 切换为 root。在 /var/lib/config-data/
puppet-generated/nova_libvirt/etc/nova/nova.conf 中注释 images_type=rbd。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(architect1-production)]$ ssh compute0
[heat-admin@compute0 ~]$ sudo -i
[root@compute0 ~]# vim \
/var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf
#images_type=rbd
[root@compute@ ~]# docker restart nova_compute
nova_compute
[root@compute0 ~]# docker ps --format="{{.Names}}\t{{.Status}}" \
| grep nova_compute
|
操作界面、表格与配置图
1
2
3
4
5
6
| nova_compute Up 55 seconds (healthy)
[root@compute0 ~]# exit
[heat-admin@compute0 ~]$ exit
logout
Connection to compute0® closed.
[student@workstation ~(architect1-production)]$
|
在 compute1 重复上述步骤。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~(architect1-production)]]$ ssh compute1
warning: Permanently added 'compute1,172.25.250.12' (ECDSA) to the list of known
hosts.
[heat-admin@compute1 ~]$ sudo -i
[root@compute1 ~]# vim \
/var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf
#images_type=rbd
[root@compute1 ~]# docker restart nova_compute
nova_compute
[root@compute1 ~]# docker ps --format="{{.Names}}\t{{.Status}}" \
| grep nova_compute
nova_compute Up 55 seconds (healthy)
[root@compute1 ~]# exit
[heat-admin@compute1 ~]$ exit
logout
Connection to compute1 closed.
[student@workstation ~(architect1-production)]$
|
在 compute1 创建 production-server10,使用 default 规格、rhel7 镜像和 production-network1。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~(architect1-production)]$ openstack server create \
--flavor default \
--image rhel7 \
--nic net-id=production-network1 \
--availability-zone nova:compute1.overcloud.example.com \
--wait production-server1o0
fone enone ee ee ee ef ee et
| Field | Value |
See ee. ee ee 2
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ: availability_zone | nova |
| OS-EXT-SRV-ATTR:host | compute1.overcloud.example.com |
| OS-EXT-SRV-ATTR: hypervisor_hostname | computel.overcloud.example.com |
|
操作界面、表格与配置图
使用 openstack server migrate 命令将 production-server10 迁移到 compute0。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~(architect1-production)]$ openstack server migrate \
--live compute@.overcloud.example.com \
--block-migration production-server10
[student@workstation ~(architect1-production)]$ openstack server show \
production-server10
ee nn niin 2
| Field | Value |
Fe ee ee ee ae ae ae ae ee ee ere
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ: availability_zone | nova |
| OS-EXT-SRV-ATTR:host | compute0.overcloud.example.com |
| OS-EXT-SRV-ATTR: hypervisor_hostname | compute0.overcloud.example.com |
.. output omitted...
|
在 workstation 上运行 lab computeresources-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab computeresources-review grade
|
在 workstation 上运行 lab computeresources-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab computeresources-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 禁用计算节点调度是否会自动迁走已有实例?
- 迁移命令返回成功之后还需做什么?
自测答案#
- 否,控制新调度与处理已有实例是不同动作。应分别处理新工作负载调度和已运行实例的维护。
- 检查目标主机位置、实例状态及业务可用性。管理操作完成后仍需要验证实际位置和业务结果。
C8-自动化云应用#
Stack 与资源依赖#
Heat Stack 将多个资源作为一个部署单元管理。模板描述所需资源及其关系,参数提供部署时可变的输入,输出向使用者暴露结果。资源之间的引用可以表达依赖,避免依靠人工记住创建顺序。
| 模板部分 | 回答的问题 | 检查重点 |
|---|
| 版本声明 | 按哪种模板语法解释? | 是否符合本版本 Heat 支持范围 |
| parameters | 哪些值由部署者提供? | 类型、默认值、约束与敏感信息 |
| resources | 需要创建什么? | 资源类型、属性、引用和依赖 |
| outputs | 部署后需要取得什么? | 是否引用正确资源与属性 |
从语法正确到应用可用#
模板能被解析,只说明格式基本符合要求。部署还可能因配额不足、资源名称错误、权限、镜像或网络问题失败。应查看 Stack 事件和具体失败资源,再验证实例内的初始化和应用服务。
编写与修改模板#
先创建最小可验证的资源组合,再逐步加入依赖和输出。YAML 缩进、资源逻辑名称以及属性引用必须保持一致。修改前保存模板版本,并理解更新可能对现有资源产生什么影响。
完成标准#
完成一次创建、查看事件、读取输出和验证应用的流程。记录 Stack 名称、输入参数与最终访问结果;清理时从 Stack 的资源关系出发,确认依赖资源是否按预期删除。不能只删除看得见的实例而忽略编排管理的其他资源。
用资源引用表达依赖#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| heat_template_version: 2016-10-14
parameters:
image:
type: string
flavor:
type: string
network:
type: string
resources:
data:
type: OS::Cinder::Volume
properties:
size: 1
server:
type: OS::Nova::Server
properties:
image: {get_param: image}
flavor: {get_param: flavor}
networks:
- network: {get_param: network}
attachment:
type: OS::Cinder::VolumeAttachment
properties:
instance_uuid: {get_resource: server}
volume_id: {get_resource: data}
outputs:
instance_id:
value: {get_resource: server}
volume_id:
value: {get_resource: data}
|
Attachment 引用 Server 和 Volume,Heat 据此知道先创建这两个资源。这个示例只完成附加,不自动在客户机中格式化或挂载。
模板管理流程#
保存为 app.yaml,env.yaml 的 parameters 填写已有 image / flavor / network。
1
2
3
4
5
6
| openstack orchestration template validate -t app.yaml -e env.yaml
openstack stack create -t app.yaml -e env.yaml demo-app
openstack stack event list demo-app
openstack stack resource list demo-app
openstack stack output show demo-app instance_id
openstack stack update -t app.yaml -e env.yaml demo-app
|
模板更新前先比较变更:某些属性修改会替换资源,不能默认所有更新都是原地修改。模板校验不验证实际配额、全部后端条件或应用可用性。
user-data、依赖与应用就绪#
Heat 资源的创建依赖,不自动等价于应用服务的就绪依赖。Web 实例被创建时,数据库服务可能尚未完成初始化;需要适当的重试或模板等待机制,不能只依赖创建顺序。
数据库与持久卷实验#
确认新盘或已有文件系统 → 挂载到应用要求目录 → 配置属主和 SELinux 上下文 → 启动数据库 → 导入数据 → 执行实际查询。若目录在挂载前已有数据,挂载会遮住原目录内容,应核对迁移步骤。
清理与数据保留#
默认由 Stack 管理的卷可能随删除一起释放;需要保留时在模板中明确 deletion_policy: Retain 并规划后续管理。保留策略不等于备份,清理前仍应核对数据要求。
实验操作#
引导练习:编写 Heat 编排模板#
引导练习#
编写 Heat 编排模板#
本练习编辑编排模板,启动多层应用栈。
学习目标#
完成后,能够:
编辑编排模板以启动多层应用栈。
使用编排模板启动应用栈。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab orchestration-heat-templates setup。脚本确保 OpenStack 服务正常运行、实验环境已配置,并准备启动应用栈所需的资源,将所需脚本下载到 /home/student/heat-templates 目录。
1
| [student@workstation ~]$ lab orchestration-heat-templates setup
|
编辑 YAML 文件时,必须使用空格缩进,不能使用制表符。如果使用 vi,请配置 .vimrc 启用自动缩进,并将 YAML 文件的 ts 和 sw 设为两个空格。编辑 /home/student/.vimrc,内容如下:
1
| autocmd FileType yaml setlocal ai ts=2 sw=2 et
|
下载 http://materials.example.com/heat/finance-app1.yaml 到 /home/student/heat-templates,编辑模板以启动定制实例。
编排模板必须包含以下内容:
finance-web 实例必须部署与 MariaDB 数据库交互的 PHP 网页。运行 webserver.sh 作为 user-data 脚本,在 finance-web 上部署 PHP 网页。
finance-db 实例必须配置 MariaDB 数据库。运行 dbserver.sh 作为 user-data 脚本,部署 MariaDB 并创建名为 mydb 的数据库。
使用 user_data 属性向 webserver.sh 脚本传递以下参数:
操作界面、表格与配置图
将 $web_public_ip 和 $web_private_ip 分别初始化为 finance-web 的外部与私有 IP,将 $db_private_ip 初始化为 finance-db 的私有 IP。这些变量供 webserver.sh 使用。
编排栈必须允许重试一次 user-data 脚本;脚本成功执行后必须返回成功。webserver.sh 的超时设为 600 秒,dbserver.sh 的超时设为 800 秒,超过对应时间后脚本必须返回失败。
切换到 /home/student/heat-templates,将 http://materials.example.com/heat/finance-app1.yaml 下载到该目录。
1
2
3
| [student@workstation ~]$ cd ~/heat-templates
[student@workstation heat-templates]$ wget \
http://mater ials.example.com/heat/finance-app1.yaml
|
使用 user_data 指定 /home/student/heat-templates/webserver.sh,在 finance-web 部署 PHP 网页。将 OS::Nova::Server 的 user_data_format 设为 RAW。
编辑 /home/student/heat-templates/finance-app1.yaml,添加下面突出显示的内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
| web_server:
type: OS: : Nova::Server
properties:
name: { get_param: web_instance_name }
image: { get_param: web_image_name }
flavor: { get_param: instance_flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: web_net_port }
user_data_format: RAW
user_data:
str_replace:
template: { get_file: /home/student/heat-templates/webserver.sh }
|
网页使用作为参数传入的 $web_private_ip、$db_private_ip 和 $web_public_ip 变量。这些参数通过 str_replace 内置函数的 params 属性定义。
$web_private_ip 使用 web_net_port 的 fixed_ips 获取 web_server 的第一个 IP;$db_private_ip 使用 db_net_port 的 fixed_ips 获取 db_server 的第一个 IP;$web_public_ip 使用 web_floating_ip 的 floating_ip_address,设置与
web_server 关联的公共 IP。编辑 /home/student/heat-templates/finance-app1.yaml,添加下面突出显示的内容:
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| type: OS: :Nova::Server
properties:
name: { get_param: instance_name }
image: { get_param: image_name }
flavor: { get_param: instance_flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: web_net_port }
user_data_format: RAW
user_data:
str_replace:
template: { get_file: /home/student/heat-templates/webserver.sh }
params:
$web_private_ip: {get_attr: [web_net_port, fixed_ips,0, ip_address]}
$db_private_ip: {get_attr: [db_net_port,fixed_ips,0,ip_address]}
$web_public_ip: {get_attr: [web_floating_ip, floating_ip_address]}
|
2.4.
使用等待条件句柄资源,发送 user-data 脚本执行状态的信号。
使用 web_wait_handle 的 curl_cli 属性,将等待句柄 URL 赋给 $wc_notify。若脚本部署的网页可访问(HTTP 200),通过 $wc_notify 返回 SUCCESS 状态。
当 WaitConditionHandle 发出 SUCCESS 信号时,web_server 状态标记为 CREATE_COMPLETE。
若网页无法访问或超过 600 秒,WaitConditionHandle 返回 FAILURE,web_server 状态标记为 CREATE_FAILED。
编辑 /home/student/heat-templates/finance-app1.yaml,添加下面突出显示的内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| web_server:
type: OS: : Nova::Server
properties:
name: { get_param: instance_name }
image: { get_param: image_name }
flavor: { get_param: instance_flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: web_net_port }
user_data_format: RAW
user_data:
str_replace:
template: { get_file: /home/student/heat-templates/webserver.sh }
params:
$web_private_ip: {get_attr: [web_net_port, fixed_ips,9,ip_address]}
$db_private_ip: {get_attr: [db_net_port, fixed_ips,0,ip_address]}
$web_public_ip: {get_attr: [web_floating_ip, floating_ip_address ]}
$wc_notify: {get_attr: [web_wait_handle,curl_cli]}
|
2:5.
使用 user_data 指定 /home/student/heat-templates/dbserver.sh,在 finance-db 配置 MariaDB。
操作界面、表格与配置图
将 OS::Nova::Server 的 user_data_format 属性设为 RAW。
使用等待条件句柄资源发送 user-data 执行状态信号。通过 db_wait_handle 的 curl_cli 属性,将等待句柄 URL 赋给 $wc_notify。
编辑 /home/student/heat-templates/finance-app1.yaml,添加下面突出显示的内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| db_server:
type: OS: : Nova: :Server
properties:
name: { get_param: db_instance_name }
image: { get_param: db_image_name }
flavor: { get_param: instance_flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: web_net_port }
user_data_format: RAW
user_data:
str_replace:
template: { get_file: /home/student/heat-templates/dbserver.sh }
params:
$db_wc_notify: {get_attr: [db_wait_handle, curl_cli]}
|
保存并退出文件。
创建环境文件 /home/student/heat-templates/environment.yaml,
填写 /home/student/heat-templates/finance-app1.yaml 中定义的全部输入参数值。
创建 /home/student/heat-templates/environment.yaml,写入以下内容:
1
2
3
4
5
6
7
8
9
10
| parameters:
web_image_name: rhel7-web
db_image_name: rhel7-db
web_instance_name: finance-web
db_instance_name: finance-db
instance_flavor: default
key_name: example-keypair
public_net: provider -datacentre
private_net: finance-network1
private_subnet: finance-subnet1
|
操作界面、表格与配置图
以 developer1 凭据启动应用栈,并访问实例部署的网页进行验证。
使用 developer1 用户凭据执行 dry-run stack 部署并检查启动 stack 时将产生的资源。在进入下一步之前纠正所有错误。
使用 finance-app1.yaml 模板和 environment.yaml 环境文件创建 finance-app1 应用栈。
注意:在试运行应用栈部署前,将 http://materials.example.com/heat/finance-app1.yaml-final 下载到 /home/student/heat-templates。使用 diff 将 finance-app1.yaml 与已验证的 finance-app1.yaml-final 模板比较。修正发现的差异,然后继续启动应用栈。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation heat-templates]$ wget \
http://materials.example.com/heat/finance-app1.yaml-final
[student@workstation heat-templates]$ diff finance-app1.yaml \
finance-app1.yaml-final
[student@workstation heat-templates]$ source ~/developer1-finance-rc
[student@workstation heat-templates(developer1-finance)]$ openstack stack \
create \
--environment environment.yaml \
--template finance-app1.yaml \
--dry-run -c description \
finance-app1
Bea a a a
| Field | Value |
Sf eee ee ce Pee ee ee See Se ee cf
| description | multi-tier stack template |
eeeee ee ee
|
使用 finance-app1.yaml 模板和 environment.yaml 环境文件启动 finance-app1 应用栈。
试运行成功后,执行 openstack stack create 正式启动应用栈,此时不要使用 –dry-run。
1
2
3
4
5
6
7
| [student@workstation heat-templates(developer1-finance)]$ openstack stack \
create \
--environment environment.yaml \
--template finance-app1.yaml \
--wait \
finance-app1
.. output omitted...
|
列出 finance-app1 stack 返回的输出。
1
2
| [student@workstation heat-templates(developer1-finance)]$ openstack stack \
output list finance-app1
|
操作界面、表格与配置图
1
2
3
4
5
6
7
| , es fire ee ee eee +
| output_key | description |
web_private_ip Private IP address of the web server
web_public_ip External IP address of the web server
website_url This URL is the "external" URL that can be used
to access the web server.
Private IP address of the DB server
|
检查应用栈的 website_url 输出,output_value 中的 IP 地址可能不同。
1
2
3
4
| [student@workstation heat-templates(developer1-finance)]$ openstack stack \
output show finance-app1 website_url
| description This URL is the "external" URL that can be
used to access the web server.
|
|
1
2
3
4
| | | used to access the web server.
| |
| output_key | website_url
| output_value | http://172.25.250.107/index.php
|
访问 website_url 返回的 URL,验证多层应用栈已创建,并且两个实例的 user-data 脚本都已成功执行。
在 workstation 上运行 lab orchestration-heat-templates cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab orchestration-heat-templates cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:自动化云应用#
自动化云应用#
操作检查清单#
本练习中,编辑编排模板,启动配置相同的定制 Web 服务器。
学习目标#
完成后,能够:
编辑编排模板,启动多个定制 Web 服务器。
使用 OS::Heat::ResourceGroup 资源类型创建相同的资源。
使用编排模板启动应用栈。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab orchestration-review setup。脚本将编排模板和环境文件下载到 /home/student/heat-templates 目录。
1
| [studentworkstation ~]$ lab orchestration-review setup
|
编辑 /home/student/heat-templates/production-stack.yaml,在 parameters 中新增 instance_count 参数,设置约束为至少一个、最多两个实例。
编辑 /home/student/heat-templates/production-stack.yaml,新增 production_resource,使用 OS::Heat::ResourceGroup 根据用户输入启动相同资源。
编辑 /home/student/heat-templates/production-environment.yaml,将 instance_count 设为 2。
编辑 /home/student/heat-templates/production-environment.yaml,定义自定义资源类型 Production::Custom::WebServer,指向 /home/student/heat-templates/production-app1.yaml。
编辑 /home/student/heat-templates/production-stack.yaml,将 production_resource 的资源定义设为 Production::Custom::WebServer,并设置启动该资源所需的属性。
使用 list_join 和 OS::Heat::ResourceGroup 的 index_var 默认值 %index%,将资源组索引作为后缀拼接到实例名称。将 instance_name 设为拼接结果,使实例分别命名为 production-server0 和 production-server1。
操作界面、表格与配置图
加载 /home/student/operator1-production-rc,以 operator1 使用 production-stack.yaml 和 production-environment.yaml 启动 production-webstack。
确认 production-webstack 创建了两个实例。使用其 instance_ipaddress 输出参数获取实例的私有 IP 地址。
在 workstation 上运行 lab orchestration-review grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
1
| [student@workstation ~] lab orchestration-review grade
|
在 workstation 上运行 lab orchestration-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~] lab orchestration-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
自动化云应用#
操作检查清单#
本练习中,编辑编排模板,启动配置相同的定制 Web 服务器。
学习目标#
完成后,能够:
编辑编排模板,启动多个定制 Web 服务器。
使用 OS::Heat::ResourceGroup 资源类型创建相同的资源。
使用编排模板启动应用栈。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab orchestration-review setup。脚本将编排模板和环境文件下载到 /home/student/heat-templates 目录。
1
| [studentworkstation ~]$ lab orchestration-review setup
|
编辑 /home/student/heat-templates/production-stack.yaml,在 parameters 中新增 instance_count,约束为至少一个、最多两个实例。
使用 range 约束将实例数量限制为 1–2。
1
2
3
4
5
6
7
| parameters:
..-output omitted...
instance_count:
type: number
description: count of servers to be provisioned
constraints:
- range: { min: 1, max: 2 }
|
编辑 /home/student/heat-templates/production-stack.yaml,新增 production_resource,使用 OS::Heat::ResourceGroup 根据用户输入启动相同资源。
将 count 属性设为使用 instance_count 输入参数。
1
2
| .. Output omitted...
resources:
|
操作界面、表格与配置图
1
2
3
4
5
| production_resource:
type: 0S: :Heat: :ResourceGroup
properties:
count: { get_param: instance_count }
... Output omitted...
|
保存并退出文件。
编辑 /home/student/heat-templates/production-environment.yaml,将 instance_count 设为 2。
1
2
3
4
5
6
7
8
9
| parameters:
key_name: "example-keypair"
image_name: "rhel7-web"
instance_name: "production-server"
instance_flavor: "default"
public_net: "provider-datacentre"
private_net: "production-network1i"
private_subnet: "production-subnet1i"
instance_count: 2
|
编辑 /home/student/heat-templates/production-environment.yaml,定义 Production::Custom::WebServer,指向 /home/student/heat-templates/production-app1.yaml。
1
2
3
4
5
6
7
8
9
10
11
| resource_registry:
Production: :Custom: :webServer: /home/student/heat-templates/product ion-app1.yaml
parameters:
key_name: "example-keypair"
image_name: "rhel7-web"
instance_name: "production-server"
instance_flavor: "default"
public_net: "provider-datacentre"
private_net: "production-network1i"
private_subnet: "production-subneti"
instance_count: 2
|
保存并退出文件。
编辑 /home/student/heat-templates/production-stack.yaml,将 production_resource 的资源定义设为
Production::Custom::WebServer,并设置启动自定义资源所需的属性。
使用 list_join 内置函数,以及 OS::Heat::ResourceGroup 的 index_var 属性默认值 %index%,将实例名称与资源组索引拼接,以索引作为后缀。将资源的 instance_name 属性设为拼接后的名称,分别命名为 production-server0 和 production-server1。
设定 production_resource 资源类型的 resource_def 属性
使用 Production::Custom::WebServer。该自定义资源类型接收配置实例所需的输入参数。编辑文件,添加下面突出显示的内容:
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| production_resource:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: instance_count }
resource_def:
type: Production: :Custom: :WwebServer
properties:
instance_name:
list_join: [ '', [ {get_param: instance_name}, "%index%" ] ]
instance_flavor: { get_param: instance_flavor }
image_name: { get_param: image_name }
key_name: { get_param: key_name }
public_net: { get_param: public_net }
private_net: { get_param: private_net }
private_subnet: { get_param: private_subnet }
|
保存并退出文件。
加载 /home/student/operator1-production-rc,以 operator1 使用 production-stack.yaml 模板和 production-environment.yaml 环境文件启动 production-webstack。
以 operator1 凭据试运行部署并检查将创建的资源。应用栈命名为 production-webstack,使用 production-stack.yaml 和 production-environment.yaml。修正所有错误后再继续。
试运行之前,将 http://materials.example.com/heat/production-stack.yaml-final 下载到 /home/student/heat-templates,用 diff 与 production-stack.yaml 比较,修正差异后再启动应用栈。
1
2
3
4
5
6
7
| [student@workstation ~]$ cd ~/heat-templates
[student@workstation heat-templates]$ source ~/operator1-production-rc
[student@workstation heat-templates(operatori1-production)]]$ openstack stack \
create --environment production-environment.yaml \
--template production-stack.yaml \
--dry-run production-webstack
..,output omitted...
|
试运行成功后执行 openstack stack create 正式启动应用栈,不要使用 –dry-run。
1
2
3
4
5
6
| [student@workstation heat-templates(operator1-production)]]$ openstack stack \
create --environment production-environment.yaml \
--template production-stack.yaml \
--wait production-webstack
... [production-webstack]: CREATE_IN_PROGRESS Stack CREATE started
... [production -webstack.production_resource]: CREATE_IN_PROGRESS state changed
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
| [production -webstack.production_resource]: CREATE_COMPLETE state changed
[production-webstack]: CREATE_COMPLETE Stack CREATE completed successfully
fewer e eee eee eee Pewee eee eee eee ee eee ee eee eee eee eee eee ee +
| eiteld | Value |
se em ae Tem a eam a ema en +
| |id 6964C8C2 -OacO-4f16 -902a- 801377 3bc2f4|
| |stack_name production-webs tack|
| |description Launch multiple custom webservers|
| creation_time 2018 -09-257T13:37:10Z ||
| |updated_time | None
| |stack_status | CREATE_COMPLETE
| stack_status_reason || Stack CREATE completed successfully
+
|
确认 production-webstack 创建了两个实例。使用其 instance_ipaddress 输出参数获取实例的私有 IP 地址。
查看编排创建的实例,实际 IP 地址可能不同。
1
2
3
4
5
6
7
| [student@workstation heat-templates(operator1-production)|]$ openstack server \
list -c Name -c Status -c Networks
Seeee eee
| Name | Status | Networks |
SR es earea
| production-server® | ACTIVE | production-network1=192.168.1.107 |
| production-server1 | ACTIVE | production-network1=192.168.1.108 |
|
使用 production-webstack 的 instance_ipaddress 输出参数获取已启动实例的私有 IP 地址。示例为 192.168.1.107 和 192.168.1.108,实际地址可能不同。
1
2
3
4
5
6
7
8
9
| [student@workstation heat-templates(operatori1-production)]$ openstack stack \
output show production-webstack instance_ipaddress
Speer eet eeeemt meere re ental ete eeeee eeNantes er ental arete eeeer ent eater ene eatetenreetep
| Field | Value |
Se pe Ye Yaa ee et ee ne ep
| description | private IP address of the webservers |
| output_key | instance_ipaddress |
| output_value | [u'192.168.1.107', u'192.168.1.108'] |
Spier eet reeemer etme tentaclesret meeee me ent ne ea eet etree eeeer eeNent ea oreene reteset
|
在 workstation 上运行 lab orchestration-review grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
1
| [student@workstation ~] lab orchestration-review grade
|
在 workstation 上运行 lab orchestration-review cleanup,清理本练习创建的资源。
操作界面、表格与配置图
1
| [student@workstation ~] lab orchestration-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- Heat 模板中的 outputs 通常用于什么?
- Stack 创建失败时应优先查看什么?
自测答案#
- 向使用者提供部署结果和资源属性。输出用于暴露部署结果,通常引用资源的属性。
- Stack 事件和具体失败资源。事件和失败资源帮助定位依赖、权限或配置问题。
C9-排查 OpenStack 运行故障#
先定义故障,再执行修复#
明确谁在什么环境执行了什么动作,预期是什么,实际得到什么。记录身份作用域、资源 UUID、时间和完整错误。一个笼统的“OpenStack 不通”往往混合了认证、API、内部通信、调度和实例网络等多个问题。
分层收集证据#
| 层次 | 优先检查 | 下一步方向 |
|---|
| 客户端与身份 | 凭据、端点、项目、权限 | 确认请求是否发往正确云与服务 |
| 服务入口 | 响应、API 日志、请求标识 | 判断请求是否被接受 |
| 内部依赖 | 消息代理、数据库、服务通信 | 寻找多个服务的共同故障点 |
| 资源执行 | 调度、端口、卷、计算进程 | 定位具体资源的失败阶段 |
| 实例与应用 | 客户机配置、初始化和监听端口 | 验证最终业务行为 |
使用日志时建立关联#
同一故障可能在多个组件中留下记录。按时间和资源标识对齐日志,再寻找首个有解释力的异常。最后一条报错可能只是上游失败的结果。容器化环境还要确认日志在宿主机的持久化位置,避免只在容器内部寻找。
最小修改与回归验证#
每次只修改与当前假设相关的配置,记录原值与新值。修复后首先重现原失败动作,再检查关联业务,最后确认环境没有留下临时放宽权限或绕过认证的设置。重启应有明确目的,并保留重启前的日志和状态。
实验笔记模板#
为每个故障记录:症状、假设、证据、排除项、变更、回归结果。无法证明的原因保持为假设。根因判断应能解释故障现象、日志证据与修复结果之间的关系。
排错顺序#
1
2
3
4
5
6
| 身份 / 云 / 项目是否正确?
→ API 是否收到请求?
→ 认证、数据库、消息队列是否可用?
→ scheduler 是否找到主机?
→ compute / network / storage 哪一步失败?
→ 客户机和应用是否就绪?
|
客户端证据#
1
2
3
4
5
| openstack server show <实例UUID>
openstack compute service list
openstack port list --server <实例UUID>
openstack volume list
openstack stack event list <Stack名称>
|
查看 server fault、task_state、所在宿主机和关联端口。管理员字段对普通用户可能不可见,不能把字段缺失直接认定为资源缺失。
宿主机与容器证据#
1
2
3
4
5
6
| sudo docker ps -a
sudo docker inspect nova_compute
sudo docker logs nova_compute
sudo tail -n 100 /var/log/containers/nova/nova-compute.log
sudo pcs status
sudo ss -lntp
|
对同一 request ID / UUID 在对应服务日志中搜索;先确认日志时间及时区。docker logs 没有内容时,继续查宿主机挂载的持久日志。
典型故障与验证#
| 现象 | 可能原因 | 修复后必须验证 |
|---|
| 多个 API 同时失败 | Keystone、数据库、VIP 或公共依赖 | 原请求及其他受影响服务 |
| No valid host | 容量、服务禁用、过滤条件、规格约束 | 实例实际落到预期节点 |
| BUILD 长时间不结束 | 消息消费、网络、镜像或存储任务停滞 | 后台任务与实例启动 |
| 卷停在 creating | cinder-scheduler / volume、消息或后端问题 | 新卷创建、附加与读写 |
| 容器反复退出 | 配置语法、文件权限、依赖失败 | healthcheck、日志与业务请求 |
| 实例无网络 | 端口绑定、OVS 映射、物理接口、ACL | 从同网段到外部逐段验证 |
配置文件权限案例#
nova-conductor 无法读取配置时,服务可能启动失败。先从日志确认权限错误,依据挂载关系定位宿主机文件,核对属主、模式与 SELinux 上下文,再修复对应的权限或配置项。不能对整个配置目录递归设置宽松权限来掩盖单个问题。
网络案例#
资源端口 → 实例 XML 中网卡 → OVS Bridge 与 Port → 物理接口配置 → 链路状态 → VLAN / 上游网络。ovs-appctl ofproto/trace 用于模拟交换路径,输入需来自真实端口和报文,不能照抄另一个实例的 MAC 或 in_port。
排错记录示例#
1
2
3
4
5
6
| 症状:卷一直 creating。
假设:Cinder 的消息通信不可用。
证据:scheduler 日志出现连接失败,volume 服务状态异常。
核对:transport_url 与消息端点、认证、网络配置。
修复:只修改已确认错误项,按资源归属重启受影响组件。
回归:新建卷 available → 附加 → 客户机写入读取。
|
这是记录方法示例,不表示所有 creating 都由消息队列引起。
实验操作#
引导练习:诊断 OpenStack 问题#
引导练习#
诊断 OpenStack 问题#
在此过程中,采用适当的诊断技术,查找日志条目,查询控制平面服务,并审查OpenStack组件和服务的状况。
学习目标#
能够找到并查看日志文件、检查服务并启用 debug-level 记录。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 运行 lab troubleshooting-diagnose setup,准备启动实例所需的资源。
1
| [student@workstation ~]$ lab troubleshooting-diagnose setup
|
检查在 controller0 上运行的容器化计算服务。登录到 controller0 并更改为 root 用户。
1
2
3
| [student@workstation ~]$ ssh controllere
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
列出容器化计算服务。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [root@controller0 ~]# docker ps --filter "name=nova*" --all
CONTAINER ID IMAGE
COMMAND CREATED STATUS PORTS
NAMES
340500c7cd3b 172.25. 249. 200:8787/rhosp13/openstack-nova-api:latest
"/usr/bin/bootstra..." 12 days ago Exited (©) 12 days ago
nova_api_discover_hosts
5bfcfobbf99b 172.25. 249. 200:8787/rhospi13/openstack-nova-api:latest
"kolla_start" 12 days ago Up 3 hours
nova_metadata
457d4ace9 2a0 172.25. 249. 200:8787/rhosp13/openstack-nova-api:latest
"kolla_start" 12 days ago Up 3 hours (healthy)
nova_api
3a98C43a04T7 172.25. 249. 200:8787/rhospi3/openstack -nova-scheduler:latest
"kolla_start" 12 days ago Up 3 hours (healthy)
nova_scheduler
357522ad5783 172.25. 249. 200:8787/rhosp13/openstack -nova-novncproxy: latest
"kolla_start" 12 days ago Up 3 hours (healthy)
nova_vnc_proxy
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| eb5d4133cd70 172.25. 249. 200:8787/rhosp13/openstack -nova-consoleauth: latest
"kolla_start" 12 days ago Up 3 hours (healthy)
nova_consoleauth
a39f81aa4asb 172.25. 249.200: 8787/rhosp13/openstack-nova-api:latest
"kolla_start" 12 days ago Up 3 hours
nova_api_cron
8ffb511c9318 172.25. 249.200: 8787/rhosp13/openstack-nova-conductor :latest
"kolla_start" 12 days ago Up 3 hours (healthy)
nova_conductor
2178875e7453 172.25. 249,200: 8787/rhosp13/openstack-nova-api:latest
"/usr/bin/bootstra..." 12 days ago Exited (©) 12 days ago
nova_db_sync
ee0b27e7e257 172.25. 249. 200:8787/rhosp13/openstack-nova-api:latest
"/usr/bin/bootstra..." 12 days ago Exited (©) 12 days ago
nova_api_ensure_default_cell
b4eae39f8 f50 172.25. 249,200: 8787/rhosp13/openstack-nova-api:latest
"/usr/bin/bootstra..." 12 days ago Exited (©) 12 days ago
nova_api_map_cello
53d487974cc1 172.25. 249. 200:8787/rhosp13/openstack -nova-placement -
api: latest "kolla_start" 12 days ago Up 3 hours
nova_placement
e77b4a296 f8t 172.25. 249,200: 8787/rhosp13/openstack -nova-api:latest
"/usr/bin/bootstra..." 12 days ago Exited (©) 12 days ago
nova_api_db_sync
d42de26be1af 172.25. 249. 200:8787/rhosp13/openstack-nova-placement -
api:latest "/bin/bash -c 'cho..." 12 days ago Exited (©) 12 days ago
nova_placement_init_log
166d1e71b4f3 172.25. 249.200: 8787/rhosp13/openstack -nova-api:latest
"/bin/bash -c 'cho..." 12 days ago Exited (©) 12 days ago
nova_metadata_init_log
26874e77508d 172.25. 249. 200:8787/rhosp13/openstack -nova-api:latest
"/bin/bash -c 'cho..." 12 days ago Exited (©) 12 days ago
nova_api_init_logs
|
在 workstation 上打开新的终端。检查在 compute0 上运行的容器化计算服务。
登录到 compute0 并更改为 root 用户。
1
2
3
| [student@workstation ~]$ ssh computee
[heat-admin@compute0 ~]$ sudo -i
[root@compute0 ~]#
|
列出容器化计算服务。
1
2
3
4
5
6
7
8
9
10
| [root@compute@ ~]# docker ps --filter "name=nova*" --all
CONTAINER ID IMAGE
COMMAND CREATED STATUS PORTS
NAMES
6b487 fO500b4 172.25. 249.200: 8787/rhosp13/openstack-nova-compute: latest
"kolla_start" 12 days ago Up 3 hours (healthy)
nova_compute
9e0ceeaT96cCcd 172.25.249.200:8787/rhosp13/openstack-nova-compute: latest
"kolla_start" 12 days ago Up 3 hours
nova_migration_target
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| 3Tf3bT523624 172.25. 249. 200:8787/rhosp13/openstack-nova-libvirt:latest UE
bin/bash -c '/us..." 12 days ago Exited (©) 12 days ago
nova_libvirt_init_secret
635€10629602 172.25. 249. 200:8787/rhosp13/openstack-nova-libvirt:latest
"kolla_start" 12 days ago Up 3 hours
nova_libvirt
leeag21b6eal 172.25. 249. 200:8787/rhosp13/openstack-nova-libvirt:latest
"kolla_start" 12 days ago Up 3 hours
nova_virtlogd
|
在 compute0 上使用 docker inspect 确定 nova_compute 的配置文件和日志文件位置,并列出这些文件。
确定配置和日志文件位置。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [root@compute0 ~]# docker inspect nova_compute
.. output omitted...
"Hostconfig": {
"Binds": [
"/etc/pki/tls/cer ts/ca-bundle.crt:/etc/pki/tls/cer ts/ca-
bundle.crt:ro",
.. output omitted...
"/var/log/containers/nova: /var/log/nova",
"/var/lib/kolla/config_files/nova_compute.json: /var/lib/kolla/
config_files/config.json:ro",
"/var/lib/conf ig-data/puppet-generated/nova_libvirt/:/var/lib/
kolla/config_files/src:ro",
"/etc/iscsi:/var/lib/kolla/config_files/src-iscsid:ro"
1,
.. output omitted...
|
列出配置文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [root@compute0O ~]# find /var/1lib/config-data/puppet-generated/nova_libvirt
/var/lib/config-data/puppet-generated/nova_libvirt
/var/lib/config-data/puppet-generated/nova_libvirt/etc
/var/lib/config -data/puppet-generated/nova_libvirt/etc/libvirt
/var/lib/config -data/puppet-generated/nova_libvirt/etc/libvirt/libvirtd.conf
/var/lib/config -data/puppet-generated/nova_libvirt/etc/libvirt/passwd.db
/var/lib/config -data/puppet-generated/nova_libvirt/etc/libvirt/qemu.conf
/var/lib/config -data/puppet-generated/nova_libvirt/etc/my.cnf.d
/var/lib/config-data/puppet-generated/nova_libvirt/etc/my.cnf.d/tripleo. cnf
/var/lib/config -data/puppet-generated/nova_libvirt/etc/nova
/var/lib/config -data/puppet-generated/nova_libvirt/etc/nova/migration
/var/lib/config -data/puppet-generated/nova_libvirt/etc/nova/migration/
authorized_keys
/var/lib/config -data/puppet-generated/nova_libvirt/etc/nova/migration/identity
/var/lib/config -data/puppet-generated/nova_libvirt/etc/nova/nova.conf
/var/lib/config -data/puppet-generated/nova_libvirt/etc/nova/secret.xml
/var/lib/config -data/puppet-generated/nova_libvirt/etc/sasl2
/var/lib/config -data/puppet-generated/nova_libvirt/etc/sasl2/libvirt.conf
/var/lib/config-data/puppet-generated/nova_libvirt/etc/ssh
/var/lib/config -data/puppet-generated/nova_libvirt/etc/ssh/sshd_config
/var/lib/config-data/puppet-generated/nova_libvirt/var
/var/lib/config-data/puppet-generated/nova_libvirt/var/lib
/var/lib/config -data/puppet-generated/nova_libvirt/var/lib/nova
|
操作界面、表格与配置图
1
2
| /var/lib/config-data/puppet-generated/nova_libvirt/var/lib/nova/.ssh
/var/lib/config-data/puppet-generated/nova_libvir t/var/lib/nova/.ssh/config
|
列出日志文件。
1
2
3
4
5
6
7
8
| [root@compute0 ~]# find /var/log/containers/nova
/var/log/containers/nova
/var/log/containers/nova/privsep-helper.log
/var/log/containers/nova/nova-compute.log.4.gz
/var/log/containers/nova/nova-compute.log.3.gz
/var/log/containers/nova/nova-compute.log.2.gz
/var/log/containers/nova/nova-compute.log.1
/var/log/container s/nova/nova-compute. log
|
在 compute0 上修改 nova_compute 的日志配置,启用 debug 级别日志。
1
2
3
| [root@compute0 ~]# crudini --set \
/var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf \
DEFAULT debug True
|
重新启动 nova_compute 服务。
1
2
| [root@compute0 ~]# docker restart nova_compute
nova_compute
|
查看 /var/log/containers/nova/nova-compute.log,确认已启用调试级别日志。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [root@compute@ ~]# tail -f /var/log/containers/nova/nova-compute.log
...output omitted...
2018-11-05 05:55:24,829 1 DEBUG nova.compute. resource_tracker
[req -1de591a0-8e6d-497d-b006-2743ab124a22 - - - - -] Compute_service record
updated for compute0.overcloud.example.com:compute0.overcloud.example.com
_update_available_resource /usr/lib/python2. 7/site-packages/nova/compute/
resource_tracker.py:764
2018-11-05 05:55:24.830 1 DEBUG oslo_concurrency.lockutils
[req-1de591a0-8e6d-497d -b006-2743ab124a22 - - - - -] Lock "compute_resources"
released by "nova.compute. resource_tracker. _update_available_resource" :: held
1.309s inner /usr/lib/python2.7/site-packages/oslo_concurrency/lockutils.py:285
2018-11-95 65:55:24,836 1 DEBUG nova.service [req-1de591a0-8e6d-497d-
bOO6-2743ab124a22 - - - - -] Creating RPC server for service compute start /usr/
lib/python2.7/site-packages/nova/service. py:184
2018-11-05 05:55:24,865 1 DEBUG nova.service [req-1de591a0-8e6d-497d-
bOO6-2743ab124a22 - - - - -] Join ServiceGroup membership for this service compute
start /usr/lib/python2. 7/site-packages/nova/ser vice. py: 202
|
在 controller0, 杀死相应的 pacemaker_remoted 进程,迫使 RabbitMQ 失败。
确定RabbitMQ容器的ID。
1
| [root@controller0 ~]# docker ps --filter "name=rabbit*"
|
操作界面、表格与配置图
1
2
3
4
5
6
| CONTAINER ID IMAGE
COMMAND CREATED STATUS PORTS
NAMES
offafb46725d 172.25. 249. 200:8787/rhosp13/openstack-rabbiting: pemklatest nyA
bin/bash /usr/lo..." 44 minutes ago Up 44 minutes
rabbi tmgq -bundle-docker-0
|
为 pacemaker_remoted 进程获取 PID。
1
2
3
| [root@controller0 ~]# docker exec -it rabbitmq-bundle-docker-o \
ps -efwww | grep pacemaker
root 20 1 © Novos ? 00:00:03 /usr/sbin/pacemaker_remoted
|
杀死容器中的 pacemaker_remoted 进程。
1
2
| [root@controller0 ~]# docker exec -it rabbitmq-bundle-docker-0 \
kill -9 20
|
在 compute0 查看 /var/log/containers/nova/nova-compute.log,查找 RabbitMQ 容器故障相关记录。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| 2018-11-07 60:31:31.914 1 ERROR oslo.messaging._drivers.impl_rabbit
[req-4f29dc69-6f17-4695-a2b9-b8bf491ea69b - - - - -]
[66daib1d-092a-4761-8294-3e188d08ee43] AMQP server on
controller0.internalapi.overcloud.example.com:5672 is unreachable: [Errno 111]
ECONNREFUSED. Trying again in 4 seconds. Client port: None: error: [Errno 111]
ECONNREFUSED
2018-11-07 60:31:33.049 1 ERROR oslo.messaging._drivers.impl_rabbit
[req-4f29dc69-6f17-4695-a2b9-b8bf491ea69b - - - - -]
[b6e28794-7a17 -404c-a1b6-6f9123126c04] AMQP server on
controller0.internalapi.overcloud.example.com:5672 is unreachable: [Errno 111]
ECONNREFUSED. Trying again in 6 seconds. Client port: None: error: [Errno 111]
ECONNREFUSED
2018-11-07 60:31:33.064 1 ERROR oslo.messaging._drivers.impl_rabbit
[req-4f29dc69-6f17-4695-a2b9-b8bf491ea69b - - - - -] [6eb337d7-dOc6-4eeb-aehbé-
dd905d13358b] AMQP server on controller0.internalapi.overcloud.example.com: 5672
is unreachable: [Errno 111] ECONNREFUSED. Trying again in 4 seconds. Client port:
None: error: [Errno 111] ECONNREFUSED
|
在 controller0 上检查 RabbitMQ 的状态。
查询 RabbitMQ 容器 ID。若 ID 与先前不同,说明 Pacemaker 已重启故障资源;运行时长也能反映重启。
1
2
3
4
| [root@controller0 ~]# docker ps --filter "name=rabbit*"
CONTAINER ID IMAGE
COMMAND CREATED STATUS PORTS
NAMES
|
操作界面、表格与配置图
1
2
3
| ofe6e34b1d49 172.25. 249. 200:8787/rhosp13/openstack-rabbitmq: pemklatest ne
bin/bash /usr/lo..." 28 minutes ago Up 28 minutes
rabbi tmg -bundle-docker-0
|
执行 pcs status 查看 Pacemaker 集群。RabbitMQ 连接各组件,因此预计会看到多个失败动作。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [root@controller0 ~]# pcs status
Cluster name: tripleo_cluster
Stack: corosync
Current DC: controller0 (version 1.1.18-11.e17_5.3-2b07d5c5a9) - partition with
quorum
Last updated: Wed Nov 7 01:02:22 2018
Last change: Mon Nov 5 00:44:01 2018 by root via cibadmin on controller0
5 nodes configured
21 resources configured
.. Output omitted...
Failed Actions:
* rabbitmq-bundle-docker -0_monitor_9 on controller0 'unknown error' (1): call=5,
status=complete, exitreason='',
last-re-change='Tue Nov 6 23:21:47 2018', queued=0ms, exec=109ms
.. Output omitted...
|
确定在8775、8774和6080端口监听的服务程序。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [root@controller0 ~]# ss -tnlp | egrep '8775|8774|6080'
LISTEN © 128 172.25.250.50:6080 *:* users: (("haproxy",pid=16308,fd=31))
LISTEN © 128 172.24.1.50:6080 *:* users: (("haproxy", pid=16308, fd=30) )
LISTEN © 100 172.24.1.1:6080 *:* users: (("nova-novncproxy",pid=4998, fd=4) )
LISTEN © 128 172.25.250.50:8774 *:* users: (("haproxy", pid=16308, fd=33))
LISTEN © 128 172.24.1.50:8774 *:* users: (("haproxy", pid=16308, fd=32))
LISTEN © 128 172.24.1.1:8774 *:* users: (("httpd", pid=20809, fd=3),
("httpd", pid=20808 , fd=3), ("httpd" , pid=20771, fd=3), ("httpd", pid=19531, fd=3),
("httpd", pid=17973, fd=3), ("httpd", pid=10449, fd=3), ("httpd", pid=10448, fd=3),
("httpd", pid=10447, fd=3), ("httpd" , pid=10446, fd=3), ("httpd", pid=10445, fd=3),
("httpd", pid=10444, fd=3), ("httpd" , pid=10443, fd=3), ("httpd", pid=10442, fd=3),
("httpd", pid=5539, fd=3))
LISTEN © 128 172.24.1.1:8775 *:* users: (("nova-api-metada",pid=22116, fd=4) )
LISTEN © 128 172.24.1.50:8775 *:* users: (("haproxy", pid=16308, fd=29))
[root@controller0 ~]# logout
[heat-admin@controller0 ~]$ logout
[student@workstation ~]$
|
在 workstation 加载 /home/student/architect1-finance-rc,然后列出计算服务。
1
| [student@workstation ~]$ source ~/architect1-finance-rc
|
操作界面、表格与配置图
1
| [student@workstation ~(architect1-finance)]$
|
执行 openstack compute service list 命令以查看计算服务的状况。
1
2
| [student@workstation ~(architect1-finance)]$ openstack compute service list \
-f json
|
[
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
| {
"Status": "enabled",
"Binary": "nova-conductor",
"Zone": "internal",
PSlave2 tip
"Host": "controller0.overcloud.example.com",
"Updated At": "2018-11-07T02: 50: 30. 900000",
*Tp* 3.
},
{
"Status": "enabled",
"Binary": "nova-compute",
"Zone": "nova",
'State': 'up™,
"Host": "compute1.overcloud.example.com",
"Updated At": "2018-11-07T02: 50: 31. 900000",
My: 2
},
{
"Status": "enabled",
"Binary": "nova-compute",
"Zone": "nova",
PS tate. tipi
"Host": "computehci@.overcloud.example.com",
"Updated At": "2018-11-07T02: 50: 26. 9000000",
"EDs 3
},
{
"Status": "enabled",
"Binary": "nova-compute",
"Zone": "nova",
"State™s 'ip',
"Host": "compute0.overcloud.example.com",
"Updated At": "2018-11-07T02:50: 21.000000",
MIT 4
},
{
"Status": "enabled",
"Binary": "nova-consoleauth",
"Zone": "internal",
PState=: tipi
"Host": "controller0.overcloud.example.com",
"Updated At": "2018-11-07TO2:50: 28.000000",
ae eiee 15)
},
{
"Status": "enabled",
"Binary": "nova-scheduler",
|
操作界面、表格与配置图
1
2
3
4
5
| "Zone": "internal",
"State": Choe
"Host": "controller0.overcloud.example.com",
"Updated At": "2018-11-07T02: 50: 24. 000000",
"Tp: 6
|
在 workstation 加载 /home/student/developer1-finance-rc,启动实例以验证全部服务是否正常。
1
2
| [student@workstation ~(architect1-finance)]$ source ~/developer1-finance-re
[student@workstation ~(developer1-finance)]$
|
创建 finance-server1,并使用 –debug 查看详细信息。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack server create \
--image rhel7 \
--flavor default \
--security-group default \
--key-name example-keypair \
--nic net-id=finance-network1 \
--wait --debug finance-server1
... Output omitted...
|
调试输出为启动一个实例所涉及的所有流程和组件提供了大量信息。在下面的例子中,您可以看到调用是向计算服务、 URL 调用、 由此产生的请求 ID 以及请求的细节。
1
2
3
4
5
6
7
| GET call to compute for http://172.25.250.50:8774/v2.1/servers/
f648a6ff -946e-409f -9316-€413013c4e42 used request id req-babca1bo-
ed9a-4e17 -9356-4ce49f 26bc9b
REQ: curl -g -i -X GET http://172.25.250.50:8774/v2.1/servers/
f648a6 ff -946e-409f -9316-e413013c4e42 -H "User-Agent: python-
novaclient" -H "Accept: application/json" -H "X-Auth-Token:
{SHA1}aa4da7Obai6ede2fcd5c4cc2e060c54d33f9d4464"
|
调用其他部件的调试输出将酌情包含JSON有效载荷。
在 workstation 上运行 lab troubleshooting-diagnose cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab troubleshooting-diagnose cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:排查常见核心问题#
引导练习#
排查常见核心问题#
在此练习中,解决与启动实例有关的问题。您还将解决网络通信问题。
学习目标#
完成后,能够:
排查并修复导致实例启动失败的问题。
排查并修复 OpenStack 网络服务中的问题。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 运行 lab troubleshooting-services setup,准备环境和本练习所需资源。
1
| [student@workstation ~]$ lab troubleshooting-services setup
|
启动一个名为 finance-server1 的实例。
加载 /home/student/developer1-finance-rc 用户环境文件。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
使用以下值创建名为 finance-server1 的实例。
| 选项 | 值 |
|---|
| 规格 | default |
| –image | rhel7 |
| –key-name | example-keypair |
| –network | provider1-104 |
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
--image rhel7 \
--key-name example-keypair \
--network provider1-104 \
--wait \
finance-server1
|
操作界面、表格与配置图
命令挂起。
按 Ctrl+C 取消部署,删除实例,再使用 –debug 重新创建。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| [student@workstation ~(developeri1-finance)]]$ openstack server delete \
finance-server1
[student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
--image rhel7 \
--key-name example-keypair \
--network provider1-104 \
--wait \
finance-server1 --debug
.. Output omitted...
GET call to compute for http://172.25.250.50: 8774/v2.1/servers/1619be15 -a922 -4e3f -
afdi-afbdc734fb31 used request id req-do4865fe-9fa?7 -4e74-8a83-d6b1id98cf640
REQ: curl -g -i -X GET http://172.25.250.50:8774/v2.1/server$/1619be15 -a922 -4e3f-
afdi-afbdc734fb31 -H "User-Agent: python-novaclient" -H "Accept: application/json"
-H "X-Auth-Token: {SHA1}41d0ee7cfod8 faa6e83c22930185063deb01960b"
http://172.25.250.50:8774 "GET /v2.1/servers/1619be15-a922-4e3f -afd1-afbdc734fb31
HTTP/1.1" 200 609
RESP: [200] Date: Tue, 13 Nov 2018 02:38:54 GMT Server: Apache OpenStack-
API-Version: compute 2.1 X-OpenStack-Nova-API-Version: 2.1 Vary: OpenStack-
API -Version, X-OpenStack-Nova-API-Version,Accept-Encoding x-openstack-request-
id: req-afaf9cca-4811-4be5-85ba-7869e22cb9e0 x-compute-request-id: req-
afaf9cca-4811-4be5 -85ba-7869e22cb9e0 Content-Encoding: gzip Content-Length: 609
Content-Type: application/json
RESP BoDY: {"server": {"OS-EXT-STS: task_state": "scheduling", "addresses": ...,
"links": [{"href": "http://172.25.250.50: 8774/v2.1/servers/1619be15 -a922-4e3f -
afdi-afbdc734fb31", "rel": "self"}, {"href": "http: //172.25.250.50:8774/
servers/1619be15-a922 -4e3f-afdi-afbdc734fb31", "rel": "bookmark"}],
"image": {"id": "6b0128a9-4481-4ceb-b34e-ffe92eedcfdd", "links": [{"href":
"http://172.25.250.50:8774/images/6b0128a9-4481 -4ceb-b34e-ffe92eedcfdd", "rel":
"bookmark"}]}, "OS-EXT-STS:vm_state": "building", "OS-SRV-USG: launched_at":
null, "flavor": {"id": "e04380ed -bO27 -4a72-a697 -4307bc014b6c", "Links": [{"href":
"http: //172.25.250.50:8774/flavors/e04380ed- b027 -4a72 -a697 -4307bc014b6c",
"rel": "bookmark"}]}, "id": "1619be15-a922-4e3f -afdi-afbdc734fb31", "user_id":
"e4035d555f 6b8 8cf 42ca4cach9 fag 999dca97 87392222d 2eboO87 5e4e34e6d76f", "OS-
DCF:diskConfig": "MANUAL", "accessIPv4": "", "accessIPv6": "", "progress"
©, "OS-EXT-STS:power_state": ©, "OS-EXT-AZ:availability_zone": "",
"config_drive": "", "status": "BUILD", "updated": "2018-11-13T02:38:54Z",
"hostId": "", "OS-SRV-USG: terminated_at": null, "key_name": "example-keypair",
"name": "finance-serveri", "created": "2018-11-13T02:37:37Z", "tenant_id":
"3c003f65d8d64914a053f178fbbf953c", "os-extended-volumes:volumes_attached": [],
"metadata": ...}}
.. output omitted...
|
部署不断循环试图调用计算服务。
按 Ctrl+C 取消部署,然后删除实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server1
|
操作界面、表格与配置图
确定部署失败的原因
作为第一步,请检查 nova_conductor 服务。登录到 controller0 , 然后变成 root。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh controller0
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
检查nova_conductor容器的健康状况。
1
2
3
4
| [root@controller0 ~]# docker exec -ti nova_conductor /openstack/healthcheck
Error response from daemon: Container
8ffb51109318d8024378f0419d709902a7601C33eE59233203e7b7037C20C263b is restarting,
wait until the container is running
|
确定 nova_conductor 失败的原因。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| [root@controller0 ~]# docker logs nova_conductor
.. Output omitted...
++ cat /run_command
+ CMD='/usr/bin/nova-conductor '
+ ARGS=
+{[!-n'' ]
+ . kolla_extend_start
++ [[ ! -d /var/log/kolla/nova ]]
+++ stat -c %a /var/log/kolla/nova
++ [[ 2755 != \7\5N5 J]
++ chmod 755 /var/log/kolla/nova
++ . /usr/local/bin/kolla_nova_extend_start
+ echo 'Running command: '\''/usr/bin/nova-conductor '\''!
+ exec /usr/bin/nova-conductor
Running command: '/usr/bin/nova-conductor '
Traceback (most recent call last):
File "/usr/bin/nova-conductor", line 106, in <module>
sys.exit(main())
File "/usr/lib/python2.7/site-packages/nova/cmd/conductor.py", line 35, in main
config.parse_args(sys.argv)
File "/usr/lib/python2.7/site-packages/nova/config.py", line 52, in parse_args
default_config_files=default_config_files)
File "/usr/lib/python2.7/site-packages/oslo_config/cfg.py", line 2507, in
-call__
self._namespace._files_permission_denied)
oslo_config.cfg.configFilesPermissionDeniedError: Failed to open some config
files: /etc/nova/nova.conf
|
错误显示 /etc/nova/nova.conf 上的权限不允许容器运行的用户访问。
使用 docker inspect 命令来确定 nova_conductor 服务的配置文件位置。
1
2
3
4
| [root@controller0o ~]# docker inspect nova_conductor
.. output omitted...
"Hostconfig": {
"Binds": [
|
操作界面、表格与配置图
1
2
3
| "/var/lib/config-data/puppet-generated/nova/ :/var/lib/kolla/
config_files/sre:ro",
.. output omitted...
|
错误中的 /etc/nova/nova.conf 对应宿主机 /var/lib/config-data/puppet-generated/nova/etc/nova/nova.conf。检查并修正文件权限。
1
2
3
4
5
6
| [root@controller0 ~]# cd /var/1lib/config-data/puppet-generated/nova
[root@controller0 nova]# ls -1 etc/nova/nova.conf
-PW-------. 1 root 42436 60203 Nov 2 06:46 etc/nova/nova.conf
[root@controller0 nova]# chmod 640 etc/nova/nova.conf
[root@controller0 nova]# ls -1 etc/nova/nova.conf
-rwW-r-----. 1 root 42436 60203 Nov 2 06:46 etc/nova/nova.conf
|
重新启动 nova_conductor 容器,等待它变成 healthy, 然后从控制器中注销。
1
2
3
4
5
6
7
8
| [root@controller0 nova]# docker restart nova_conductor
nova_conductor
[root@controller0 nova]# docker ps | grep nova_conductor
8ffb511c9318 172.25.249.200:8787/rhosp13/openstack-nova-conductor :latest
"kolla_start" 2 weeks ago Up About a minute (healthy)
[root@controller0 nova]# logout
[heat-admin@controller0 ~]$ logout
[student@workstation ~(developer1-finance)]$
|
重新尝试启动 finance-server1 实例。
1
2
3
4
5
6
7
8
| [student@workstation ~(developeri1-finance)]]$ openstack server create \
--flavor default \
--image rhel7 \
--key-name example-keypair \
--network provider1-104 \
--wait \
finance-server1
.. Output omitted...
|
部署应该成功。
从 finance-server1 ping utility 的地址 10.0.104.1。取得 finance-server1 的控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack console url \
show finance-server1
SE eRe seKe! he a ee a ee a ee ean +
| Field | value |
teen eeee Pi ee ee ee ee eee +
| type | novne |
| url | http: //172. 25. 250.50: 6080/vnc_auto. html? token=a4d2bbb0-c625 |
| | -4b38 -acdb-ob5a3f fd9e7a |
|
操作界面、表格与配置图
在 Web 浏览器中打开 console URL, 用 redhat 作为密码以 root 登录为 root。使用 ping 命令测试 10.0.104.1 连接到 utility。
1
2
3
4
5
6
7
| [root@finance-server1 ~]# ping -c3 10.0.104.1
PING 10.0.104.1 (10.0.104.1) 56(84) bytes of data.
From 10.0.104.105 icmp_seq=1 Destination Host Unreachable
From 10.0.104.105 icmp_seq=2 Destination Host Unreachable
From 10.0.104.105 icmp_seq=3 Destination Host Unreachable
--- 160.0.104.1 ping statistics ---
3 packets transmitted, © received, +3 errors, 100% packet loss, time 2001ms
|
调查通信问题,找出原因。
在 workstation 上,确定 provider1-104 网络的 ID。这将用于确定包流。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack network show \
provider1-104 -c id
fiw ee ei ete ei i i ie ei ie ee ei ie ee ee ee et
| Field | Value |
aeee
| id | b9189edb -fc58-45fe-8eef -79f118ea2539 |
finn nn pe nn en rn eet
|
确定 finance-server1 所在计算节点,同时记录其通用实例名称。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(developer1-finance)]$ source ~/architect1-finance-re
[student@workstation ~(architect1-finance)]$ openstack server show finance-server1
SP ere eer he et etteFe Fe ee ef Ve tht eee ee ee eeee eaeeee Fee eee Fel
| Field | Value |
fee ee ce eee ehcele teeee et tet eee efeetee eee cetee tentet ee eetee etoe fet ete ee tee fetee eter fete teeter tee ete eter tetera ai
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ: availability_zone | nova |
| OS-EXT-SRV-ATTR:host | compute0.overcloud.example.com |
| OS-EXT-SRV-ATTR: hypervisor_hostname | compute0.overcloud.example.com |
| OS-EXT-SRV-ATTR:ins tance_name | instance-9000000a |
| OS-EXT-STS:power_state | Running |
.. output omitted...
|
登录到相应的计算节点,并更改为 root 用户。
1
2
3
| [student@workstation ~(architect1-finance)]$ ssh compute0
[heat-admin@compute0 ~]$ sudo -i
[root@compute0 ~]#
|
查找实例中使用的 TAP 设备。注意它应该连接到 br-int。另请注意 MAC 地址; 这将用于跟踪包流。
1
2
3
| [root@compute0 ~]# virsh dumpxml instance-99e0000a
.. Output omitted...
<interface type='bridge'>
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| <mac address='fa:16:3e:05:e0:c2'/>
<source bridge='br-int'/>
<virtualport type='openvswitch'>
<parameters interfaceid=' fc742bd3-2133-4a29 -9a53-d4cch6e61alf' />
</virtualport>
<target dev='tapfc742bd3-21'/>
<model type='virtio'/>
<mtu size='1500'/>
<alias name='neto'/>
<address type='pci' domain='0x0000' bus='0xeO' slot='®xe3' function='Ox@'/>
</interface>
..,output omitted...
|
查看 provider1-104 网络及 finance-server1 TAP 设备的 OVS 连接。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| [root@compute0 ~]# ovs-vsctl show
.. Output omitted...
Bridge "br-eth3"
fail_mode: standalone
Port "br-eth3"
Interface "br-eth3"
type: internal
Port "patch-provnet -b9189edb -fc58-45fe-8eef -79f118ea2539-to-br-int"
Interface "patch-provnet -b9189edb - fc58- 45fe-8eef -79f118ea2539-to-br-
int"
type: patch
options: {peer="patch-br-int-to-provnet-b9189edb-
fc58-45fe -8eef-79f118ea2539"}
Bridge br-int
fail_mode: secure
.. output omitted...
Port "patch-br-int-to-provnet-b9189edb-fc58 -45 fe- 8eef-79f118ea2539"
Interface "patch-br-int-to-provnet-b9189edb-
fc58-45fe-S8eef -79f118ea2539"
type: patch
options: {peer="patch-provnet -b9189edb-
fc58-45fe -8eef -79f118ea2539-to-br-int"}
Port "tapfc742bd3-21"
Interface "tapfc742bd3-21"
|
请注意,TAP 设备将实例连接到 br-int。请注意,provider1-104 网络的创建产生了一对接口,将 br-int 与 br-eth3 连接到一个补丁端口。接口名称包含 provider1-104 网络的 ID。
逐条追踪 OpenFlow 规则繁琐且易出错。使用 ovs-appctl 模拟从 finance-server1 发往 utility 的 ICMP 数据包。根据上一步的 OVS 连接,实例流量应
操作界面、表格与配置图
通过 tapfc742bd3-21 进入 br-int,再经 patch 端口到达 br-eth3。
下表说明命令中使用的包字段。
数据包字段
| 字段 | 说明 |
|---|
| in_port= | 指定数据包进入交换机的端口。finance-server1 的 TAP 端口是 tapfc742bd3-21。 |
| protocol | 数据包协议。本例模拟 ping,因此使用 ICMP。 |
| nw_src= | 源 IP 地址,finance-server1 的地址为 10.0.104.105。 |
| d1_src= | 源 MAC 地址,finance-server1 的地址为 fa:16:3e:05:e0:c2。 |
| nw_dst= | 目的地网络地址( IP)。utility 的 IP 地址是 10.0.104.1。 |
注意:下面的命令为便于阅读进行了换行;实际输入时不要包含回车。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| [root@compute0 ~]# ovs-appctl ofproto/trace br-int \
in_port="tapfc742bd3-21",icmp, nw_src=10.0.104.105,
dl_src=fa:16:3e:05:e0:c2,nw_dst=10.0.104.1
Flow:
icmp, in_por t=4,vlan_tci=0x0000,d1_src=fa:16:3e:05:e0:c2,d1_dst=00:00:00:00:00:00,
nw_src=10.0.104.105,nw_dst=10.0.104.1,nw_tos=0,nw_ecn=0,nw_tt1=0,icmp_type=0,
icmp_code=0
bridge("br-int")
®. in_port=4, priority 100
set_field:0x1->reg13
set_field:0x3->reg11
set_field:0x2->regi2
set_field:0x8->metadata
set_field:0x4->reg14
resubmit (,8)
8. regl4=0x4,metadata=0x8,d1_src=fa:16:3e:05:e0:c2, priority 50, cookie
Oxab405c15
resubmit (,9)
9. ip,reg14=0x4,metadata=0x8,d1_src=fa:16:3e:05:e0:c2,nw_src=10.0.104.105,
priority 90, cookie o0x6d4e4677
resubmit (,10)
10. metadata=0x8, priority 6, cookie oxb42ed0a4
resubmit (,11)
11. ip,metadata=0x8, priority 100, cookie 0xa4029170
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| load: 0x1->NXM_NX_XXREGO[96]
resubmit(,12)
12. metadata=0x8, priority 6, cookie 0x6603eb2c
resubmit(,13)
13. ip, regO=0x1/0x1,metadata=Ox8, priority 100, cookie Oxaodb21ab5
ct (table=14, zone=NXM_NX_REG13[0. .15])
drop
-> A clone of the packet is forked to recirculate. The forked pipeline will
be resumed at table 14.
Final flow: icmp, rego=0x1, reg11=0x3, reg12=0x2, reg13=0x1, reg14=0x4, metadata=0x8,
in_por t=4,vlan_tci=0x9000,d1_src=fa:16: 3e:05:e0:c2,d1_dst=00:00:00:00:00:00,
nw_src=10.0.104.105,nw_dst=10.0.104.1,nw_tos=0, nw_ecn=0,nw_ttl=0,icmp_type=0,i
icmp_code=0
Megaflow:
recirc_id=0,eth,ip,in_port=4, vlan_tci=0x0000/0x1000,d1_src=fa:16: 3e:05:e0:c2,
nw_src=10.0.104.105,nw_dst=0.0.0.0/1,nw_frag=no
Datapath actions: ct(zone=1),recirc(0xa)
recirc(®xa) - resume conntrack with default ct_state=trk|new (use --ct-next to
customize)
Flow: recirc_id=0xa,ct_state=new|
trk,ct_zone=1,eth,icmp, rego=0x1, reg11=0x3, reg12=0x2,
reg13=0x1, reg14=0x4, metadata=0x8, in_por t=4,vlan_tci=0x0000,d1_src=fa:16:3e:05:e0:C2,
d1_dst=00: 00:00: 00:00:00, nw_src=10.0.104.105, nw_dst=10.0.104.1, nw_tos=0, nw_ecn=0,
nw_ttl=0, icmp_type=0, icmp_code=0
bridge("br-int")
thaw
Resuming from table 14
14. ct_state=tnew-est+trk,ip,reg14=0x4, metadata=0x8, priority 2002, cookie
Ox43cfb2b5
load: 0x1->NXM_NX_XXREGO[97]
resubmit(,15)
15. metadata=0x8, priority 96, cookie oxba3f581d
resubmit(,16)
16. metadata=0x8, priority ©, cookie 0x42968196
resubmit(,17)
17. metadata=0x8, priority 9, cookie ox8d3beedd
resubmit(,18)
18. ip, rego=0x2/0x2,metadata=0x8, priority 100, cookie 0x8c9c9578
ct (commit, Zone=NXM_NX_REG13[0..15],exec(load:@->NXM_NX_CT_LABEL[0]))
load: @->NXM_NX_CT_LABEL[0]
resubmit(,19)
19. metadata=0x8, priority 9, cookie 0x491f8315
resubmit (,20)
20. metadata=0x8, priority 9, cookie Ox66f27962
resubmit(,21)
21. metadata=0x8, priority 0, cookie 0xc32c3d73
resubmit(,22)
22. metadata=0x8, priority 0, cookie Oxdebd3512
resubmit(,23)
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
| 23. metadata=0x8, priority 9, cookie 60x8f98275c
resubmit (,24)
24. metadata=0x8, priority 0, cookie ox6f85bied
set_field: oxfffe->regi5
resubmit (,32)
32. priority 6
resubmit(,33)
33. regi5=oxfffe,metadata=0x8, priority 100
set_field:0x4->reg13
set_field:0x1->regi5
resubmit (,34)
34. priority 6
set_field:9->rego
set_field:0->reg1
set_field:0->reg2
set_field:0->reg3
set_field:09->reg4
set_field:0->reg5
set_field:09->reg6
set_field:0->reg7/
set_field:0->reg8
set_field:0->reg9
resubmit(,40)
40. metadata=0x8, priority 6, cookie oxb4s84f3de
resubmit(,41)
41. ip, regibs=0x1,metadata=0x8, priority 110, cookie 0x1d2d7934
resubmit(,42)
42. metadata=0x8, priority 0, cookie Oxd311b4f8
resubmit(,43)
43. metadata=0x8, priority 6, cookie 9x9eCc6220a
resubmit(,44)
44. metadata=0x8, priority 0, cookie Oxe1453aba
resubmit(,45)
45. metadata=0x8, priority 0, cookie Ox3fad4aed4
resubmit(,46)
46. metadata=0x8, priority 6, cookie 9x61ba3940
resubmit(,47)
47. metadata=0x8, priority 0, cookie Ox6efeaece
resubmit(,48)
48. metadata=0x8, priority ©, cookie 0x1734102d
resubmit(,49)
49. reg15=0x1,metadata=0x8, priority 50, cookie Ox75acabé86
resubmit(,64)
64. priority 0
resubmit(,65)
65. regi5=0x1,metadata=0x8, priority 100
push_vlan:0x8100
set_field:4200->vlan_vid
output:5
bridge("br-eth3")
®. priority 0
NORMAL
-> no learned MAC for destination, flooding
pop_vlan
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| set_field:oxfffe->reg15
Final flow: recirc_id=0xa,eth,icmp, reg11=0x3, reg12=0x2, reg13=0x4, reg14=0x4,
regi5=0xf ffe, me tadata=0x8, in_por t=4, vlan_tci=0x0000,d1_src=fa:16:3e:05:e0:Cc2,
d1_dst=00: 00:00: 00:00:00,nw_src=10.0.104.105, nw_dst=10.0.104.1,nw_tos=0, nw_ecn=0,
nw_ttl=0, icmp_type=0, icmp_code=0
Megaflow: recirc_id=0xa,ct_state=tnew-est-rel-rpl-inv+trk,ct_label=0/ox1,eth,icmp,
in_por t=4, vlan_tci=0x0000/0x1f ff,d1_src=fa:16:3e:05:e0:c2,d1_dst=00:00:00:00:00:00,
nw_src=10.0.104.105,nw_dst=10.0.104.1,nw_frag=no
Datapath actions: ct(commit ,zone=1,label=0/0x1),push_vlan(vid=104,pcp=0) ,3
|
模拟的 ICMP 流量成功到达 br-eth3。
审查br-eth3的配置。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [root@compute0 ~]# ovs-vsctl show
..- Output omitted...
Bridge "br-eth3"
fail_mode: standalone
Port "br-eth3"
Interface "br-eth3"
type: internal
Port "patch-provnet -b9189edb -fcb8 -45fe-8eef -79f118ea2539-to-br-int"
Interface "patch-provnet -b9189edb - fc58 -45fe-8eef -79f118ea2539-to-br-
int"
type: patch
options: {peer="patch-br-int-to-provnet-b9189edb-
fc58-45fe-8eef -79f118ea2539"}
..- output omitted...
|
请注意,目前只有一个内部端口和一个补丁端口;没有显示外部接口。
为计算节点查看 IP 配置。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [root@compute0 ~]# ipa
..- Output omitted...
5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen
1000
link/ether 52:54:00:03:00:02 brd ff: ff: ff: ff: ff: ff
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-
system state UP group default qlen 1000
link/ether 52:54:00:04:00:02 brd ff: ff: ff: ff: ff: ff
inet6 fes8o: :5054: ff: feO4:2/64 scope link
valid_lft forever preferred_lft forever
7: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
qlen 1000
link/ether 86:46: ff:6a:61:a8 brd ff: ff: ff: ff: ff: ff
8: genev_sys_6081: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65000 qdisc noqueue
master ovs-system state UNKNOWN group default qlen 1000
link/ether 46:3f:1b:5a:6d:29 brd ff: ff: ff: ff: ff: ff
inet6 fe8o: :443f:1bff: feba:6d29/64 scope link
valid_lft forever preferred_lft forever
9: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen
1000
link/ether 86:a7:a5:b8:33:42 brd ff: ff: ff: ff: ff: ff
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| 10: br-eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
link/ether 52:54:00:03:00:02 brd ff: ff: ff: ff: ff: ff
inet6 fes8o: :5054: ff: feO3:2/64 scope link
valid_lft forever preferred_lft forever
11: br-eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
link/ether 52:54:00:04:00:02 brd ff: ff: ff: tf: ff: ff
inet6 fe8o: :5054: ff: fe@4:2/64 scope link
valid_lft forever preferred_lft forever
..- output omitted...
|
eth3 接口被列为 down。
审查 /etc/sysconfig/network-scripts/ifcfg-eth3 文件。
1
2
3
4
5
6
7
8
9
10
11
| [root@compute0 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth3
# This file is autogenerated by os-net-config
DEVICE=eth3
ONBOOT=no
HOTPLUG=na
NM_CONTROLLED=no
PEERDNS=no
DEVICETYPE=ovs
TYPE=0OvsPort
OVS_BRIDGE=br-eth3
BOOTPROTO=none
|
该接口已配置为启动时不启用。
启用 eth3 接口。
1
| [root@compute0 ~]# ifup eth3
|
再次审查 br-eth3 的配置。
1
2
3
4
5
6
7
8
9
10
| [root@compute0 ~]# ovs-vsctl show
.. output omitted...
Bridge "br-eth3"
fail_mode: standalone
Port "eth3"
Interface "eth3"
Port "br-eth3"
Interface "br-eth3"
type: internal
.. Output omitted...
|
现在输出中已出现 eth3,将其 ONBOOT 设为 yes。
1
2
3
4
| # This file is autogenerated by os-net-config
DEVICE=eth3
ONBOOT=yes
... Output omitted...
|
操作界面、表格与配置图
使用 ping 命令重新测试 finance-server1 和 utility 之间的通信。
1
2
3
4
5
6
7
8
| [root@finance-server1 ~]# ping -c3 10.0.104.1
PING 10.0.104.1 (10.0.104.1) 56(84) bytes of data.
64 bytes from 10.0.104.1: icmp_seq=1 ttl=64 time=0.193 ms
64 bytes from 10.0.104.1: icmp_seq=2 ttl=64 time=0.228 ms
64 bytes from 10.0.104.1: icmp_seq=3 ttl=64 time=0.191 ms
--- 10.0.104.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = ©.191/0.204/0.228/0.017 ms
|
在 workstation 上运行 lab troubleshooting-services cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab troubleshooting-services cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:排查 OpenStack 故障#
排查 OpenStack 故障#
操作检查清单#
在此实验中,发现并修正 OpenStack 环境中的问题。解决认证、 网络、 计算节点和安全方面的问题。最后,启动一个实例,并确保一切正常运行。
学习目标#
完成后,能够:
排查 OpenStack 认证问题。
搜索日志,帮助判断问题性质。
排查 OpenStack 内部消息通信问题。
排查 OpenStack 网络问题。
开始之前#
以 student 用户登录 workstation,密码为 student。
从 workstation 运行 lab troubleshooting-review setup,检查 OpenStack 服务并准备实验资源。脚本也会故意破坏计算配置、认证和网络,以供排错。
1
| [student@workstation ~]$ lab troubleshooting-review setup
|
以 production 项目的 operator1 删除 production-rhel7 镜像,排查并修复遇到的问题。
加载 /home/student/architect1-production-rc,执行 lab troubleshooting-review break,准备下一部分实验。
1
2
| [student@workstation ~(operator1-production)]$ source ~/architect1-production-rc
[student@workstation ~(architect1-production)]$ lab troubleshooting-review break
|
加载 /home/student/operator1-production-rc,列出全部镜像,排查并修复问题。
使用下表的设置创建名为 production-web1 的新服务器实例。此动作将失败。故障排除并修正任何问题。
实例选项
操作界面、表格与配置图
| 选项 | 值 |
|---|
| –key-name | example-keypair |
| –network | production-networkl |
| group –security- | production-web |
创建浮动 IP 地址并将其指派给实例。解决故障并修正任何问题。
试图使用 SSH 登录到 production-web1。故障排除并解决任何问题。
创建 1 GB 的 production-volume1 并检查状态,使用 controller0 上 /home/heat-admin/overcloudrc 中的管理员凭据。
排查并修复所有问题。
在 workstation 上运行 lab troubleshooting-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab troubleshooting-review grade
|
在 workstation 上运行 lab troubleshooting-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab troubleshooting-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
排查 OpenStack 故障#
操作检查清单#
在此实验中,发现并修正 OpenStack 环境中的问题。解决认证、 网络、 计算节点和安全方面的问题。最后,启动一个实例,并确保一切正常运行。
学习目标#
完成后,能够:
排查 OpenStack 认证问题。
搜索日志,帮助判断问题性质。
排查 OpenStack 内部消息通信问题。
排查 OpenStack 网络问题。
e
开始之前#
以 student 用户登录 workstation,密码为 student。
从 workstation 运行 lab troubleshooting-review setup,检查 OpenStack 服务并准备实验资源。脚本也会故意破坏计算配置、认证和网络,以供排错。
1
| [student@workstation ~]$ lab troubleshooting-review setup
|
以 production 项目的 operator1 删除 production-rhel7 镜像,排查并修复遇到的问题。
加载 /home/student/operator1-production-rc。
1
| [student@workstation ~]$ source ~/operator1i-production-rce
|
删除 production-rhel7 镜像。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack image delete \
production-rhel7
Failed to delete image with name or ID '21b3b8ba-e28e-4b41-9150-ac5b44f9d8ef': 403
Forbidden
Image 21b3b8ba-e28e-4b41-9150-ac5b44f9d8ef is protected and cannot be deleted.
(HTTP 403)
Failed to delete 1 of 1 images.
|
您看到错误是因为镜像目前被保护。您需要取消镜像保护才能将其删除。
1
| [student@workstation ~(operator1-production)]$ openstack image set \
|
操作界面、表格与配置图
1
2
3
| --unprotected production-rhel7
[student@workstation ~(operator1-production)]$ openstack image delete \
production-rhel7
|
加载 /home/student/architect1-production-rc,执行 lab troubleshooting-review break,准备下一部分实验。
1
2
| [student@workstation ~(operator1-production)]$ source ~/architect1-production-rce
[student@workstation ~(architect1-production)]$ lab troubleshooting-review break
|
加载 /home/student/operator1-production-rc,列出全部镜像,排查并修复问题。
列出所有 OpenStack 镜像。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(architect1-production)]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$ openstack image list
Failed to discover available identity versions when contacting
http: //172.25.251.50:5000/v3. Attempting to parse version from URL.
Unable to establish connection to http: //172.25.251.50:5000/Vv3/
auth/tokens: HTTPConnectionPool(host='172.25.251.50', port=5000):
Max retries exceeded with url: /v3/auth/tokens (Caused by
NewConnectionError('<requests. packages.urllib3.connection.HTTPConnection object
at 0x7fbbbbc445d0>: Failed to establish a new connection: [Errno 111] Connection
refused',))
|
该错误说明 OpenStack 无法认证 operator1,可能是用户环境文件配置错误。登录 controller0,在 /var/lib/config-data/puppet-generated/haproxy/etc/haproxy/haproxy.cfg 中查找 listen keystone_public。第二个 IP 是环境文件应使用的地址,完成后退出。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(operator1-production)]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$ sudo cat \
/var/lib/config-data/puppet-generated/haproxy/etc/haproxy/haproxy.cfg
.. output omitted...
listen keystone_public
bind 172.24.1.50:5000 transparent
bind 172.25.250.50:5000 transparent
... Output omitted...
[heat-admin@controller0 ~]$ logout
[student@workstation ~(operator1i-production)]$
|
将 HAProxy 中的 IP 与环境文件的 OS_AUTH_URL 比较,必要时修正环境文件。
1
2
| .. Output omitted...
export OS_AUTH_URL=http://172.25.250.50: 5000/Vv3
|
操作界面、表格与配置图
重新加载 /home/student/operator1-production-rc,执行
openstack image list 命令以确保 OS_AUTH_URL 选项正确。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(operator1-production)]$ source ~/operator1-production-re
[student@workstation ~(operator1-production)]$ openstack image list
poe oe err errr er rep rer
| ID | Name | Status |
Peee er ee er Fe Fe Fe ee eV cP a et ee eer er ree Pore eer ere
| ec9473de-4048 -4ebb-be8a-a9be619477ac | octavia-amphora | active |
| 6b0128a9 -4481 -4ceb-b34e-ffe92e0dcfdd | rhel7 | active |
| 5f7f8208-33b5 -4f17-8297-588f938182co | rhel7-db | active |
| 14b7e8b2-7céd -4bcf-b159-1e4e7582107c | rhel7-web | active |
EeeS ee ee eee
|
使用下表的设置创建名为 production-web1 的新服务器实例。此动作将失败。故障排除并修正任何问题。
实例选项
| 选项 | 值 |
|---|
| –flavor | default |
| 镜像 | rhel7 |
| –key-name | example-keypair |
| -network | production-networkl |
| group –security- | production-web |
创建新服务器实例。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--key-name example-keypair \
--nic net-id=production-network1 \
--security-group production-web \
--image rhel7 --wait production-web1
Error creating server: production -web1
Error creating server
|
错误来自计算服务。先加载 /home/student/architect1-production-rc,再列出计算服务;operator1 没有直接管理计算服务的权限。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ source ~/architect1-production-re
[student@workstation ~(architect1-production)|]$ openstack compute service list \
-c Binary -c Host -c Status
Se RR a ee ar a ee
| Binary | Host | Status |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| eenre ohare Seon kare eae Sara nae eaeneseneko neKale aekane aekaneneKane aekaneacerca ae eon cnn kone
nova-conductor | controller0.overcloud.example.com | enabled |
nova-compute | compute1. overcloud.example. com | disabled
nova-compu te | computehci0.overcloud.example.com | enabled |
nova-compute | compute0. overcloud.example.com | disabled
nova-consoleauth | controller0.overcloud.example.com | enabled |
nova-scheduler | controller0.overcloud.example.com | enabled |
memes fenerme myme ame meme. ame mye mse. ane meejeer mm
|
启用 compute0 和 compute1 上的 nova-compute。
1
2
3
4
| [student@workstation ~(architect1-production)]$ openstack compute service set \
--enable compute0.overcloud.example.com nova-compute
[student@workstation ~(architect1-production)]$ openstack compute service set \
--enable compute1.overcloud.example.com nova-compute
|
验证 nova-compute 服务的状态。
1
2
3
| [student@workstation ~(architect1-production) ]$ openstack compute service list \
-c Binary -c Host -c Status
| |
|
|
1
2
3
4
| + + ce
| nova-conductor | |controller, overcloud.example. com
nova-compute | |compute1. overcloud.example.com
nova-compu te | computehci0. overcloud.example.com | enabled
|
| | | |
1
2
3
4
| nova -compu te | |compute0. overcloud.example. com
nova-consoleauth | |controller, overcloud.example. com
| controller0. overcloud.example. comnova-scheduler | |
+ +
|
加载 /home/student/operator1-production-rc,删除失败实例,再尝试重新创建。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(architect1-production)]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$ openstack server delete \
production-web1
[student@workstation ~(operator1-production)]$ openstack server list
[student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--key-name example-keypair \
--nic net-id=production-network1 \
--security-group production-web \
--image rhel7 --wait production-web1
|
创建浮动 IP 地址并将其指派给实例。解决故障并修正任何问题。
创建浮动 IP 地址。
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack floating ip create \
provider-datacentre
eeted ee a eR ete eG tote te tad een ated
| ID | Floating IP Address | Fixed IP Address | Port |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-web1 172.25.250.N
Unable to associate floating IP 172.25.250.N to fixed IP 192.168.0.6
for instance a53e66d9-6413-4ae4-b95b-2012dd52f908. Error: External
network 7aaf57c1-3c34-45df-94d3-dbc12754b22e is not reachable from subnet
cfc7ddfa-4403-41a7-878f-es679596eafd. Therefore, cannot associate Port
dcb6692d -0094-42ec-bc8e-ab2fd97d7a4c with a Floating IP.
Neutron server returns request_ids: ['req-4f88fb24-7628-4155 -a921-ff628cb4b371' |
(HTTP 400) (Request-ID: req-d6862c58-66c4-44b6-a4d1-bf26514bfo04b)
|
此错误消息发生的原因是外部网络没有连接到作为 production-network1 网络网关的路由器。
连接 production-router1 到 provider-datacentre 外部网络。
1
2
| [student@workstation ~(operator1-production)]$ openstack router set \
--external-gateway provider-datacentre production-router1
|
将浮动 IP 地址附加到实例中。验证此实例是否被指定为浮动 IP 地址。
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-web1 172.25.250.N
[student@workstation ~(operator1-production)]$ openstack server list \
-c Name -c Networks
|
试图使用 SSH 登录到 production-web1。故障排除并解决任何问题。
试图使用 SSH 登录到实例。
1
2
| [student@workstation ~(operator1-production)]$ ssh cloud-user@172.25.250.N
ssh: connect to host 172.25.250.N port 22: Connection timed out
|
找出该实例所使用的安全组,然后列出该安全组的规则。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(operator1-production)]$ openstack server show \
production-web1 -f json
.. output omitted...
"security_groups": "name='production-web'",
.. Output omitted...
[student@workstation ~(operator1-production)]$ openstack security group rule \
list production-web
4. Ome paaiPresnesore sea ctiecesnesoecbenescesneaotecesnescesnesosereseed
| ID | IP Protocol | IP Range | Port Range | Remote Security Group |
pee me ei ei eisai ere ef ee ee eee bie ee ie ee fee er ei ei ie eee eet
| cc92(...)95b1 | None | None | | None |
| eb84(...)c6e7 | None | None | | None |
|
操作界面、表格与配置图
注意:没有允许通过 SSH 访问实例的规则。
创建安全组规则允许 SSH 访问。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| [student@workstation ~(operator1-production)]$ openstack security group rule \
create --protocol tcp --dst-port 22:22 production-web
created_at 2017 -06-12T07: 24: 34Z
description
direction ingress
ethertype IPv4
headers
id 06070264 -1427 - 4679 -bd8e-e3a8f2e189e9
por t_range_max 22
port_range_min 22
project_id 9913a8abd192443¢c96587a8dc1cea364
project_id 9913a8abd192443c96587a8dc1c0a364
protocol tcp
remo te_group_id None
remote_ip_prefix 0.0.0.0/0
revision_number 1
security_group_id ac9ae6e6 -0056 -4501-afea-f83087b8297 fF
updated_at 2017 -@6-12TO7: 24: 34Z
|
试图再次登录此实例。
1
2
3
4
| [student@workstation ~(operator1-production)]$ ssh cloud-user@172.25.250.N
Warning: Permanently added '172.25.250.N' (ECDSA) to the list of Known hosts.
[cloud-user@production-web1 ~]$ logout
[student@workstation ~(operator1-production)]$
|
创建 1 GB 的 production-volume1,检查状态。使用 controller0 上 /home/heat-admin/overcloudrc 中的管理员凭据,排查并修复问题。
创建卷。
1
2
3
| [student@workstation ~(operator1-production)]$ openstack volume create \
--size 1 production-volume1
.. Output omitted...
|
确定 production-volume1 状态。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ openstack volume list
fan nn ene ee ee pe ee et te ee pee ee ee ee et
| ID | Display Name | Status | Size | Attached to |
Fae a ee a ee ener
| Odas(...)be3f | production-volume1 | creating | 1 | |
|
操作界面、表格与配置图
卷一直处于 creating。以 heat-admin 登录 controller0,检查块存储调度服务日志。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(operator1-production)]$ ssh heat-admin@controller0
[heat-admin@controller ~]$ sudo less \
/var/log/container s/cinder/cinder -scheduler . log
.. output omitted...
2018-11-16 61:57:52.112 1 ERROR oslo_service.service MessageDeliveryFailure:
Unable to connect to AMQP server on controller0o.
internalapi. overcloud.example.com:5672 after None tries: (0, 0): (403)
ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For
details see the broker logfile.
.. Output omitted...
|
上述重复错误表明,块存储调度服务无法向 RabbitMQ 进行身份认证。
检查块存储卷服务日志中的错误。
1
2
3
4
5
6
7
8
9
10
| (overcloud) [heat-admin@controller0 ~]$ sudo less \
/var/log/containers/cinder/cinder-volume. log
.. output omitted...
2018-11-16 01:00:47.170 194544 ERROR oslo_service.service
[req-2086d653-8982-40dc-9e75-7cObbage4774 - - - - -] Error starting
thread.: MessageDeliveryFailure: Unable to connect to AMQP server on
controller0.internalapi.overcloud.example.com:5672 after None tries: (6,
©): (403) ACCESS_REFUSED - Login was refused using authentication mechanism
AMQPLAIN. For details see the broker logfile.
.. output omitted...
|
上述错误表明,卷服务同样无法向 RabbitMQ 进行身份认证。
加载 /home/heat-admin/overcloudrc,查询卷服务状态。
1
2
3
4
5
6
7
8
9
| [heat-admin@controller0 ~]$ source ~/overcloudre
(overcloud) [heat-admin@controller0 ~]$ openstack volume service list \
-c Binary -c Host -c Status -c State
SR ee a at Be et
| Binary | Host | Status | State |
Beta Sei aeTeeNa eta aoenae etn eta eto ia Oot enhota erecta renee
| cinder-scheduler | controller0 | enabled | down |
| cinder -volume | hostgroup@tripleo_ceph | enabled | down |
Peeyare yee eryore eyepiece ee etyoesetyoresetyeen ay yore conet yet aoe oe onyoe meh yc ery ea
|
使用 docker exec 命令列出 RabbitMQ 用户。
1
2
3
| (overcloud) [heat-admin@controller0 ~]$ sudo docker exec -t \
rabbitmq-bundle-docker-9 rabbitmqctl list_users
Listing users
|
操作界面、表格与配置图
唯一的非管理员用户是 guest。检查块存储服务配置,找到 transport_url。
1
2
3
4
5
6
| (overcloud) [heat-admin@controller0 ~]$ sudo grep "transport_url \
/var/lib/config-data/puppet-generated/cinder/etc/cinder/cinder .conf
transport_url=rabbit: //change_me: V6VpJgBNvThefbnRyE3xx9sag@controller0.internalapi.
overcloud.example.com:5672/?ss1=0
transport_url=rabbit: //change_me: V6VpJgBNv ThefbnRyE3xx9sag@controller0.internalapi.
overcloud.example.com:5672/?ss1=0
|
URL 的用户部分设为 change_me, 不存在为 RabbitMQ 用户。
将两处 transport_url 中的用户名都改为 guest,重启 Pacemaker 资源 openstack-cinder-volume 和容器化服务 cinder_scheduler。
1
2
3
4
5
6
7
| (overcloud) [heat-admin@controller0 ~]$ sudo pcs resource restart \
openstack-cinder-volume
openstack-cinder-volume successfully restarted
(overcloud) [heat-admin@controller0 ~]$ sudo docker restart cinder_scheduler
cinder_scheduler
(overcloud) [heat-admin@controller0 ~]$ logout
[student@workstation ~(operator1-production)]$
|
在 workstation 上,请删除错误的卷并重新创建它。验证它是否正确创建。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| [student@workstation ~(operator1-production)]$ openstack volume delete \
production-volume1
[student@workstation ~(operator1-production)]$ openstack volume create \
--size 1 production-volume1
Se em eeem ementsnnn sn mn mm tm em semOh
| Field | Value |
BTN ee ae a SNe nF et Oe CN a a eNO en ee eT
| attachments | 0] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2017-06-14T08:08:01.726844 |
| description | None |
| encrypted | False |
| id | 128a9514-f8bd-4162-9f7e-72036f684cba |
| multiattach | False |
| name | production-volumet1 |
| properties |
| replication_status | disabled |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| type | None |
| updated_at | None |
|
操作界面、表格与配置图
1
| | user_id | 9Gac575bb96e24950a9551ac4cdao82a4 |
|
在 workstation 上运行 lab troubleshooting-review grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab troubleshooting-review grade
|
在 workstation 上运行 lab troubleshooting-review cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab troubleshooting-review cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 一次有效的故障记录应包含什么?
- 修复后最关键的验证是什么?
自测答案#
- 时间、身份作用域、动作、资源标识和错误。这些信息可以关联请求与多组件日志。
- 重现原失败动作并确认业务恢复。修复应由原问题消失及业务路径恢复来证明。
C10-综合复习#
综合任务一:构建自定义镜像#
先列出镜像必须包含的软件与配置,再区分构建阶段和首次启动阶段的职责。完成构建、上传和实例测试。验收时同时检查镜像属性、实例启动结果及客户机内部配置。
综合任务二:管理项目组织#
将身份来源、域、项目、用户或组和角色分配写成对应关系。完成配置后,使用目标用户验证其应有的权限和资源可见性。不要把管理员视角的成功作为普通用户权限正确的证据。
综合任务三:启动应用栈#
将模板、参数和依赖资源一起检查。创建 Stack 后查看事件和输出,验证应用是否真正可访问。若失败,先定位失败资源,回到相应章节的排错路径,修复后重新验证。
独立验收#
验收覆盖操作顺序、身份作用域、资源依赖和业务结果。完成后清理临时资源,保留模板、构建输入与验证记录。
| 验收问题 | 应提供的证据 |
|---|
| 镜像是否满足要求? | 构建输入、镜像属性和启动测试 |
| 授权是否符合目标? | 目标身份的认证与实际访问结果 |
| Stack 是否完成部署? | 资源状态、事件、输出与应用访问 |
| 排错过程是否可解释? | 假设、日志证据、修改和回归结果 |
| 实验能否重新开始? | 清理记录和保留下来的可复现配置 |
综合实验一:自定义镜像#
1
2
3
4
5
6
| 基础镜像 + elements + 软件源
→ 构建与离线定制
→ Glance 上传
→ 密钥、安全组与网络
→ 测试实例
→ 软件 / 服务 / 业务验证
|
FTP 服务验收包括配置与文件传输。验收不只看软件包存在,还需验证监听、目录、权限以及真正的文件传输。保留构建脚本与输入参数,才能复现镜像。
综合实验二:项目组织#
列出 Domain → 父项目 → 子项目 → 用户 / 组 → 角色的关系表;分别核对直接授权与继承授权。以目标用户重新认证,验证允许访问的项目和预期隔离范围。
综合实验三:应用栈#
检查镜像、Flavor、网络、用户角色、配额 → 编写环境文件 → 创建 Stack → 查看具体资源事件 → 挂载持久卷并准备数据库 → 导入数据与查询 → 验证应用访问。
综合验收表#
| 层次 | 需要保存的结果 |
|---|
| 构建输入 | 基础镜像、elements、软件源和定制脚本 |
| 身份 | 域、项目层级、用户组与有效角色 |
| 编排 | 模板、环境文件、资源 ID 与事件 |
| 存储 | 卷 ID、客户机设备、挂载点、数据内容 |
| 应用 | 服务运行、实际请求与数据库查询结果 |
| 清理 | 删除与保留对象清单、清理结果 |
看到错误先确定失败层次,再回到对应章节;不要通过扩大管理员权限、删除数据或反复重建来回避根因。
实验操作#
实验:构建自定义镜像#
构建自定义镜像#
操作检查清单#
本复习中,构建自定义镜像,并使用该镜像启动实例。
学习目标#
完成后,能够:
为启动实例做好准备。
构建定制镜像。
为访问实例创建 SSH 密钥对。
使用新镜像启动实例。
创建安全组规则,允许 FTP 往来于实例。
开始之前#
在开始以下练习前,您必须重置您的 workstation、 director 和 overcloud 虚拟机。这将销毁先前练习中存储在这些机器上的任何数据。如果您想要从实验环境中保存任何数据,在重设您的机器之前保存它。您必须重置实验环境中的所有机器,以便以下的练习如期运行。
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab image-cr setup,确保 OpenStack 服务正常运行,且实验环境配置正确。
1
| [studentworkstation ~]$ lab image-cr setup
|
操作说明
使用以下指令来制作带有定制的镜像,并利用定制镜像启动实例。
确认启动实例所需的用户、项目、网络、路由器、规格和安全组均已存在。architect1 和 developer1 用户的凭据分别存储在 /home/student/architect1-rc 与 /home/student/developer1-rc 中。
操作界面、表格与配置图
实验资源
| 资源类型 | 资源名称 |
|---|
| 项目 | marketing |
| 用户 | developeri, architect1 |
| 私有网络 | marketing-network1 |
| 路由器 | marketing-router1 |
| 规格 | marketing- flavor |
| 安全组 | marketing-secgroup |
将 /usr/share/diskimage-builder/elements 目录复制到 /home/student/ 下作为工作副本。
在 rhel7 元素的工作副本下创建 post-install.d 目录。
在 rhel7 元素的 post-install.d 阶段目录下创建两个脚本,启用 vsftpd 服务并配置匿名 FTP 用户向 FTP 服务器上传文件。
设置脚本上的可执行权限。
导出 disk-image-create 命令所需的环境变量,以成功构建自定义镜像。
构建包含 vsftpd 软件包的 marketing-rhel-ftp.qcow2 磁盘镜像。之前创建的脚本会自动集成。出现提示时,为 student 用户输入密码 student。
使用 guestfish 命令更新 marketing-rhel-ftp.qcow2 镜像中的 /etc/motd 文件,加入自定义消息。
- 以 OpenStack 用户 developer1 上传 marketing-rhel-ftp.qcow2 到镜像服务,名称为 marketing-rhel-ftp,最小磁盘要求为 10 GiB,最小内存要求为 2 GiB。
以 developer1 用户在 marketing 项目中创建名为 marketing-keypair 的 SSH 密钥对,将私钥保存到 /home/student/.ssh/marketing-keypair.pem。
为 marketing-ftp-server 实例关联可用的浮动 IP 地址。
在现有的 marketing-secgroup 安全组中添加新的安全组规则,允许 FTP 连接请求和数据传输到 marketing-ftp-server 实例。
验证实例中的 FTP 服务及配置的自定义每日消息。
操作界面、表格与配置图
在 workstation 上运行 lab image-cr grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
1
| [student@workstation ~(developer1-marketing)]$ lab image-cr grade
|
在 workstation 上运行 lab image-cr cleanup,清理本练习创建的资源。
1
| [student@workstation ~(developer1-marketing)]$ lab image-cr cleanup
|
本实验到此结束。
操作界面、表格与配置图
构建自定义镜像#
操作检查清单#
本复习中,构建自定义镜像,并使用该镜像启动实例。
学习目标#
完成后,能够:
为启动实例做好准备。
构建定制镜像。
为访问实例创建 SSH 密钥对。
使用新镜像启动实例。
为实例关联浮动 IP 地址。
创建安全组规则,允许 FTP 往来于实例。
开始之前#
在开始以下练习前,您必须重置您的 workstation、 director 和 overcloud 虚拟机。这将销毁先前练习中存储在这些机器上的任何数据。如果您想要从实验环境中保存任何数据,在重设您的机器之前保存它。您必须重置实验环境中的所有机器,以便以下的练习如期运行。
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab image-cr setup,确保 OpenStack 服务正常运行,且实验环境配置正确。
1
| [studentworkstation ~]$ lab image-cr setup
|
操作说明
使用以下指令来制作带有定制的镜像,并利用定制镜像启动实例。
确认启动实例所需的用户、项目、网络、路由器、规格和安全组均已存在。architect1 和 developer1 用户的凭据分别存储在 /home/student/architect1-rc 与 /home/student/developer1-rc 中。
操作界面、表格与配置图
实验资源
| 资源类型 | 资源名称 |
|---|
| 项目 | marketing |
| 用户 | developeri, architect1 |
| 私有网络 | marketing-network1 |
| 路由器 | marketing-router1 |
| 规格 | marketing-flavor |
| 安全组 | marketing-secgroup |
在 workstation 下载 http://materials.example.com/osp-small.qcow2 磁盘镜像,保存到 /home/student/。
将 /usr/share/diskimage-builder/elements 目录复制到 /home/student/ 下作为工作副本。
在 rhel7 元素的工作副本下创建 post-install.d 目录。
在 rhel7 元素的 post-install.d 阶段目录下创建两个脚本,启用 vsftpd 服务并配置匿名 FTP 用户向 FTP 服务器上传文件。
设置脚本上的可执行权限。
导出 disk-image-create 命令所需的环境变量,以成功构建自定义镜像。
构建包含 vsftpd 软件包的 marketing-rhel-ftp.qcow2 磁盘镜像。之前创建的脚本会自动集成。出现提示时,为 student 用户输入密码 student。
使用 guestfish 命令更新 marketing-rhel-ftp.qcow2 镜像中的 /etc/motd 文件,加入自定义消息。
以 OpenStack 用户 developer1 上传 marketing-rhel-ftp.qcow2 到镜像服务,名称为 marketing-rhel-ftp,最小磁盘要求为 10 GiB,最小内存要求为 2 GiB。
以 developer1 用户在 marketing 项目中创建名为 marketing-keypair 的 SSH 密钥对,将私钥保存到 /home/student/.ssh/marketing-keypair.pem。
为 marketing-ftp-server 实例关联可用的浮动 IP 地址。
在现有的 marketing-secgroup 安全组中添加新的安全组规则,允许 FTP 连接请求和数据传输到 marketing-ftp-server 实例。
验证实例中的 FTP 服务及配置的自定义每日消息。
确认存在启动该实例所需的用户、项目、网络、路由器、规格和安全组。
操作界面、表格与配置图
以 architect1 验证 developer1 的角色分配,用户域使用 Example。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ source architect1-marketing-rc
[student@workstation ~(architect1-marketing)]$ openstack role assignment list \
--name --user developer1 \
--user-domain Example
Se ee a eS ce iene
| Role | User | Group | Project | Domain | Inherited |
BeSCI CSCTMC ie IC (CSC SCN CSE HCI I Seig IC ICTe TICTI TICTICTSCTICTaleeT IC CeTelsne aCe eae SCT
| _member_ | developer1@Example | | marketing@Default | | False |
pateiereteiereteyere eerece eretereretereecetereteterete eres creer err erciaree Perc eerererere cepereerererererereh
|
上述输出表明,developer1 属于 marketing 项目,角色为 member。
以 developer1 确认 marketing-network1 网络存在。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(architect1-marketing)]$ source developer1-marketing-re
[student@workstation ~(developer1-marketing)]$ openstack network list
BRON MSC SC NCICig IC CNC Ie IC ICTS eT TC Ce
| ID | Name | Subnets |
Se ee ee ee ge eg gee
| 8fda...4666 | marketing-network1 | 5dc9...c143 |
| d55f...a220 | provider -storage | 6eba...1d11 |
| fc54...efb3 | provider-datacentre | 30c0...33f1 |
eses
|
确认 marketing-router1 路由器存在。
1
| [student@workstation ~(developer1-marketing)]$ openstack router list -c Name
|
核实marketing-flavor1的规格是否存在。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-marketing)]$ openstack flavor list -c Name
Se
| Name |
fesse eect
| default-extra-disk |
| default |
| default -swap |
| marketing-flavor |
|
确认 marketing-secgroup 安全组存在。
1
2
| [student@workstation ~(developer1-marketing)]$ openstack security group list \
-c Name
|
操作界面、表格与配置图
1
2
3
4
5
6
| BAe eae Set eg a aCee ea
| Name |
fen ne nee nee eee eet
| default |
| marketing-secgroup |
panneeeeeeeee eee et
|
在 workstation 下载 http://materials.example.com/osp-small.qcow2,保存到 /home/student/。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-marketing)]$ wget \
http://materials.example.com/osp-small. qcow2
--2018-11-22 08:40:58-- http://materials.example.com/osp-small.qcow2
Resolving materials.example.com (materials.example.com)... 172.25.254.254
Connecting to materials.example.com (materials.example.com)|]172.25.254.254|:80...
connected.
HTTP request sent, awaiting response... 200 OK
Length: 1632174080 (1.5G)
Saving to: 'osp-small.qcow2'
100% [ ====== $55 SSSSSS SSS SSS SSS 555555S55555==5====>] 1,632,174,080 40.5MB/s in 28s
2018-11-22 08:41:26 (55.6 MB/s) - 'osp-small.qcow2' saved [1632174080/1632174080|
|
创建要在 /home/student/. 下工作的 /usr/share/diskimage-builder/elements 目录副本
1
2
| [student@workstation ~(developer1-marketing)]$ cp -a \
/usr/share/diskimage-builder/elements /home/student/
|
在 rhel7 元素的工作副本下创建 post-install.d。
1
2
| [student@workstation ~(developer1-marketing)]$ mkdir -p \
/home/student/elements/rhel7/post-install.d
|
在 rhel7 元素的 post-install.d 阶段目录下创建两个脚本:启用 vsftpd,并允许匿名 FTP 用户上传文件。
创建第一个脚本 /home/student/elements/rhel7/post-install.d/01-enable-vsftpd,写入以下内容:
1
2
| #!/bin/bash
systemctl enable vsftpd
|
创建第二个脚本 /home/student/elements/rhel7/post-install.d/02-configure-vsftpd,写入以下内容:
1
2
3
4
5
| #!/bin/bash
# Enable upload access for the anonymous users
sed -i -e 's/.*anon_upload_enable=. */anon_upload_enable=YES/' \
/etc/vsftpd/vsftpd.conf
# Create upload directory
|
操作界面、表格与配置图
1
2
3
4
| mkdir /var/ftp/upload
# Adjust ownership and permissions
chgrp ftp /var/ftp/upload/
chmod gtw /var/ftp/upload/
|
切换到 /home/student 目录,并设置脚本上的可执行权限。
1
2
3
| [student@workstation post-install.d(developer1-marketing)]$ cd
[student@workstation ~(developer1-marketing)]$ chmod +x \
/home/student/elements/rhel7/post-install.d/*
|
导出diskimage-builder所要求的以下环境变量。
环境变量
| 变量 | 内容 |
|---|
| DIB_LOCAL_IMAGE | /home/student /osp-small.qcow2 |
| DIB_YUM_REPO_CONF | /etc/yum. repos.d/openstack.repo |
| ELEMENTS_PATH | /home/student /elements |
| DIB_NO_TMPFS | 1 |
1
2
3
4
5
6
7
| [student@workstation ~(developer1-marketing)]$ export \
DIB_LOCAL_IMAGE=/home/student/osp-small.qcow2
[student@workstation ~(developer1-marketing)]$ export \
DIB_YUM_REPO_CONF=/etc/yum. repos.d/openstack. repo
[student@workstation ~(developer1-marketing)]$ export \
ELEMENTS_PATH=/home/student/elements
[student@workstation ~]$ export DIB_NO_TMPFS=1
|
构建 marketing-rhel-ftp.qcow2,包含 vsftpd 软件包。先前创建的脚本会自动集成;出现提示时,输入 student 用户的密码 student。
1
2
3
4
5
| [student@workstation ~(developer1-marketing)]$ disk-image-create vm rhel7 \
-t qcow2 \
-p vsftpd \
-o marketing-rhel-ftp.qcow2
.. output omitted...
|
使用 guestfish 修改 marketing-rhel-ftp.qcow2 的 /etc/motd,加入自定义消息。
1
2
3
4
5
| [student@workstation ~(developer1-marketing)]$ guestfish -i -a \
~/marketing-rhel-ftp.qcow2
welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
Type: 'help' for help on commands
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| 'man' to read the manual
'quit' to quit the shell
Operating system: Red Hat Enterprise Linux Server 7.5 (Maipo)
/dev/sda1 mounted on /
><fs> write /etc/motd "Hello World"
><fs> cat /etc/motd
Hello world
><fs> selinux-relabel /etc/selinux/targeted/contexts/files/file_contexts /
><fs> exit
|
重要
上述 selinux-relabel 会递归设置根文件系统中正确的 SELinux 文件上下文。
以 developer1 将 marketing-rhel-ftp.qcow2 上传到镜像服务,命名为 marketing-rhel-ftp,要求最小磁盘 10 GiB、最小内存 2 GiB。
以 developer1 使用 openstack,将 marketing-rhel-ftp.qcow2 上传到镜像服务。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-marketing)]$ openstack image create \
--disk-format qcow2 \
--min-disk 10 \
--min-ram 2048 \
--file ~/marketing-rhel-ftp.qcow2 \
marketing-rhel-ftp
.. Output omitted...
|
以 developer1 在 marketing 项目创建 marketing-keypair SSH 密钥对,将私钥保存到 /home/student/.ssh/marketing-keypair.pem,并设置文件权限为 600。
1
2
3
4
| [student@workstation ~(developer1-marketing)]$ openstack keypair create \
marketing-keypair > /home/student/.ssh/marketing-keypair. pem
[student@workstation ~(developer1-marketing)]$ chmod 600 \
~/.ssh/marketing-keypair .pem
|
使用下列属性启动实例。使用 /home/student/cr1-user-data 文件定制 marketing-ftp-server 实例的 SELinux 设置。
实例属性
| 属性 | 值 |
|---|
| 规格 | marketing- flavor |
| 密钥对 | marketing-keypair |
| 网络 | marketing-network1 |
操作界面、表格与配置图
| 属性 | 值 |
|---|
| 镜像 | marketing-rhel-ftp |
| 安全组 | marketing-secgroup |
| 用户数据文件 | /home/student/cr1-user-data |
| 名称 | marketing-ftp-server |
1
2
3
4
5
6
7
8
9
| [student@workstation ~(developer1-marketing)]$ openstack server create \
--flavor marketing-flavor \
--key-name marketing-keypair \
--nic net-id=marketing-network1 \
--image marketing-rhel-ftp \
--security-group marketing-secgroup \
--user-data cri-user-data \
--wait marketing-ftp-server
.. Output omitted...
|
列出可用浮动 IP,将其中一个分配给 marketing-ftp-server。
列出可用的浮动 IP 地址。您系统中可用的浮动 IP 地址可能与下面显示的地址不同。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-marketing)]$ openstack floating ip list \
-c "Floating IP Address" -c Port
es eos eeeSeton ees atoneseyoeseensation
| Floating IP Address | Port |
Peace ee eee eee eee eee eee eet
| 172.25. 250.101 | None |
fe oot ete eo eet etereee emit eetett ete
|
将可用浮动 IP 关联到 marketing-ftp-server。
1
2
| [student@workstation ~(developer1-marketing)]$ openstack server add floating \
ip marketing-ftp-server 172.25.250.101
|
在现有的 marketing-secgroup 安全组中添加新的安全组规则,允许 FTP 连接请求和数据传输到 marketing-ftp-server 实例。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(developer1-marketing)]$ openstack security group \
rule create \
--dst-port 21:21 \
--protocol tcp \
market ing-secgroup
.. Output omitted...
[student@workstation ~(developer1-marketing)]$ openstack security group \
rule create \
--dst-port 20:20 \
--protocol tcp \
mar keting-secgroup
.. Output omitted...
|
操作界面、表格与配置图
如果镜像构建和定制成功,使用此镜像创建的实例将启动 FTP 服务,供匿名 FTP 用户上传文件。
使用 ftp 连接 marketing-ftp-server,以匿名用户 ftp 将 /home/student/developer1-marketing-rc 上传到 FTP 服务器。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| [student@workstation ~(developer1-marketing)]$ ftp -A 172.25.250.102
Connected to 172.25.250.101 (172.25.250.101).
220 (vsFTPd 3.0.2)
Name (172.25.250.101: student): ftp
331 Please specify the password.
Password: Enter
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd upload
250 Directory successfully changed.
ftp> pwd
257 "/upload"
ftp> put developer1-marketing-rc
local: developer1-marketing-rc remote: developer1-marketing-re
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
347 bytes sent in 3.9e-05 secs (8897.44 Kbytes/sec)
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-PW------- 1 14 50 347 Nov 22 12:34 developer1-marketing-rc
226 Directory send OK.
ftp> exit
221 Goodbye.
|
上述 ftp 的 -A 选项使客户端使用主动模式,而非被动模式。
校验实例的 /etc/motd 文件中的自定义消息。
1
2
3
4
5
| [student@workstation ~(developer1-marketing)]$ ssh -i \
~/.ssh/marketing-keypair .pem cloud-user@172.25.250.101
Last login: Thu Nov 22 12:12:57 2018 from workstation.lab.example.com
Hello world
[cloud-user@marketing-ftp-server ~]$
|
注意在成功 SSH 认证后出现的上一个输出中的自定义消息。
从 marketing-ftp-server 实例中注销。
1
| [cloud-user@marketing-ftp-server ~]$ logout
|
在 workstation 上运行 lab image-cr grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
操作界面、表格与配置图
1
| [student@workstation ~(developer1-marketing)]$ lab image-cr grade
|
在 workstation 上运行 lab image-cr cleanup,清理本练习创建的资源。
1
| [student@workstation ~(developer1-marketing)]$ lab image-cr cleanup
|
本实验到此结束。
操作界面、表格与配置图
实验:管理项目组织#
管理项目组织#
操作检查清单#
本复习中,在域内创建嵌套项目,并为身份服务认证的用户分配 OpenStack 角色。
学习目标#
完成后,能够:
创建域、项目和子项目。
创建用户并分配用户角色。
创建组并分配组角色。
开始之前#
在开始以下练习前,您必须重置您的 workstation、 director 和 overcloud 虚拟机。这将销毁先前练习中存储在这些机器上的任何数据。如果您想要从实验环境中保存任何数据,在重设您的机器之前保存它。您必须重置实验环境中的所有机器,以便以下的练习如期运行。
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab identity-cr setup,确保 OpenStack 服务正常运行,且实验环境配置正确。
1
| [studentworkstation ~]$ lab identity-cr setup
|
操作说明
按以下说明在域内设置嵌套项目,并为身份服务认证的用户分配 OpenStack 角色。
创建名为 Lab 的新域。
在 Lab 域创建名为 marketing 的项目。
在 marketing 项目中创建名为 development 的子项目。
在 Lab 域内创建 developers 和 admins 两个用户组。
为 Lab 域内的 developers 组分配 development 项目的 member 角色。
操作界面、表格与配置图
为 Lab 域内的 admins 组分配 development 项目的 admin 角色。
在 Lab 域内创建 operator1 和 architect1 两个用户,密码均设为 redhat。
将 operator1 用户添加到 Lab 域的 developers 用户组。
将 architect1 用户添加到 Lab 域的 admins 用户组。
为 Lab 域内的 operator1 用户分配该域内 marketing 项目的 member 角色。
为 Lab 域内的 architect1 用户分配该域内 marketing 项目的 admin 角色。
验证 operator1 和 architect1 在不同项目中获分配的角色。
在 workstation 上运行 lab identity-cr grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
1
| [student@workstation ~]$ lab identity-cr grade
|
在 workstation 上运行 lab identity-cr cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab identity-cr cleanup
|
本实验到此结束。
操作界面、表格与配置图
管理项目组织#
操作检查清单#
本复习中,在域内创建嵌套项目,并为身份服务认证的用户分配 OpenStack 角色。
学习目标#
完成后,能够:
创建域、项目和子项目。
创建用户并分配用户角色。
创建组并分配组角色。
识别域内用户获分配的角色。
开始之前#
在开始以下练习前,您必须重置您的 workstation、 director 和 overcloud 虚拟机。这将销毁先前练习中存储在这些机器上的任何数据。如果您想要从实验环境中保存任何数据,在重设您的机器之前保存它。您必须重置实验环境中的所有机器,以便以下的练习如期运行。
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab identity-cr setup,确保 OpenStack 服务正常运行,且实验环境配置正确。
1
| [studentworkstation ~]$ lab identity-cr setup
|
操作说明
按以下说明在域内设置嵌套项目,并为身份服务认证的用户分配 OpenStack 角色。
创建名为 Lab 的新域。
在 Lab 域创建名为 marketing 的项目。
.
在 marketing 项目中创建名为 development 的子项目。
在 Lab 域内创建 developers 和 admins 两个用户组。
为 Lab 域内的 developers 组分配 development 项目的 member 角色。
为 Lab 域内的 admins 组分配 development 项目的 admin 角色。
操作界面、表格与配置图
在 Lab 域内创建 operator1 和 architect1 两个用户,密码均设为 redhat。
将 operator1 用户添加到 Lab 域的 developers 用户组。
将 architect1 用户添加到 Lab 域的 admins 用户组。
为 Lab 域内的 operator1 用户分配该域内 marketing 项目的 member 角色。
为 Lab 域内的 architect1 用户分配该域内 marketing 项目的 admin 角色。
验证 operator1 和 architect1 在不同项目中获分配的角色。
在 workstation 加载 /home/student/admin-rc,创建 Lab 域。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$ openstack domain create Lab
eea er
| Field | Value |
Foon Lee es Ceccesyet(Ce t(Cevit(C et(Cnvt(Cevel(O vetCOneCeseCOsos r E
| description |
| enabled | True |
| id | f4b6864041e945dfab5af34592919c8a |
| name | Lab |
| tags | (] |
Foon CL es Cece (Ce (Cesta vCal(C(O veCee Cos eC
|
在 Lab 域内创建一个名为 marketing 的项目和一个名为 development 的子项目。
在 Lab 域内创建名为 marketing 的项目。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~]$ openstack project create marketing --domain Lab
SC oeIe Neere Ie Ie ee ee ee oe en Ke eC ee
| 'Field | Value |
SB aa a a gn a a a
| description | |
| domain_id | f4b6864041e945dfab5af34592919C8a |
| enabled | True |
| id | 5e2af53627d24004a218989be21262de |
| is_domain | False |
| name | marketing |
| parent_id | f4b6864041e945dfab5af34592919c8a |
| tags | C] |
a mae a Ta Yee ne Ve
|
在 Lab 域内创建名为 development 的子子项目,以 marketing 项目为父项。
1
2
| [student@workstation ~]$ openstack project create \
development --parent marketing --domain Lab
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| BAER a a SE ge SESE PSN NRO SE PN NF ea CO ET
| Field | Value |
Finn we en ep ne eet
| description | |
| domain_id | f4b6864041e945dfabb5af34592919c8a |
| enabled | True |
| id | dbdbfec36b164c6ab64376c2ae4c3C22 |
| is_domain | False |
| name | development |
| parent_id | 5e2af53627d24004a218989be21262de |
| tags | 0] |
Finn enn nn nn pn nn ee en ee en eet
|
在 Lab 域中创建 developers 和 admins 用户组,先创建 developers。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ openstack group create developers --domain Lab
tees se se sete eee eee eee eee eee eeeeee eet
| Field | Value |
Sete ee nee ee roe te et ere ee ke aoe eee ere one tne renee eons
| description | |
| domain_id | f4b6864041e945dfa55af34592919c8a |
| id | 6dfb18c4553144eabeefb7ca268c2432 |
| name | developers |
Feee ee eee
|
在 Lab 域中创建 admins 用户组。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ openstack group create admins --domain Lab
Se seme em ementsmn sm comOf
| Field | Value |
eee ee Se eee ee ee ee
| description | |
| domain_id | f4b6864041e945dfa55af34592919c8a |
| id | €856ac04b487473c8af240eb138cc124 |
| name | admins |
fen ne ee eet ee er ee ee ee et
|
为 Lab 域内的 developers 组分配该域 development 项目的 member 角色。
1
2
3
4
| [student@workstation ~]$ openstack role add \
--project development --project-domain Lab \
--group developers --group-domain Lab \
_member_
|
为 Lab 域中的 admins 组授予 development 项目的 admin 角色。
1
2
3
4
| [student@workstation ~]$ openstack role add \
--project development --project-domain Lab \
--group admins --group-domain Lab \
admin
|
操作界面、表格与配置图
在 Lab 域创建两个名为 operator1 和 architect1 的用户。设置两个用户的密码为 redhat。
在 Lab 域创建 operator1,密码设为 redhat。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~]$ openstack user create \
--domain Lab --password redhat operator1
SO a ea a sr eee eee ee ee 2
| -Eateld | Value |
Se ee ee a a ee
| domain_id | f4b6864041e945dfa55af34592919c8a |
| enabled | True |
| id | 88b7672f6ale4f47as43a6d39f2aec19 |
| name | operator |
| options | tt |
| password_expires_at | None |
Seee ee ee eee
|
在 Lab 域创建用户名为 architect1 的用户。设置用户密码为 redhat。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~]$ openstack user create \
--domain Lab --password redhat architect1
PE a a a eH
| Field | Value |
EP ce yas eens a cons oa eetedst nas ens a eonseyioaesentient cons eens hyenaseos spent sve
| domain_id | £4b6864041e945d fa55af34592919c8a |
| enabled | True |
| id | 557e0d11f6d14a4795bf9f78ide9cfdb |
| name | architect1 |
| options | tt |
| password_expires_at | None |
nn cee Ye a a Ye nm a Yee ree
|
在 Lab 域中,将 operator1 加入 developers,将 architect1 加入 admins。
将 Lab 域的 operator1 加入该域的 developers 组。
1
2
3
| [student@workstation ~]$ openstack group add user \
--group-domain Lab --user-domain Lab \
developers operator1
|
将 Lab 域的 architect1 加入该域的 admins 组。
1
2
3
| [student@workstation ~]$ openstack group add user \
--group-domain Lab --user-domain Lab \
admins architect1
|
为 operator1 授予 marketing 项目的 member 角色。
1
2
| [student@workstation ~]$ openstack role add \
--project marketing --project-domain Lab \
|
操作界面、表格与配置图
1
2
| --user operator1 --user-domain Lab \
_member_
|
将 marketing 项目的 admin 角色指定给 architect1 用户。
1
2
3
4
| [student@workstation ~]$ openstack role add \
--project marketing --project-domain Lab \
--user architect1 --user-domain Lab \
admin
|
核查 marketing 和 development 项目中 operator1 用户的角色分配。
验证 operator1 在 marketing 项目中的角色。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ openstack role assignment list \
--project marketing --project-domain Lab \
--user operator1 --user-domain Lab \
--names --effective
SON aN aS NTE a TE HEE CHES CATS KHER CO Ha RT HENCEN Cd ENCATS EE EENA ONAEN CATS EK ae OK aN TE NTE KIS
| Role | User | Group | Project | Domain | Inherited |
See eee Pace eee ce ce ee cP et et a et ee eee eee ee
| _member_ | operator1@Lab | | marketing@Lab | | False |
Ce en ee See eee eee See ee ein
|
验证 operator1 在 development 项目中的角色。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ openstack role assignment list \
--project development --project-domain Lab \
--user operator1 --user-domain Lab \
--names --effective
en.en ee. ee eee
| Role | User | Group | Project | Domain | Inherited |
eeee ee
| _member_ | operator1@Lab | | development@Lab | | False |
fw nn ne np pa ne ep nn nn pene ee etn ee et
|
登录到仪表板,以校验 architect1 用户的角色。
在 workstation 启动 Firefox,访问 http://dashboard.overcloud.example.com/。
为域输入 Lab, 为用户名输入 architect1, 为密码认证输入 redhat。
在登录到仪表板后,观察顶端导航菜单显示项目、管理员和身份标签。
从项目菜单中选择 development, 从 marketing 项目切换到 development 项目。注意上面的导航菜单显示项目、 管理员和身份标签。
退出 Dashboard。
在 workstation 上运行 lab identity-cr grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
操作界面、表格与配置图
1
| [student@workstation ~]$ lab identity-cr grade
|
在 workstation 上运行 lab identity-cr cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab identity-cr cleanup
|
本实验到此结束。
操作界面、表格与配置图
实验:启动应用栈#
启动应用栈#
操作检查清单#
本练习中,编写模板以启动应用栈。
学习目标#
完成后,能够:
修改简单的编排模板。
使用编排模板启动包含多个实例的应用栈。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab stack-cr setup。脚本将编排模板和环境文件下载到 /home/student/heat-templates 目录。
1
| [studentworkstation ~]$ lab stack-cr setup
|
操作说明
使用以下指令来制作带有定制的镜像,并利用定制镜像启动实例。
编辑 /home/student/.vimrc,写入以下内容以设置自动缩进。
编辑编排模板 /home/student/heat-templates/marketing-app1.yaml,启动由一个 Web 服务器实例和一个数据库服务器实例组成的应用栈。数据库实例使用持久卷作为数据库后端存储,持久卷也必须作为栈中的资源创建。Web 和数据库服务器分别使用 /home/student/heat-templates/webserver-cr3.sh 和 /home/student/heat-templates/dbserver-cr3.sh 作为 user-data 文件进行定制。编排栈必须允许重试一次 user-data 脚本;脚本成功执行后必须返回成功。webserver-cr3.sh 超时设为 600 秒,dbserver-cr3.sh 超时设为 800 秒,超过对应时间后脚本必须返回失败。
创建环境文件 /home/student/heat-templates/environment-cr3.yaml,填写 /home/student/heat-templates/marketing-app1.yaml 模板中定义的所有输入参数的值。
操作界面、表格与配置图
输入参数
| 资源类型 | 资源名称 |
|---|
| Web 服务器镜像 | rhel7-web |
| 数据库服务器镜像 | rhel7-db |
| Web 服务器名称 | marketing-web-servert |
| 数据库服务器名称 | marketing-db-server2 |
| 规格 | default |
| 密钥对名称 | marketing-keypair |
| 公共网络 | provider-datacentre |
| 私有网络 | marketing-network1 |
| 私有子网 | marketing-subnet1 |
以 developer1 凭据启动应用栈,并访问实例部署的网页进行验证。
在 workstation 上运行 lab stack-cr grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
1
| [student@workstation ~]$ lab stack-cr grade
|
在 workstation 上运行 lab stack-cr cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab stack-cr cleanup
|
本实验到此结束。
操作界面、表格与配置图
启动应用栈#
操作检查清单#
本练习中,编写模板以启动应用栈。
学习目标#
完成后,能够:
修改简单的编排模板。
使用编排模板启动包含多个实例的应用栈。
开始之前#
以 student 用户登录 workstation,密码为 student。
在 workstation 上运行 lab stack-cr setup。脚本将编排模板和环境文件下载到 /home/student/heat-templates 目录。
1
| [studentworkstation ~]$ lab stack-cr setup
|
操作说明
使用以下指令来制作带有定制的镜像,并利用定制镜像启动实例。
编辑 /home/student/.vimrc,写入以下内容以设置自动缩进。
编辑编排模板 /home/student/heat-templates/marketing-app1.yaml,启动由一个 Web 服务器实例和一个数据库服务器实例组成的应用栈。数据库实例使用持久卷作为数据库后端存储,持久卷也必须作为栈中的资源创建。Web 和数据库服务器分别使用 /home/student/heat-templates/webserver-cr3.sh 和 /home/student/heat-templates/dbserver-cr3.sh 作为 user-data 文件进行定制。编排栈必须允许重试一次 user-data 脚本;脚本成功执行后必须返回成功。webserver-cr3.sh 超时设为 600 秒,dbserver-cr3.sh 超时设为 800 秒,超过对应时间后脚本必须返回失败。
创建环境文件 /home/student/heat-templates/environment-cr3.yaml,填写 /home/student/heat-templates/marketing-app1.yaml 模板中定义的所有输入参数的值。
操作界面、表格与配置图
输入参数
| 资源类型 | 资源名称 |
|---|
| Web 服务器镜像 | rhel7-web |
| 数据库服务器镜像 | rhel7-db |
| Web 服务器名称 | marketing-web-servert |
| 数据库服务器名称 | marketing-db-server2 |
| 规格 | default |
| 密钥对名称 | marketing-keypair |
| 公共网络 | provider-datacentre |
| 私有网络 | marketing-network1 |
| 私有子网 | marketing-subnet1 |
以 developer1 用户的凭据启动应用栈,并访问实例部署的网页进行验证。
编辑 /home/student/.vimrc,写入以下内容以设置自动缩进:
1
| autocmd FileType yaml setlocal ai ts=2 sw=2 et
|
编辑 /home/student/heat-templates/marketing-app1.yaml,启动包含一个 Web 实例和一个数据库实例的应用栈。数据库使用持久卷作为后端,该卷也必须作为栈内资源创建。
编排模板必须包含以下内容:
web_server 资源定义部署与 MariaDB 数据库交互的 PHP 网页。使用 /home/student/heat-templates/webserver-cr3.sh 作为 user-data 脚本,在 marketing-web-server1 上部署指定的 PHP 网页。
db_server 资源定义部署 MariaDB 数据库。使用 /home/student/heat-templates/dbserver-cr3.sh 作为 user-data 脚本,在 marketing-db-server2 上部署指定的 MariaDB 数据库,并创建名为 mydb 的数据库。
使用 user_data 属性向 webserver-cr3.sh 脚本传递以下参数:
$web_public_ip 和 $web_private_ip 变量必须分别使用 finance-web 实例的外部和私人 IP 地址初始化。$db_private_ip 变量必须使用 finance-
db 实例。这些变量用于 webserver-cr3.sh 脚本。
操作界面、表格与配置图
编排栈必须允许重试一次 user-data 脚本;脚本成功执行后必须返回成功。webserver-cr3.sh 超时设为 600 秒,dbserver-cr3.sh 超时设为 800 秒,超过对应时间后脚本必须返回失败。
切换到 /home/student/heat-templates/。
1
2
| [studentworkstation ~]$ cd heat-templates
[studentworkstation heat-templates]$
|
编辑 /home/student/heat-templates/marketing-app1.yaml,使用 user_data 指定 webserver-cr3.sh,在 marketing-web 部署 PHP 网页。将 OS::Nova::Server 的 user_data_format 设为 RAW。
编辑后的 /home/student/heat-templates/marketing-app1.yaml 应包含下面突出显示的内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
| web_server:
type: OS: : Nova: :Server
properties:
name: { get_param: web_instance_name }
image: { get_param: web_image_name }
flavor: { get_param: instance_flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: web_net_port }
user_data_format: RAW
user_data:
str_replace:
template: { get_file: /home/student/heat-templates/webserver-cr3.sh }
|
网页使用作为参数传入的 $web_private_ip、$db_private_ip 和 $web_public_ip 变量。这些参数通过 str_replace 内置函数的 params 属性定义。
$web_private_ip 使用 web_net_port 的 fixed_ips 获取 web_server 的第一个 IP;$db_private_ip 使用 db_net_port 的 fixed_ips 获取 db_server 的第一个 IP;$web_public_ip 使用 web_floating_ip 的 floating_ip_address 设置 web_server 的公共 IP。
编辑 /home/student /heat-templates/marketing-app1.yaml 文件并添加以下重点内容:
1
2
3
4
5
6
7
8
| web_server:
type: OS: : Nova::Server
properties:
name: { get_param: instance_name }
image: { get_param: image_name }
flavor: { get_param: instance_flavor }
key_name: { get_param: key_name }
networks:
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| - port: { get_resource: web_net_port }
user_data_format: RAW
user_data:
str_replace:
template: { get_file: /home/student/heat-templates/webserver-cr3.sh }
params:
$web_private_ip: {get_attr: [web_net_port, fixed_ips,0, ip_address]}
$db_private_ip: {get_attr: [db_net_port,fixed_ips,0,ip_address]}
$web_public_ip: {get_attr: [web_floating_ip,floating_ip_address]}
|
使用等待条件句柄资源发送 user-data 脚本执行状态信号。
通过 web_wait_handle 的 curl_cli 属性,将等待句柄 URL 赋给
$wc_notify。若网页可访问(HTTP 200),返回 SUCCESS;WaitConditionHandle 发出 SUCCESS 时,web_server 标记为 CREATE_COMPLETE。
若网页不可访问或超过 600 秒,WaitConditionHandle 返回 FAILURE,web_server 标记为 CREATE_FAILED。
编辑 /home/student /heat-templates/marketing-app1.yaml 文件并添加以下重点内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| web_server:
type: OS: : Nova: :Server
properties:
name: { get_param: instance_name }
image: { get_param: image_name }
flavor: { get_param: instance_flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: web_net_port }
user_data_format: RAW
user_data:
str_replace:
template: { get_file: /home/student/heat-templates/webserver-cr3.sh }
params:
$web_private_ip: {get_attr: [web_net_port, fixed_ips,0,ip_address]}
$db_private_ip: {get_attr: [db_net_port,fixed_ips,0,ip_address]}
$web_public_ip: {get_attr: [web_floating_ip,ip, floating_ip_address ]}
$wc_notify: {get_attr: [web_wait_handle,curl_cli]}
|
使用 user_data 指定 /home/student/heat-templates/dbserver-cr3.sh,在 finance-db 配置 MariaDB。将 OS::Nova::Server 的 user_data_format 设为 RAW。
使用等待条件句柄发送 user-data 状态信号。通过 db_wait_handle 的 curl_cli 属性,将等待句柄 URL 赋给 $wc_notify。
编辑 /home/student/heat-templates/marketing-app1.yaml,添加下面突出显示的内容:
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| type: OS: :Nova::Server
properties:
name: { get_param: db_instance_name }
image: { get_param: db_image_name }
flavor: { get_param: instance_flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: web_net_port }
user_data_format: RAW
user_data:
str_replace:
template: { get_file: /home/student/heat-templates/dbserver-cr3.sh }
params:
$db_wc_notify: {get_attr: [db_wait_handle, cur1_cli]}
|
新增 OS::Cinder::Volume 资源,为 marketing-db-server2 创建数据库持久卷。定义可用区、容量和挂载点参数。编辑 /home/student/heat-templates/marketing-app1.yaml,加入下面的卷资源及参数定义。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| parameters:
..,output omitted...
availability_zone:
type: string
description: The Availability Zone to launch the instance.
default: nova
volume_size:
type: number
description: Size of the volume to be created.
default: 1
volume_mountpoint:
type: string
description: The location where the volume is exposed on the instance.
default: /dev/vdb
resources:
.. output omitted...
cinder_volume:
type: OS::Cinder::Volume
properties:
size: { get_param: volume_size }
availability_zone: { get_param: availability_zone }
cinder_volume_attachment:
type: OS::Cinder: :VolumeAt tachment
properties:
volume_id: { get_resource: cinder_volume }
instance_uuid: { get_resource: db_server }
mountpoint: { get_param: volume_mountpoint }
|
也可下载已经准备好的模板:http://materials.example.com/heat/marketing-app1-final.yaml。
操作界面、表格与配置图
3. 创建环境文件 /home/student/heat-templates/environment-cr3.yaml,
输入 /home/student /heat-templates/marketing-app1.yaml 模板文件中定义的所有输入参数的值。
创建 /home/student/heat-templates/environment-cr3.yaml,写入以下内容:
1
2
3
4
5
6
7
8
9
10
| parameters:
web_image_name: rhel7-web
db_image_name: rhel7-db
web_instance_name: marketing-web-server1
db_instance_name: marketing-db-server2
instance_flavor: default
key_name: marketing-keypair
public_net: provider -datacentre
private_net: marketing-network1
private_subnet: marketing-subnet1
|
以 developer1 凭据启动应用栈,再访问部署的网页进行验证。
以 developer1 试运行部署,检查将创建的资源,并修正全部错误后再继续。
使用 marketing-app1.yaml 和 environment-cr3.yaml 创建 marketing-app1 应用栈。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation heat-templates]$ source ~/developer1-marketing-re
[student@workstation heat-templates(developeri1-marketing)]$ openstack stack \
create \
--environment /home/student/heat-templates/environment-cr3.yaml \
--template /home/student/heat-templates/marketing-app1.yaml \
--dry-run -c description \
mar keting-app1
Peyote omer Breer a Spann oer omen an rc
| Field | Value |
eee
| description | multi-instance stack template |
fan nnn nn ee epee ee ee ee ee ee ee ee et
|
使用 marketing-app1.yaml 和 environment-cr3.yaml 启动 marketing-app1 应用栈。
试运行成功后执行 openstack stack create 正式启动,不要使用 –dry-run。
1
2
3
4
5
6
| [student@workstation heat-templates(developeri1-marketing)]$ openstack stack \
create \
--environment /home/student/heat-templates/environment-cr3.yaml \
--template /home/student/heat-templates/marketing-app1.yaml \
--wait \
market ing-app1
|
操作界面、表格与配置图
列出 marketing-app1 stack 返回的输出。
1
2
3
4
5
6
7
8
9
| [student@workstation heat-templates(developeri1-marketing)]$ openstack stack \
output list marketing-app1
eae ee ee eee eee ee ee ee ee eet
| output_key | description
Be a a a
| web_private_ip | Private IP address of the web server |
| web_public_ip | External IP address of the web server |
| website_url | This URL is the "external" URL that can be used |
| | to access the web server. |
|
| |
1
| db_private_ip | Private IP address of the DB server
|
检查 website_url 输出;output_value 中的 IP 地址可能不同。
1
2
3
4
| [student@workstation heat-templates(developer1-marketing)]$ openstack stack \
output show marketing-app1 website_url
| description This URL is the "external" URL that can be
used to access the web server.
|
|
1
2
3
4
| | |
| |
| output_key | website_url
| output_value | http://172.25.250.105/ index. php
|
访问 website_url 输出所返回的 URL,验证多层应用栈已创建,且两个实例上的 user-data 脚本均已成功执行。
访问 marketing-db-server2,配置 mariadb 服务,将容量为 1 GB 的持久块存储卷 vdb 用于数据库数据目录。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation heat-templates(developer1-marketing)]$ openstack server \
list -c Name -c Networks
Sf eee ee ce See eh eS eee fe eee eS eee eee eS eee ele Se cee mich
| Name | Networks |
ee ase eee ee oe ee eee eee ee eee
| marketing-web-server1 | marketing-network1=192.168.1.10, 172.25.250.105 |
| marketing-db-server2 | marketing-network1=192.168.1.13, 172.25.250.102 |
Sf eee eeee ee eS ee eh ee Se eee mf ee eee Se eee eee eS eee eelenSee ce eh
[student@workstation heat-templates(developer1-marketing)]$ ssh \
-i ~/.ssh/marketing-keypair cloud-user@172 .25.250.102
[cloud-user@marketing-db-server2 ~]$ lsblk -fs
NAME FSTYPE LABEL UUID MOUNTPOINT
vda1 xfs 6bea2b7b -e6cc-4dba-ac79 -be6530d348f5 /
Lvda
vdb xfs 488eb97f -83d2 - 4067-8a4c -c79d35970044
[cloud-user@marketing-db-server2 ~]$ sudo mount \
/dev/vdb /var/1lib/mysql
|
操作界面、表格与配置图
1
2
3
4
5
6
| [cloud-user@marketing-db-server2 ~]$ sudo chcon \
-Rt mysqld_db_t /var/lib/mysql/
[cloud-user@marketing-db-server2 ~]$ sudo chown \
-R mysql:mysql /var/1lib/mysql/
[cloud-user@marketing-db-server2 ~]$ sudo systemctl \
restart mariadb.service
|
持久卷作为 marketing-app1 的资源创建。mysqld_db_t 上下文允许数据库服务访问 /var/lib/mysql。数据库以 mysql 用户运行,因此数据目录应属于 mysql 用户和 mysql 组。
在 marketing-db-server2 下载 http://materials.example.com/heat/scripts/test_db.dump 到 /home/cloud-user/,恢复到 MariaDB 的 test 数据库,确认新表 tbl_1 存在且包含一条记录。
1
2
3
4
| [cloud-user@marketing-db-server2 ~]$ curl -s -o test_db.dump \
http://materials.example.com/heat/scripts/test_db.dump
[cloud-user@marketing-db-server2 ~]$ mysql -u root test < test_db.dump
[cloud-user@marketing-db-server2 ~]$ mysql -u root test -e "select * from tbl_1;"
|
退出 marketing-db-server2。
1
2
| [cloud-user@marketing-db-server2 ~]$ logout
[student@workstation heat-templates(developer1-marketing)]$
|
在 workstation 上运行 lab stack-cr grade,检查本实验是否成功。修正报告的错误并重新执行,直至成功。
1
| [student@workstation ~]$ lab stack-cr grade
|
在 workstation 上运行 lab stack-cr cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab stack-cr cleanup
|
本实验到此结束。
操作界面、表格与配置图
操作界面、表格与配置图
自测问题#
- 综合实验验收应核对哪些内容?
- 为了让实验可以复现,应该保留什么?
自测答案#
- 比较顺序、作用域、资源依赖与验证方法。验收需要覆盖资源依赖与业务结果。
- 模板、参数、构建输入、操作证据和清理记录。可复现过程需要输入、执行证据和明确的环境起点。
命令索引#
| 要做的事 | 查阅章节 |
|---|
| 分清主机、容器与云上下文 | C1 |
| 消息、数据库与高可用 | C2 |
| IdM、域、继承、Fernet | C3 |
| 构建与定制镜像 | C4 |
| Ceph、卷、对象、共享文件 | C5 |
| OVN、Provider 网络、流量路径 | C6 |
| 调度、HCI、迁移与维护 | C7 |
| HOT 模板和应用栈 | C8 |
| 服务与网络排错 | C9 |
| 综合验收 | C10 |