本文根据 CL110 学习笔记整理,保留概念说明、命令示例、实验步骤与自测内容。
实验版本:RHOSP 13 / RHEL 7。命令、主机名、账户、路径与软件依赖按课程环境记录;阅读其他版本时需核对对应配置。文中引用的课程镜像、脚本和课件不随本文提供。
相关阅读:CL210 · 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 与关联关系:
操作与预期结果:
实际验证:
故障、证据与修复:
清理结果:
|
章节目录#
C1-初识实例启动#
实例资源依赖#
镜像提供操作系统内容;规格定义 vCPU、内存及磁盘参数;网络提供端口与地址;项目确定资源归属。Horizon 和统一 CLI 调用同一套服务,界面创建的实例也能从 CLI 查询。
| 问题 | 检查对象 | 实验中的证据 |
|---|
| 当前资源属于哪个项目? | 用户、项目、环境变量 | RC 文件及 OS_* 变量 |
| 实例采用什么配置? | 镜像、规格、网络 | server show、flavor show |
| 系统真的运行了吗? | 状态、控制台、启动日志 | ACTIVE、控制台登录、console log |
| 网络是否正常? | 地址、路由、DHCP | 实例内 ip route、ping |
身份环境文件#
source 在当前 shell 中加载 RC 文件,设置认证端点和用户、项目等变量。打开新终端不会自动继承之前终端里所有设置。切换身份后应重新确认用户和项目,避免管理员操作与普通用户操作混用。
名称与 UUID#
同一项目可以存在两个同名实例。实例名称不保证唯一。停止或删除对象前先查 UUID,核对状态和资源详情。示例中的 UUID 不是固定参数,不能直接套到自己的环境。
连通性判断#
未连接外部路由器时,可通过测试 DHCP 地址判断局部连通性,区分“本地网络已通”和“具备外部访问”。控制台可登录,也不等于 SSH 已经配置好。
实例启动的最小输入#
1
2
3
4
5
6
| 镜像 Image:装什么系统
规格 Flavor:分配多少计算资源
网络 Network:接入哪张网
项目 Project:资源算在谁名下
↓
Nova Server
|
命令行操作#
执行位置:workstation,加载目标项目用户 RC。示例使用 rhel7、default 和 finance-network1,先确认存在。
1
2
3
4
5
6
7
8
9
| openstack image list
openstack flavor list
openstack network list
openstack server create --image rhel7 --flavor default \
--nic net-id=finance-network1 --wait demo-server
openstack server list
openstack server show demo-server
openstack console url show demo-server
openstack console log show demo-server
|
--wait:等待创建操作完成,不能代替系统与应用检查。--nic net-id=…:指定网络;名称重复时使用网络 UUID。console url show:获取控制台入口,不依赖实例已经开放 SSH。- 同名实例存在时,后续
show / stop / delete 使用 UUID。
Horizon 与 CLI 操作对照#
- 在 Horizon 中选择项目,填写镜像、规格和网络。
- 用 CLI 找到同一个实例,比较 ID、Status、Networks。
- 从控制台观察启动,记录固定 IP。
- 执行停止、启动,再比较状态变化。最初没有外部路由时,不用公网可达性评价创建结果。
1
2
3
| openstack server stop <实例UUID>
openstack server show <实例UUID>
openstack server start <实例UUID>
|
实验操作#
引导练习:使用仪表板启动实例#
在此练习中,使用 OpenStack 仪表板启动一个实例。
学习目标#
完成后能够:
登录到仪表板。
利用仪表板发起一个实例。
验证实例正常运行。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。
在 workstation 上,使用 setup 参数运行 launch-instance 脚本。它为此项练习创建了所需的组件,如用户、 密码、 镜像和网络。
1
| [student@workstation ~]$ lab launch-instance setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
2. 以 developer1 作为用户名和 redhat 作为密码登录到仪表板。
3. 单击项目菜单以核实 finance 是当前项目。
4. 使用 default 规格、 rhel7 镜像和 finance-network1 网络启动一个名为 finance-server1 的实例。
4.1. 打开 Compute(计算)下的 Instances(实例)子选项卡。
4.2. 点击 Launch Instance(启动实例)。
4.3. 在详细选项卡中,输入 finance-server1 作为实例名称。
4.4. 在 Source 选项卡中选择 Select Boot Source > Image。
4.5. 在 Source 选项卡点击 rhel7 镜像同行的向上箭头,选用该镜像。在 Create New Volume 下选择 No。
4.6. 在 Flavor 标签上,单击同一行的向上箭头按钮来分配 default 规格。
4.7. 在网络标签上,如果 finance-network1 网络尚未分配,请单击与网络同行的向上箭头按钮来分配 finance-network1 网络。
操作界面、表格与配置图
4.8. 点击 Launch Instance,启动 finance-server1。
5. 等几秒钟,然后核实该实例在 Power State 列中的状态。该实例应该是 Running 状态。
6. 右键点击 finance-server1 链接,选择 Open Link in New Tab。在新标签页打开 Console,再点击 Click here to show only console。若出现证书错误,接受自签名证书。观察虚拟机启动过程(它可能已启动)。
7. 为校验设置,登录到 finance-server1 实例,以 redhat 为密码,作为 root 用户。
1
2
3
4
| small image
finance-server1 login: root
Password: redhat
[root@finance-server1 ~]#
|
8. 列出查找 gateway 服务器 IP 地址的路由表。
1
2
3
4
| [root@finance-server1 ~]# ip route show
default via 192.168.1.1 dev eth0 proto dhcp metric 100
169.254.169.254 via 192.168.1.2 dev eth0 proto dhcp metric 100
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.X metric 100
|
9. 验证能否从 finance-server1 访问网关服务器(上例中为 192.168.1.1)。
1
2
3
4
5
6
7
| [root@finance-server1 ~]# ping -c3 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
From 192.168.1.3: icmp_seq=1 Destination Host Unreachable
From 192.168.1.3: icmp_seq=2 Destination Host Unreachable
From 192.168.1.3: icmp_seq=3 Destination Host Unreachable
--- 192.168.1.1 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 1000ms
|
此时网络未连接外部路由器,因此没有有效网关,无法 ping 通 192.168.1.0/24 网络之外的地址。
10. 验证 finance-server1 能否访问 DHCP 服务器。本练习中 DHCP 服务器的 IP 地址为 192.168.1.2。
在实例控制台中,使用 ping 命令与 DHCP 服务器 DHCP 服务器的 IP 地址,192.168.1.2 来验证连接。
1
2
3
4
5
6
7
8
| [student@finance-server1 ~]$ ping -c3 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=63 time=0.642 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=63 time=0.457 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=63 time=0.596 ms
--- 192.168.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.457/0.565/0.642/0.078 ms
|
操作界面、表格与配置图
11. 关闭浏览器中的实例标签页。点击右上角 developer1 菜单,选择 Sign out,退出仪表板。
在 workstation 上运行 lab launch-instance cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab launch-instance cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:使用 OpenStack 统一命令行#
在此练习中,使用统一的 命令行 接口( CLI) 来列出和检查现有项目、 用户、 规格、 镜像和实例的细节。
学习目标#
你应能够说明身份服务环境文件的作用,并使用统一命令行接口。
开始之前#
以 student 登录 workstation,密码为 student。
在 workstation 上运行 lab instances-cli setup, 以确保 developer1-finance-rc 文件存在。脚本还创建 finance-server1 实例。
1
| [student@workstation ~]$ lab instances-cli setup
|
操作步骤#
1. 打开终端,检查 student 主目录下 developer1-finance-rc 环境文件中的凭据。用户名为 developer1,密码为 redhat,所属项目为 finance。身份服务端点的 IP 对应 Overcloud 节点 controller0 使用的负载均衡虚拟 IP。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~]$ cat developer1-finance-rc
...output omitted...
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_PASSWORD=redhat
export OS_PROJECT_DOMAIN_NAME=Default
export OS_PROJECT_NAME=finance
export OS_USERNAME=developer1
export OS_USER_DOMAIN_NAME=Default
...output omitted...
|
2. 使用 source 加载 developer1-finance-rc,取得 RHOSP 环境中相应的用户权限。这将设置 OS_* 环境变量,其中至少包含 developer1 的凭据和身份服务公共端点。
1
2
| [student@workstation ~]$ source developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
3. 确认 OS_* 变量已导出到 shell。OS_USERNAME 为 developer1,OS_PASSWORD 为 redhat,OS_PROJECT_NAME 为 finance,OS_AUTH_URL 为 http://172.25.250.50:5000/v3。该地址包含托管身份服务的 controller0 公共 IP、公共端点端口 5000,以及身份服务 API 版本 3.0。
操作界面、表格与配置图
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ env | grep OS_
...output omitted...
OS_PASSWORD=redhat
OS_AUTH_URL=http://172.25.250.50:5000/v3
OS_USERNAME=developer1
OS_PROJECT_NAME=finance
|
4. 使用 openstack help project show 命令来确定如何显示特定项目的细节。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack help project show
usage: openstack project show [-h] [-f {json,shell,table,value,yaml}]
[-c COLUMN] [--max-width <integer>]
[--fit-width] [--print-empty] [--noindent]
[--prefix PREFIX] [--domain <domain>]
[--parents] [--children]
<project>
Display project details
positional arguments:
<project> Project to display (name or ID)
...output omitted...
|
5. 收集关于 developer1 用户当前项目的更多信息,名为 finance。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~(developer1-finance)]$ openstack project show finance
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | finance |
| domain_id | default |
| enabled | True |
| id | 903ebb6e211a4bf093f8a7215784682e |
| is_domain | False |
| name | finance |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
|
6. 使用 openstack help user show 命令来确定如何显示特定用户账户的细节。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(developer1-finance)]$ openstack help user show
usage: openstack user show [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN]
[--max-width <integer>] [--fit-width]
[--print-empty] [--noindent] [--prefix PREFIX]
[--domain <domain>]
<user>
Display user details
positional arguments:
<user> User to display (name or ID)
...output omitted...
|
操作界面、表格与配置图
7. 列出 developer1 账户的详情。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~(developer1-finance)]$ openstack user show developer1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 903ebb6e211a4bf093f8a7215784682e |
| domain_id | default |
| email | developer1@lab.example.com |
| enabled | True |
| id | fc318aa670314cc08148c4828b71bdc2 |
| name | developer1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
|
8. 使用 openstack help flavor list 命令来确定如何显示所有可用的规格。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(developer1-finance)]$ openstack help flavor list
usage: openstack flavor list [-h] [-f {csv,json,table,value,yaml}] [-c COLUMN]
[--max-width <integer>] [--fit-width]
[--print-empty] [--noindent]
[--quote {all,minimal,none, numeric}]
[--sort-column SORT_COLUMN]
[--public | --private | --all] [--long]
[--marker <flavor-id>] [--limit <num-flavors>]
List flavors
...output omitted...
|
9. 使用 openstack flavor list 命令列出所有可用的规格。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack flavor list
--------------+---------+------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+-------------+---------+------+------+-----------+-------+-----------+
| 6586...fc13 | default | 2048 | 10 | 0 | 2 | True |
+-------------+---------+------+------+-----------+-------+-----------+
|
10. 使用 openstack flavor show default 命令来显示 default 规格的细节。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(developer1-finance)]$ openstack flavor show default
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| access_project_ids | None |
| disk | 10 |
| id | 6586868d-c5bb-4e09-b68f-392a755afc13 |
| name | default |
| os-flavor-access:is_public | True |
| properties | |
| ram | 2048 |
| rxtx_factor | 1.0 |
| swap | |
|
操作界面、表格与配置图
1
2
| | vcpus | 2 |
+----------------------------+--------------------------------------+
|
11. 使用 openstack image list 命令列出所有可用的镜像。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack image list
+--------------------------------------+-------+--------+
| ID | Name | Status |
+--------------------------------------+-------+--------+
| 6533cafe-7629-48ea-aef1-1efcc7a09913 | rhel7 | active |
+--------------------------------------+-------+--------+
|
12. 使用 openstack help server 命令来确定如何列出所有实例。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(developer1-finance)]$ openstack help server
Command "server" matches:
server add fixed ip
server add floating ip
server add security group
server add volume
server backup create
server create
server delete
server dump create
server group create
server group delete
server group list
server group show
server image create
server list
server lock
server migrate
server pause
server reboot
...output omitted...
|
13. 使用 openstack server list -f json 命令列出所有可用的实例。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server1",
"Image": "rhel7",
"ID": "d7fe0d57-2490-40f9-a5b4-0945332d1610",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.X"
}
]
|
14. 使用 openstack server show finance-server1 命令显示 finance-server1 实例的细节。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ openstack server show finance-server1
+-----------------------------+-----------------------------------------------+
| Field | Value |
+-----------------------------+-----------------------------------------------+
|
操作界面、表格与配置图
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
| | 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-06-01T07:45:26.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | finance-network1=192.168.1.X |
| config_drive | |
| created | 2018-06-01T07:45:07Z |
| flavor | default (6586868d-c5bb-4e09-b68f-392a755afc13)|
| hostId | 2e58...f2c0 |
| id | d7fe0d57-2490-40f9-a5b4-0945332d1610 |
| image | rhel7 (6533cafe-7629-48ea-aef1-1efcc7a09913) |
| key_name | None |
| name | finance-server1 |
| progress | 0 |
| project_id | 903ebb6e211a4bf093f8a7215784682e |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-01T07:45:26Z |
| user_id | fc318aa670314cc08148c4828b71bdc2 |
| volumes_attached | |
+-----------------------------+-----------------------------------------------+
|
在 workstation 上运行 lab instances-cli 脚本,使用 cleanup 参数来清理此项练习。
1
| [student@workstation ~]$ lab instances-cli cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:使用命令行启动实例#
在此练习中,使用 命令行 接口启动一个实例。
学习目标#
完成后能够:
验证启动实例所需的全部资源。
发起新的实例。
核实新实例使用正确的镜像和规格。
删去一个使用 ID 的示例。
停止、开始和删除一个使用其名称的实例。
连接实例控制台。
从实例 ping DHCP 服务器。
开始之前#
确保 workstation 和 Overcloud 虚拟机已启动。
如果尚未登录,使用 student 的密码将 workstation 登录为 student。
从 workstation 运行 lab launch-cli 脚本,并使用 setup 参数,该参数验证或创建此项练习所需的资源,包括用户、 密码、 镜像和启动实例的网络。
1
| [student@workstation ~]$ lab launch-cli setup
|
操作步骤#
1. 在命令行用 source 加载 /home/student/developer1-finance-rc。该环境文件设置身份服务认证端点,以及 OpenStack 统一 CLI 使用的用户名、密码、域和项目。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
2. 使用 openstack flavor list 命令列出所有可用的规格。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack flavor list
+-------------+---------+------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+-------------+---------+------+------+-----------+-------+-----------+
| 6586...fc13 | default | 2048 | 10 | 0 | 2 | True |
+-------------+---------+------+------+-----------+-------+-----------+
|
3. 使用 openstack image list 命令列出所有可用的镜像。
操作界面、表格与配置图
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 6533cafe-7629-48ea-aef1-1efcc7a09913 | rhel7 | active |
+--------------------------------------+-------+---------+
|
4. 使用带有镜像名称的 openstack image show 命令查看镜像的详细信息。
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
| [student@workstation ~(developer1-finance)]$ openstack image show rhel7
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | c4fdd1059af61b68ce342a6ed35cb357 |
| container_format | bare |
| created_at | 2018-06-01T07:38:17Z |
| disk_format | qcow2 |
| file | /v2/images/6533cafe-7629-48ea-aef1-1efcc7a09913/file |
| id | 6533cafe-7629-48ea-aef1-1efcc7a09913 |
| min_disk | 10 |
| min_ram | 2048 |
| name | rhel7 |
| owner | 903ebb6e211a4bf093f8a7215784682e |
| properties | direct_url='rbd://6e503d0c-635a-11e8-b2fc- |
| | 52540001fac8/images/6533cafe-7629-48ea- |
| | aef1-1efcc7a09913/snap', locations='[{u'url': u'rbd |
| | ://6e503d0c-635a-11e8-b2fc- |
| | 52540001fac8/images/6533cafe-7629-48ea- |
| | aef1-1efcc7a09913/snap', u'metadata': {}}]' |
| protected | True |
| schema | /v2/schemas/image |
| size | 844890112 |
| status | active |
| tags | |
| updated_at | 2018-06-01T07:38:17Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
|
5. 使用 openstack server list 命令来列出所有可用的实例。例如 IP 地址可能与输出不同。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server1",
"Image": "rhel7",
"ID": "62e92f09-e8e1-4e95-a555-00e8bac4fe94",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.X"
}
]
|
操作界面、表格与配置图
6. 创建一个与现有名称相同的新实例。使用 openstack server create 命令创建另一个 finance-server1 实例。使用 rhel7 镜像、 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
| [student@workstation ~(developer1-finance)]$ openstack server create --image rhel7 \
--flavor default --nic net-id=finance-network1 --wait finance-server1
+-----------------------------+-----------------------------------------------+
| Field | Value |
+-----------------------------+-----------------------------------------------+
| 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-06-01T11:55:51.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | finance-network1=192.168.1.Y |
| adminPass | FdP6Zc9Hz7Ks |
| config_drive | |
| created | 2018-06-01T11:55:39Z |
| flavor | default (6586868d-c5bb-4e09-b68f-392a755afc13)|
| hostId | f0df...635d |
| id | 89f48040-970c-434f-bb0f-6fc5abd6b2fb |
| image | rhel7 (6533cafe-7629-48ea-aef1-1efcc7a09913) |
| key_name | None |
| name | finance-server1 |
| progress | 0 |
| project_id | 903ebb6e211a4bf093f8a7215784682e |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-01T11:55:51Z |
| user_id | fc318aa670314cc08148c4828b71bdc2 |
| volumes_attached | |
+-----------------------------+-----------------------------------------------+
|
7. 使用 openstack server list 命令再次列出所有可用的实例。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server1",
"Image": "rhel7",
"ID": "62e92f09-e8e1-4e95-a555-00e8bac4fe94",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.X"
},
{
"Status": "ACTIVE",
"Name": "finance-server1",
"Image": "rhel7",
"ID": "89f48040-970c-434f-bb0f-6fc5abd6b2fb",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.Y"
}
]
|
操作界面、表格与配置图
现在存在两个同名实例。在简单的做法中,不推荐,但它是常见的 real-world 应用程序设计。因此,具体指定名称可能不够明确,使 OpenStack 无法理解命令指的是哪个实例。但是,以 ID 引用一个实例总是唯一的参考。
8. 记下原有运行实例的 ID,再使用 openstack server stop 和该 ID 停止它。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server stop \
62e92f09-e8e1-4e95-a555-00e8bac4fe94
|
9. 使用 openstack server list 命令再次列出所有可用的实例。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "SHUTOFF",
"Name": "finance-server1",
"Image": "rhel7",
"ID": "62e92f09-e8e1-4e95-a555-00e8bac4fe94",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.X"
},
{
"Status": "ACTIVE",
"Name": "finance-server1",
"Image": "rhel7",
"ID": "89f48040-970c-434f-bb0f-6fc5abd6b2fb",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.Y"
}
]
|
10. 使用带有 UUID 的 openstack server show 命令来验证新的和活跃的实例是否使用了正确的规格和镜像。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(developer1-finance)]$ openstack server show \
89f48040-970c-434f-bb0f-6fc5abd6b2fb
+-----------------------------+------------------------------------------------+
| Field | Value |
+-----------------------------+------------------------------------------------+
| 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-06-01T11:55:51.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | finance-network1=192.168.1.Y |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| | config_drive | |
| created | 2018-06-01T11:55:39Z |
| flavor | default (6586868d-c5bb-4e09-b68f-392a755afc13) |
| hostId | f0df...635d |
| id | 89f48040-970c-434f-bb0f-6fc5abd6b2fb |
| image | rhel7 (6533cafe-7629-48ea-aef1-1efcc7a09913) |
| key_name | None |
| name | finance-server1 |
| progress | 0 |
| project_id | 903ebb6e211a4bf093f8a7215784682e |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-01T11:55:51Z |
| user_id | fc318aa670314cc08148c4828b71bdc2 |
| volumes_attached | |
+-----------------------------+------------------------------------------------+
|
11. 删除名为 finance-server1 的现有实例。在上一个样本输出中,这是在 SHUTOFF 状态中的第一个实例。使用此实例的 UUID 的 openstack server delete 命令删除此实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
62e92f09-e8e1-4e95-a555-00e8bac4fe94
|
12. 使用 openstack server list 命令再次列出所有可用的实例。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server1",
"Image": "rhel7",
"ID": "89f48040-970c-434f-bb0f-6fc5abd6b2fb",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.Y"
}
]
|
13. 使用 openstack console log show 命令校验活动实例的日志。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack console log show \
finance-server1
...output omitted...
Red Hat Enterprise Linux Server 7.5 (Maipo)
Kernel 3.10.0-862.el7.x86_64 on an x86_64
small image
finance-server1 login:
|
14. 使用 openstack url show 显示实例控制台 URL。通过浏览器打开该 URL,可使用 VNC 控制台访问实例。
1
| [student@workstation ~(developer1-finance)]$ openstack console url show \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| finance-server1
+-------+----------------------------------------------------------------------+
| Field | Value |
+-------+----------------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=962dfd71-f047-43d3-89 |
| | a5-13cb88261eb9 |
+-------+----------------------------------------------------------------------+
|
15. 要查看控制台,请打开前一步与 Firefox 的 URL 链接。
16. 为校验实例配置,登录到 finance-server1 实例时,以 root 用户的密码 redhat 登录到 finance-server1。
1
2
3
4
| small image
finance-server1 login: root
Password: redhat
[root@finance-server1 ~]#
|
17. 使用 ping 命令从实例中到达 DHCP 服务器的 IP 地址。
1
2
3
4
5
6
7
8
| [root@finance-server1 ~]# ping -c3 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=63 time=0.642 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=63 time=0.457 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=63 time=0.596 ms
--- 192.168.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.457/0.565/0.642/0.078 ms
|
18. 返回到 workstation 终端和 stop 实例。使用带有实例名称的 openstack server stop 命令。
1
| [student@workstation ~(developer1-finance)]$ openstack server stop finance-server1
|
19. 删除现有的实例 finance-server1。用实例名称使用 openstack server delete 命令。
1
| [student@workstation ~(developer1-finance)]$ openstack server delete finance-server1
|
在 workstation 上运行 lab launch-cli cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab launch-cli cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:初识实例启动#
在此实验中,删除设置脚本创建的示例,启动一个实例,验证创建的示例使用了正确的镜像和规格,并验证实例正在运行中。您可以使用仪表板或 OpenStack 统一 CLI 执行本实验的任务。
学习目标#
完成后能够:
开始之前#
确保 workstation、director 和 Overcloud 虚拟机已启动。若尚未登录,以 student 登录 workstation,密码为 student。
从 workstation 运行 lab launch-lab setup 脚本,并使用 setup 参数,从而创建这项练习所需的组件,如用户、 项目、 镜像和启动实例的网络。
1
| [student@workstation ~]$ lab launch-lab setup
|
操作步骤#
1. 使用仪表板执行实验任务,在 workstation 上打开火狐,浏览到 http://dashboard.overcloud.example.com。
使用 workstation 上的 OpenStack 统一 CLI, 执行实验任务,打开终端。
2. 以 operator1 作为用户名和 redhat 作为密码登录到仪表板。
或者,使用 OpenStack 统一的 CLI, 加载命令行的 operator1 环境文件 /home/student/operator1-production-rc。
3. 删除名为 production-server2 的现有实例。
4. 使用 default 规格、 production-network1 网络和 rhel7 镜像启动一个名为 production-server1 的实例。
5. 连接到 production-server1 控制台。
6. 从 production-server1 控制台验证实例,并使用 ping 命令到达 DHCP 服务器。
在 workstation 上运行 lab launch-lab grade,检查本实验是否成功。
操作界面、表格与配置图
1
| [student@workstation ~]$ lab launch-lab grade
|
在 workstation 上运行 lab launch-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab launch-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
在此实验中,删除设置脚本创建的示例,启动一个实例,验证创建的示例使用了正确的镜像和规格,并验证实例正在运行中。您可以使用仪表板或 OpenStack 统一 CLI 执行本实验的任务。
学习目标#
完成后能够:
开始之前#
确保 workstation、director 和 Overcloud 虚拟机已启动。若尚未登录,以 student 登录 workstation,密码为 student。
从 workstation 运行 lab launch-lab setup 脚本,并使用 setup 参数,从而创建这项练习所需的组件,如用户、 项目、 镜像和启动实例的网络。
1
| [student@workstation ~]$ lab launch-lab setup
|
操作步骤#
1. 使用仪表板执行实验任务,在 workstation 上打开火狐,浏览到 http://dashboard.overcloud.example.com。
使用 workstation 上的 OpenStack 统一 CLI, 执行实验任务,打开终端。
2. 以 operator1 作为用户名和 redhat 作为密码登录到仪表板。
或者,使用 OpenStack 统一的 CLI, 加载命令行的 operator1 环境文件 /home/student/operator1-production-rc。
2.1. 输入用户名的 operator1 和密码的 redhat。
要使用命令行执行任务,请加载 operator1 环境文件。环境文件设置身份服务认证端点、 用户名、 密码、 域名和项目,供 OpenStack 统一 CLI 使用。
1
2
| [student@workstation ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$
|
3. 删除名为 production-server2 的现有实例。
3.1. 要使用仪表板执行此项任务,请在计算标签下导航到 Discents subtab。
3.2. 在子选项卡实例上,在 production-server2 行中,单击“动作”菜单。单击“删除”实例。
操作界面、表格与配置图
3.3. 单击删除实例确认。
3.4. 或者,使用 openstack server list 命令来列出所有可用的实例。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(operator1-production)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "production-server2",
"Image": "rhel7",
"ID": "302be439-5032-4a8d-a306-2cf7d1a6faff",
"Flavor": "default",
"Networks": "production-network1=192.168.1.Y"
}
]
|
3.5. 使用前一个步骤中名为 production-server2 或 ID 的 openstack server delete 命令删除实例。
1
2
| [student@workstation ~(operator1-production)]$ openstack server delete \
production-server2
|
4. 使用 default 规格、 production-network1 网络和 rhel7 镜像启动一个名为 production-server1 的实例。
4.1. 要使用仪表板执行此项任务,请在计算标签下导航到 Discents subtab。
4.2. 点击 Launch Instance(启动实例)。
4.3. 在详细选项卡中,输入 production-server1 作为实例名称。
4.4. 在 Source 选项卡中选择 Instance Boot Source > Image。
4.5. 在 Source 选项卡点击 rhel7 同行的向上箭头,选用该镜像。在 Create New Volume 下点击 No。
4.6. 在 Flavor 选项卡点击 default 同行的向上箭头,选用 default 规格。
4.7. 点击 Launch Instance,启动 production-server1。
4.8. 或者,使用 openstack server create 命令创建 production-server1 实例。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(operator1-production)]$ openstack server create \
--image rhel7 \
--flavor default \
--wait production-server1
+-----------------------------+-----------------------------------------------+
| Field | Value |
+-----------------------------+-----------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
|
操作界面、表格与配置图
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
| | OS-EXT-STS:power_state | Running |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2018-06-04T13:10:17.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | production-network1=192.168.1.X |
| adminPass | khdcFj44rQA4 |
| config_drive | |
| created | 2018-06-04T13:09:50Z |
| flavor | default (677cc5e4-fd40-4689-a49d-e8382403d609)|
| hostId | 5406...fce0 |
| id | 18f32508-7348-48d2-903a-58b95e8eea75 |
| image | rhel7 (30af028a-0aa0-424c-b57c-436c15c89c0e) |
| key_name | None |
| name | production-server1 |
| progress | 0 |
| project_id | d1d0a0f55d5e47c7a46f1a7e689a7544 |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-04T13:10:17Z |
| user_id | 620ad3829dcd4f31af7abde5d7571d6c |
| volumes_attached | |
+-----------------------------+-----------------------------------------------+
|
5. 连接到 production-server1 控制台。
5.1. 打开 Compute 下的 Instances 子选项卡。
5.2. Right-click production-server1 实例链接,并在新标签中选择打开链接。如果出现证书错误,请接受 自签名 证书。
5.3. 在新标签中,选择控制台标签,然后单击单击这里只显示控制台链接。注意虚拟机启动器( 它可能已经启动 )。
5.4. 或者,使用 openstack console url show 命令从 CLI 查看控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack console url show \
production-server1
+-------+-----------------------------------------------------------------+
| Field | Value |
+-------+-----------------------------------------------------------------+
| type | novnc |
| url | https://172.25.250.50:6080/vnc_auto.html?token=72f431(...)da10a |
+-------+-----------------------------------------------------------------+
|
5.5. 使用 Firefox 打开 URL 访问 VNC 实例控制台。
6. 从 production-server1 控制台验证实例,并使用 ping 命令到达 DHCP 服务器。
6.1. 要验证设置,请登录到 production-server1 实例,以 redhat 为密码,作为 root 用户。
1
| Red Hat Enterprise Linux Server 7.5 (Maipo)
|
操作界面、表格与配置图
1
2
3
4
5
| Kernel 3.10.0-862.el7.x86_64 on an x86_64
small image
production-server1 login: root
Password: redhat
[root@production-server1 ~]#
|
6.2. 从 production-server1 ping DHCP 服务器。
1
2
3
4
5
6
7
8
| [root@production-server1 ~]# ping -c3 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=63 time=0.642 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=63 time=0.457 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=63 time=0.596 ms
--- 192.168.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.457/0.565/0.642/0.078 ms
|
在 workstation 上运行 lab launch-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab launch-lab grade
|
在 workstation 上运行 lab launch-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab launch-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 同一项目中出现两个同名实例,删除前应如何定位?
- 实例能 ping DHCP 地址,但尚未连接外部路由器,说明什么?
自测答案#
- 核对 UUID 和详情。实例名称不保证唯一,UUID 用于明确定位。
- 只验证了局部连通性。本地连通并不等于具备外部路由。
C2-组织用户与资源#
用户、项目与角色#
用户是认证主体,项目是资源组织范围,角色决定某用户在某范围内的权限。创建用户、设置其默认项目与授予项目角色是不同动作,不能只完成其中一步就认定授权已经生效。
| 对象 | 用途 | 常见误判 |
|---|
| 用户 | 认证与账户启停 | 能看到用户不等于该用户已获项目角色 |
| 项目 | 资源归属与配额 | 资源名称相同不代表属于同一项目 |
| 角色 | 授权关系 | 用管理员测试通过,不能证明普通用户权限正确 |
| RC 文件 | 客户端认证上下文 | 改了用户密码却仍加载旧密码 |
启停账户与修改凭据#
禁用账户后,要退出已有仪表板会话,再用该用户尝试登录。改密码后同步更新 RC 文件中的 OS_PASSWORD。账户删除后,旧环境变量仍留在 shell 中,命令失败不意味着服务停止。
配额是多维限制#
实例数、vCPU 总数、RAM 等配额同时约束创建操作。即使实例数尚未用完,也可能因为 RAM 不足而失败。读错误信息中 requested、used 和 limit 的关系,再决定应调整哪个配额。
完成标准#
用普通用户验证授权,用管理员完成规定的管理动作;禁用时应登录失败,启用并更新凭据后应成功。删除项目或用户前先核对身份,避免使用仍指向已删除账户的 RC 文件继续验证。
身份关系图#
1
2
3
4
5
| Domain
├─ User / Group
└─ Project → 实例、网络、卷等资源
User 或 Group + Role + Project/Domain = 角色分配
|
认证回答“你是谁”;授权回答“在这个范围内可以做什么”。 默认项目只是身份属性,项目访问权限还需角色分配。
项目与用户管理#
执行位置:workstation,管理员 RC。示例角色名为 _member_;实际权限由服务策略决定。
1
2
3
4
5
6
7
8
| openstack domain list
openstack project create --domain Default demo-project
openstack user create --domain Default --password-prompt demo-user
openstack role list
openstack role add --project demo-project --user demo-user _member_
openstack role assignment list --user demo-user --names
openstack user set --disable demo-user
openstack user set --enable demo-user
|
配额的计算#
若剩余配额是 2 个实例、2 个 vCPU、2048 MiB RAM,则不能因为“还可以建 2 个实例”就创建两台各 2 vCPU / 2048 MiB 的实例。多个限制需要同时满足。
1
2
| openstack quota show demo-project
openstack quota set --instances 5 --cores 10 --ram 10240 demo-project
|
项目权限验证#
管理员创建对象与授权 → 目标用户加载自己的 RC → 请求 Token → 列出项目资源 → 创建允许的资源 → 禁用后重新登录测试 → 恢复账户。
错误码可作为入口:401 优先看认证与令牌;403 优先看角色和策略。仍需结合服务返回的具体原因,不只凭数字定性。
实验操作#
引导练习:管理项目#
在此练习中,使用仪表板和 OpenStack 统一 CLI 创建和删除项目。
学习目标#
完成后能够:
开始之前#
确保 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。运行 lab manage-projects setup,验证 OpenStack 环境并检查 admin 用户环境文件是否可用。
1
| [student@workstation ~]$ lab manage-projects setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
2. 以 admin 作为用户名和 redhat 作为密码登录到仪表板。
3. 使用仪表板使用默认项目配额创建 research 项目。
3.1. 导航到身份 > 项目并单击+Create 项目。
3.2. 在名称字段中输入 research, 在描述字段中输入 Research Project。保留选中的启用复选框。
单击创建项目,然后从仪表板上注销。
4. 在 workstation 作为用户 student 时,使用 OpenStack 统一 CLI 从命令行创建 sales 项目。使用 /home/student/admin-rc 环境文件访问 OpenStack 作为 admin 用户。
4.1. 在 workstation 上,从命令行中加载 admin 用户的身份环境文件以获取管理员权利。环境文件为 OpenStack 统一 CLI 设置了 OpenStack 身份认证端点、 用户名、 密码、 区域和项目。
1
2
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$
|
4.2. 创建 sales 项目。使用 Sales Project 作为描述。
1
| [student@workstation ~]$ openstack project create \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| --description "Sales Project" \
sales
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Sales Project |
| domain_id | default |
| enabled | True |
| id | a141c847e10448568f71d5091613b506 |
| is_domain | False |
| name | sales |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
|
5. 验证 sales 项目是否已创建。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ openstack project list
+----------------------------------+-----------+
| ID | Name |
+----------------------------------+-----------+
| 76c7203da79a423e9676711f4c880aa3 | sales |
| 6e47d5fd39c6444b959f08d2afbe4342 | research |
... output omitted ...
+----------------------------------+-----------+
|
6. 删除 sales 项目。
6.1. 使用命令行删除 sales 项目。
1
| [student@workstation ~]$ openstack project delete sales
|
6.2. 核实 sales 项目已被删除。
1
2
3
4
5
6
7
| [student@workstation ~]$ openstack project list
+----------------------------------+----------+
| ID | Name |
+----------------------------------+----------+
| 76c7203da79a423e9676711f4c880aa3 | research |
... output omitted ...
+----------------------------------+----------+
|
在 workstation 上运行 lab manage-projects cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab manage-projects cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理用户#
在此练习中,使用仪表板和 OpenStack 统一 CLI 管理用户账户。
学习目标#
完成后能够:
创建用户。
编辑用户账户。
项目增加用户。
删除用户账户。
启用和禁用用户账户。
核查创建的用户。
开始之前#
确保 workstation 和 Overcloud 虚拟机已启动。
使用密码 student 登录到 workstation 作为 student。在 workstation 机器上,使用 setup 参数执行 lab administer-users 脚本。实验脚本确保 finance 项目和 admin 用户的环境文件存在。
1
| [student@workstation ~]$ lab administer-users setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
2. 使用 admin 用户和 redhat 作为密码登录到仪表板。
3. 使用仪表板创建 developer2、 developer3 和 developer4 用户。设置这些用户账户的密码到 redhat。将用户添加到 finance 项目。
3.1. 导航到身份 > 用户,单击+Create 用户。
3.2. 在 User Name 输入 developer2;在 Password 和 Confirm Password 输入 redhat。Primary Project 选择 finance,Role 保持 member,并保持 Enabled 勾选。
单击创建用户。
3.3. 为 developer3 和 developer4 用户重复步骤。
4. 使用仪表板删除 developer3 用户账户。
4.1. 在用户标签上,选择 developer3 用户账户。单击删除用户,然后再次单击删除用户确认。
操作界面、表格与配置图
5. 禁用 developer4 用户账户,并校验用户无法登录到仪表板。
5.1. 在用户标签栏中,在“动作”栏下为“developer4”用户选择禁用用户。
5.2. 验证 developer4 用户无法登录到仪表板。
退出 admin 的仪表板会话,再尝试以 developer4 登录,密码为 redhat。此时 developer4 应无法登录。
6. 使用仪表板启用 developer4 用户账户。
6.1. 作为 admin 用户登录到仪表板。
6.2. 在“行动”栏下,导航到身份 > 用户,并为 developer4 用户选择启用用户。
7. 将 developer4 用户的密码改为 password。
7.1.
在“动作列”栏下,在“用户”标签上为“developer4”用户选择更改密码。
在对话框中,在密码和确认密码字段中输入 password,然后单击保存。
8. 验证 developer4 能以密码 password 登录仪表板。
8.1. 以 admin 用户身份退出。
以 developer4 登录仪表板,密码为 password。若账户已启用,登录应成功。
8.2. 退出 developer4 的仪表板会话。
9. 使用 OpenStack CLI 创建 developer5,作为 finance 项目的成员。密码设为 redhat,电子邮件地址为 user@workstation.lab.example.com。
9.1. 以 student 登录 workstation,用 source 加载 /home/student/admin-rc,取得 admin 权限。该文件设置 OpenStack CLI 使用的身份服务认证端点、用户名、密码、区域和项目。
1
2
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$
|
9.2. 创建 developer5 用户作为 finance 项目的成员。将 member 角色指派给 finance 项目的 developer5 用户。设置 redhat 的密码和 user@workstation.lab.example.com 的电子邮件地址。
1
2
| [student@workstation ~]$ openstack user create \
--project finance \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| --password redhat \
--email user@workstation.lab.example.com \
developer5
+---------------------+-------------------------------------+
| Field | Value |
+---------------------+-------------------------------------+
| default_project_id | 4848228431d44e3a9373fa0547f50bdb |
| domain_id | default |
| email | user@workstation.lab.example.com |
| enabled | True |
| id | 77c286549bf94507abebdc9ac5e00b6f |
| name | developer5 |
| options | {} |
| password_expires_at | None |
+---------------------+-------------------------------------+
|
9.3. 在 finance 项目中将 member 角色指派给 developer5 用户。
1
2
3
4
| [student@workstation ~]$ openstack role add \
--project finance \
--user developer5 \
_member_
|
9.4. 验证 developer5 用户是否已创建。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ openstack user list
+----------------------------------+-------------------------+
| ID | Name |
+----------------------------------+-------------------------+
... output omitted ...
| 77c286549bf94507abebdc9ac5e00b6f | developer5 |
... output omitted ...
+----------------------------------+-------------------------+
|
10. 为 developer5 用户创建 /home/student/developer5-finance-rc 环境文件。
10.1. 将现有的 /home/student/admin-rc 环境文件复制到 /home/student/developer5-finance-rc。
1
| [student@workstation ~]$ cp ~/admin-rc ~/developer5-finance-rc
|
10.2. 编辑 /home/student/developer5-finance-rc,按下方内容修改 OS_USERNAME、OS_PASSWORD、OS_PROJECT_NAME 和 PS1。
1
2
3
4
5
6
| export OS_USERNAME=developer5
export OS_PASSWORD=redhat
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export PS1='[\u@\h \W(developer5-finance)]\$ '
export OS_PROJECT_NAME=finance
...output omitted...
|
11. 使用 OpenStack CLI 禁用 developer5 用户账户。
操作界面、表格与配置图
11.1. 禁用 developer5 用户账户。
1
2
| [student@workstation ~]$ openstack user set \
--disable developer5
|
12. 验证 developer5 用户账户已禁用。
12.1. 用 source 加载 developer5 用户的 /home/student/developer5-finance-rc 环境文件。
1
2
| [student@workstation ~]$ source ~/developer5-finance-rc
[student@workstation ~(developer5-finance)]$
|
12.2. 运行openstack flavor list 命令。请注意回复中返回的消息。
1
2
3
| [student@workstation ~(developer5-finance)]$ openstack flavor list
The request you have made requires authentication. (HTTP 401) (Request-ID:
req-ab5de0a1-106b-4d20-898b-3a785e3c956a)
|
13. 使用 OpenStack CLI 启用 developer5,将密码改为 password,将电子邮件地址改为 student@workstation.lab.example.com。
13.1. 用 source 加载身份环境文件,取得 admin 管理权限。
1
| [student@workstation ~(developer5-finance)]$ source ~/admin-rc
|
13.2. 启用 developer5,将密码改为 password,电子邮件地址改为 student@workstation.lab.example.com。
1
2
3
4
| [student@workstation ~(developer5-finance)]$ openstack user set \
--password password \
--email student@workstation.lab.example.com \
--enable developer5
|
14. 验证是否启用了 developer5 用户账户,并使用密码设置进行认证。
14.1. 在 /home/student/developer5-finance-rc 环境文件中,将 OS_PASSWORD 变量值修改为 password。
1
2
3
4
5
6
| export OS_USERNAME=developer5
export OS_PASSWORD=password
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export PS1='[\u@\h \W(developer5-finance)]\$ '
export OS_PROJECT_NAME=finance
...output omitted...
|
操作界面、表格与配置图
14.2. 用 source 加载 developer5 的 /home/student/developer5-finance-rc 环境文件。
1
2
| [student@workstation ~(developer5-finance)]$ source ~/developer5-finance-rc
[student@workstation ~(developer5-finance)]$
|
14.3. 运行 openstack flavor list,确认账户已启用且认证正常。若没有可用规格,命令可能没有输出。
1
2
3
4
5
6
| [student@workstation ~(developer5-finance)]$ openstack flavor list
+-------------+---------+------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+-------------+---------+------+------+-----------+-------+-----------+
| 688d...b154 | default | 2048 | 10 | 0 | 2 | True |
+-------------+---------+------+------+-----------+-------+-----------+
|
15. 使用 OpenStack CLI 删除 developer5 用户账户。
15.1. 用 source 加载环境文件,取得 admin 管理权限。
1
2
| [student@workstation ~(developer5-finance)]$ source ~/admin-rc
[student@workstation ~(developer5-finance)]$
|
15.2. 删除 developer5 用户账户。
1
| [student@workstation ~(developer5-finance)]$ openstack user delete developer5
|
15.3. 验证该用户已被删除。
1
| [student@workstation ~(developer5-finance)]$ openstack user list
|
在 workstation 上运行 lab administer-users cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab administer-users cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:分配用户角色与权限#
在此练习中,使用仪表板和 OpenStack 统一 CLI 来为用户指定用户角色。
学习目标#
完成后能够:
开始之前#
确保 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。运行 lab assign-roles setup,确保 finance 项目存在。
1
| [student@workstation ~]$ lab assign-roles setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
2. 以 admin 作为用户名和 redhat 作为密码登录到仪表板。
3. 使用 admin 权限创建 architect1 用户。设置 architect1 用户的密码到 redhat , 并将用户添加到 finance 项目。
3.1. 导航到身份 > 用户,单击+Create 用户。
3.2. User Name 输入 architect1,Password 和 Confirm Password 输入 redhat;Primary Project 选择 finance,Role 选择 admin。保持 Enabled 勾选,点击 Create User。
4. 验证 architect1 用户是否拥有 admin 权限,方法是登录到仪表板上,创建一个名为 developer2 的用户。设置 developer2 用户的密码到 redhat , 并将用户添加到 finance 项目。
4.1. 退出 admin 的仪表板会话,再以 architect1 登录,密码为 redhat。
4.2. 导航到身份 > 用户,然后单击+Create 用户。
操作界面、表格与配置图
4.3. User Name 输入 developer2,Password 和 Confirm Password 输入 redhat;Primary Project 选择 finance,Role 保持 member,保持 Enabled 勾选。
单击创建用户。
因为 architect1 用户账户指定了 admin 用户角色,用户成功创建了 developer2 账户。
4.4. 退出仪表板。
5. 为 architect1 用户创建 /home/student/architect1-finance-rc 环境文件。
5.1. 在 workstation 上打开一个终端。复制包含 admin 认证参数的现有 /home/student/admin-rc 文件到 /home/student/architect1-finance-rc。
1
| [student@workstation ~]$ cp ~/admin-rc ~/architect1-finance-rc
|
5.2. 编辑 /home/student/architect1-finance-rc 文件,并修改 OS_USERNAME、OS_PASSWORD、OS_PROJECT_NAME 和 PS1 变量如下:
1
2
3
4
5
6
| export OS_USERNAME=architect1
export OS_PASSWORD=redhat
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export PS1='[\u@\h \W(architect1-finance)]\$ '
export OS_PROJECT_NAME=finance
...output omitted...
|
6. 用 source 加载 /home/student/architect1-finance-rc 环境文件。使用密码 redhat 创建 developer3 用户。将用户指派为 finance 项目。将 admin 用户角色指派为 developer3 用户。核查指定给 developer3 用户的角色。
6.1. 用 source 加载 architect1 用户的 /home/student/architect1-finance-rc 环境文件。
1
2
| [student@workstation ~]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
6.2. 创建用户 developer3, 密码为 redhat, 并使其成为 finance 项目的成员。
1
2
3
4
5
6
7
8
| [student@workstation ~(architect1-finance)]$ openstack user create \
--password redhat \
--project finance \
developer3
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 08e3ce2bdb0e46b8834663ba15294934 |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
| | domain_id | default |
| enabled | True |
| id | dcfe3c22da8a4dcfb0123b482a34c05a |
| name | developer3 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
|
6.3. 验证在 finance 项目中没有指定 developer3 用户的角色。命令输出不能返回任何值。
1
2
3
4
| [student@workstation ~(architect1-finance)]$ openstack role assignment list \
--user developer3 \
--project finance \
--names
|
6.4. 将 admin 用户角色指派给 developer3 用户。
1
2
3
4
| [student@workstation ~(architect1-finance)]$ openstack role add \
--project finance \
--user developer3 \
admin
|
6.5. 验证指定给 developer3 用户的用户角色。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(architect1-finance)]$ openstack role assignment list \
--user developer3 \
--project finance \
--names
+-------+--------------------+-------+-----------------+--------+-----------+
| Role | User | Group | Project | Domain | Inherited |
+-------+--------------------+-------+-----------------+--------+-----------+
| admin | developer3@Default | | finance@Default | | False |
+-------+--------------------+-------+-----------------+--------+-----------+
|
7. 为 developer3 用户创建 /home/student/developer3-finance-rc 环境文件。
7.1.
将包含 architect1 认证参数的现有 /home/student/architect1-finance-rc 文件复制到 /home/student/developer3-finance-rc。
1
2
| [student@workstation ~(architect1-finance)]$ cp ~/architect1-finance-rc \
~/developer3-finance-rc
|
7.2. 编辑 /home/student/developer3-finance-rc 文件,修改 OS_USERNAME、 OS_PASSWORD 和 PS1 变量如下:
1
2
3
4
5
| export OS_USERNAME=developer3
export OS_PASSWORD=redhat
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export PS1='[\u@\h \W(developer3-finance)]\$ '
export OS_PROJECT_NAME=finance
|
操作界面、表格与配置图
8. 用 source 加载 /home/student/developer3-finance-rc 环境文件,并删除 developer2 用户。
8.1. 用 source 加载 developer3 用户的 /home/student/developer3-finance-rc 环境文件。
1
2
| [student@workstation ~(architect1-finance)]$ source ~/developer3-finance-rc
[student@workstation ~(developer3-finance)]$
|
8.2. 删除 developer2 用户。
1
| [student@workstation ~(developer3-finance)]$ openstack user delete developer2
|
9. 删除 developer3 用户。验证用户已被删除。
9.1. 删除 developer3 用户。
1
| [student@workstation ~(developer3-finance)]$ openstack user delete developer3
|
9.2. 由于 developer3 用户已被删除,环境变量不足以验证一个有效的用户。试图列出 OpenStack 用户。
1
2
3
| [student@workstation ~(developer3-finance)]$ openstack user list
The request you have made requires authentication. (HTTP 401) (Request-
ID: req-1e50...b997)
|
9.3. 认证为有效用户。用 source 加载 admin 用户的 /home/student/admin-rc 环境文件。
1
2
| [student@workstation ~(developer3-finance)]$ source ~/admin-rc
[student@workstation ~(developer3-finance)]$
|
9.4. 核实 developer2 和 developer3 用户是否已被删除。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer3-finance)]$ openstack user list \
--project finance
+----------------------------------+------------+
| ID | Name |
+----------------------------------+------------+
| 11941ae6cecc495da6cfce31a0d6f7ed | architect1 |
...output omitted...
+----------------------------------+------------+
|
10. 删除 developer3 用户的环境文件。
1
| [student@workstation ~(developer3-finance)]$ rm -f ~/developer3-finance-rc
|
11. 校验 developer2 无法列出 finance 项目的用户。
操作界面、表格与配置图
11.1. 复制现有的 /home/student/architect1-finance-rc 环境文件到 /home/student/developer2-finance-rc。
1
2
| [student@workstation ~(developer3-finance)]$ cp ~/architect1-finance-rc \
~/developer2-finance-rc
|
11.2. 编辑 developer2-finance-rc 环境文件,修改 OS_USERNAME、 OS_PASSWORD 和 PS1 变量如下:
1
2
3
4
5
6
| export OS_USERNAME=developer2
export OS_PASSWORD=redhat
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export PS1='[\u@\h \W(developer2-finance)]\$ '
export OS_PROJECT_NAME=finance
...output omitted...
|
11.3. 运行 openstack user list 命令。
1
2
3
4
| [student@workstation ~(developer3-finance)]$ source ~/developer2-finance-rc
[student@workstation ~(developer2-finance)]$ openstack user list
The request you have made requires authentication. (HTTP 401) (Request-ID:
req-6867...d789)
|
在 workstation 上运行 lab assign-roles cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab assign-roles cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理配额#
在此练习中,使用仪表板和 OpenStack 统一 CLI 启动实例,设定、编辑和核查项目配额。
学习目标#
完成后能够:
· 通过启动实例核查项目定额。
开始之前#
确保 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。运行 lab manage-quotas setup。脚本确保 finance、research 项目,architect1、developer2 用户,default 规格、rhel7 镜像、finance-network1 私有网络和 architect1 环境文件存在。
1
| [student@workstation ~]$ lab manage-quotas setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
2. 以 architect1 作为用户名和 redhat 作为密码登录到仪表板。
3. 根据下表确定 research 项目的项目配额:
| 配额配置 | |
|---|
| 配额 | 2 个 VCPU、2 个实例、2048 MB RAM |
3.1. 导航到身份 > 项目。从 research 项目的“行动”栏下的列表中选择修改配额。
VCPUs 输入 2,Instances 输入 2,RAM (MB) 输入 2048。
3.2. 单击保存。
4. 验证 research 项目的 RAM 配额为 2048 MB。以 developer2 使用 default 规格尝试启动两个实例,参数见下表。
| 设置 | 第一个实例 | 第二个实例 |
|---|
| 实例名称 | research-server1 | research-server2 |
| 镜像 | rhel7 | rhel7 |
| 规格 | default | default |
操作界面、表格与配置图
| 设置 | 第一个实例 | 第二个实例 |
|---|
| 网络(私有) | research-network1 | research-network1 |
4.1. 退出并登录为 developer2 用户,密码为 redhat。
4.2. 导航至项目 > 计算 > 实例并单击启动实例。
4.3. 在详细选项卡中,请在实例名称字段中输入 research-server1。
在 Source 选项卡的 Select Boot Source 中选择 Image,将 Create New Volume 设为 No。点击向上箭头,选用 rhel7 镜像。
在 Flavor 选项卡点击向上箭头,选用 default 规格。
在“网络”标签中,确保 research-network1 网络得到分配。
4.4. 点击 Launch Instance,启动 research-server1。
4.5. 达到配额限制后,Launch Instance 按钮被禁用,并显示 Launch Instance (Quota exceeded)。此时无法启动 research-server2。
4.6. 退出仪表板。
5. 用 source 加载 /home/student/developer2-research-rc 环境文件,并使用 OpenStack CLI 启动 research-server2 实例。在启动此实例时使用下表的值 :
| 设置 | 值 |
|---|
| 实例名称 | research-server2 |
| 镜像 | rhel7 |
| 规格 | default |
| 网络(私有) | research-network1 |
5.1. 用 source 加载 developer2 用户的 /home/student/developer2-research-rc 环境文件。
1
2
| [student@workstation ~]$ source ~/developer2-research-rc
[student@workstation ~(developer2-research)]$
|
5.2. 使用上一个表格中的信息,从命令行启动 research-server2 实例。
1
2
3
4
5
6
7
| [student@workstation ~(developer2-research)]$ openstack server create \
--image rhel7 \
--flavor default \
--nic net-id=research-network1 \
--wait research-server2
Quota exceeded for cores, ram: Requested 2, 2048, but already used 2, 2048 of 2,
2048 cores, ram (HTTP 403) (Request-ID: req-7780...90cca)
|
由于 VCPUs 和 RAM 要求超过 research 项目的配额,该案例未能启动。
操作界面、表格与配置图
6. 用 source 加载 architect1 用户的环境文件,以启用管理员权限。编辑 research 项目的配额,将 VCPU 限制为 4 和 RAM 限制为 8192 MB。
6.1. 用 source 加载 architect1 用户的 /home/student/architect1-finance-rc 环境文件。
1
2
| [student@workstation ~(developer2-research)]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
6.2. 列出 research 项目目前的项目配额。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(architect1-finance)]$ openstack quota show research
+----------------------+----------------------------------+
| Field | Value |
+----------------------+----------------------------------+
...output omitted...
| cores | 2 |
...output omitted...
| ram | 2048 |
...output omitted...
+----------------------+----------------------------------+
|
6.3. 修改 research 项目的配额,将 VCPU 设为 4,将内存设为 8192 MB。
1
2
3
4
| [student@workstation ~(architect1-finance)]$ openstack quota set \
--cores 4 \
--ram 8192 \
research
|
6.4. 列出 research 项目的配额,以确认所作的修改。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(architect1-finance)]$ openstack quota show research
+----------------------+----------------------------------+
| Field | Value |
+----------------------+----------------------------------+
...output omitted...
| cores | 4 |
...output omitted...
| ram | 8192 |
...output omitted...
+----------------------+----------------------------------+
|
7. 验证新配额是否适合启动 research-server2 实例。使用 developer2 环境文件启动 research-server2 实例。
使用 rhel7 镜像、 default 规格和 research-network1 网络启动 research-server2 实例。
7.1.
用 source 加载 /home/student/developer2-research-rc 环境文件。
1
2
| [student@workstation ~(architect1-finance)]$ source ~/developer2-research-rc
[student@workstation ~(developer2-research)]$
|
操作界面、表格与配置图
7.2. 使用 rhel7 镜像、 default 规格和 research-network1 私有网络启动 research-server2 实例。
1
2
3
4
5
| [student@workstation ~(developer2-research)]$ openstack server create \
--image rhel7 \
--flavor default \
--nic net-id=research-network1 \
--wait research-server2
|
7.3. 验证 research-server2 实例已成功启动。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer2-research)]$ openstack server list \
-c Name -c Status
+------------------+--------+
| Name | Status |
+------------------+--------+
| research-server2 | ACTIVE |
| research-server1 | ACTIVE |
+------------------+--------+
|
8. 删除 research-server1 和 research-server2 实例。
1
2
3
4
| [student@workstation ~(developer2-research)]$ openstack server delete \
research-server1
[student@workstation ~(developer2-research)]$ openstack server delete \
research-server2
|
9. 使用 architect1 认证参数删除 developer2 用户和 research 项目。
1
2
3
| [student@workstation ~(developer1-finance)]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$ openstack user delete developer2
[student@workstation ~(architect1-finance)]$ openstack project delete research
|
10. 删除 developer2 用户的身份环境文件。
1
| [student@workstation ~(architect1-finance)]$ rm ~/developer2-research-rc
|
在 workstation 上运行 lab manage-quotas cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab manage-quotas cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:组织用户与资源#
在此实验中,管理一个项目及其用户,并为该项目设定配额。您可以使用仪表板或 OpenStack 统一 CLI 来完成这个实验的任务。
学习目标#
完成后能够:
· 创建、删除和在项目中添加用户。
开始之前#
确保启动 workstation 和 overcloud 的虚拟机。以 student 作为密码登录到 workstation 中。
在 workstation 上运行 lab resources-lab setup, 创建 production 和 marketing 项目。实验脚本还创建了 operator1 、 operator2 和 operator3 用户,并禁用 operator2 用户。
1
| [student@workstation ~]$ lab resources-lab setup
|
操作步骤#
1. 使用仪表板、打开 Firefox 和浏览到 http://dashboard.overcloud.example.com,执行 workstation 上的实验任务。
使用 OpenStack 统一的 CLI 执行 workstation 上的实验任务,打开终端会话。
2. 以 architect1 作为用户名和 redhat 作为密码登录到仪表板。
或者,使用 OpenStack 统一的 CLI, 源为 /home/student/architect1-production-rc 文件,包含 architect1 认证参数。
3. 创建名为 consulting 的项目。
4. 创建名为 operator4 的用户,密码为 redhat。operator4 用户必须是 consulting 项目中一个没有特权的成员。
5. 创建 architect2 用户,在 consulting 项目中授予 admin 角色。密码设为 redhat。
6. 设定 consulting 项目的项目配额,使项目具有 4 VCPUs、7500 MB RAM 和 4 实例。
7. 启用 operator2 用户。
8. 将 operator2 用户的电子邮件地址更改为 student@workstation.lab.example.com, 并将密码更改为 redhat。
操作界面、表格与配置图
9. 删除 operator3 用户账户。
10. 作为 architect1 用户,删除 marketing 项目并从仪表板上注销。
在 workstation 上运行 lab resources-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab resources-lab grade
|
在 workstation 上运行 lab resources-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab resources-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
在此实验中,管理一个项目及其用户,并为该项目设定配额。您可以使用仪表板或 OpenStack 统一 CLI 来完成这个实验的任务。
学习目标#
完成后能够:
· 创建、删除和在项目中添加用户。
开始之前#
确保启动 workstation 和 overcloud 的虚拟机。以 student 作为密码登录到 workstation 中。
在 workstation 上运行 lab resources-lab setup, 创建 production 和 marketing 项目。实验脚本还创建了 operator1 、 operator2 和 operator3 用户,并禁用 operator2 用户。
1
| [student@workstation ~]$ lab resources-lab setup
|
操作步骤#
1. 使用仪表板、打开 Firefox 和浏览到 http://dashboard.overcloud.example.com,执行 workstation 上的实验任务。
使用 OpenStack 统一的 CLI 执行 workstation 上的实验任务,打开终端会话。
2. 以 architect1 作为用户名和 redhat 作为密码登录到仪表板。
或者,使用 OpenStack 统一的 CLI, 源为 /home/student/architect1-production-rc 文件,包含 architect1 认证参数。
2.1. 对于仪表板,输入 architect1 作为用户名,redhat 作为仪表板上的密码。
2.2. 要从命令行执行任务,请用 source 加载包含 architect1 认证参数的 /home/student/architect1-production-rc 文件。文件为 OpenStack 命令行 客户端设置 OpenStack 身份认证端点、 用户名、 密码、 区域和项目。
1
2
| [student@workstation ~]$ source ~/architect1-production-rc
[student@workstation ~(architect1-production)]$
|
3. 创建名为 consulting 的项目。
3.1. 导航到身份 > 项目并单击+Create 项目。
操作界面、表格与配置图
在名称字段中输入 consulting, 在描述字段中输入 consulting。保留选中的启用复选框。单击创建项目。
3.2. 或者,从命令行创建 consulting 项目。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(architect1-production)]$ openstack project create \
--description consulting \
--enable consulting
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | consulting |
| domain_id | default |
| enabled | True |
| id | 744b3acea749493588ece8655b9ae477 |
| is_domain | False |
| name | consulting |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
|
4. 创建名为 operator4 的用户,密码为 redhat。operator4 用户必须是 consulting 项目中一个没有特权的成员。
4.1. 在身份标签上,选择用户标签并单击+Create 用户。
User Name 输入 operator4,Password 和 Confirm Password 输入 redhat。Primary Project 选择 consulting,Role 选择 member。保持 Enabled 勾选,点击 Create User。
4.2. 或者,从命令行创建 operator4 用户。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(architect1-production)]$ openstack user create \
--project consulting \
--password redhat \
operator4
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 744b3acea749493588ece8655b9ae477 |
| domain_id | default |
| enabled | True |
| id | 368e8a021ed54e02b8ec4e8687ab4cd1 |
| name | operator4 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
|
4.3. 将 member 角色指派给 operator4 用户。
1
2
3
4
| [student@workstation ~(architect1-production)]$ openstack role add \
--project consulting \
--user operator4 \
_member_
|
操作界面、表格与配置图
5. 创建 architect2 用户,在 consulting 项目中授予 admin 角色。密码设为 redhat。
5.1. 在用户标签中,单击“创建”用户。
User Name 输入 architect2,Password 和 Confirm Password 输入 redhat。Primary Project 选择 consulting,Role 选择 admin,并保持 Enabled 勾选。
单击创建用户。
5.2. 或者,使用命令行创建 architect2 用户作为 consulting 项目的成员。设置 redhat 作为用户的密码。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(architect1-production)]$ openstack user create \
--project consulting \
--password redhat \
architect2
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 744b3acea749493588ece8655b9ae477 |
| domain_id | default |
| enabled | True |
| id | 49a3becce0224487bf606f87af637c26 |
| name | architect2 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
|
5.3. 将 admin 角色指派给 architect2 用户。
1
2
3
4
| [student@workstation ~(architect1-production)]$ openstack role add \
--project consulting \
--user architect2 \
admin
|
6. 设定 consulting 项目的项目配额,使项目具有 4 VCPUs、7500 MB RAM 和 4 实例。
6.1. 导航到身份 > 项目选项卡。从 consulting 项目的动作列下列表中选择修改配额。
6.2. 将 VCPU 的配额值改为 4,例改为 4,RAM(MB)改为 7500,然后单击 Save。
6.3. 或者,在使用 OpenStackCLI 时,为 consulting 项目规定配额。
1
2
3
4
5
| [student@workstation ~(architect1-production)]$ openstack quota set \
--cores 4 \
--instances 4 \
--ram 7500 \
consulting
|
7. 启用 operator2 用户。
操作界面、表格与配置图
7.1.
导航到身份 > 用户。
在 operator2 的 Actions 列中选择 Enable User。
7.2. 或者,使用命令行启用 operator2 用户。
1
2
| [student@workstation ~(architect1-production)]$ openstack user set \
--enable operator2
|
8. 将 operator2 用户的电子邮件地址更改为 student@workstation.lab.example.com, 并将密码更改为 redhat。
8.1. 在用户标签上,为 operator2 用户在“动作列”中选择编辑。在电子邮件字段中输入 student@workstation.lab.example.com。单击“更新”用户。
更改 operator2 用户的密码。在动作栏下选择更改密码。为新密码输入 redhat 并单击保存。
8.2. 或者,使用命令行改变 operator2 用户的电子邮件地址和密码。
1
2
3
4
| [student@workstation ~(architect1-production)]$ openstack user set \
--email student@workstation.lab.example.com \
--password redhat \
operator2
|
9. 删除 operator3 用户账户。
9.1. 在用户标签上,选择 operator3 用户。单击删除用户。再次单击删除用户确认。
9.2. 要使用 OpenStack CLI 执行此步骤,请使用 openstack user delete 命令删除 operator3 用户。
1
| [student@workstation ~(architect1-production)]$ openstack user delete operator3
|
10. 作为 architect1 用户,删除 marketing 项目并从仪表板上注销。
10.1. 打开 Identity > Projects,选择 marketing 项目。在 Action 列点击 Delete Project,再次点击确认删除。
退出仪表板。
10.2. 也可以使用 OpenStack CLI 的 project delete 子命令删除 marketing 项目。
1
2
| [student@workstation ~(architect1-production)]$ openstack project delete \
marketing
|
操作界面、表格与配置图
在 workstation 上运行 lab resources-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab resources-lab grade
|
在 workstation 上运行 lab resources-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab resources-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 用户已创建,但无法访问指定项目,应优先检查什么?
- 实例数未达到上限,却出现 RAM quota exceeded,应如何判断?
自测答案#
- 项目角色分配和认证上下文。用户存在与拥有项目权限是不同条件。
- 检查已用 RAM、请求量和 RAM 上限。实例数、vCPU 和 RAM 是不同配额维度。
C3-理解云计算#
服务分工#
| 服务 | 主要职责 | 与实例的关系 |
|---|
| Keystone | 身份认证、授权和服务目录 | 决定用户能访问哪些服务与项目 |
| Glance | 镜像管理 | 提供启动所需镜像 |
| Nova | 计算调度和实例生命周期 | 协调计算节点创建、停止、删除实例 |
| Neutron | 网络、子网、路由、端口 | 提供实例网络连接 |
| Cinder | 持久块存储 | 创建和附加卷 |
| Swift | 对象存储 | 通过容器与对象组织文件 |
| Heat | 编排 | 按模板创建并关联多个资源 |
虚拟机与容器#
业务实例通常是计算节点承载的虚拟机;RHOSP 13 中的 OpenStack 控制服务又可能运行在容器内。openstack server list 查询云实例,docker ps 查询当前节点上的容器,两者对象不同。
查看服务状态#
在 controller0 上查看控制服务容器。先确认节点和权限,再用格式化输出缩小范围。不要把所有 Exited 容器都判成故障:初始化容器可能在完成任务后正常退出。应结合容器用途、退出情况和实际 API 响应判断。
云服务责任边界#
IaaS 由用户管理实例操作系统和应用;PaaS(Platform as a Service,平台即服务)进一步提供应用运行环境。平台类型决定基础设施、操作系统、运行时和应用的管理责任。
云服务与基础设施服务#
| 类型 | 组件 | 故障可能表现 |
|---|
| 认证与服务发现 | Keystone、Service Catalog、Endpoint | 无法认证或找到 API |
| API 与资源控制 | Nova、Neutron、Glance、Cinder | 对应资源操作失败 |
| 内部协作 | RabbitMQ | 请求已接受但后台任务停滞 |
| 持久状态 | MariaDB | 查询、更新状态或服务初始化异常 |
| 虚拟化执行 | nova-compute、libvirt、KVM | 实例创建与运行异常 |
查看服务目录#
1
2
3
4
5
| openstack service list
openstack endpoint list
openstack catalog list
openstack compute service list
openstack hypervisor list
|
前两项通常需要管理员权限。Service 表示服务类型,Endpoint 表示访问地址和 interface;目录有记录,不代表该地址当前可用。
查看容器化服务#
执行位置:controller0,具备 sudo 权限。
1
2
3
| sudo docker ps
sudo docker ps -a
sudo docker logs keystone
|
运行一次后退出的初始化容器与长期服务容器要区别判断。docker ps 显示当前节点,不能代表整个集群。
一次创建实例涉及什么#
认证 → Nova 接收请求 → 调度计算节点 → 准备镜像、网络及所需卷 → 计算节点启动虚拟机 → 异步更新状态。后端有部分资源已创建时,重试前应检查残留端口和卷。
实验操作#
引导练习:验证 OpenStack 服务#
在此练习中,探索使用命令查看状态信息并管理 Red Hat OpenStack 平台所使用的服务。
学习目标#
完成后能够:
显示已安装的 OpenStack 服务状态概览。
查看和控制启用 OpenStack 服务。
开始之前#
以 student 为密码登录到 workstation 时为 student。从 workstation 运行 lab verify-osp-services setup , 保证 OpenStack 服务正在运行。
1
| [student@workstation ~]$ lab verify-osp-services setup
|
操作步骤#
1. 从 workstation,打开终端,使用 SSH 进入 controller0。
1
2
| [student@workstation ~]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$
|
2. 使用 docker ps 命令列表运行中的容器在 controller0 节点上。
2.1. docker ps 命令需要 root 权限。使用 sudo -i 成为 root。
1
2
| [heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
2.2. 使用 docker ps 命令来列出 controller0 节点上的运行中服务。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| [root@controller0 ~]# docker ps
CONTAINER ID IMAGE
COMMAND CREATED STATUS
PORTS NAMES
...output omitted...
8bddfa6bad7e 172.25.249.200:8787/rhosp13-beta/openstack-neutron-dhcp-
agent:latest "kolla_start" 6 days ago Up 22 hours
(healthy) neutron_dhcp
ffea52e3683b 172.25.249.200:8787/rhosp13-beta/openstack-nova-api:latest
"kolla_start" 6 days ago Up 22 hours
nova_metadata
15dabb3a0e80 172.25.249.200:8787/rhosp13-beta/openstack-nova-api:latest
"kolla_start" 6 days ago Up 22 hours
(healthy) nova_api
ce408b6da970 172.25.249.200:8787/rhosp13-beta/openstack-glance-api:latest
"kolla_start" 6 days ago Up 22 hours
(healthy) glance_api
...output omitted...
|
2.3. 输出较难阅读。使用 docker ps 的 –format 选项选择显示列,并结合 grep 限制输出内容。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [root@controller0 ~]# docker ps --format="{{.Names}}" | grep swift
swift_proxy
swift_container_auditor
swift_object_expirer
swift_object_updater
swift_container_replicator
swift_account_auditor
swift_account_server
swift_object_replicator
swift_container_server
swift_rsync
swift_account_reaper
swift_account_replicator
swift_object_auditor
swift_object_server
swift_container_updater
|
2.4. 还有一些其他选项可以让 docker ps 命令的输出更容易读取。例如,使用 json 格式并将输出插入 jq , 或者用 GO 语言定义自定义格式。
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
| [root@controller0 ~]# docker ps --format '{{ json .}}' | jq .
...output omitted...
{
"Status": "Up 22 hours",
"Size": "0 B",
"RunningFor": "6 days",
"Ports": "",
"Networks": "host",
"Command": "\"kolla_start\"",
"CreatedAt": "2018-06-01 12:16:26 +0000 UTC",
"ID": "897056bbee32",
"Image": "172.25.249.200:8787/rhosp13-beta/openstack-horizon:latest",
"Labels": "summary=Red Hat OpenStack Platform 13.0 horizon,vendor=Red Hat,...
...
"Names": "horizon"
}
...output omitted...
[root@controller0 ~]# docker ps --format \
'CONTAINER ID: {{.ID}}
IMAGE: {{.Image}}
COMMAND: {{.Command}}
CREATED: {{.CreatedAt}}
STATUS: {{.Status}}
NAMES: {{.Names}}
'
CONTAINER ID: 0ede0883fdf1
IMAGE: 172.25.249.200:8787/rhosp13-beta/openstack-nova-scheduler:latest
COMMAND: "kolla_start"
CREATED: 2018-06-01 12:23:40 +0000 UTC
STATUS: Up 22 hours (healthy)
NAMES: nova_scheduler
...output omitted...
|
3. 使用 docker ps 命令来验证 OpenStack 服务的状况。
1
2
| [root@controller0 ~]# docker ps -a --format="{{.Names}}\t{{.Status}}"
ceph-mgr-controller0 Up 22 hours
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| nova_api_discover_hosts Exited (0) 6 days ago
cinder_volume_init_bundle Exited (0) 6 days ago
neutron_ovs_agent Up 22 hours (healthy)
neutron_l3_agent Up 22 hours (healthy)
neutron_metadata_agent Up 22 hours (healthy)
neutron_dhcp Up 22 hours (healthy)
nova_metadata Up 22 hours
nova_api Up 22 hours (healthy)
glance_api Up 22 hours (healthy)
swift_proxy Up 22 hours (healthy)
...output omitted...
|
状态为 Exited 的这些容器并非出错;它们是系统启动时执行、随后退出的初始化容器。
4. 使用 stop 和 start 选项的 docker 命令管理 swift_proxy 服务。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [root@controller0 ~]# docker ps -a --format="{{.Names}}\t{{.Status}}" \
| grep swift_proxy
swift_proxy Up 23 hours (healthy)
[root@controller0 ~]# docker stop swift_proxy
swift_proxy
[root@controller0 ~]# docker ps -a --format="{{.Names}}\t{{.Status}}" \
| grep swift_proxy
swift_proxy Exited (0) 53 seconds ago
[root@controller0 ~]# docker start swift_proxy
swift_proxy
[root@controller0 ~]# docker ps -a --format="{{.Names}}\t{{.Status}}" \
| grep swift_proxy
swift_proxy Up 22 seconds (health: starting)
|
5. 退出 controller0 虚拟机。
1
2
3
4
5
| [root@controller0 ~]# exit
logout
[heat-admin@controller0 ~]$ exit
logout
[student@workstation ~]$
|
在 workstation 上运行 lab verify-osp-services cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab verify-osp-services cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
自测问题#
- docker ps 与 openstack server list 查询的对象有什么区别?
- 实验中某个初始化容器为 Exited,能否直接判为故障?
自测答案#
- 前者是当前主机容器,后者是云实例。要区分承载服务的容器和业务虚拟机。
- 不能,应结合容器用途和退出情况。一次性初始化容器完成后可以退出。
C4-管理 Linux 网络#
三个观察层次#
| 层次 | 观察内容 | 典型工具 |
|---|
| 实例内部 | 接口、地址、路由、ARP | ip、ping、tcpdump |
| 计算节点 | 网桥和物理接口连接 | brctl、ovs-vsctl、ip |
| 云资源 | 网络、子网、端口归属 | OpenStack CLI |
在实例内部看到 eth0,与在 compute0 上看到 eth0,含义不同。抓包前写明主机、接口和预期方向;只看到请求没有回复时,继续检查路径与对端。
Linux 网桥与 OVS#
Linux 网桥通过接口转发以太网帧;Open vSwitch 提供由其数据库和工具管理的桥与端口。创建桥、加入端口、分配 IP、启用设备是不同动作,不能以某一步命令成功代替完整验证。
添加接口前后应检查桥的 MAC,不要把两种桥的默认行为混为一谈。
持久配置与临时配置#
ip、brctl 等即时命令适合验证当前状态;重启后的持久性取决于相应配置文件和管理服务。实验要求编辑 ifcfg 文件时,应核对设备名、协议与网关,再按步骤重启验证。
排错记录#
记录抓包开始时间、进程或作业号、输出文件及测试命令。停止抓包后再读取文件;比较 ping 前后的 ARP 表,观察地址解析是否发生。抓包结束后停止采集进程,删除不再需要的临时网络配置。
二层与三层#
- MAC / 网桥 / VLAN:解决二层帧怎样到达同一广播域内的目标。
- IP / 子网 / 路由:解决数据包怎样跨网段到达目标。
- ARP:IPv4 同网段下一跳 IP 到 MAC 的解析。
- 默认路由:没有更具体路由匹配时使用,不保证网关之外一定可达。
Linux 网络观测#
1
2
3
4
5
6
| ip -br address
ip link show
ip route
ip neigh
ping -c 3 <目标IP>
sudo tcpdump -nn -i <接口名> 'arp or icmp'
|
抓包顺序:先选对主机和接口,再发出测试流量,最后对照请求与响应。抓不到包先检查观测位置,不立即判定包被丢弃。
Linux Bridge 与 Open vSwitch#
1
| 实例虚拟网卡 → TAP → Linux Bridge 或 OVS Bridge → 物理网卡
|
1
2
3
4
5
6
| # 查看课堂 Linux Bridge
brctl show
# 查看 OVS
sudo ovs-vsctl show
sudo ovs-vsctl list-br
sudo ovs-vsctl list-ports <桥名>
|
实验创建桥的核心动作:创建桥 → 加入指定接口 → 配置桥地址和路由 → 启用 → 测试。被纳入桥的端口与桥上的 IP 应按同一方案设计,不能把管理地址随意挪走。
RHEL 7使用 /etc/sysconfig/network-scripts/ifcfg-* 保存配置。临时 ip 命令与持久配置应分别验证。
网桥转发验证#
画出两个端口的连接关系;记录加端口前后的桥 MAC;在桥和物理口观察 ARP / ICMP;重启网络后核对持久配置。Linux Bridge 与 OVS 的管理工具不同,不能用一个工具的空结果认定另一种桥不存在。
实验操作#
引导练习:管理网络接口#
在此练习中,使用各种网络工具,并将 IP 地址指定给一个实例所附的网络接口。
学习目标#
完成后能够:
开始之前#
确认 workstation 和Overcloud的虚拟机启动
登录到 workstation 时为 student , 使用 student 作为密码。在 workstation 上运行 lab manage-interfaces setup 命令。实验脚本以三个网络接口启动一个名为 finance-server1 的实例,并为 developer1 用户创建身份环境文件。
1
| [student@workstation ~]$ lab manage-interfaces setup
|
操作步骤#
1. 在 workstation 上,使用命令线用 source 加载于 /home/student/developer1-finance-rc 身份环境文件,为 developer1 用户提供访问 OpenStack 服务的机会。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
2. 为 finance-server1 实例获取控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack console url \
show finance-server1
+-------+-------------------------------------------------------------+
| Field | Value |
+-------+-------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=9c45...c761 |
+-------+-------------------------------------------------------------+
|
3. 在 Firefox 中打开此 URL,连接 finance-server1 实例控制台。
1
2
| [student@workstation ~(developer1-finance)]$ firefox \
http://172.25.250.50:6080/vnc_auto.html?token=9c45....c761
|
4. 使用 root 作为用户名,使用 redhat 作为登录此实例的密码。
1
2
| small image
finance-server1 login: root
|
操作界面、表格与配置图
1
2
| Password: redhat
[root@finance-server1 ~]#
|
5. 使用 ip a 命令验证 finance-server1 实例所附的网络接口。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [root@finance-server1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00: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 1450 qdisc pfifo_fast state UP qlen
1000
link/ether fa:16:3e:ac:1a:92 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.7/24 brd 192.168.0.255 scope global dynamic eth0
valid_lft 77736sec preferred_lft 77736sec
inet6 fe80::f816:3eff:feac:1a92/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen
1000
link/ether fa:16:3e:9a:70:48 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen
1000
link/ether fa:16:3e:81:40:70 brd ff:ff:ff:ff:ff:ff
|
6. 使用 ethtool 命令查看 eth0 接口的网络驱动程序。
1
2
3
4
5
6
7
8
9
10
11
| [root@finance-server1 ~]# ethtool -i eth0
driver: virtio_net
version: 1.0.0
firmware-version:
expansion-rom-version:
bus-info: 0000:00:03.0
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no
|
7. 创建并配置 ifcfg-eth1 配置文件。配置启动协议为 DHCP。网关为 192.168.20.1。重新启动 finance-server1 实例。
1
2
3
4
5
6
| [root@finance-server1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
BOOTPROTO=dhcp
GATEWAY=192.168.20.1
[root@finance-server1 ~]# reboot
|
8. 登录到此实例并使用 tcpdump 命令来监测通过 eth1 接口接收和发送的包。运行 tcpdump 命令作为背景进程。命令收集的包内容的描述必须写入 tcpdump-eth1.txt 文件。
操作界面、表格与配置图
1
2
| [root@finance-server1 ~]# nohup tcpdump -n -i eth1 > tcpdump-eth1.txt 2>/dev/null &
[1] 10783
|
9. 校验 IP 指定给 eth1 接口的地址。
1
2
3
4
5
6
| [root@finance-server1 ~]# ip a show dev eth1
3: eth1: >BROADCAST,MULTICAST,UP,LOWER_UP< mtu 1500 qdisc pfifo_fast state UP group
default qlen 1000
link/ether fa:16:3e:11:e8:50 brd ff:ff:ff:ff:ff:ff
inet 192.168.20.11/24 scope global eth1
valid_lft forever preferred_lft forever
|
10. 使用 ping 从 eth1 接口向 192.168.20.1 IP 地址发送 ICMP 请求。
1
2
3
4
5
6
7
8
| [root@finance-server1 ~]# ping -I eth1 -c 3 192.168.20.1
PING 192.168.20.1 (192.168.20.1) from 192.168.20.11 eth1: 56(84) bytes of data.
64 bytes from 192.168.20.1: icmp_seq=1 ttl=64 time=3.66 ms
64 bytes from 192.168.20.1: icmp_seq=2 ttl=64 time=1.02 ms
64 bytes from 192.168.20.1: icmp_seq=3 ttl=64 time=1.17 ms
--- 192.168.20.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.027/1.958/3.669/1.211 ms
|
11. 停止 tcpdump 命令。分析 tcpdump 命令为 eth1 接口获取的包信息。
11.1. 停止运行 tcpdump 的背景进程。
1
2
| [root@finance-server1 ~]# jobs
[1]+ Running nohup tcpdump -n -i eth1 > tcpdump-eth1.txt 2> /dev/null &
|
注意方括号中指定的工作编号,并使用 kill 停止进程。
1
| [root@finance-server1 ~]# kill %1
|
11.2. 在 tcpdump-eth1.txt 文件中查看包件信息。包件信息显示 ICMP 请求来自 192.168.20.11 IP 地址,从 192.168.20.1 网关 IP 地址收到的 ICMP 回复。另请注意,接口通过发送 ARP (地址解析协议) 请求,获取网关的 MAC 地址。对 ARP 请求的答复是网关的 MAC 地址。
1
2
3
4
5
6
7
8
9
10
| [root@finance-server1 ~]# cat tcpdump-eth1.txt
05:16:09.653429 ARP, Request who-has 192.168.20.1 tell 192.168.20.11, length 28
05:16:09.657206 ARP, Reply 192.168.20.1 is-at fa:16:3e:e1:d8:64, length 28
05:16:09.657215 IP 192.168.20.11 > 192.168.20.1: ICMP echo request, ...
05:16:09.658732 IP 192.168.20.1 > 192.168.20.11: ICMP echo reply, ...
05:16:10.655636 IP 192.168.20.11 > 192.168.20.1: ICMP echo request, ...
05:16:10.657148 IP 192.168.20.1 > 192.168.20.11: ICMP echo reply, ...
05:16:11.657208 IP 192.168.20.11 > 192.168.20.1: ICMP echo request, ...
05:16:11.658503 IP 192.168.20.1 > 192.168.20.11: ICMP echo reply, ...
05:16:14.665080 ARP, Request who-has 192.168.20.11 tell 192.168.20.1, length 28
|
操作界面、表格与配置图
1
| 05:16:14.665097 ARP, Reply 192.168.20.11 is-at fa:16:3e:73:e9:10, length 28
|
12. 退出实例并关闭实例控制台的浏览器标签。
1
| [root@finance-server1 ~]# exit
|
在 workstation 上运行 lab manage-interfaces cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab manage-interfaces cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:实现 Linux 网桥#
在此练习中,创建一个 Linux 网桥,并给桥指定一个静态 IP 地址。
学习目标#
完成后能够:
建立 Linux 网桥。
在桥上指定一个静态 IP 地址。
开始之前#
确认 workstation 和Overcloud的虚拟机启动
以 student 为密码,登录到 workstation 作为 student。在 workstation 上运行 lab linuxbridges setup 命令。
1
| [student@workstation ~]$ lab linuxbridges setup
|
操作步骤#
1. 从 workstation 登录到 compute0, 成为 heat-admin 用户。使用 sudo -i 成为 compute0 节点上的 root。
1
2
3
| [student@workstation ~]$ ssh heat-admin@compute0
[heat-admin@compute0 ~]$ sudo -i
[root@compute0 ~]#
|
2. 查看 eth3 接口的信息。创建一个名为 br-linux1 的新网桥并显示其信息。
2.1. 使用 ip link show 命令查看 eth3 MAC 地址的细节。
1
2
3
4
| [root@compute0 ~]# ip link show eth3
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
mode DEFAULT group default qlen 1000
link/ether 52:54:00:03:00:02 brd ff:ff:ff:ff:ff:ff
|
2.2. 使用 brctl 命令创建一座名为 br-linux1 的桥。
1
2
| [root@compute0 ~]# brctl addbr br-linux1
[root@compute0 ~]#
|
2.3. 使用 ip link show 命令视图查看 br-linux1 桥 MAC 地址的细节。
1
2
3
4
| [root@compute0 ~]# ip link show br-linux1
63: br-linux1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT
group default qlen 1000
link/ether fe:48:da:d5:b0:29 brd ff:ff:ff:ff:ff:ff
|
操作界面、表格与配置图
3. 向 br-linux1 添加 eth3 接口。查看 eth3 接口和 br-linux1 桥的细节。
3.1. 使用 addif 选项的 brctl 命令将 eth3 设备连接到桥上。
1
2
| [root@compute0 ~]# brctl addif br-linux1 eth3
[root@compute0 ~]#
|
3.2. 使用 ip link show 命令视图查看 eth3 和 br-linux1 的 MAC 地址的细节。
1
2
3
4
5
6
7
8
| [root@compute0 ~]# ip link show eth3
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br-
linux1 state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:03:00:02 brd ff:ff:ff:ff:ff:ff
[root@compute0 ~]# ip link show br-linux1
63: br-linux1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT
group default qlen 1000
link/ether 52:54:00:03:00:02 brd ff:ff:ff:ff:ff:ff
|
请注意 MAC 与 eth3 和 br-linux1 匹配的地址。Linux 网桥 br-linux1 现在可以代表 Linux 接口 eth3 进行回复。
4. 使用 ip address add 命令,将 172.25.249.33 IP 地址添加到 br-linux1 桥上。
1
2
| [root@compute0 ~]# ip address add 172.25.249.33 dev br-linux1
[root@compute0 ~]#
|
5. 使用 brctl show 命令,访问 br-linux1 桥的细节。
1
2
3
| [root@compute0 ~]# brctl show br-linux1
bridge name bridge id STP enabled interfaces
br-linux1 8000.525400030002 no eth3
|
6. 使用 brctl showmacs 列出 br-linux1 网桥所有端口的 MAC 地址。
1
2
3
4
| [root@compute0 ~]# brctl showmacs br-linux1
port no mac addr is local? ageing timer
1 52:54:00:03:00:02 yes 0.00
1 52:54:00:03:00:02 yes 0.00
|
7. 使用 ip link 命令启用网桥。
1
2
| [root@compute0 ~]# ip link set dev br-linux1 up
[root@compute0 ~]#
|
8. 使用 ip addr 命令视图 br-linux1 桥的设备状态。
1
| [root@compute0 ~]# ip addr show dev br-linux1
|
操作界面、表格与配置图
1
2
3
4
5
6
7
| 63: br-linux1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
group default qlen 1000
link/ether 52:54:00:03:00:02 brd ff:ff:ff:ff:ff:ff
inet 172.25.249.33/24 scope global br-linux1
valid_lft forever preferred_lft foreve
inet6 fe80::5054:ff:fe03:2/64 scope link
valid_lft forever preferred_lft forever
|
9. 退出 compute0 节点。
1
2
3
| [root@compute0 ~]# exit
[heat-admin@compute0 ~]$ exit
[student@workstation ~]$
|
在 workstation 上运行 lab linuxbridges cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab linuxbridges cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:实现 Open vSwitch 网桥#
在此练习中,管理 Open vSwitch 桥。
学习目标#
完成后能够:
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 为密码,登录到 workstation 作为 student。在 workstation 上运行 lab ovsbridges setup 命令。
1
| [student@workstation ~]$ lab ovsbridges setup
|
操作步骤#
1. 在 workstation 上,以 heat-admin 用户的身份登录到 compute0 节点。在 compute0 节点上,使用 sudo -i 变成 root。
1
2
3
| [student@workstation ~]$ ssh heat-admin@compute0
[heat-admin@compute0 ~]$ sudo -i
[root@compute0 ~]#
|
2. 使用 rpm -q 确认 openvswitch 软件包已安装。
1
2
| [root@compute0 ~]# rpm -q openvswitch
openvswitch-2.9.0-19.el7fdp.1.x86_64
|
3. 使用 systemctl 命令检查 openvswitch 服务的状况。
1
2
3
4
5
6
7
8
9
10
11
12
| [root@compute0 ~]# systemctl status openvswitch.service
● openvswitch.service - Open vSwitch
Loaded: loaded (/usr/lib/systemd/system/openvswitch.service; enabled; vendor
preset: disabled)
Active: active (exited) since Mon 2018-06-11 08:23:23 UTC; 13min left
Process: 1021 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 1021 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CGroup: /system.slice/openvswitch.service
Jun 11 08:23:23 compute0 systemd[1]: Starting Open vSwitch...
Jun 11 08:23:23 compute0 systemd[1]: Started Open vSwitch.
|
4. 查看 eth4 接口的信息。创建一个名为 br-ovs1 的新 OVS 桥并显示其信息。
操作界面、表格与配置图
4.1. 使用 ip link show 命令查看 eth4 MAC 地址的细节。
1
2
3
4
| [root@compute0 ~]# ip link show eth4
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-
system state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:04:00:02 brd ff:ff:ff:ff:ff:ff
|
4.2. 使用 ovs-vsctl 命令创建名为 br-ovs1 的 Open vSwitch 桥。
1
2
| [root@compute0 ~]# ovs-vsctl add-br br-ovs1
[root@compute0 ~]#
|
4.3. 使用 ip link show 命令查看 br-ovs1 MAC 地址的细节。
1
2
3
4
| [root@compute0 ~]# ip link show br-ovs1
64: br-ovs1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT
group default qlen 1000
link/ether ca:8a:5c:4e:10:48 brd ff:ff:ff:ff:ff:ff
|
5. 将 eth4 接口添加到 br-ovs1。在 br-ovs1 桥上指定一个特定的 MAC 地址。查看 eth4 接口和 br-ovs1 桥的细节。
5.1. 使用 add-port 选项的 ovs-vsctl 命令,将 eth4 网络设备添加到 br-ovs1 桥上。
1
2
| [root@compute0 ~]# ovs-vsctl add-port br-ovs1 eth4
[root@compute0 ~]#
|
5.2. 使用 ovs-vsctl set 命令将 MAC 地址 52:54:00:04:00:01 指定为 br-ovs1 桥。
1
2
3
| [root@compute0 ~]# ovs-vsctl set bridge br-ovs1 \
other-config:hwaddr=\"52:54:00:04:00:01\"
[root@compute0 ~]#
|
5.3. 使用 ip link show 命令视图查看 eth4 网络接口和 br-ovs1 桥 MAC 地址的细节。
1
2
3
4
5
6
7
8
| [root@compute0 ~]# ip link show eth4
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-
system state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:04:00:02 brd ff:ff:ff:ff:ff:ff
[root@compute0 ~]# ip link show br-ovs1
64: br-ovs1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT
group default qlen 1000
link/ether 52:54:00:04:00:01 brd ff:ff:ff:ff:ff:ff
|
注意:与 Linux 网桥不同,OVS 网桥不会自动采用所连接 Linux 接口的 MAC 地址。
6. 使用 ip 命令指定 172.25.249.55 IP 地址为 br-ovs1。
操作界面、表格与配置图
1
2
| [root@compute0 ~]# ip address add 172.25.249.55/24 dev br-ovs1
[root@compute0 ~]#
|
7. 使用 ip 命令启用 br-ovs1 网桥。
1
2
| [root@compute0 ~]# ip link set dev br-ovs1 up
[root@compute0 ~]#
|
8. 使用 ovs-vsctl 命令来使用 show 选项来审查 Open vSwitch 数据库的内容。
1
2
3
4
5
6
7
| [root@compute0 ~]# ovs-vsctl show | grep -A3 br-ovs1
Bridge "br-ovs1"
Port "br-ovs1"
Interface "br-ovs1"
type: internal
Port "eth4"
Interface "eth4"
|
9. 要列出 br-ovs1 桥的 ports 使用 ovs-vsctl 命令,使用 list-ports 选项。
1
2
| [root@compute0 ~]# ovs-vsctl list-ports br-ovs1
eth4
|
10. 使用 ip addr show 命令视图 br-ovs1 桥的设备状态。
1
2
3
4
5
6
| [root@compute0 ~]# ip addr show br-ovs1
64: br-ovs1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
group default qlen 1000
link/ether 52:54:00:04:00:01 brd ff:ff:ff:ff:ff:ff
inet6 fe80::5054:ff:fe04:2/64 scope link
valid_lft forever preferred_lft forever
|
11. 退出 compute0 节点。
1
2
3
| [root@compute0 ~]# exit
[heat-admin@compute0 ~]$ exit
[student@workstation ~]$
|
在 workstation 上运行 lab ovsbridges cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab ovsbridges cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:管理 Linux 网络#
本实验管理 Linux 接口,创建 Linux 网桥和 Open vSwitch 网桥,并分别连接 compute0 的 eth3 和 eth4。
学习目标#
能够管理 Linux 接口,并创建 Linux 和 Open vSwitch 桥。
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 登录 workstation,密码为 student。
在 workstation 运行 lab networks-lab setup 脚本,以 production-server1 和 production-server2 发布两个实例。
1
| [student@workstation ~]$ lab networks-lab setup
|
操作步骤#
1. 在 workstation 上源为 operator1 用户的 /home/student/operator1-production-rc 身份环境文件。
2. 使用 openstack server list 获取 production-server1 和 production-server2 的 IP。登录 production-server1 查看 ARP 表,再 ping production-server2。随后查看两台实例的 ARP 表。
3. 从 workstation 登录到 compute0 的 heat-admin 用户。使用 sudo -i 命令,在 compute0 节点上成为 root。
4. 在 compute0 创建名为 br-linux1 的 Linux 网桥。查看 br-linux1 的设备状态。将 eth3 网络接口附加到桥上。配置 br-linux1 桥 , 配置 IP 地址 172.25.249.100 和 255.255.255.0 的子网掩码。
5. 确保内核模块已加载,启用 br-linux1 网桥。
6. 在 compute0 上创建名为 br-ovs1 的 Open vSwitch 桥。将 eth4 网络接口作为桥的端口。配置 br-ovs1 桥,使用 IP 地址 172.25.249.110 和 255.255.255.0 子网掩码。
7. 启动桥接口。校验 br-ovs1 OVS 桥的设置,以及 eth4 网络接口端口的设置。
8. 退出 compute0。
1
2
3
| [root@compute0 ~]# exit
[heat-admin@compute0 ~]$ exit
[student@workstation ~]$
|
在 workstation 上运行 lab networks-lab grade,检查本实验是否成功。
操作界面、表格与配置图
1
| [student@workstation ~]$ lab networks-lab grade
|
在 workstation 上运行 lab networks-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab networks-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
本实验管理 Linux 接口,创建 Linux 网桥和 Open vSwitch 网桥,并分别连接 compute0 的 eth3 和 eth4。
学习目标#
能够管理 Linux 接口,并创建 Linux 和 Open vSwitch 桥。
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 登录 workstation,密码为 student。
在 workstation 运行 lab networks-lab setup 脚本,以 production-server1 和 production-server2 发布两个实例。
1
| [student@workstation ~]$ lab networks-lab setup
|
操作步骤#
1. 在 workstation 上源为 operator1 用户的 /home/student/operator1-production-rc 身份环境文件。
1
2
| [student@workstation ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$
|
2. 使用 openstack server list 获取 production-server1 和 production-server2 的 IP。登录 production-server1 查看 ARP 表,再 ping production-server2。随后查看两台实例的 ARP 表。
2.1. 使用 openstack server list 命令列出 production 项目中的服务器。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack server list \
-c Name -c Networks -c Status
+--------------------+--------+----------------------------------+
| Name | Status | Networks |
+--------------------+--------+----------------------------------+
| production-server2 | ACTIVE | production-network1=192.168.1.Y |
| production-server1 | ACTIVE | production-network1=192.168.1.X |
+--------------------+--------+----------------------------------+
|
2.2. 使用 openstack console url show 命令来检索 production-server1 的控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack console url \
show production-server1
+-------+-----------------------------------------------------------+
| Field | Value |
+-------+-----------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=8212...1873 |
+-------+-----------------------------------------------------------+
|
操作界面、表格与配置图
2.3. 使用此 URL 从 Firefox 浏览器连接到 production-server1 实例控制台。以 root 登录为 root , 以 redhat 为密码。
1
2
| [student@workstation ~(operator1-production)]$ firefox \
http://172.25.250.50:6080/vnc_auto.html?token=8212...1873
|
2.4. ,审查 ARP 表格
1
2
3
4
| [root@production-server1 ~]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.1.2 ether fa:16:3e:c5:3d:86 C eth0
gateway ether fa:16:3e:0b:7e:32 C eth0
|
2.5. production-server1 中的 Ping production-server2,再次审查 ARP 表格。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [root@production-server1 ~]# ping -c 3 192.168.1.Y
PING 192.168.1.Y (192.168.1.Y) 56(84) bytes of data.
64 bytes from 192.168.1.Y: icmp_seq=1 ttl=64 time=1.17 ms
64 bytes from 192.168.1.Y: icmp_seq=2 ttl=64 time=0.335 ms
64 bytes from 192.168.1.Y: icmp_seq=3 ttl=64 time=0.458 ms
--- 192.168.1.Y ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.335/0.656/1.176/0.371 ms
[root@production-server1 ~]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.1.Y ether fa:16:3e:15:9f:f1 C eth0
192.168.1.2 ether fa:16:3e:c5:3d:86 C eth0
gateway ether fa:16:3e:0b:7e:32 C eth0
|
2.6. 登录到 production-server2 以显示 ARP 表格。为此,从 workstation ,使用 openstack console url show 命令为 production-server2 获取控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack console url \
show production-server2
+-------+-----------------------------------------------------------+
| Field | Value |
+-------+-----------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=1234...1865 |
+-------+-----------------------------------------------------------+
|
使用此 URL 连接到 Firefox 浏览器上的 production-server2 实例控制台。以 redhat 作为密码登录为 root。
在 production-server2 上显示 ARP 表格。您会看到 production-server1 的条目,原因是 ping 流量。
1
2
3
4
| [root@production-server2 ~]$ arp
Address HWtype HWaddress Flags Mask Iface
gateway ether fa:16:3e:0b:7e:32 C eth0
192.168.1.X ether fa:16:3e:a3:19:85 C eth0
|
操作界面、表格与配置图
1
| 192.168.1.2 ether fa:16:3e:c5:3d:86 C eth0
|
2.7. 退出 production-server1 和 production-server2。
1
2
| [root@production-server1 ~]# logout
[root@production-server2 ~]$ logout
|
3. 从 workstation 登录到 compute0 的 heat-admin 用户。使用 sudo -i 命令,在 compute0 节点上成为 root。
1
2
3
| [student@workstation ~]$ ssh heat-admin@compute0
[heat-admin@compute0 ~]$ sudo -i
[root@compute0 ~]#
|
4. 在 compute0 创建名为 br-linux1 的 Linux 网桥。查看 br-linux1 的设备状态。将 eth3 网络接口附加到桥上。配置 br-linux1 桥 , 配置 IP 地址 172.25.249.100 和 255.255.255.0 的子网掩码。
4.1. 在 compute0 上确保安装 bridge-utils 软件包。
1
2
| [root@compute0 ~]# rpm -q bridge-utils
bridge-utils-1.5-9.el7.x86_64
|
4.2. 使用 brctl 命令创建一座名为 br-linux1 的桥。
1
2
| [root@compute0 ~]# brctl addbr br-linux1
[root@compute0 ~]#
|
4.3. 查看 br-linux1 桥的设备状态。
1
2
3
4
| [root@compute0 ~]# ip addr show dev br-linux1
34: br-linux1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group
default qlen 1000
link/ether 7a:14:5b:0e:69:c4 brd ff:ff:ff:ff:ff:ff
|
4.4. 使用 brctl 和 addif 选项将 eth3 设备附加到桥上。
1
2
| [root@compute0 ~]# brctl addif br-linux1 eth3
[root@compute0 ~]#
|
4.5. 使用 ip address add 命令,将 172.25.249.100/24 IP 地址添加到 br-linux1。
1
2
| [root@compute0 ~]# ip address add 172.25.249.100/24 dev br-linux1
[root@compute0 ~]#
|
5. 确保内核模块已加载,启用 br-linux1 网桥。
操作界面、表格与配置图
5.1. 使用 lsmod 确保内核模块装入。
1
2
3
4
| [root@compute0 ~]# lsmod | grep bridge
bridge 146976 1 br_netfilter
stp 12976 1 bridge
llc 14552 2 stp,bridge
|
5.2. 使用 ip link 启用 br-linux1 网桥。
1
2
| [root@compute0 ~]# ip link set dev br-linux1 up
[root@compute0 ~]#
|
5.3. 使用 ip addr 查看 br-linux1 的设备状态。
1
2
3
4
5
6
7
8
| [root@compute0 ~]# ip addr show dev br-linux1
34: br-linux1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
group default qlen 1000
link/ether 7a:14:5b:0e:69:c4 brd ff:ff:ff:ff:ff:ff
inet 172.25.249.100/24 scope global br-linux1
valid_lft forever preferred_lft forever
inet6 fe80::7814:5bff:fe0e:69c4/64 scope link
valid_lft forever preferred_lft forever
|
6. 在 compute0 上创建名为 br-ovs1 的 Open vSwitch 桥。将 eth4 网络接口作为桥的端口。配置 br-ovs1 桥,使用 IP 地址 172.25.249.110 和 255.255.255.0 子网掩码。
6.1. 在 compute0 以 root 确认 openvswitch 软件包已安装。
1
2
| [root@compute0 ~]# rpm -q openvswitch
openvswitch-2.9.0-19.el7fdp.1.x86_64
|
6.2. 检查 openvswitch 服务状态。
1
2
3
4
5
6
7
8
9
10
11
12
| [root@compute0 ~]# systemctl status openvswitch.service
● openvswitch.service - Open vSwitch
Loaded: loaded (/usr/lib/systemd/system/openvswitch.service; enabled; vendor
preset: disabled)
Active: active (exited) since Tue 2018-06-12 07:52:49 UTC; 1h 19min ago
Process: 1020 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 1020 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CGroup: /system.slice/openvswitch.service
Jun 12 07:52:49 compute0 systemd[1]: Starting Open vSwitch...
Jun 12 07:52:49 compute0 systemd[1]: Started Open vSwitch.
|
6.3. 使用 ovs-vsctl 命令创建名为 br-ovs1 的 Open vSwitch 桥。
1
2
| [root@compute0 ~]# ovs-vsctl add-br br-ovs1
[root@compute0 ~]#
|
操作界面、表格与配置图
6.4. 使用 ip 命令指定 172.25.249.110/24 IP 地址为 br-ovs1。
1
2
| [root@compute0 ~]# ip address add 172.25.249.110/24 dev br-ovs1
[root@compute0 ~]#
|
6.5. 使用 ovs-vsctl 和 add-port 选项,将 eth4 网络设备添加到 br-ovs1 桥上。
1
2
| [root@compute0 ~]# ovs-vsctl add-port br-ovs1 eth4
[root@compute0 ~]#
|
7. 启动桥接口。校验 br-ovs1 OVS 桥的设置,以及 eth4 网络接口端口的设置。
7.1.
使用 ip 命令启用 br-ovs1 网桥。
1
2
| [root@compute0 ~]# ip link set dev br-ovs1 up
[root@compute0 ~]#
|
7.2. 审查分配给 br-ovs1 OVS 桥的 IP 和 MAC 地址。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [root@compute0 ~]# ip a
...output omitted...
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default qlen 1000
link/ether 52:54:00:04:00:02 brd ff:ff:ff:ff:ff:ff
inet6 fe80::5054:ff:fe04:2/64 scope link
valid_lft forever preferred_lft forever
...output omitted...
41: br-ovs1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
link/ether f2:a2:e5:35:61:49 brd ff:ff:ff:ff:ff:ff
inet 172.25.249.110/24 scope global br-ovs1
valid_lft forever preferred_lft forever
inet6 fe80::f0a2:e5ff:fe35:6149/64 scope link
valid_lft forever preferred_lft forever
|
7.3. 使用 ovs-vsctl 确认桥和端口配置正确。
1
2
3
4
5
6
7
8
| [root@compute0 ~]# ovs-vsctl show | grep -A2 br-ovs1
Bridge "br-ovs1"
Port "eth4"
Interface "eth4"
Port "br-ovs1"
Interface "br-ovs1"
type: internal
Bridge br-tun
|
8. 退出 compute0。
1
2
| [root@compute0 ~]# exit
[heat-admin@compute0 ~]$ exit
|
操作界面、表格与配置图
1
| [student@workstation ~]$
|
在 workstation 上运行 lab networks-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab networks-lab grade
|
在 workstation 上运行 lab networks-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab networks-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 检查网络接口前应先确认什么?
- 网桥创建成功后,还需要检查哪些内容?
自测答案#
- 主机和网络层次。实例内接口与计算节点接口不能混淆。
- 端口、地址和启用状态。创建桥不等于端口、IP 和设备状态都已完成。
C5-准备实例部署#
镜像准备#
镜像格式、最小磁盘和最小 RAM 限制影响可用规格。protected 控制删除保护,visibility 控制可见范围,二者相互独立。删除受保护镜像前先取消保护;设为公开时使用具备相应权限的管理员身份。
规格参数#
| 参数 | 含义 | 注意事项 |
|---|
| vCPU | 虚拟 CPU 数量 | 与项目配额合并判断 |
| RAM | 实例内存 | 留意 MB、MiB 与系统预留 |
| Root Disk | 根磁盘容量 | 应满足镜像最小磁盘要求 |
| Ephemeral Disk | 附加临时磁盘 | 生命周期与实例相关 |
| Swap | 交换空间 | 不等于普通数据卷 |
网络与子网#
网络承载二层连接,子网定义地址范围、DHCP、网关和 DNS 等三层参数。网络改名不等于重新创建;子网删除前检查关联端口和路由接口。
启动前检查#
确认镜像 active、规格参数满足需求、网络对子项目可见、子网启用了实验要求的 DHCP,并加载正确身份。资源名称可以复用,创建前仍需核对实际属性。
三项准备资源#
1. 镜像#
1
2
3
4
5
| openstack image create --disk-format qcow2 --container-format bare \
--file ./rhel7.qcow2 --min-disk 10 --min-ram 1024 demo-image
openstack image show demo-image
openstack image set --protected demo-image
openstack image set --unprotected demo-image
|
文件需已准备好;格式参数必须与真实文件格式匹配。bare 是 container format,不表示没有操作系统。保护与可见性相互独立。
2. 规格#
管理员执行:
1
2
| openstack flavor create --vcpus 1 --ram 1024 --disk 10 demo-small
openstack flavor show demo-small
|
--ram 以 MiB 表示,磁盘参数以 GiB 表示。镜像要求更大最小磁盘或内存时,应更换规格,不只看镜像文件压缩后的大小。
3. 私有网络与子网#
项目用户执行;下面网段仅用于独立示例。
1
2
3
4
5
6
| openstack network create demo-net
openstack subnet create --network demo-net \
--subnet-range 192.168.50.0/24 --gateway 192.168.50.1 \
--dns-nameserver 172.25.250.254 demo-subnet
openstack network show demo-net
openstack subnet show demo-subnet
|
Network 是二层逻辑网络;Subnet 提供 CIDR、网关、DHCP 和 DNS 设置;实例实际接入的是 Port。
启动前验收#
镜像 active → Flavor 满足镜像限制 → Network 可见 → Subnet 地址范围正确 → 项目配额足够。此时只完成了私有网络准备,公共访问还需要外部网络、路由、安全组和认证配置。
实验操作#
引导练习:上传镜像#
在此练习中,使用仪表板和统一的 CLI 管理镜像。创建和删除镜像,修改镜像设置,包括可见度、 最小磁盘容量和保护。
学习目标#
完成后能够:
利用仪表板创建和管理镜像。
使用统一的 CLI 工具创建和管理镜像。
删除镜像。
开始之前#
确保启动 workstation 和 overcloud 虚拟机。
以 student 登录 workstation,密码为 student。
在 workstation 上运行 lab prepinternal-images setup, 核实 OpenStack 服务正在运行,前几节所创造的资源已经到位。
1
| [student@workstation ~]$ lab prepinternal-images setup
|
操作步骤#
1. 在 workstation 上打开一个终端,从 http://materials.example.com/osp-small.qcow2 下载 osp-small.qcow2 镜像文件到 /home/student/Downloads 目录。
1
2
3
4
5
| [student@workstation ~]$ wget -P ~/Downloads \
http://materials.example.com/osp-small.qcow2
...output omitted...
2018-06-13 06:27:18 (240 MB/s) - '/home/student/Downloads/osp-small.qcow2' saved
[842661888/842661888]
|
2. 开放Firefox并浏览到 http://dashboard.overcloud.example.com。
3. 登录到仪表板上,成为 developer1 用户,密码为 redhat。使用您刚刚下载的 osp-small.qcow2 镜像,使用 QCOW2 格式和默认设置创建名为 rhel7-small 的镜像。
3.1. 使用 developer1 作为用户名和 redhat 作为密码登录到仪表板。
3.2. 导航到项目 > 计算 > 镜像并单击 +Create 镜像。请输入镜像的以下细节 :
操作界面、表格与配置图
单击“ 创建镜像” 按钮来创建镜像。等待 rhel7-small 镜像的状态字段值为 Active。您可能需要刷新网页来更新状态字段。
4. 将 rhel7-small 设为受保护,最小磁盘大小设为 10 GB,然后退出仪表板。
4.1. 单击启动按钮旁边的箭头,用于标有 rhel7-small 的行。选择编辑镜像以编辑镜像。
在保护字段中选择 Yes。在最小磁盘( GB) 字段中输入 10。单击更新镜像。
4.2. 退出仪表板。
5. 使用 CLI 创建名为 rhel7-small2 的新镜像,使用 developer1 用户凭据。从先前下载的 osp-small.qcow2 镜像文件创建此镜像,并使用 QCOW2 格式。
5.1. 在 workstation 上打开一个终端。用 source 加载 /home/student/developer1-finance-rc 环境文件以导出 developer1 用户凭据。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
5.2. 使用 osp-small.qcow2 镜像文件和 QCOW2 格式创建 rhel7-small2 镜像。
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
| [student@workstation ~(developer1-finance)]$ openstack image create \
--disk-format qcow2 \
--file ~/Downloads/osp-small.qcow2 \
rhel7-small2
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | d3bc2ff8b3533697a0acaacd5b28016d |
| container_format | bare |
| created_at | 2018-06-15T02:58:03Z |
| disk_format | qcow2 |
| file | /v2/images/3369dc9b-05f4-4455-9348-23d3a39f6344/file |
| id | 3369dc9b-05f4-4455-9348-23d3a39f6344 |
| min_disk | 0 |
| min_ram | 0 |
| name | rhel7-small2 |
| owner | cec9ea4041ff4aeb82236ea702e0e338 |
| properties | direct_url='...', locations='...' |
| protected | False |
| schema | /v2/schemas/image |
| size | 842661888 |
| status | active |
| tags | |
| updated_at | 2018-06-15T02:58:14Z |
| virtual_size | None |
| visibility | shared |
+------------------+------------------------------------------------------+
|
操作界面、表格与配置图
6. 将 rhel7-small2 镜像状态设为 protected,并将最小磁盘大小设为 10 GB。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ openstack image set \
--protected \
--min-disk 10 \
rhel7-small2
|
7. 校验 rhel7-small2 镜像是否通过列出可用镜像并显示 rhel7-small2 镜像的细节而正确创建。
7.1.
列出可用的镜像并确认 rhel7-small2 镜像的 Status 是 active。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack image list
+--------------------------------------+---------------+--------+
| ID | Name | Status |
+--------------------------------------+---------------+--------+
| 30c17bad-ce14-4d0d-abb9-0f5b323adace | rhel7-small | active |
| 3369dc9b-05f4-4455-9348-23d3a39f6344 | rhel7-small2 | active |
...output omitted...
|
7.2. 显示 rhel7-small2 镜像的细节,并核实其是否正确更新。确认 min_disk 字段的值为 10, 受保护字段的值为 True。
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 ~(developer1-finance)]$ openstack image show rhel7-small2
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | d3bc2ff8b3533697a0acaacd5b28016d |
| container_format | bare |
| created_at | 2018-06-15T02:58:03Z |
| disk_format | qcow2 |
| file | /v2/images/3369dc9b-05f4-4455-9348-23d3a39f6344/file |
| id | 3369dc9b-05f4-4455-9348-23d3a39f6344 |
| min_disk | 10 |
| min_ram | 0 |
| name | rhel7-small2 |
| owner | cec9ea4041ff4aeb82236ea702e0e338 |
| properties | direct_url='...', locations='...' |
| protected | True |
| schema | /v2/schemas/image |
| size | 842661888 |
| status | active |
| tags | |
| updated_at | 2018-06-15T03:00:32Z |
| virtual_size | None |
| visibility | shared |
+------------------+------------------------------------------------------+
|
8. 删除 rhel7-small2 镜像。在删除前必须取消保护。
8.1. 尝试删除 rhel7-small2 镜像而不解除保护。它应该返回错误。
操作界面、表格与配置图
1
2
3
4
5
| [student@workstation ~(developer1-finance)]$ openstack image delete rhel7-small2
Failed to delete image with name or ID 'rhel7-small2': 403 Forbidden:
Image 3369dc9b-05f4-4455-9348-23d3a39f6344 is protected and cannot be deleted.
(HTTP 403)
Failed to delete 1 of 1 images.
|
8.2. 设置 rhel7-small2 镜像不受保护。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack image set \
--unprotected \
rhel7-small2
|
8.3. 删除 rhel7-small2 镜像。
1
| [student@workstation ~(developer1-finance)]$ openstack image delete rhel7-small2
|
9. 使用有行政权的 architect1 用户凭据,将 rhel7-small 镜像公之于众。您必须拥有公示镜像的管理权限。完成后,请确认 rhel7-small 镜像是否已经正确更新。
9.1. 用 source 加载 ~/architect1-finance-rc 文件,以装入 architect1 用户凭据。该用户拥有管理权限。
1
2
| [student@workstation ~(developer1-finance)]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
9.2. 设置 rhel7-small 镜像为公开。
1
2
3
| [student@workstation ~(architect1-finance)]$ openstack image set \
--public \
rhel7-small
|
9.3. 验证 rhel7-small 镜像是否已经正确更新。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [student@workstation ~(architect1-finance)]$ openstack image show rhel7-small
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | d3bc2ff8b3533697a0acaacd5b28016d |
| container_format | bare |
| created_at | 2018-06-15T02:54:47Z |
| disk_format | qcow2 |
| file | /v2/images/30c17bad-ce14-4d0d-abb9-0f5b323adace/file |
| id | 30c17bad-ce14-4d0d-abb9-0f5b323adace |
| min_disk | 10 |
| min_ram | 0 |
| name | rhel7-small |
| owner | cec9ea4041ff4aeb82236ea702e0e338 |
| properties | direct_url='...', locations='...' |
| protected | True |
| schema | /v2/schemas/image |
| size | 842661888 |
| status | active |
|
操作界面、表格与配置图
1
2
3
4
5
| | tags | |
| updated_at | 2018-06-15T03:30:21Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
|
在 workstation 上运行 lab prepinternal-images cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab prepinternal-images cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:创建实例规格#
本练习使用仪表板和统一 CLI 管理实例规格:创建、删除规格,并修改根磁盘、vCPU 数量、RAM、临时磁盘和交换空间等设置。
学习目标#
完成后能够:
· 删除规格。
开始之前#
确保启动 workstation 和 overcloud 虚拟机。
以 student 登录 workstation,密码为 student。
在 workstation 上运行 lab prepinternal-flavors setup, 核实 OpenStack 服务正在运行,前几节所创造的资源已经到位。
1
| [student@workstation ~]$ lab prepinternal-flavors setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
2. 使用仪表板上的 architect1 用户凭据,创建一种名为 small 的规格,与两个 VCPU, RAM 的 1024 MB 和 10 GB 根磁盘配置此规格。
2.1. 使用 architect1 作为用户名和 redhat 作为密码登录到仪表板。
2.2. 打开 Admin > Compute > Flavors,点击 +Create Flavor。输入以下规格参数:
名称:small
VCPUs: 2
RAM (MB): 1024
根磁盘(GB):10
单击创建 Flavor 并创建规格。
2.3. 退出仪表板。
3. 使用 architect1 凭据在 CLI 创建 small-swap 规格:2 个 vCPU、1024 MB RAM、10 GB 根磁盘、2 GB 临时磁盘和 1024 MB 交换空间。
操作界面、表格与配置图
3.1. 在 workstation 上打开终端。
3.2. 用 source 加载 /home/student/architect1-finance-rc 文件,以装入 architect1 用户凭据。
1
2
| [student@workstation ~]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
3.3. 创建 small-swap 规格:2 个 vCPU、1024 MB RAM、10 GB 根磁盘、2 GB 临时磁盘和 1024 MB 交换空间。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| [student@workstation ~(architect1-finance)]$ openstack flavor create \
--vcpus 2 \
--ram 1024 \
--disk 10 \
--ephemeral 2 \
--swap 1024 \
small-swap
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 2 |
| disk | 10 |
| id | 053941f1-5607-408e-b8fd-b8e68b40abb0 |
| name | small-swap |
| os-flavor-access:is_public | True |
| properties | |
| ram | 1024 |
| rxtx_factor | 1.0 |
| swap | 1024 |
| vcpus | 2 |
+----------------------------+--------------------------------------+
|
3.4. 验证 small-swap 规格是否与正确的设置一起创建。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~(architect1-finance)]$ openstack flavor show small-swap
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 2 |
| access_project_ids | None |
| disk | 10 |
| id | cd725c48-9f68-4024-8712-3aa957c49ec8 |
| name | small-swap |
| os-flavor-access:is_public | True |
| properties | |
| ram | 1024 |
| rxtx_factor | 1.0 |
| swap | 1024 |
| vcpus | 2 |
+----------------------------+--------------------------------------+
|
4. 删除 small 规格。
操作界面、表格与配置图
4.1. 删去 small 的规格
1
| [student@workstation ~(architect1-finance)]$ openstack flavor delete small
|
4.2. 验证 small 规格是否被正确删除。
1
2
| [student@workstation ~(architect1-finance)]$ openstack flavor show small
No flavor with a name or ID of 'small' exists.
|
在 workstation 上运行 lab prepinternal-flavors cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab prepinternal-flavors cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理私有网络#
在此练习中,使用仪表板和统一的 CLI 管理网络和子网络。创建和删除网络和子网络,更新它们的设置,并重命名它们。
学习目标#
完成后能够:
利用仪表板建立一个网络和子网。
利用 CLI 建立一个网络和子网。
重新命名一个网络。
更新子网。
开始之前#
确保启动 workstation 和 overcloud 虚拟机。
以 student 登录 workstation,密码为 student。
在 workstation 上运行 lab prepinternal-networks setup, 核实 OpenStack 服务正在运行,前几节所创造的资源已经到位。
1
| [student@workstation ~]$ lab prepinternal-networks setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
2. 使用仪表板上的 developer1 用户凭据,创建一个名为 finance-network2 的网络和一个名为 finance-subnet2 的子网,并使用 192.168.2.0/24 网络地址。在您完成创建网络和子网后从仪表板上注销。
2.1. 使用 developer1 作为用户名和 redhat 作为密码登录到仪表板。
2.2. 导航到项目 > 网络 > 网络,单击+Create 网络。
在网络区域中,请在网络名称字段中输入 finance-network2。验证是否选中创建子网框。单击下一步。
2.3. 在子网段,在子网名字段中输入 finance-subnet2。在网络地址字段中输入 192.168.2.0/24。单击下一步。
2.4. 在子网细节部分,审查并接受默认设置。然后单击 Create。
2.5. 退出仪表板。
3. 使用 CLI 中的 developer1 凭据创建名为 finance-network4 的网络。
3.1. 在 workstation, 打开终端。
操作界面、表格与配置图
3.2. 用 source 加载 /home/student/developer1-finance-rc 文件,以装入 developer1 用户凭据。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
3.3. 创建一个名为 finance-network4 的网络。
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
| [student@workstation ~(developer1-finance)]$ openstack network create \
finance-network4
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-15T05:33:30Z |
| description | |
| dns_domain | None |
| id | 02b7194c-eef0-4cac-867f-81dd2a3f33fa |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1450 |
| name | finance-network4 |
| port_security_enabled | True |
| project_id | cec9ea4041ff4aeb82236ea702e0e338 |
| provider:network_type | None |
| provider:physical_network | None |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 3 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-15T05:33:30Z |
+---------------------------+--------------------------------------+
|
4. 在 finance-network4 中创建 finance-subnet4,网段为 192.168.4.0/24,然后验证子网设置。
4.1. 在 finance-network4 网络中创建名为 finance-subnet4 的子网。配置此子网以使用 192.168.4.0/24 范围。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(developer1-finance)]$ openstack subnet create \
--subnet-range 192.168.4.0/24 \
--network finance-network4 \
finance-subnet4
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.4.2-192.168.4.254 |
| cidr | 192.168.4.0/24 |
| created_at | 2018-06-15T05:39:22Z |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| | description | |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 192.168.4.1 |
| host_routes | |
| id | 3aa323aa-1695-4bdd-b088-999ada97006d |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | finance-subnet4 |
| network_id | 02b7194c-eef0-4cac-867f-81dd2a3f33fa |
| project_id | cec9ea4041ff4aeb82236ea702e0e338 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-15T05:39:22Z |
+-------------------+--------------------------------------+
|
4.2. 核实 finance-subnet4 子网的 network_id 字段值是 finance-network4 网络的 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
| [student@workstation ~(developer1-finance)]$ openstack subnet show \
finance-subnet4
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.4.2-192.168.4.254 |
| cidr | 192.168.4.0/24 |
| created_at | 2018-06-15T05:39:22Z |
| description | |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 192.168.4.1 |
| host_routes | |
| id | 3aa323aa-1695-4bdd-b088-999ada97006d |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | finance-subnet4 |
| network_id | 02b7194c-eef0-4cac-867f-81dd2a3f33fa |
| project_id | cec9ea4041ff4aeb82236ea702e0e338 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-15T05:39:22Z |
+-------------------+--------------------------------------+
|
5. 将 finance-network2 网络的名称更改为 finance-network3. 验证网络名称。
5.1. 将 finance-network2 网络的名称更改为 finance-network3。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack network set \
--name finance-network3 \
finance-network2
|
操作界面、表格与配置图
5.2. 核实 finance-network2 网络名称已正确更改为 finance-network3。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack network list
+-------------+------------------+-------------+
| ID | Name | Subnets |
+-------------+------------------+-------------+
...output omitted...
| de90...2648 | finance-network3 | 7841...4f47 |
...output omitted...
+-------------+------------------+-------------+
|
6. 更新 finance-subnet2 子网以禁用 DHCP。校验更改。
6.1. 更新 finance-subnet2 子网以禁用 DHCP。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack subnet set \
--no-dhcp \
finance-subnet2
|
6.2. 核实 finance-subnet2 子网是否已经正确更新。
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
| [student@workstation ~(developer1-finance)]$ openstack subnet show \
finance-subnet2
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.2.2-192.168.2.254 |
| cidr | 192.168.2.0/24 |
| created_at | 2018-06-15T05:30:55Z |
| description | |
| dns_nameservers | |
| enable_dhcp | False |
| gateway_ip | 192.168.2.1 |
| host_routes | |
| id | 7841e286-950f-4b5e-a2fe-1aa6776d4f47 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | finance-subnet2 |
| network_id | de906011-f182-40d1-8878-233fd3bb2648 |
| project_id | cec9ea4041ff4aeb82236ea702e0e338 |
| revision_number | 1 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-15T05:50:14Z |
+-------------------+--------------------------------------+
|
7. 删除 finance-subnet2 子网并确保子网被正确删除。
7.1.
删除 finance-subnet2 子网。
1
| [student@workstation ~(developer1-finance)]$ openstack subnet delete \
|
操作界面、表格与配置图
7.2. 验证 finance-subnet2 子网已被正确删除。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack subnet show \
finance-subnet2
No Subnet found for finance-subnet2
|
8. 删除 finance-network3 网络,确保网络被正确删除。
8.1. 删除 finance-network3 网络。
1
2
| [student@workstation ~(developer1-finance)]$ openstack network delete \
finance-network3
|
8.2. 验证 finance-network3 网络已被正确删除。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack network show \
finance-network3
Error while executing command: No Network found for finance-network3
|
在 workstation 上运行 lab prepinternal-networks cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab prepinternal-networks cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:准备实例部署#
在这个实验里,创造出启动一个实例所需要的资源,包括镜像、项目网络和子网络,以及一种规格。
学习目标#
完成后能够:
创建镜像并将其设为公开。
建立一个项目网络和一个子网络。
· 创造规格。
开始之前#
确保启动 workstation 和 overcloud 虚拟机。
以 student 登录 workstation,密码为 student。
在 workstation 上运行 lab prepinternal-lab setup, 核实 OpenStack 服务正在运行,并可获得前几节中创建的资源。实验脚本创建了 workstation 在 /home/student/architect1-production-rc 和 /home/student/operator1-production-rc 中的用户环境文件。
1
| [student@workstation ~]$ lab prepinternal-lab setup
|
如果您需要管理权限,请使用 architect1 账户(密码: redhat)。用户环境文件可在 workstation 中作为 /home/student/architect1-production-rc 找到。
操作步骤#
1. 使用 http://materials.example.com/osp-web.qcow2 文件创建名为 rhel7-web 的镜像,使用 operator1 用户凭据。配置此镜像为 protected, 使用 10 GB 作为最小磁盘大小,使用 2048 MB 作为最小数量 RAM。
2. 使用 operator1 凭据创建 production-network2 及其子网 production-subnet2。子网使用 192.168.2.0/24 网段,DNS 服务器为 172.25.250.254。
3. 创建 default-extra-disk 规格:10 GB 根磁盘、2048 MB RAM、2 个 vCPU、5 GB 临时磁盘、1024 MB 交换空间,规格 ID 为 42。
4. 配置 rhel7-web 镜像为 public。
在 workstation 上运行 lab prepinternal-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab prepinternal-lab grade
|
操作界面、表格与配置图
在 workstation 上运行 lab prepinternal-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab prepinternal-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
在这个实验里,创造出启动一个实例所需要的资源,包括镜像、项目网络和子网络,以及一种规格。
学习目标#
完成后能够:
创建镜像并将其设为公开。
建立一个项目网络和一个子网络。
· 创造规格。
开始之前#
确保启动 workstation 和 overcloud 虚拟机。
以 student 登录 workstation,密码为 student。
在 workstation 上运行 lab prepinternal-lab setup, 核实 OpenStack 服务正在运行,并可获得前几节中创建的资源。实验脚本创建了 workstation 在 /home/student/architect1-production-rc 和 /home/student/operator1-production-rc 中的用户环境文件。
1
| [student@workstation ~]$ lab prepinternal-lab setup
|
如果您需要管理权限,请使用 architect1 账户(密码: redhat)。用户环境文件可在 workstation 中作为 /home/student/architect1-production-rc 找到。
操作步骤#
1. 使用 http://materials.example.com/osp-web.qcow2 文件创建名为 rhel7-web 的镜像,使用 operator1 用户凭据。配置此镜像为 protected, 使用 10 GB 作为最小磁盘大小,使用 2048 MB 作为最小数量 RAM。
1.1.
从 workstation 中打开终端。从材料仓库下载 osp-web.qcow2 镜像文件。
1
2
3
| [student@workstation ~]$ wget http://materials.example.com/osp-web.qcow2
...output omitted...
2018-06-19 05:11:38 (211 MB/s) - 'osp-web.qcow2' saved [971767808/971767808]
|
1.2. 用 source 加载 operator1-production-rc 文件,以装入 operator1 用户凭据。
1
| [student@workstation ~]$ source ~/operator1-production-rc
|
1.3. 使用先前下载的 osp-web.qcow2 镜像文件创建名为 rhel7-web 的镜像。配置此镜像为 protected, 并使用 10 GB 作为最小磁盘大小,并使用 2048 MB 作为最小数量 RAM。
1
2
| [student@workstation ~(operator1-production)]$ openstack image create \
--disk-format qcow2 \
|
操作界面、表格与配置图
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
| --min-disk 10 \
--min-ram 2048 \
--protected \
--file osp-web.qcow2 \
rhel7-web
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | c37de831bdbc9b50379bd2008c399275 |
| container_format | bare |
| created_at | 2018-06-19T05:14:18Z |
| disk_format | qcow2 |
| file | /v2/images/a6b0ab1f-2ff8-4751-bed4-efcfb140d0fe/file |
| id | a6b0ab1f-2ff8-4751-bed4-efcfb140d0fe |
| min_disk | 10 |
| min_ram | 2048 |
| name | rhel7-web |
| owner | 00f7c7f68e7c4d72bab53dda8492ffcb |
| properties | direct_url='...', locations='...' |
| protected | True |
| schema | /v2/schemas/image |
| size | 971767808 |
| status | active |
| tags | |
| updated_at | 2018-06-19T05:14:33Z |
| virtual_size | None |
| visibility | shared |
+------------------+------------------------------------------------------+
|
1.4. 验证 rhel7-web 镜像状态为 active。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack image list
+--------------------------------------+-------------+--------+
| ID | Name | Status |
+--------------------------------------+-------------+--------+
...output omitted...
| a6b0ab1f-2ff8-4751-bed4-efcfb140d0fe | rhel7-web | active |
...output omitted...
+--------------------------------------+-------------+--------+
|
2. 使用 operator1 凭据创建 production-network2 及其子网 production-subnet2。子网使用 192.168.2.0/24 网段,DNS 服务器为 172.25.250.254。
2.1. 创建一个名为 production-network2 的网络。默认情况下,此网络将创建为内部网络。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~(operator1-production)]$ openstack network create \
production-network2
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-19T05:27:09Z |
| description | |
| dns_domain | None |
| id | 6fa4ac0d-409e-4bf3-8ff8-20680e817f53 |
| ipv4_address_scope | None |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| | ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1450 |
| name | production-network2 |
| project_id | 00f7c7f68e7c4d72bab53dda8492ffcb |
| provider:network_type | None |
| provider:physical_network | None |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 3 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-19T05:27:09Z |
+---------------------------+--------------------------------------+
|
2.2. 在 production-network2 网络上创建一个名为 production-subnet2 的子网络。为该子网络使用 192.168.2.0/24 区域以及 172.25.250.254 DNS 名称服务器。
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
| [student@workstation ~(operator1-production)]$ openstack subnet create \
production-subnet2 \
--network production-network2 \
--dns-nameserver 172.25.250.254 \
--subnet-range 192.168.2.0/24
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.2.2-192.168.2.254 |
| cidr | 192.168.2.0/24 |
| created_at | 2018-06-19T05:33:24Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | True |
| gateway_ip | 192.168.2.1 |
| host_routes | |
| id | 725d62c8-d99d-44f6-aa7b-c265f4f330eb |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | production-subnet2 |
| network_id | 6fa4ac0d-409e-4bf3-8ff8-20680e817f53 |
| project_id | 00f7c7f68e7c4d72bab53dda8492ffcb |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-19T05:33:24Z |
+-------------------+--------------------------------------+
|
3. 创建 default-extra-disk 规格:10 GB 根磁盘、2048 MB RAM、2 个 vCPU、5 GB 临时磁盘、1024 MB 交换空间,规格 ID 为 42。
操作界面、表格与配置图
3.1. 创建规格需要管理员账户。用 source 加载 architect1-production-rc,取得 architect1 凭据。
1
2
| [student@workstation ~(operator1-production)]$ source ~/architect1-production-rc
[student@workstation ~(architect1-production)]$
|
3.2. 创建 default-extra-disk 规格:10 GB 根磁盘、2048 MB RAM、2 个 vCPU、5 GB 临时磁盘、1024 MB 交换空间,规格 ID 为 42。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [student@workstation ~(architect1-production)]$ openstack flavor create \
--id 42 \
--ram 2048 \
--disk 10 \
--vcpus 2 \
--ephemeral 5 \
--swap 1024 \
default-extra-disk
+----------------------------+--------------------+
| Field | Value |
+----------------------------+--------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 5 |
| disk | 10 |
| id | 42 |
| name | default-extra-disk |
| os-flavor-access:is_public | True |
| properties | |
| ram | 2048 |
| rxtx_factor | 1.0 |
| swap | 1024 |
| vcpus | 2 |
+----------------------------+--------------------+
|
4. 配置 rhel7-web 镜像为 public。
4.1. 这必须作为一个管理员用户来操作,所以验证您是否持有 architect1 凭据。修改 rhel7-web 镜像可见度为 public。
1
2
3
| [student@workstation ~(architect1-production)]$ openstack image set \
--public \
rhel7-web
|
4.2. 验证 rhel7-web 镜像可见度现在是 public。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(architect1-production)]$ openstack image show rhel7-web
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | c37de831bdbc9b50379bd2008c399275 |
| container_format | bare |
| created_at | 2018-06-19T05:14:18Z |
| disk_format | qcow2 |
| file | /v2/images/a6b0ab1f-2ff8-4751-bed4-efcfb140d0fe/file |
| id | a6b0ab1f-2ff8-4751-bed4-efcfb140d0fe |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| | min_disk | 10 |
| min_ram | 2048 |
| name | rhel7-web |
| owner | 00f7c7f68e7c4d72bab53dda8492ffcb |
| properties | direct_url='...', locations='...' |
| protected | True |
| schema | /v2/schemas/image |
| size | 971767808 |
| status | active |
| tags | |
| updated_at | 2018-06-19T05:45:11Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
|
在 workstation 上运行 lab prepinternal-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab prepinternal-lab grade
|
在 workstation 上运行 lab prepinternal-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab prepinternal-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- protected 镜像与 public 镜像是什么关系?
- 网络与子网分别侧重什么?
自测答案#
- 删除保护与可见范围相互独立。保护属性控制删除,可见性控制访问范围。
- 二层连接与地址参数。子网定义 CIDR、DHCP、网关等参数。
C6-部署实例#
实例功能验证#
依次检查 server show 中的镜像、规格和网络,取得控制台 URL,登录操作系统,检查内存、磁盘与 CPU,再验证 DHCP 或应用服务访问。不要只依据仪表板 Power State 下结论。
pause、unpause 与 stop#
暂停实例会冻结执行,控制台与运行中的 ping 也会停住;取消暂停后继续执行。停止实例是另一种状态变化。通过连续 ping 观察执行暂停与恢复,记录操作前后状态和控制台现象。
DHCP 命名空间验证#
没有公共访问路径时,可在 controller0 的对应 DHCP 网络命名空间中测试实例。先用网络 UUID 找到正确命名空间,再执行 ping 或 curl。检查的是指定网络内的连接,不应误认为已测试外部客户端访问。
常见问题#
控制台 URL 中含临时令牌,过期后重新获取。实例 IP 和 UUID 以实际输出为准。内存数值可能因 kdump 等预留小于规格值,核算时注意 /proc/meminfo 的单位,按输出字段的实际单位换算。
实例生命周期#
| 操作 | 含义 | 观察点 |
|---|
| start / stop | 启动 / 关闭实例 | ACTIVE / SHUTOFF |
| pause / unpause | 暂停 / 恢复执行 | PAUSED / ACTIVE;应用请求会停顿 |
| reboot | 重启实例 | 启动日志与业务重新就绪 |
| delete | 删除实例资源 | 临时磁盘及关联资源生命周期 |
1
2
3
4
| openstack server show <实例UUID>
openstack server pause <实例UUID>
openstack server unpause <实例UUID>
openstack console log show <实例UUID>
|
实例内检查#
1
2
3
4
5
| ip address
ip route
cat /proc/meminfo
lscpu
lsblk
|
MemTotal 受内核及预留内存影响,小于 Flavor 的 RAM 不必然是错误;/proc/meminfo 中 kB 字段按其单位换算。
从 DHCP namespace 访问私有网络#
仅适用于采用 Neutron DHCP agent 的网络后端。在 controller0 先找实际命名空间:
1
2
| sudo ip netns list
sudo ip netns exec qdhcp-<网络UUID> ping -c 3 <实例固定IP>
|
CL210 的 OVN 后端不应默认存在同样的 qdhcp namespace。
实例验证流程#
创建 → 控制台登录 → 查看 CPU / RAM / 磁盘 → 查看地址路由 → 从正确网络位置访问 → 暂停与恢复时观察连续测试 → 清理。ACTIVE 但应用不通时,把排查继续推进到实例内部。
实验操作#
引导练习:启动实例#
在此指导练习中,启动一个使用仪表板的示例。您还将删除该实例,并使用 CLI 启动一个新实例。
学习目标#
完成后能够:
登录到仪表板上,并使用现有资源推出一个实例。
删除使用 CLI 的例子。
利用现有资源,从 CLI 中创建一个新的实例。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。
在 workstation 上,使用 setup 参数运行 lab depinternal-launch 脚本。它为此项练习创建了所需的组件,如用户、 密码、 镜像和网络。
1
| [student@workstation ~]$ lab depinternal-launch setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
2. 以 developer1 作为用户名和 redhat 作为密码登录到仪表板。
3. 单击窗口右上角的项目菜单以核实 finance 是当前项目。
4. 使用 default 规格、 rhel7 镜像和 finance-network1 网络启动一个名为 finance-server2 的实例。
4.1. 打开 Compute(计算)下的 Instances(实例)子选项卡。
4.2. 点击 Launch Instance(启动实例)。
4.3. 在详细选项卡中,输入 finance-server2 作为实例名称。
4.4. 在 Source 选项卡点击 Select Boot Source > Image。
4.5. 在 Source 选项卡点击 rhel7 镜像同行的向上箭头,选用该镜像。在 Create New Volume 下选择 No。
4.6. 在 Flavor 标签上,单击同一行的向上箭头按钮来分配 default 规格。
4.7. 在网络标签上,如果 finance-network1 网络尚未分配,请单击与网络同行的向上箭头按钮来分配 finance-network1 网络。
操作界面、表格与配置图
4.8. 点击 Launch Instance,启动 finance-server2。
5. 稍等几秒,检查 Power State 列。实例应处于 Running 状态。实例运行后,退出仪表板。
6. 在 workstation 上,打开一个终端并打开用 source 加载 developer1 用户的身份环境文件 /home/student/developer1-finance-rc。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
7. 删除在仪表板上创建的实例。校验此实例将被删除。
7.1.
列出所有可用的实例。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server2",
"Image": "rhel7",
"ID": "bc8560ae-d9fa-4fdd-847d-fa58f8fd64ac",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.N"
}
]
|
7.2. 删除名为 finance-server2 的现有实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server2
|
7.3. 列出实例,验证该实例已删除。
1
| [student@workstation ~(developer1-finance)]$ openstack server list
|
8. 使用现有资源启动名为 finance-server3 的新实例。验证此实例正在运行。
8.1. 创建一个名为 finance-server3 的新实例。使用 rhel7 镜像、 default 规格和 finance-network1 网络。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(developer1-finance)]$ openstack server create \
--image rhel7 \
--flavor default \
--nic net-id=finance-network1 \
--wait finance-server3
+-----------------------------+-----------------------------------------------+
| Field | Value |
+-----------------------------+-----------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
|
操作界面、表格与配置图
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
| | OS-EXT-STS:power_state | Running |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2018-06-12T06:12:28.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | finance-network1=192.168.1.P |
| adminPass | PczUCE2wL6ss |
| config_drive | |
| created | 2018-06-12T06:12:13Z |
| flavor | default (5ed66a7a-7e62-46ad-9ab7-1cc42a18fc0c)|
| hostId | c624...44a0 |
| id | 3172b88d-7259-44e4-9016-25fb7d4f5bde |
| image | rhel7 (d6a496f1-87b2-4176-bd61-1700ce3f6887) |
| key_name | None |
| name | finance-server3 |
| progress | 0 |
| project_id | 438f276649894dcdbedb36ba1dc5296f |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-12T06:12:29Z |
| user_id | 17dd9d37aaff43b7beb31771a6e1227c |
| volumes_attached | |
+-----------------------------+-----------------------------------------------+
|
8.2. 列出所有可用于验证 finance-server3 实例运行中的可用实例。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server3",
"Image": "rhel7",
"ID": "e2304849-8e71-4702-97e1-5cada99d83bf",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.P"
}
]
|
在 workstation 上运行 lab depinternal-launch cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab depinternal-launch cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:验证实例功能#
在此引导练习中,连接到运行中的实例,并校验规格设置。您还将使用 CLI 暂停并停止一个实例。
学习目标#
完成后能够:
打开控制台并登录到运行实例。
核查运行实例的规格设置。
使用 CLI 停止、暂停和删除运行实例。
开始之前#
确保 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。
在 workstation 上,运行 lab depinternal-verify setup,核查 OpenStack 服务是否运行,前几节创造的资源是否可用。
1
| [student@workstation ~]$ lab depinternal-verify setup
|
操作步骤#
1. 在 workstation 上打开终端并用 source 加载 developer1 用户的身份环境文件。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
2. 查找运行实例所使用的规格细节。
2.1. 列出所有可用实例以查找运行中实例的名称。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server3",
"Image": "rhel7",
"ID": "deca6e99-f662-4109-811e-5141c0406564",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.N"
}
]
|
2.2. 查看实例详情,确定它使用的规格。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server show \
finance-server3
|
操作界面、表格与配置图
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
| +-----------------------------+-----------------------------------------------+
| Field | Value |
+-----------------------------+-----------------------------------------------+
| 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-06-12T06:32:56.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | finance-network1=192.168.1.N |
| config_drive | |
| created | 2018-06-12T06:32:40Z |
| flavor | default (5ed66a7a-7e62-46ad-9ab7-1cc42a18fc0c)|
| hostId | c624...44a0 |
| id | deca6e99-f662-4109-811e-5141c0406564 |
| image | rhel7 (d6a496f1-87b2-4176-bd61-1700ce3f6887) |
| key_name | None |
| name | finance-server3 |
| progress | 0 |
| project_id | 438f276649894dcdbedb36ba1dc5296f |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-12T06:32:57Z |
| user_id | 17dd9d37aaff43b7beb31771a6e1227c |
| volumes_attached | |
+-----------------------------+-----------------------------------------------+
|
2.3. 审查 default 规格的规格
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~(developer1-finance)]$ openstack flavor show default
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| access_project_ids | None |
| disk | 10 |
| id | 5ed66a7a-7e62-46ad-9ab7-1cc42a18fc0c |
| name | default |
| os-flavor-access:is_public | True |
| properties | |
| ram | 2048 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 2 |
+----------------------------+--------------------------------------+
|
3. 登录到实例。
3.1. 获取控制台连接的 URL。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack console url show \
finance-server3
+-------+------------------------------------------------------------+
| Field | Value |
+-------+------------------------------------------------------------+
| type | novnc |
|
操作界面、表格与配置图
1
2
| | url | http://172.25.250.50:6080/vnc_auto.html?token=2f25...438f |
+-------+------------------------------------------------------------+
|
3.2. 在 workstation 上,打开Firefox,浏览前一个输出 http://172.25.250.50:6080/vnc_auto.html?token=2f252beb-4fe3-4e97-bf85-073533b1438f 的 URL。
3.3. 从 Firefox 的主控台,登录到 finance-server3 实例为 root。密码是 redhat。
1
2
3
4
5
6
| Red Hat Enterprise Linux Server release 7.5 (Maipo)
Kernel 3.10.0-862.el7.x86_64 on an x86_64
small image
finance-server3 login: root
Password: redhat
[root@finance-server3 ~]#
|
4. 审查 RAM、磁盘和 CPU 配置实例。
4.1. 从 /proc/meminfo 特殊文件中获取 MemTotal 变量的值,以确保 RAM 数量与规格定义的数值,即 2048 MiB 匹配。
1
2
| [root@finance-server3 ~]# grep MemTotal /proc/meminfo
MemTotal: 1882616 kB
|
内核在启动时为 kdump 预留一部分内存。kdump 可在内核崩溃时将系统内存副本保存到磁盘供分析。这解释了上方输出中约 200 MiB 的差额;内存差值为 2097152 − 1882616 = 214536 KiB,约 209.5 MiB。
4.2. 使用 df 命令确保此实例有按规格定义的 10 GB 盘。
1
2
3
4
5
6
7
8
| [root@finance-server3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 10G 1.1G 9.0G 11% /
devtmpfs 898M 0 898M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.5M 911M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs 184M 0 184M 0% /run/user/0
|
4.3. 确定实例使用的 CPU 数量。确保该数量与规格定义的 VCPU 数量相符。
1
2
3
4
| [root@finance-server3 ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 2
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 13
Model name: QEMU Virtual CPU version 2.5+
Stepping: 11
CPU MHz: 2294.872
BogoMIPS: 4589.74
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K
L3 cache: 16384K
NUMA node0 CPU(s): 0,1
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx lm constant_tsc rep_good
nopl pni ssse3 cx16 x2apic hypervisor lahf_lm
|
5. 验证实例网络,然后依次暂停、取消暂停和停止实例,观察其反应。
5.1. 在实例内使用 ping 测试网络的 DHCP 服务器。保持 ping 运行,后续步骤将用它观察状态变化。
1
2
3
4
5
6
| [root@finance-server3 ~]# ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=63 time=0.642 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=63 time=0.457 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=63 time=0.596 ms
...output omitted...
|
5.2. 当 ping 命令正在激活时,请返回 workstation 上的终端。作为 developer1 用户,请暂停运行实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server pause \
finance-server3
|
在 Firefox 的例控制台中,请在例暂停时观察行为。请注意 ping 命令已暂停,且控制台没有响应。
5.3. 返回 workstation 终端,取消实例暂停,观察实例反应。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server unpause \
finance-server3
|
ping 命令应该恢复在 Firefox 控制台。
5.4. 停止此例并在 Firefox 中观察此例的控制台: 您应该断开。
操作界面、表格与配置图
1
2
| [student@workstation ~(developer1-finance)]$ openstack server stop \
finance-server3
|
5.5. 关闭火狐
6. 重新启动实例并验证它正在运行。
6.1. 启动实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server start \
finance-server3
|
6.2. 列出所有可用的实例,检查实例的状态。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server3",
"Image": "rhel7",
"ID": "deca6e99-f662-4109-811e-5141c0406564",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.N"
}
]
|
7. 删除实例并核实它被删除。
7.1.
删除 finance-server3 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server3
|
7.2. 列出所有可用实例,以核实 finance-server3 实例已被删除。
1
| [student@workstation ~(developer1-finance)]$ openstack server list
|
在 workstation 上运行 lab depinternal-verify cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab depinternal-verify cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:部署实例#
在此实验中,删除设置脚本创建的实例,启动一个实例,并验证被启动实例使用正确的镜像、 规格和网络。
学习目标#
完成后能够:
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。
在 workstation 上,使用 setup 参数运行 lab depinternal-lab 脚本。它为这个实验创造所需的资源。
1
| [student@workstation ~]$ lab depinternal-lab setup
|
操作步骤#
1. 在 workstation 上,打开一个终端作为 student 并加载 operator1 环境文件,/home/student/operator1-production-rc。
2. 删除名为 production-server6 的现有实例。
3. 使用 default 规格、 rhel7-web 镜像和 production-network1 网络启动一个名为 production-server7 的实例。
4. 验证此实例是否使用正确的规格、 网络和镜像创建。
5. 在 controller0 上,校验您能够从与 production-network1 网络有关联的 DHCP 网络命名空间进入此实例内运行的Web 服务器。您可以在用于测试的命名空间内运行 curl 命令。
要登录到 controller0 成为 root, 您应该先登录为 heat-admin 用户,然后使用 sudo -i 命令成为 root。
在 workstation 上运行 lab depinternal-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab depinternal-lab grade
|
在 workstation 上运行 lab depinternal-lab cleanup,清理本练习创建的资源。
操作界面、表格与配置图
1
| [student@workstation ~]$ lab depinternal-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
在此实验中,删除设置脚本创建的实例,启动一个实例,并验证被启动实例使用正确的镜像、 规格和网络。
学习目标#
完成后能够:
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。
在 workstation 上,使用 setup 参数运行 lab depinternal-lab 脚本。它为这个实验创造所需的资源。
1
| [student@workstation ~]$ lab depinternal-lab setup
|
操作步骤#
1. 在 workstation 上,打开一个终端作为 student 并加载 operator1 环境文件,/home/student/operator1-production-rc。
1.1.
在 workstation 上,加载 operator1 用户的环境文件。环境文件设置身份验证服务终端、 用户名、 密码、 域名和项目,供 OpenStack 统一 CLI 使用。
1
2
| [student@workstation ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$
|
2. 删除名为 production-server6 的现有实例。
2.1. 列出所有可以查找名为 production-server6 的实例。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(operator1-production)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "production-server6",
"Image": "rhel7-web",
"ID": "2d7526ed-70bd-400e-94e0-bba213c44f8a",
"Flavor": "default",
"Networks": "production-network1=192.168.1.N"
}
]
|
2.2. 删除 production-server6 实例。
1
| [student@workstation ~(operator1-production)]$ openstack server delete \
|
操作界面、表格与配置图
2.3. 列出所有可用实例,验证实例已删除。
1
| [student@workstation ~(operator1-production)]$ openstack server list
|
3. 使用 default 规格、 rhel7-web 镜像和 production-network1 网络启动一个名为 production-server7 的实例。
3.1. 使用给定的资源创建 production-server7 实例。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ openstack server create \
--image rhel7-web \
--flavor default \
--nic net-id=production-network1 \
--wait production-server7
...output omitted...
|
4. 验证此实例是否使用正确的规格、 网络和镜像创建。
4.1. 查看 production-server7 实例的细节,以核实是否使用了正确的资源。
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
| [student@workstation ~(operator1-production)]$ openstack server show \
production-server7
+-----------------------------+-----------------------------------------------+
| Field | Value |
+-----------------------------+-----------------------------------------------+
| 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-06-12T11:21:33.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | production-network1=192.168.1.P |
| config_drive | |
| created | 2018-06-12T11:21:01Z |
| flavor | default (db97...1fbc) |
| hostId | 2e30...efb8 |
| id | 16664e74-608d-4d53-9c15-6c317a5cee7a |
| image | rhel7-web (9c06...cbc7) |
| key_name | None |
| name | production-server7 |
| progress | 0 |
| project_id | 1bfc1e465c0442aab6d5fa387ae1c244 |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-12T11:21:34Z |
| user_id | c0a85a6918b14200884a276d92415872 |
| volumes_attached | |
+-----------------------------+-----------------------------------------------+
|
操作界面、表格与配置图
5. 在 controller0 上,校验您能够从与 production-network1 网络有关联的 DHCP 网络命名空间进入此实例内运行的Web 服务器。您可以在用于测试的命名空间内运行 curl 命令。
要登录到 controller0 成为 root, 您应该先登录为 heat-admin 用户,然后使用 sudo -i 命令成为 root。
5.1. 获取 production-server7 实例的 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
26
27
28
29
30
31
32
| [student@workstation ~(operator1-production)]$ openstack server show \
production-server7
+-----------------------------+-----------------------------------------------+
| Field | Value |
+-----------------------------+-----------------------------------------------+
| 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-06-12T11:21:33.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | production-network1=192.168.1.P |
| config_drive | |
| created | 2018-06-12T11:21:01Z |
| flavor | default (db97...1fbc) |
| hostId | 2e30...efb8 |
| id | 1666...ee7a |
| image | rhel7-web (9c06...cbc7) |
| key_name | None |
| name | production-server7 |
| progress | 0 |
| project_id | 1bfc1e465c0442aab6d5fa387ae1c244 |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-12T11:21:34Z |
| user_id | c0a85a6918b14200884a276d92415872 |
| volumes_attached | |
+-----------------------------+-----------------------------------------------+
|
注意上一个输出中的地址 192.168.1.P。
5.2. 获取 production-network1 网络的 ID。您在下一步使用此 ID 来定位相关网络命名空间。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~(operator1-production)]$ openstack network show \
production-network1
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | nova |
| created_at | 2018-06-12T09:01:11Z |
| description | |
| dns_domain | None |
| id | 49f4ab91-42f9-4944-8694-81ba503991b3 |
| ipv4_address_scope | None |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| | ipv6_address_scope | None |
| is_default | None |
| is_vlan_transparent | None |
| mtu | 1450 |
| name | production-network1 |
| port_security_enabled | True |
| project_id | 1bfc1e465c0442aab6d5fa387ae1c244 |
| provider:network_type | None |
| provider:physical_network | None |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 4 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | dbdb156f-8c2b-4ffa-82ff-d6b4976aed2a |
| tags | |
| updated_at | 2018-06-12T09:01:29Z |
+---------------------------+--------------------------------------+
|
记下网络 ID。上例中的 49f4ab91-42f9-4944-8694-81ba503991b3 可能与你的环境不同。
5.3. 以 heat-admin 方式登录到 controller0, 并使用 sudo -i 命令成为 root。
1
2
3
| [student@workstation ~(operator1-production)]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
5.4. 列出可用的 DHCP 网络命名空间,并找到使用 production-network1 网络 ID 的命名空间。
1
2
3
| [root@controller0 ~]# ip netns
qdhcp-49f4ab91-42f9-4944-8694-81ba503991b3 (id: 1)
qdhcp-0177f4ee-87d1-47e0-b0e1-c42171311dce (id: 0)
|
5.5. 使用 production-network1 网络的 DHCP 网络命名空间,使用 ping 命令达到 production-server7 实例的 IP 地址。
1
2
3
4
5
6
7
8
9
10
| [root@controller0 ~]# ip netns exec \
qdhcp-49f4ab91-42f9-4944-8694-81ba503991b3 \
ping -c3 192.168.1.P
PING 192.168.1.P (192.168.1.P) 56(84) bytes of data.
64 bytes from 192.168.1.P: icmp_seq=1 ttl=64 time=5.18 ms
64 bytes from 192.168.1.P: icmp_seq=2 ttl=64 time=3.43 ms
64 bytes from 192.168.1.P: icmp_seq=3 ttl=64 time=4.72 ms
--- 192.168.1.P ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 3.436/4.449/5.188/0.743 ms
|
5.6. 使用 curl 命令访问在实例内运行的Web 服务器。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
| [root@controller0 ~]# ip netns exec \
qdhcp-49f4ab91-42f9-4944-8694-81ba503991b3 \
curl 192.168.1.P
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/
DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test Page for the Apache HTTP Server on Red Hat Enterprise Linux</
title>
...output omitted...
|
5.7. 从 controller0 登出。
1
2
3
| [root@controller0 ~]# exit
[heat-admin@controller0 ~]$ exit
[student@workstation ~(operator1-production)]$
|
在 workstation 上运行 lab depinternal-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab depinternal-lab grade
|
在 workstation 上运行 lab depinternal-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab depinternal-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 实例 ACTIVE 是否足以证明 Web 服务可用?
- 对实例执行 unpause 是什么操作?
自测答案#
- 还需要应用访问验证。生命周期状态不能替代实际服务响应。
- 取消暂停继续运行 unpause 恢复暂停的实例执行。
C7-管理块存储#
存储对象对照#
| 对象 | 作用 | 验证方式 |
|---|
| 临时磁盘、交换磁盘 | 随实例使用的磁盘资源 | 查看实例设备与后端 RBD 镜像 |
| 持久卷 | 独立于实例管理的数据块设备 | 附加、分区、格式化、挂载、写文件 |
| 卷快照 | 记录卷状态供恢复或克隆 | 从快照建卷,再读原文件 |
| 可启动卷 | 作为实例根磁盘启动 | 删除旧实例后用原卷启动新实例 |
| 卷转移 | 交给其他项目用户接收 | 转移 ID 与授权密钥、接收后验证数据 |
附加不等于挂载#
OpenStack 附加卷后,实例操作系统才看到块设备。文件系统的分区、格式化和挂载在实例内部完成。分离卷前先卸载文件系统,验证没有挂载点,再回到云端执行 detach,等待卷 available。
设备名不能凭记忆判断。不同实例、不同附加顺序可能出现 /dev/vdb 或 /dev/vdd;先核对 Attached To 和实例内部设备信息。格式化会覆盖文件系统,只对确认无须保留数据的新卷执行。
快照与转移#
快照创建、卷创建、附加与分离都是需要等待状态收敛的操作。转移时保存 ID 和 auth_key,在接收用户环境中接受。验证不能只看卷列表,还要挂载后读取此前写入的文件。
搁置与恢复#
shelve 和 unshelve 用于搁置及恢复实例。可通过恢复后读取文件验证启动卷的数据保留。SHELVED_OFFLOADED 表示已卸载计算资源的搁置状态;恢复后确认 ACTIVE,再登录读取文件。不要把 unshelve 解释为卸载文件系统或删除实例。
存储生命周期#
| 存储 | 创建来源 | 删除实例后的处理 |
|---|
| 本地或 RBD 临时根磁盘 | 镜像启动 | 随实例生命周期管理 |
| Ephemeral 附加磁盘 | Flavor | 随实例生命周期管理 |
| Cinder 数据卷 | 独立创建或由编排创建 | 按卷和删除策略处理 |
| Cinder 启动卷 | 镜像生成或已有可启动卷 | 核对 delete-on-termination,不一概认为保留 |
卷的完整使用过程#
1
2
3
4
| # workstation:项目用户
openstack volume create --size 2 demo-data
openstack volume show demo-data
openstack server add volume <实例UUID> demo-data
|
实例内部先用 lsblk -f 确定新设备。以下假设已核实空白新卷为 /dev/vdb:
1
2
3
4
5
6
| sudo mkfs.xfs /dev/vdb
sudo mkdir -p /data
sudo mount /dev/vdb /data
echo persistent-test | sudo tee /data/proof.txt
sudo sync
sudo umount /data
|
只对确认没有需要保留数据的新卷执行 mkfs。 对已有卷应挂载原文件系统。
1
2
3
4
5
| # 回到 workstation,等待分离后 available
openstack server remove volume <实例UUID> demo-data
openstack volume show demo-data
openstack volume snapshot create --volume demo-data demo-snap
openstack volume create --snapshot demo-snap --size 2 demo-restore
|
将恢复卷附加到验证实例,直接挂载并读取 proof.txt;重新格式化会破坏恢复验证。
卷转移#
1
2
3
4
| # 发送项目用户:卷应已卸载并分离
openstack volume transfer request create demo-data
# 接收项目用户:加载自己的 RC 后使用刚返回的 ID 和 auth_key
openstack volume transfer request accept --auth-key <授权密钥> <转移ID>
|
从卷启动#
1
2
3
4
| openstack volume create --image rhel7 --size 10 demo-root
openstack volume show demo-root
openstack server create --volume demo-root --flavor default \
--nic net-id=finance-network1 --wait demo-volume-server
|
快照通常是某一时点的块状态,应用一致性还依赖停写、刷盘或应用自身机制。用“能创建快照”替代“数据库可恢复”会遗漏验证。
实验操作#
引导练习:管理临时块存储#
本练习创建带临时磁盘和交换磁盘的实例,验证对应的后端 Ceph RBD 镜像已创建。随后删除实例,并确认关联的后端 RBD 镜像已移除。
学习目标#
完成后能够:
建立互换和临时磁盘的实例。
验证交换磁盘和临时磁盘的后端文件。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
以 student 为密码,登录到 workstation 时为 student。从 workstation 运行 lab blockstorage-ephemeral setup 以核实前几节创建的资源是否可用。
1
| [student@workstation ~]$ lab blockstorage-ephemeral setup
|
操作步骤#
1. 使用 developer1 环境文件创建实例,名为 finance-server7。配置此实例可使用 rhel7 镜像、 default-extra-disk 规格和 finance-network1 网络。
1.1.
用 source 加载 developer1-finance-rc 环境文件,以装入 developer1 用户凭据。
1
| [student@workstation ~]$ source ~/developer1-finance-rc
|
1.2. 使用 rhel7 镜像、 default-extra-disk 规格和 finance-network1 网络创建一个名为 finance-server7 的示例。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~(developer1-finance)]$ openstack server create \
--image rhel7 \
--flavor default-extra-disk \
--nic net-id=finance-network1 \
finance-server7
+--------------------------------------+------------------------------------+
| Field | Value |
+--------------------------------------+------------------------------------+
|... | |
| flavor | default-extra-disk (d7aa...ae28) |
| image | rhel7 (ca303...da81) |
| name | finance-server7 |
|... | |
+--------------------------------------+------------------------------------+
|
操作界面、表格与配置图
1.3. 核实 finance-server7 实例的状态为 ACTIVE。成为 ACTIVE 可能需要一些时间。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Status
+-----------------+--------+
| Name | Status |
+-----------------+--------+
| finance-server7 | ACTIVE |
+-----------------+--------+
|
2. 验证 finance-server7 中的交换磁盘和临时磁盘可用。
2.1. 为 finance-server7 实例显示控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack console url show \
finance-server7
+-------+--------------------------------------------------------------+
| Field | Value |
+-------+--------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=0a90...a9e6 |
+-------+--------------------------------------------------------------+
|
2.2. 打开一个 Firefox 浏览器,然后从上一步输入 URL 以访问 finance-server7 实例控制台。
2.3. 将 finance-server7 实例登录为 root, 使用 redhat 进行密码输入。控制台显示登录提示可能需要一些时间。
2.4. 验证在 /dev/vdc 中的交换盘是否可用。
1
2
3
| [root@finance-server7 ~]# swapon -s
Filename Type Size Used Priority
/dev/vdc partition 1048572 0 -1
|
2.5. 验证临时磁盘为 /dev/vdb,并在 finance-server7 中挂载到 /mnt。
1
2
| [root@finance-server7 ~]# mount | grep /mnt
/dev/vdb on /mnt type vfat (rw,...)
|
2.6. 创建名为 /mnt/testfile.txt 的 10 MB 文件。
1
2
3
4
5
6
7
8
| [root@finance-server7 ~]# dd \
if=/dev/zero \
of=/mnt/testfile.txt \
bs=1024k \
count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.0486917 s, 215 MB/s
|
操作界面、表格与配置图
3. 在 controller0 查找 finance-server7 根磁盘、临时磁盘及交换磁盘对应的后端 Ceph RBD 镜像。
3.1. 为 finance-server7 实例获取 ID。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack server show \
finance-server7 -c id -f value
9d5164a5-e409-4409-b3a0-779e0b90dec9
|
3.2. 登录到 controller0 节点为 heat-admin。不需要密码。
1
2
| [student@workstation ~(developer1-finance)]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$
|
3.3. 使用 ceph df 命令显示 RED Hat OpenStack 平台 director 配置的 Ceph 池。验证 vms 池是否可用。
1
2
3
4
5
6
| [heat-admin@controller0 ~]$ ceph df
...output omitted...
POOLS:
NAME ID USED %USED MAX AVAIL OBJECTS
vms 4 1379M 2.57 52340M 364
...output omitted...
|
3.4. 使用 rbd ls –pool vms 列出 vms 池中的 RBD 镜像。应看到与实例对应的三个镜像,名称前缀为 finance-server7 的 ID;后缀分别为 _disk(根磁盘)、_disk.eph0(临时磁盘)和 _disk.swap(交换磁盘)。
1
2
3
4
| [heat-admin@controller0 ~]$ rbd ls --pool vms
9d5164a5-e409-4409-b3a0-779e0b90dec9_disk
9d5164a5-e409-4409-b3a0-779e0b90dec9_disk.eph0
9d5164a5-e409-4409-b3a0-779e0b90dec9_disk.swap
|
3.5. 从 controller0 中退出。
1
2
3
| [heat-admin@controller0 ~]$ logout
Connection to controller0 closed.
[student@workstation ~(developer1-finance)]$
|
4. 在 workstation 上,删除 finance-server7 实例。
4.1. 删除 finance-server7 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server7
|
4.2. 验证 finance-server7 实例已被删除。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server list
... output omitted ...
|
操作界面、表格与配置图
5. 验证 finance-server7 实例相关磁盘的 RBD 后端镜像是否已被删除。
5.1. 登录到 controller0 服务器为 heat-admin。不需要密码。
1
2
| [student@workstation ~(developer1-finance)]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$
|
5.2. 运行 rbd ls –pool vms。列表中应不再有以 finance-server7 实例 ID 为名称前缀的 RBD 镜像。
1
| [heat-admin@controller0 ~]$ rbd ls --pool vms
|
5.3. 从 controller0 中退出。
1
2
3
| [heat-admin@controller0 ~]$ logout
Connection to controller0 closed.
[student@workstation ~(developer1-finance)]$
|
6. 关闭显示 finance-server7 控制台的浏览器标签。
在 workstation 上运行 lab blockstorage-ephemeral cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab blockstorage-ephemeral cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理持久块存储#
在此练习中,创建一个卷,将一些数据写入其中,并将它传输到另一个用户。第二个用户将检查卷数据是否仍然可用,在一个实例中加载卷。
学习目标#
完成后能够:
创建一卷。
将卷附在一例之后并使用卷。
转让一卷。
核实某一卷的数据持久性。
· 删除一个卷。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。
从 workstation 运行 lab blockstorage-persistent setup, 以核实 OpenStack 服务正在运行,且前几节中创建的资源已经可用。实验脚本还创建了 research 项目、 research-server1 实例、 developer4 用户及其环境文件。
1
| [student@workstation ~]$ lab blockstorage-persistent setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。以 developer1 登录仪表板,密码为 redhat。
2. 作为 developer1 用户,创建名为 finance-volume1 的 1 GB 卷
2.1. 导航到项目 > 卷 > 卷和单击+ Create 卷。
在卷名字段中输入 finance-volume1。在大小( GiB) 字段中选择 1。单击创建卷以创建卷。
3. 将 finance-volume1 卷附加到 finance-server7 实例,并核实设备状态为 In-Use。
3.1. 选择 finance-volume1 卷菜单中的管理附件。
3.2. 在 Attach to Instance 中选择 finance-server7,点击 Attach Volume。
操作界面、表格与配置图
3.3. 观察状态由 Attaching 变为 In-Use。检查 Attached To 字段,确认 finance-volume1 在 finance-server7 上映射到 /dev/vdd。
4. 连接到 finance-server7 实例的主控台。
4.1. 导航到项目 > 计算 > 实例。
单击菜单中的 finance-server7 实例控制台打开控制台。
4.2. 单击 Click here to show only console 链接。
4.3. 以 root 作为用户名和 redhat 作为密码,登录到 finance-server7 实例控制台。
5. 在 finance-server7 内对 finance-volume1 分区,并挂载到 /volume1。
5.1. 核查/dev/vdd 是否有与 volume1 卷有关的设备可用。
1
2
| [root@finance-server7 ~]# parted /dev/vdd print
...output omitted...
|
5.2. 在 /dev/vdd 设备上新建一个 1 GB 分区。
1
2
3
4
| [root@finance-server7 ~]# parted /dev/vdd \
mklabel msdos \
mkpart primary xfs 1M 1G
...output omitted...
|
5.3. 在 /dev/vdd1 分区上创建 XFS 文件系统。
1
2
| [root@finance-server7 ~]# mkfs.xfs /dev/vdd1
...output omitted...
|
5.4. 创建 /volume1 目录。
1
| [root@finance-server7 ~]# mkdir /volume1
|
5.5. 在 /volume1 目录上挂载 /dev/vdd1 分区。
1
| [root@finance-server7 ~]# mount -t xfs /dev/vdd1 /volume1
|
5.6. 验证 /dev/vdd1 分区是否正确挂载。
1
2
| [root@finance-server7 ~]# mount | grep /volume1
/dev/vdd1 on /volume1 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
|
5.7. 创建名为 /volume1/testfile 的 10 MB 文件
1
| [root@finance-server7 ~]# dd \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
| if=/dev/zero \
of=/volume1/testfile \
bs=1024k \
count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.0486917 s, 215 MB/s
|
6. 从 finance-server7 实例中卸载 volume1 卷。
6.1. 从 /volume1 中卸载 /dev/vdd1 设备。
1
| [root@finance-server7 ~]# umount /volume1
|
6.2. 验证 /dev/vdd1 设备是否正确卸载。/volume1 目录不应返回挂载点。
1
| [root@finance-server7 ~]# mount | grep /volume1
|
7. 在仪表板上,从 finance-server7 实例中分离出 volume1 卷。
7.1.
导航到项目 > 卷 > 卷并单击 finance-volume1 卷菜单中的管理附件。
7.2. 单击 Detach 卷以获取 finance-server7。在窗口中再次单击 Detach 卷以确认。
7.3. 当状态从 Detaching 转换为 Available 时观察此卷。
8. 传输 finance-volume1 卷并保存转账 ID 和授权密钥。
8.1. 单击 finance-volume1 卷的菜单中创建传输。
在传输名称字段中输入 financevolume1-transfer。单击创建卷传输并创建传输。
8.2. 单击下载传输凭据并保存文件。此文件包含传输 ID 和授权密钥。完成后单击关闭。
9. 在 workstation 终端中用 source 加载 developer4 用户凭据,再用之前取得的转移凭据接受卷转移。
9.1. 用 source 加载 developer4-research-rc 文件,以装入 developer4 用户凭据。
1
| [student@workstation ~]$ source ~/developer4-research-rc
|
9.2. 检查传输 ID 和授权密钥。
1
2
3
4
| [student@workstation ~(developer4-research)]$ cat ~/Downloads/e3170c79-
c08c-4a32-8535-7c71b5c26685.txt
Transfer name: financevolume1-transfer
Transfer ID: e3170c79-c08c-4a32-8535-7c71b5c26685
|
操作界面、表格与配置图
1
| Authorization Key: d160ca8abd86ecb1
|
9.3. 使用之前取得的转移 ID 和授权密钥,接受 finance-volume1 卷转移。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer4-research)]$ openstack volume transfer \
request accept \
--auth-key d160ca8abd86ecb1 \
e3170c79-c08c-4a32-8535-7c71b5c26685
+-----------+--------------------------------------+
| Field | Value |
+-----------+--------------------------------------+
| id | e3170c79-c08c-4a32-8535-7c71b5c26685 |
| name | financevolume1-transfer |
| volume_id | 77b196b6-6bc8-404e-9fbb-5d2cc7b24ede |
+-----------+--------------------------------------+
|
9.4. 验证 finance-volume1 卷现在是否可用于 developer4 用户。
1
2
3
4
5
6
7
| [student@workstation ~(developer4-research)]$ openstack volume list \
-c Name -c Status
+-----------------+-----------+
| Name | Status |
+-----------------+-----------+
| finance-volume1 | available |
+-----------------+-----------+
|
10. 将 finance-volume1 卷附加到由实验脚本创建的 research-server1 实例。
10.1. 验证 research-server1 实例的状态是 ACTIVE。
1
2
3
4
5
6
7
| [student@workstation ~(developer4-research)]$ openstack server list \
-c Name -c Status
+------------------+--------+
| Name | Status |
+------------------+--------+
| research-server1 | ACTIVE |
+------------------+--------+
|
10.2. 将 finance-volume1 卷附加到 research-server1。
1
2
| [student@workstation ~(developer4-research)]$ openstack server add volume \
research-server1 finance-volume1
|
10.3. 验证finance-volume1 已被映射到 research-server1 实例中的 /dev/vdd 设备。
1
2
3
4
5
6
| [student@workstation ~(developer4-research)]$ openstack volume list \
-c Name -c Status -c "Attached to"
+-----------------+--------+-------------------------------------------+
| Name | Status | Attached to |
+-----------------+--------+-------------------------------------------+
| finance-volume1 | in-use | Attached to research-server1 on /dev/vdd |
|
操作界面、表格与配置图
1
| +-----------------+--------+-------------------------------------------+
|
11. 在实例中,将 /dev/vdd 设备挂载到 /volume1,验证数据保持完好。
11.1. 为 research-server1 实例获取控制台 URL, 并使用 Firefox 浏览器导航。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer4-research)]$ openstack console url show \
research-server1
+-------+----------------------------------------------------------------+
| Field | Value |
+-------+----------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=f975(...)8b40 |
+-------+----------------------------------------------------------------+
|
11.2. 以 root 作为用户名和 redhat 作为密码,登录到 research-server1 实例控制台。
11.3. 创建 /volume1 目录。
1
| [root@research-server1 ~]# mkdir /volume1
|
11.4. 在 /volume1 目录上挂载 /dev/vdd1 分区。
1
| [root@research-server1 ~]# mount -t xfs /dev/vdd1 /volume1
|
11.5. 验证 /dev/vdd1 分区是否正确挂载。
1
2
| [root@research-server1 ~]# mount | grep /volume1
/dev/vdd1 on /volume1 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
|
11.6. 验证 /volume1/testfile 是否仍然可用。
1
2
| [root@research-server1 ~]# ls /volume1
testfile
|
12. 从 research-server1 实例中卸载 finance-volume1 卷。
12.1. 从 /volume1 中卸载 /dev/vdd1 设备。
1
| [root@research-server1 ~]# umount /volume1
|
12.2. 验证称 /dev/vdd1 设备已被正确卸载。/volume1 目录不应返回挂载点。
1
| [root@research-server1 ~]# mount | grep /volume1
|
操作界面、表格与配置图
13. 从 workstation 中分离出 research-server1 实例中的 finance-volume1 卷。
13.1. 从 research-server1 实例中分离 finance-volume1 卷。
1
2
| [student@workstation ~(developer4-research)]$ openstack server remove volume \
research-server1 finance-volume1
|
13.2. 验证即 finance-volume1 卷已正确分离。请检查 finance-volume1 卷的状态是 available。
1
2
3
4
5
6
7
| [student@workstation ~(developer4-research)]$ openstack volume list \
-c Name -c Status
+-----------------+-----------+
| Name | Status |
+-----------------+-----------+
| finance-volume1 | available |
+-----------------+-----------+
|
14. 删除 finance-volume1 卷。
14.1. 删除 finance-volume1 卷。
1
2
| [student@workstation ~(developer4-research)]$ openstack volume delete \
finance-volume1
|
14.2. 验证已正确删除 finance-volume1 卷。
1
| [student@workstation ~(developer4-research)]$ openstack volume list
|
15. 退出仪表板,关闭显示实例控制台的浏览器标签页。
在 workstation 上运行 lab blockstorage-persistent cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab blockstorage-persistent cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:创建快照#
在此练习中,创建和删除快照。您也将从快照中创建卷,并将其附加到实例中。
学习目标#
完成后能够:
创建一卷。
制作快照。
从快照中创建卷,并在一例中使用。
删除快照。
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 登录 workstation,密码为 student。
从 workstation,运行 lab blockstorage-snapshots setup,核查 OpenStack 服务是否运行,前几节创造的资源是否可用。
1
| [student@workstation ~]$ lab blockstorage-snapshots setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。以 developer1 登录,密码为 redhat。
2. 将 finance-volume1 卷附加到 finance-server7 实例中。
2.1. 导航到项目 > 卷 > 卷 > 卷,并在 finance-volume1 卷的菜单中选择管理附件。
2.2. 在 Attach to Instance 中选择 finance-server7,再点击 Attach Volume。
2.3. 验证 finance-volume1 卷的状态字段值为 In-use。
3. 在 finance-server7 实例中,将 finance-volume1 卷挂载到 /volume1 目录中,并添加一个文件。
3.1. 导航到项目 > 计算 > 实例并在菜单中单击控制台以显示 finance-server7 实例的主控台。
3.2. 单击此处仅显示控制台。
3.3. 以 redhat 密码作为 root 用户登录到 finance-server7。
3.4. 请检查 finance-volume1 卷是否已映射到 /dev/vdd 设备。
1
| [root@finance-server7 ~]# parted /dev/vdd print
|
操作界面、表格与配置图
3.5. 在 /dev/vdd 设备中创建新分区。
1
2
3
4
| [root@finance-server7 ~]# parted /dev/vdd \
mklabel msdos \
mkpart primary xfs 1M 1G
...output omitted...
|
3.6. 在 /dev/vdd1 分区上创建 XFS 文件系统。
1
2
| [root@finance-server7 ~]# mkfs.xfs /dev/vdd1
...output omitted...
|
3.7. 创建 /volume1 目录。
1
| [root@finance-server7 ~]# mkdir /volume1
|
3.8. 在 /volume1 目录上挂载 /dev/vdd1 分区。
1
| [root@finance-server7 ~]# mount -t xfs /dev/vdd1 /volume1
|
3.9. 验证 /dev/vdd1 分区是否正确挂载。
1
2
| [root@finance-server7 ~]# mount | grep /volume1
/dev/vdd1 on /volume1 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
|
3.10. 创建 /volume1/testfile.txt,验证可向卷写入数据。
1
| [root@finance-server7 ~]# touch /volume1/testfile.txt
|
3.11. 卸载 /volume1/ 目录。
1
| [root@finance-server7 ~]# umount /volume1
|
4. 从 finance-server7 实例中分离出 finance-volume1 卷。
4.1. 导航到项目 > 卷 > 卷 > 卷并单击 finance-volume1 卷菜单中的管理附件。
4.2. 单击 Detach 卷将卷从 finance-server7 实例中分离出来。再次单击 Detach 卷以确认。
4.3. 验证 finance-volume1 卷状态为 Available。要分离卷可能需要一些时间。
5. 从 finance-volume1 卷中创建名为 finance-volume1-snapshot1 的快照。
操作界面、表格与配置图
5.1. 导航到项目 > 卷 > 卷并单击 finance-volume1 卷菜单中的创建快照。
在快照名称字段中输入 finance-volume1-snapshot1。单击创建卷快照。等待 finance-volume1-snapshot1 快照的状态字段值为 Available。
6. 从 finance-volume1-snapshot1 快照中创建名为 finance-snapshot1-volume1 的卷。
6.1. 在菜单中单击创建卷,用于 finance-volume1-snapshot1 快照。
6.2. 在卷名字段中输入 finance-snapshot1-volume1。单击创建卷。
7. 将 finance-snapshot1-volume1 卷附加到 finance-server7 实例中。
7.1.
选择 finance-snapshot1-volume1 卷的菜单中管理附件。
7.2. 在 Attach to Instance 中选择 finance-server7,再点击 Attach Volume。
7.3. 验证 finance-snapshot1-volume1 卷的状态字段值为 In-use。
8. 在 finance-server7 实例中,将 finance-snapshot1-volume1 卷挂载到 /snapshot1-vol1 目录,并核实 /snapshot1-vol1/testfile.txt 是否存在。
8.1. 导航到项目 > 计算 > 实例并在菜单中单击控制台以显示 finance-server7 实例的主控台。
8.2. 单击此处仅显示控制台。
8.3. 请检查 finance-snapshot1-volume1 卷是否已映射到 /dev/vdd 设备。
1
2
| [root@finance-server7 ~]# parted /dev/vdd print
...output omitted...
|
8.4. 创建 /snapshot1-vol1 目录。
1
| [root@finance-server7 ~]# mkdir /snapshot1-vol1
|
8.5. 在 /snapshot1-vol1 目录上挂载 /dev/vdd1 分区。
1
| [root@finance-server7 ~]# mount -t xfs /dev/vdd1 /snapshot1-vol1
|
8.6. 验证 /dev/vdd1 分区是否正确挂载。
1
| [root@finance-server7 ~]# mount | grep /snapshot1-vol1
|
操作界面、表格与配置图
1
2
| /dev/vdd1 on /snapshot1-vol1 type xfs
(rw,relatime,seclabel,attr2,inode64,noquota)
|
8.7. 验证 /snapshot1-vol1/testfile.txt 文件是否存在。
1
2
| [root@finance-server7 ~]# ls /snapshot1-vol1/testfile.txt
/snapshot1-vol1/testfile.txt
|
8.8. 卸载 /snapshot1-vol1/ 目录。
1
| [root@finance-server7 ~]# umount /snapshot1-vol1
|
9. 在 CLI 中,作为 developer1,从 finance-server7 实例中分离出 finance-snapshot1-volume1 卷并删除。
9.1. 从 workstation, 打开终端。
9.2. 用 source 加载 developer1-finance-rc 环境文件以导出 developer1 用户凭据。
1
| [student@workstation ~]$ source ~/developer1-finance-rc
|
9.3. 从 finance-server7 实例中分离 finance-snapshot1-volume1 卷。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server remove volume \
finance-server7 finance-snapshot1-volume1
|
9.4. 验证 finance-snapshot1-volume1 卷状态为 available。要分离卷可能需要一些时间。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack volume list \
-c Name -c Status
+---------------------------+-----------+
| Name | Status |
+---------------------------+-----------+
| finance-snapshot1-volume1 | available |
| ... | ... |
+---------------------------+-----------+
|
9.5. 删除 finance-snapshot1-volume1 卷。
1
2
| [student@workstation ~(developer1-finance)]$ openstack volume delete \
finance-snapshot1-volume1
|
9.6. 核实 finance-snapshot1-volume1 卷已被删除。
1
2
| [student@workstation ~(developer1-finance)]$ openstack volume list
...output omitted...
|
操作界面、表格与配置图
10. 使用 developer1 用户凭据删除 finance-volume1-snapshot1 快照。
10.1. 删除 finance-volume1-snapshot1 快照。
1
2
| [student@workstation ~(developer1-finance)]$ openstack volume snapshot delete \
finance-volume1-snapshot1
|
10.2. 验证即 finance-volume1-snapshot1 快照已被删除。不应显示快照。快照可能需要一些时间才能删除。
1
| [student@workstation ~(developer1-finance)]$ openstack volume snapshot list
|
11. 将 finance-volume2 卷附加到 finance-server7 实例中。
11.1. 将 finance-volume2 卷附加到 finance-server7 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add volume \
finance-server7 finance-volume2
|
11.2. 核实 finance-volume2 卷是否正确附于 finance-server7 实例。确认 finance-volume2 卷状态为 in-use, 并在此卷中查询 Attached to 字段,以获得 finance-server7 实例中已绘制的设备。可能需要一段时间才能附加该卷。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack volume list \
-c Name -c Status -c "Attached to"
+-----------------+-----------+------------------------------------------+
| Name | Status | Attached to |
+-----------------+-----------+------------------------------------------+
| finance-volume2 | in-use | Attached to finance-server7 on /dev/vdd |
| ... | ... | ... |
+-----------------+-----------+------------------------------------------+
|
12. 在 finance-server7 实例中,将 finance-volume2 卷挂载到 /volume2 目录中,并添加一个文件。
12.1. 为 finance-server7 实例获取控制台 URL, 并使用 Firefox 浏览器导航。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack console url show \
finance-server7
+-------+-----------------------------------------------------------------+
| Field | Value |
+-------+-----------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=f7cc...956a |
+-------+-----------------------------------------------------------------+
|
12.2. 检查finance-volume2 卷已被映射到 /dev/vdd 设备上。
操作界面、表格与配置图
1
2
| [root@finance-server7 ~]# parted /dev/vdd print
...output omitted...
|
12.3. 创建/dev/vdd 设备中的新分区。
1
2
3
4
| [root@finance-server7 ~]# parted /dev/vdd \
mklabel msdos \
mkpart primary xfs 1M 1G
...output omitted...
|
12.4. 创建/dev/vdd1 分区上的 XFS 文件系统。
1
2
| [root@finance-server7 ~]# mkfs.xfs /dev/vdd1
...output omitted...
|
12.5. 创建/volume2 目录。
1
| [root@finance-server7 ~]# mkdir /volume2
|
12.6. 挂载/dev/vdd1 分区在 /volume2 目录上。
1
| [root@finance-server7 ~]# mount -t xfs /dev/vdd1 /volume2
|
12.7. 验证 /dev/vdd1 分区是否正确挂载。
1
2
| [root@finance-server7 ~]# mount | grep /volume2
/dev/vdd1 on /volume2 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
|
12.8. 创建一个名为 /volume2/testfile.txt 的文件,用于验证您可以写入卷。
1
| [root@finance-server7 ~]# touch /volume2/testfile.txt
|
12.9. 卸载/volume2 目录。
1
| [root@finance-server7 ~]# umount /volume2
|
13. 在 workstation 上,从 finance-server7 实例中卸除 finance-volume2 卷并删除。
13.1. 从 finance-server7 实例中分离 finance-volume2 卷。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server remove volume \
finance-server7 finance-volume2
|
13.2. 验证即 finance-volume2 卷状态为 available。要分离卷可能需要一些时间。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack volume list \
-c Name -c Status
+-----------------+-----------+
| Name | Status |
+-----------------+-----------+
| finance-volume2 | available |
| ... | ... |
+-----------------+-----------+
|
14. 创建名为 finance-volume2-snapshot1 的 finance-volume2 卷的快照。
14.1. 创建名为 finance-volume2-snapshot1 的 finance-volume2 卷的快照。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~(developer1-finance)]$ openstack volume snapshot create \
--volume finance-volume2 \
finance-volume2-snapshot1
+-------------+--------------------------------------+
| Field | Value |
+-------------+--------------------------------------+
| created_at | 2018-06-14T17:59:49.127171 |
| description | None |
| id | fc3410c1-9060-402c-80ea-6865813a49d1 |
| name | finance-volume2-snapshot1 |
| properties | |
| size | 1 |
| status | creating |
| updated_at | None |
| volume_id | 285f48d2-1025-4270-be7d-72daea700d85 |
+-------------+--------------------------------------+
|
14.2. 验证,即 finance-volume2-snapshot1 快照通过检查其状态创建为 available。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack volume snapshot list \
-c Name -c Status
+---------------------------+-----------+
| Name | Status |
+---------------------------+-----------+
| finance-volume2-snapshot1 | available |
+---------------------------+-----------+
|
15. 创建 1 GB 卷,从 finance-volume2-snapshot1 快照中创建名为 finance-snapshot2-volume1 的卷。
15.1. 创建 1 GB 卷,从 finance-volume2-snapshot1 快照中命名为 finance-snapshot2-volume1。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack volume create \
--size 1 \
--snapshot finance-volume2-snapshot1 \
finance-snapshot2-volume1
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
|
操作界面、表格与配置图
1
2
3
| | name | finance-snapshot2-volume1 |
...output omitted...
+---------------------+--------------------------------------+
|
15.2. 验证即 finance-snapshot2-volume1 正确创建,检查其状态为 available。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack volume list \
-c Name -c Status
+---------------------------+-----------+
| Name | Status |
+---------------------------+-----------+
| finance-snapshot2-volume1 | available |
...output omitted...
+---------------------------+-----------+
|
16. 将 finance-snapshot2-volume1 卷附加到 finance-server7 实例中。
16.1. 将 finance-snapshot2-volume1 卷附加到 finance-server7 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add volume \
finance-server7 finance-snapshot2-volume1
|
16.2. 验证称 finance-snapshot2-volume1 卷已正确附在 finance-server7 实例上。确认 finance-snapshot2-volume1 卷状态为 in-use , 并核实 Attached to 字段是否为此卷,以获取 finance-server7 实例中已映射到的设备。可能需要一些时间才能附加该卷。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(developer1-finance)]$ openstack volume list \
-c Name -c Status -c "Attached to"
+---------------------------+--------+------------------------------+
| Name | Status | Attached to |
+---------------------------+--------+------------------------------+
| finance-snapshot2-volume1 | in-use | Attached to |
| | | finance-server7 on /dev/vdd |
...output omitted...
+---------------------------+--------+------------------------------+
|
17. 在 finance-server7 实例中,将 finance-snapshot2-volume1 卷挂载到 /snapshot2-vol1 目录,并核实/snapshot2-vol1/testfile.txt 是否存在
17.1. 为 finance-server7 实例获取控制台 URL, 并使用 Firefox 浏览器导航。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack console url show \
finance-server7
+-------+-----------------------------------------------------------------+
| Field | Value |
+-------+-----------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=f7cc...956a |
|
操作界面、表格与配置图
1
| +-------+-----------------------------------------------------------------+
|
17.2. 确认 finance-snapshot2-volume1 卷已被映射到 /dev/vdd 设备上。
1
2
| [root@finance-server7 ~]# parted /dev/vdd print
...output omitted...
|
17.3. 创建 /snapshot2-vol1 目录。
1
| [root@finance-server7 ~]# mkdir /snapshot2-vol1
|
17.4. 在 /snapshot2-vol1 目录上挂载 /dev/vdd1 分区。
1
| [root@finance-server7 ~]# mount -t xfs /dev/vdd1 /snapshot2-vol1
|
17.5. 验证 /dev/vdd1 分区是否正确挂载。
1
2
3
4
| [root@finance-server7 ~]# mount | grep /snapshot2-vol1
...output omitted...
/dev/vdd1 on /snapshot2-vol1 type xfs
(rw,relatime,seclabel,attr2,inode64,noquota)
|
17.6. 验证 /snapshot2-vol1/testfile.txt 文件是否存在。
1
2
| [root@finance-server7 ~]# ls /snapshot2-vol1/testfile.txt
/snapshot2-vol1/testfile.txt
|
17.7. 卸载 /snapshot2-vol1 目录。
1
| [root@finance-server7 ~]# umount /snapshot2-vol1
|
18. 在 workstation 上,从 finance-server7 实例中分离出 finance-snapshot2-volume1 卷。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server remove volume \
finance-server7 finance-snapshot2-volume1
|
19. 校验 finance-snapshot2-volume1 卷状态是否为 available。要分离卷可能需要一些时间。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack volume list \
-c Name -c Status
+---------------------------+-----------+
| Name | Status |
+---------------------------+-----------+
| finance-snapshot2-volume1 | available |
...output omitted...
+---------------------------+-----------+
|
操作界面、表格与配置图
20. 退出仪表板,关闭显示实例控制台的浏览器标签页。
在 workstation 上运行 lab blockstorage-snapshots cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab blockstorage-snapshots cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理持久根磁盘#
本练习创建可启动卷,并在多个实例之间验证卷中数据的持久性;还将对使用可启动卷的实例执行搁置和取消搁置,再次验证数据持久性。
学习目标#
完成后能够:
从镜像创建可启动卷。
使用可启动卷验证数据持久性。
搁置和取消搁置使用可启动卷的实例。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。
从 workstation,运行 lab blockstorage-rootdisk setup,核查前几节创造的资源是否可用。
1
| [student@workstation ~]$ lab blockstorage-rootdisk setup
|
操作步骤#
1. 在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
2. 在仪表板上,登录为 developer1,并从 rhel7 镜像中创建 10 GB 卷,命名为 finance-volume1。
2.1. 使用 redhat 作为密码登录到仪表板上为 developer1。
2.2. 导航到项目 > 计算 > 镜像。为 rhel7 镜像选择下调菜单并选择创建卷。忽略 Unable to retrieve the default volume type 错误信息。
在名称字段中输入 finance-volume1。在大小( GiB) 中输入 10。单击+Create 卷。
2.3. 打开 Project > Volumes > Volumes。
等待 finance-volume1 卷的状态字段值为 Available。您可能需要刷新页面才能更新状态。
3. 使用 finance-volume1 卷、 default 规格和 finance-network1 网络启动一个名为 finance-server8 的实例。
3.1. 在 finance-volume1 的菜单中点击 Launch as Instance。Instance Name 输入 finance-server8。在 Flavor 部分点击向上箭头,选用
操作界面、表格与配置图
default 规格。在 Networks 中确认已选择 finance-network1;在 Source 中确认已选择 finance-volume1。点击 Launch Instance。
3.2. 导航到项目 > 计算 > 实例。
等待 finance-server8 实例的状态字段值为 Active。您可能需要刷新网页才能刷新状态。启用该状态可能需要一些时间。
4. 连接到实例的主控台并创建文件。
4.1. 在菜单中单击控制台,以便 finance-server8 实例打开控制台。
4.2. 单击此处仅显示控制台。
4.3. 以 root 和 redhat 为密码登录到 finance-server8 实例控制台。控制台显示登录提示可能需要一些时间。
4.4. 创建名为 /root/testfile.txt 的文件。
1
| [root@finance-server8 ~]# touch testfile.txt
|
5. 在 CLI 中,使用 developer1 用户凭据删除 finance-server8 实例。
5.1. 在 workstation 上,加载 developer1-finance-rc 文件,以装入 developer1 用户凭据。
1
| [student@workstation ~]$ source ~/developer1-finance-rc
|
5.2. 删除 finance-server8 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server8
|
5.3. 验证 finance-server8 实例被正确删除是否正确。要删除此实例可能需要一些时间。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server list
...output omitted...
|
6. 使用 finance-volume1 卷和 default 规格创建一个名为 finance-server9 的新实例。
6.1. 使用 finance-volume1 卷、 default 规格和 finance-network1 网络创建一个名为 finance-server9 的新实例。
1
2
3
4
5
| [student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
--volume finance-volume1 \
--nic net-id=finance-network1 \
finance-server9
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| +-----------------------------+------------------------------------------------+
| Field | Value |
+-----------------------------+------------------------------------------------+
...output omitted...
| flavor | default (12e28c2e-7e28-4e18-bba0-7782496398aa) |
| name | finance-server9 |
...output omitted...
+-----------------------------+------------------------------------------------+
|
6.2. 验证 finance-server9 实例的状态为 ACTIVE。状态为 ACTIVE 可能需要一段时间。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Status
+-----------------+--------+
| Name | Status |
+-----------------+--------+
| finance-server9 | ACTIVE |
+-----------------+--------+
|
7. 连接到 finance-server9 实例的主控台。确认先前创建的 /root/testfile.txt 文件具有持久性。
7.1.
为 finance-server9 实例获取控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack console url show \
finance-server9
+-------+------------------------------------------------------------+
| Field | Value |
+-------+------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=de97...5c62 |
+-------+------------------------------------------------------------+
|
7.2. 打开火狐并导航到控制台 URL。
7.3. 以 root 和 redhat 为密码登录到 finance-server9 实例控制台。控制台显示登录提示可能需要一些时间。
7.4. 验证 /root/testfile.txt 文件是否具有持久性。
1
2
| [root@finance-server9 ~]# ls testfile.txt
testfile.txt
|
8. 删除 finance-server9 实例和 finance-volume1 卷。
8.1. 在 workstation 上,删除 finance-server9 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server9
|
8.2. 验证 finance-server9 实例被正确删除。
1
| [student@workstation ~(developer1-finance)]$ openstack server list
|
操作界面、表格与配置图
8.3. 删除 finance-volume1 卷。
1
2
| [student@workstation ~(developer1-finance)]$ openstack volume delete \
finance-volume1
|
8.4. 核实 finance-volume1 卷已被正确删除。finance-volume1 卷不应列出。
1
| [student@workstation ~(developer1-finance)]$ openstack volume list
|
9. 从 rhel7 镜像创建名为 finance-volume2 的 10 GB 卷。
9.1. 从 rhel7 镜像创建 finance-volume2 卷,大小设为 10 GB。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(developer1-finance)]$ openstack volume create \
--size 10 \
--image rhel7 \
finance-volume2
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
...output omitted...
| name | finance-volume2 |
| size | 10 |
...output omitted...
+---------------------+--------------------------------------+
|
9.2. 验证 finance-volume2 卷是否正确创建。请检查 Status 字段的值是 available。卷可能是 available 需要一些时间。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack volume list \
-c Name -c Status
+-----------------+-----------+
| Name | Status |
+-----------------+-----------+
| finance-volume2 | available |
+-----------------+-----------+
|
10. 使用 finance-volume2 卷和您以前使用的其他选项启动一个名为 finance-server10 的实例。
10.1. 使用 finance-volume2 卷启动一个名为 finance-server10 的实例。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server create \
--flavor default \
--nic net-id=finance-network1 \
--volume finance-volume2 \
finance-server10
+-----------------------------+------------------------------------------------+
| Field | Value |
|
操作界面、表格与配置图
1
2
3
4
5
6
| +-----------------------------+------------------------------------------------+
...output omitted...
| flavor | default (12e28c2e-7e28-4e18-bba0-7782496398aa) |
| name | finance-server10 |
...output omitted...
+-----------------------------+------------------------------------------------+
|
10.2. 验证finance-server10 实例的状态为 ACTIVE。状态为 ACTIVE 可能需要一些时间。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Status
+------------------+--------+
| Name | Status |
+------------------+--------+
| finance-server10 | ACTIVE |
+------------------+--------+
|
11. 连接到 finance-server10 实例的主控台并创建 /root/testfile.txt 文件。
11.1. 为 finance-server10 实例获取控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack console url show \
finance-server10
+-------+---------------------------------------------------------------+
| Field | Value |
+-------+---------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=c851...d75e |
+-------+---------------------------------------------------------------+
|
11.2. 打开火狐并导航到控制台 URL。
11.3. 以 root 和 redhat 为密码登录到 finance-server10 实例控制台。控制台显示登录提示可能需要一些时间。
11.4. 创建 /root/testfile.txt 文件。
1
| [root@finance-server10 ~]# touch testfile.txt
|
11.5. 验证 /root/testfile.txt 文件是否正确创建。
1
2
| [root@finance-server10 ~]# ls testfile.txt
testfile.txt
|
12. 在 workstation 上,搁置 finance-server10 实例,并核实它是否处于 SHELVED_OFFLOADED 状态。
12.1. 将 finance-server10 实例搁置
1
2
| [student@workstation ~(developer1-finance)]$ openstack server shelve \
finance-server10
|
操作界面、表格与配置图
12.2. 验证finance-server10 实例状态为 SHELVED_OFFLOADED。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Status
+------------------+-------------------+
| Name | Status |
+------------------+-------------------+
| finance-server10 | SHELVED_OFFLOADED |
+------------------+-------------------+
|
13. 取消搁置 finance-server10 实例。
13.1. 取消搁置 finance-server10 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server unshelve \
finance-server10
|
13.2. 验证 finance-server10 已取消搁置,Status 字段应为 ACTIVE。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Status
+------------------+--------+
| Name | Status |
+------------------+--------+
| finance-server10 | ACTIVE |
+------------------+--------+
|
14. 连接到 finance-server10 实例的主控台,并验证 /root/testfile.txt 文件仍然可用。
14.1. 为 finance-server10 实例获取控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack console url show \
finance-server10
+-------+---------------------------------------------------------------+
| Field | Value |
+-------+---------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=fb21...882c |
+-------+---------------------------------------------------------------+
|
14.2. 打开Firefox 和导航到控制台 URL。
14.3. 以 root 登录 finance-server10 控制台,密码为 redhat。控制台显示登录提示可能需要一些时间。
14.4. 验证即 /root/testfile.txt 文件仍然可用。
1
2
| [root@finance-server10 ~]# ls testfile.txt
testfile.txt
|
15. 在 workstation 上,删除 finance-server10 实例。
操作界面、表格与配置图
15.1. 删除 finance-server10 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
finance-server10
|
15.2. 验证中,finance-server10 实例已被正确删除。要删除此实例可能需要一些时间。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server list
...output omitted...
|
16. 退出仪表板并关闭显示实例控制台的浏览器标签。
在 workstation 上运行 lab blockstorage-rootdisk cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab blockstorage-rootdisk cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:管理块存储#
本实验创建卷、附加卷并创建快照;从镜像创建卷并用卷启动实例;在用户之间转移卷,并搁置实例。
学习目标#
完成后能够:
创建一卷。
将卷附在实例上。
制作快照。
将卷从一个用户转移给另一个用户。
从镜像中创建卷。
使用卷启动实例。
搁置实例。
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 登录 workstation,密码为 student。
从 workstation 运行 lab blockstorage-lab setup, 核实 OpenStack 服务正在运行,并创建 production-volume2 卷和 consulting-volume1 实例。
1
| [student@workstation ~]$ lab blockstorage-lab setup
|
操作步骤#
1. 使用 operator1 用户凭据创建名为 production-volume1 的卷。配置此卷的大小为 1 GB。
2. 将 production-volume1 卷附加到由实验脚本创建的 production-server1 实例。
3. 作为 operator1 用户,打开 production-server1 实例的主控台。
4. 在 production-volume1 卷上创建 XFS 文件系统。
5. 在 production-server1 实例中的 /volume1 目录上挂载上前一个文件系统,并创建一个名为 /volume1/testfile.txt 的文件。完成后,卸载文件系统。
6. 从 production-server1 实例中分离出 production-volume1 卷。
7. 创建 production-volume1 卷的快照。命名为 production-volume1-snapshot1。
操作界面、表格与配置图
8. 使用 production-volume1-snapshot1 快照创建名为 production-snapshot1-volume1 的卷。配置此卷的大小为 1 GB。
9. 将 production-snapshot1-volume1 卷附加到 production-server1 实例中。
10. 打开 production-server1 实例的主控台。
11. 在 production-server1 实例的 /snapshot 目录上挂载前一个文件系统,并验证 /snapshot/testfile.txt 文件是否存在。完成后,卸载文件系统。
12. 从 production-server1 实例中分离出 production-snapshot1-volume1 卷。
13. 以 consulting 项目的 operator2 用户为 consulting-volume1(实验脚本创建的卷)申请卷转移。
14. 使用 operator1 用户接受卷传输。
15. 从 rhel7 镜像创建 production-volume3 卷,大小设为 10 GB。
16. 创建 production-server2,使用 production-volume3 卷、production-network1 网络和 default 规格。
17. 搁置 production-server2 实例。
在 workstation 上运行 lab blockstorage-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab blockstorage-lab grade
|
在 workstation 上运行 lab blockstorage-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab blockstorage-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
本实验创建卷、附加卷并创建快照;从镜像创建卷并用卷启动实例;在用户之间转移卷,并搁置实例。
学习目标#
完成后能够:
创建一卷。
将卷附在实例上。
制作快照。
将卷从一个用户转移给另一个用户。
从镜像中创建卷。
使用卷启动实例。
搁置实例。
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 登录 workstation,密码为 student。
从 workstation 运行 lab blockstorage-lab setup, 核实 OpenStack 服务正在运行,并创建 production-volume2 卷和 consulting-volume1 实例。
1
| [student@workstation ~]$ lab blockstorage-lab setup
|
操作步骤#
1. 使用 operator1 用户凭据创建名为 production-volume1 的卷。配置此卷的大小为 1 GB。
1.1.
要导出 operator1 用户凭据的用 source 加载 operator1-production-rc 环境文件。
1
| [student@workstation ~]$ source ~/operator1-production-rc
|
1.2. 创建一个名为 production-volume1 的卷。配置此卷的大小为 1 GB。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(operator1-production)]$ openstack volume create \
--size 1 production-volume1
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
...output omitted...
| name | production-volume1 |
...output omitted...
+---------------------+--------------------------------------+
|
操作界面、表格与配置图
2. 将 production-volume1 卷附加到由实验脚本创建的 production-server1 实例。
2.1. 验证 production-server1 状态为 ACTIVE。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack server list \
-c Name -c Status
+--------------------+--------+
| Name | Status |
+--------------------+--------+
| production-server1 | ACTIVE |
+--------------------+--------+
|
2.2. 将 production-volume1 卷附加到 production-server1 实例。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add volume \
production-server1 production-volume1
|
2.3. 验证 production-volume1 作为/dev/vdb 设备是否正确连接到 production-server1 实例上。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name -c "Attached to"
+--------------------+---------------------------------------------+
| Name | Attached to |
+--------------------+---------------------------------------------+
| production-volume1 | Attached to production-server1 on /dev/vdb |
...output omitted...
+--------------------+---------------------------------------------+
|
3. 作为 operator1 用户,打开 production-server1 实例的主控台。
3.1. 为 production-server1 实例获取控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack console url show \
production-server1
+-------+--------------------------------------------------------------+
| Field | Value |
+-------+--------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=d502(...)4c27 |
+-------+--------------------------------------------------------------+
|
3.2. 打开一个 Firefox 浏览器,并浏览到先前获得的控制台 URL。
3.3. 单击此处仅显示控制台。
3.4. 使用 root 和 redhat 密码登录到 production-server1。控制台显示登录提示可能需要一些时间。
4. 在 production-volume1 卷上创建 XFS 文件系统。
4.1. 在 production-server1 实例中核查 production-volume1 卷被映射到 /dev/vdb 设备。
操作界面、表格与配置图
1
2
3
4
5
6
7
| [root@production-server1 ~]# parted /dev/vdb print
Error: /dev/vdb: unrecognised disk label
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
|
4.2. 在 /dev/vdb 设备中创建新分区。
1
2
3
4
| [root@production-server1 ~]# parted /dev/vdb \
mklabel msdos \
mkpart primary xfs 1M 1G
...output omitted...
|
4.3. 在 /dev/vdb1 分区上创建 XFS 文件系统。
1
2
| [root@production-server1 ~]# mkfs.xfs /dev/vdb1
...output omitted...
|
5. 在 production-server1 实例中的 /volume1 目录上挂载上前一个文件系统,并创建一个名为 /volume1/testfile.txt 的文件。完成后,卸载文件系统。
5.1. 创建 /volume1 目录。
1
| [root@production-server1 ~]# mkdir /volume1
|
5.2. 在 /volume1 目录上挂载 /dev/vdb1 分区。
1
| [root@production-server1 ~]# mount -t xfs /dev/vdb1 /volume1
|
5.3. 验证 /dev/vdb1 分区是否正确挂载。
1
2
| [root@production-server1 ~]# mount | grep /volume1
/dev/vdb1 on /volume1 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
|
5.4. 创建名为 /volume1/testfile.txt 的文件
1
| [root@production-server1 ~]# touch /volume1/testfile.txt
|
5.5. 从 /volume1 目录中卸载 /dev/vdb1 分区。
1
| [root@production-server1 ~]# umount /volume1
|
6. 从 production-server1 实例中分离出 production-volume1 卷。
6.1. 在 workstation 上,从 production-server1 实例中分离出 production-volume1 卷。
操作界面、表格与配置图
1
2
| [student@workstation ~(operator1-production)]$ openstack server remove volume \
production-server1 production-volume1
|
6.2. 验证 production-volume1 卷是否正确分离。请检查 production-volume1 卷的状态是 available。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name -c Status
+--------------------+-----------+
| Name | Status |
+--------------------+-----------+
| production-volume1 | available |
...output omitted...
+--------------------+-----------+
|
7. 创建 production-volume1 卷的快照。命名为 production-volume1-snapshot1。
7.1.
创建 production-volume1 卷的快照。命名为 production-volume1-snapshot1。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(operator1-production)]$ openstack volume \
snapshot create \
--volume production-volume1 \
production-volume1-snapshot1
+-------------+--------------------------------------+
| Field | Value |
+-------------+--------------------------------------+
...output omitted...
| name | production-volume1-snapshot1 |
...output omitted...
+-------------+--------------------------------------+
|
7.2. 验证 production-volume1-snapshot1 快照的状态是 available。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack volume snapshot list \
-c Name -c Status
+------------------------------+-----------+
| Name | Status |
+------------------------------+-----------+
| production-volume1-snapshot1 | available |
+------------------------------+-----------+
|
8. 使用 production-volume1-snapshot1 快照创建名为 production-snapshot1-volume1 的卷。配置此卷的大小为 1 GB。
8.1. 使用 production-volume1-snapshot1 快照创建名为 production-snapshot1-volume1 的卷。配置此卷的大小为 1 GB。
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack volume create \
--size 1 \
--snapshot production-volume1-snapshot1 \
production-snapshot1-volume1
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| +---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
...output omitted...
| name | production-snapshot1-volume1 |
| size | 1 |
...output omitted...
+---------------------+--------------------------------------+
|
8.2. 验证 production-snapshot1-volume1 卷的状态为 available。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name -c Status
+------------------------------+-----------+
| Name | Status |
+------------------------------+-----------+
| production-snapshot1-volume1 | available |
...output omitted...
+------------------------------+-----------+
|
9. 将 production-snapshot1-volume1 卷附加到 production-server1 实例中。
9.1. 将 production-snapshot1-volume1 卷附加到 production-server1 实例。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add volume \
production-server1 production-snapshot1-volume1
|
9.2. 验证 production-snapshot1-volume1 作为/dev/vdb 设备是否正确连接到 production-server1 实例上。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name -c "Attached to"
+------------------------------+---------------------------------------------+
| Name | Attached to |
+------------------------------+---------------------------------------------+
| production-snapshot1-volume1 | Attached to production-server1 on /dev/vdb |
...output omitted...
+------------------------------+---------------------------------------------+
|
10. 打开 production-server1 实例的主控台。
10.1. 为 production-server1 实例获取控制台 URL。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack console url show \
production-server1
+-------+--------------------------------------------------------------+
| Field | Value |
+-------+--------------------------------------------------------------+
| type | novnc |
| url | http://172.25.250.50:6080/vnc_auto.html?token=d502(...)4c27 |
+-------+--------------------------------------------------------------+
|
操作界面、表格与配置图
10.2. 打开一个 Firefox 浏览器,并浏览到之前获得的控制台 URL。
11. 在 production-server1 实例的 /snapshot 目录上挂载前一个文件系统,并验证 /snapshot/testfile.txt 文件是否存在。完成后,卸载文件系统。
11.1. 创建 /snapshot 目录。
1
| [root@production-server1 ~]# mkdir /snapshot
|
11.2. 在 /snapshot 目录上挂载 /dev/vdb1 分区。
1
| [root@production-server1 ~]# mount -t xfs /dev/vdb1 /snapshot
|
11.3. 验证 /dev/vdb1 分区是否正确挂载。
1
2
| [root@production-server1 ~]# mount | grep /snapshot
/dev/vdb1 on /snapshot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
|
11.4. 验证 /snapshot/testfile.txt 文件是否存在。
1
2
| [root@production-server1 ~]# ls /snapshot/testfile.txt
/snapshot/testfile.txt
|
11.5. 从 /snapshot 目录中卸载 /dev/vdb1 分区。
1
| [root@production-server1 ~]# umount /snapshot
|
12. 从 production-server1 实例中分离出 production-snapshot1-volume1 卷。
12.1. 在 workstation 上,从 production-server1 实例中分离出 production-snapshot1-volume1 卷。
1
2
| [student@workstation ~(operator1-production)]$ openstack server remove volume \
production-server1 production-snapshot1-volume1
|
12.2. 验证即 production-snapshot1-volume1 卷已正确分离。请检查 production-snapshot1-volume1 卷的状态是 available。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name -c Status
+------------------------------+-----------+
| Name | Status |
+------------------------------+-----------+
| production-snapshot1-volume1 | available |
...output omitted...
+------------------------------+-----------+
|
操作界面、表格与配置图
13. 以 consulting 项目的 operator2 用户为 consulting-volume1(实验脚本创建的卷)申请卷转移。
13.1. 用 source 加载 operator2-consulting-rc 文件,以装入 operator2 用户凭据。
1
2
| [student@workstation ~(operator1-production)]$ source ~/operator2-consulting-rc
[student@workstation ~(operator2-consulting)]$
|
13.2. 验证consulting-volume1 卷处于 available 状态。
1
2
3
4
5
6
7
| [student@workstation ~(operator2-consulting)]$ openstack volume list \
-c Name -c Status
+--------------------+-----------+
| Name | Status |
+--------------------+-----------+
| consulting-volume1 | available |
+--------------------+-----------+
|
13.3. 为 consulting-volume1 创建卷转移,名称设为 consultingvolume1-transfer。记下 auth_key 和 id 字段的值。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(operator2-consulting)]$ openstack volume transfer \
request create \
--name consultingvolume1-transfer \
consulting-volume1
+------------+--------------------------------------+
| Field | Value |
+------------+--------------------------------------+
| auth_key | b30da8b74e915ca4 |
| id | 4c5b9156-6dbf-4528-a41c-0605ab77aaa9 |
| name | consultingvolume1-transfer |
...output omitted...
+------------+--------------------------------------+
|
14. 使用 operator1 用户接受卷传输。
14.1. 用 source 加载 operator1-production-rc 文件,以装入 operator1 用户凭据。
1
2
| [student@workstation ~(operator2-consulting)]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$
|
14.2. 使用之前取得的 auth_key 和 id 接受卷转移。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(operator1-production)]$ openstack volume transfer \
request accept \
--auth-key b30da8b74e915ca4 \
4c5b9156-6dbf-4528-a41c-0605ab77aaa9
+-----------+--------------------------------------+
| Field | Value |
+-----------+--------------------------------------+
| id | 4c5b9156-6dbf-4528-a41c-0605ab77aaa9 |
| name | consultingvolume1-transfer |
...output omitted...
|
操作界面、表格与配置图
1
| +-----------+--------------------------------------+
|
14.3. 验证consulting-volume1 卷可供 operator1 用户使用。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name -c Status
+------------------------------+-----------+
| Name | Status |
+------------------------------+-----------+
| consulting-volume1 | available |
...output omitted...
+------------------------------+-----------+
|
15. 从 rhel7 镜像创建 production-volume3 卷,大小设为 10 GB。
15.1. 验证 rhel7 镜像是否激活。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack image list \
-c Name -c Status
+-------+--------+
| Name | Status |
+-------+--------+
| rhel7 | active |
+-------+--------+
|
15.2. 创建rhel7 镜像的卷,名为 production-volume3。配置此卷的大小为 10 GB。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(operator1-production)]$ openstack volume create \
--size 10 \
--image rhel7 \
production-volume3
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
...output omitted...
| name | production-volume3 |
| size | 10 |
...output omitted...
+---------------------+--------------------------------------+
|
16. 创建 production-server2,使用 production-volume3 卷、production-network1 网络和 default 规格。
16.1. 验证 production-volume3 卷是否可用。此卷可能需要一些时间才能可用。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name -c Status
+------------------------------+-----------+
| Name | Status |
+------------------------------+-----------+
| production-volume3 | available |
...output omitted...
|
操作界面、表格与配置图
1
| +------------------------------+-----------+
|
16.2. 创建一个名为 production-server2 的例子使用 production-volume3 卷、production-network1 网络和 default 规格。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~(operator1-production)]$ openstack server create \
--nic net-id=production-network1 \
--flavor default \
--volume production-volume3 \
production-server2
+-----------------------------+------------------------------------------------+
| Field | Value |
+-----------------------------+------------------------------------------------+
...output omitted...
| flavor | default (12e28c2e-7e28-4e18-bba0-7782496398aa) |
| name | production-server2 |
...output omitted...
+-----------------------------+------------------------------------------------+
|
16.3. 验证production-server2 实例的状态为 ACTIVE。状态为 active 可能需要一些时间。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack server list \
-c Name -c Status
+--------------------+--------+
| Name | Status |
+--------------------+--------+
| production-server2 | ACTIVE |
...output omitted...
+--------------------+--------+
|
17. 搁置 production-server2 实例。
17.1. 将 production-server2 实例搁置
1
2
| [student@workstation ~(operator1-production)]$ openstack server shelve \
production-server2
|
17.2. 核实 production-server2 实例状态为 SHELVED_OFFLOADED。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack server list \
-c Name -c Status
+--------------------+-------------------+
| Name | Status |
+--------------------+-------------------+
| production-server2 | SHELVED_OFFLOADED |
...output omitted...
+--------------------+-------------------+
|
在 workstation 上运行 lab blockstorage-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab blockstorage-lab grade
|
操作界面、表格与配置图
在 workstation 上运行 lab blockstorage-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab blockstorage-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 从实例分离卷前,应先做什么?
- 如何验证快照恢复的数据?
自测答案#
- 在实例内卸载文件系统。先停止使用并卸载文件系统,再分离云端卷。
- 从快照建卷并读取原文件。状态和名称不能替代实际数据验证。
C8-管理对象存储#
容器与伪文件夹#
Swift Container 是对象容器,与 Docker 容器无关。界面中的文件夹通过对象名称前缀呈现,不应套用普通磁盘目录的所有语义。记录完整对象名,例如 html/index.html,而不只记录文件末尾名称。
上传与下载链路#
在 workstation 创建本地目录和文件,加载指定用户凭据,创建容器并上传对象,再用列表确认对象存在。下载时写明目标路径和文件名,核对内容,避免误把已有本地文件当成下载成功的证据。
权限和清理#
容器是否公开由访问策略决定。综合练习涉及 swiftoperator 角色时,要检查用户的角色分配。删除顺序通常先对象、后容器;用 object list 和 container list 验证每一步,而不是仅看页面是否刷新。
对象存储的组织方式#
1
2
3
| Project / Account → Container → Object
├─ index.html
└─ images/logo.png
|
images/logo.png 是完整对象名;斜杠提供命名前缀,不等于普通文件系统目录。对象通过 API 上传与下载,不需要给实例附加磁盘。
对象操作#
执行位置:workstation,项目用户;index.html 为已有本地文件。
1
2
3
4
5
6
| openstack container create demo-container
openstack object create demo-container ./index.html
openstack object list demo-container
openstack object show demo-container index.html
openstack object save --file ./downloaded-index.html demo-container index.html
cmp ./index.html ./downloaded-index.html
|
释放对象与容器#
1
2
| openstack object delete demo-container index.html
openstack container delete demo-container
|
上传成功后应下载并核对内容;下载到新文件避免把原文件误当作下载结果。权限按实验角色和容器 ACL 配置,不用“知道 URL 就一定能读”推断公开性。
与 Ceph RGW 对照#
Swift 是 OpenStack 对象服务;RGW 可以提供兼容 Swift 的接口。用 openstack catalog list 确认 object-store endpoint,再判断本次请求实际进入哪种后端。
实验操作#
引导练习:管理对象#
在此练习中,创建和删除对象容器、文件夹对象和文件对象。
学习目标#
完成后能够:
创建、查看和删除对象容器。
创建、列出、下载和删除容器对象。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
登录到 workstation 的 workstation 用户为 student 用户,密码为 student。从 workstation , 运行 lab manage-objects setup , 以确保 OpenStack 服务正在运行,先前创建的资源可用于完成此项操作。
1
| [student@workstation ~]$ lab manage-objects setup
|
操作步骤#
1. 登录到仪表板为 developer1。
1.1.
在 workstation 打开 Firefox,访问 http://dashboard.overcloud.example.com。
1.2. 登录到仪表板,用户名 developer1 和密码 redhat。
2. 创建一个名为 developer1-container1 的容器。
2.1. 如果容器不是活跃页面元素,导航到菜单栏的左侧,单击名为“ 对象存储” 的下拉菜单,然后选择容器来激活管理容器的接口。
2.2. 点击 +Container,在 Create Container 对话框的 Container Name 中输入 developer1-container1。不要勾选 Container Access > Public。
单击“提交”按钮。
在 developer1-container1 容器中创建名为 folder1 的文件夹。
3. 3.1. 在接口的左侧,单击名为 developer1-container1 的容器来激活容器的管理接口。
3.2. 在 Containers 管理界面右侧点击 +Folder。在 Create Folder In: developer1-container1 对话框的 Folder Name 中输入 folder1。
单击 +Create Folder 按钮。
4. 在 workstation 上,在 student 的主目录中,创建一个名为 developer1-helloworld.txt 的文件,稍后将上传到 folder1 文件夹的 developer1-container container。
操作界面、表格与配置图
1
2
3
| [student@workstation ~]$ mkdir /home/student/folder1
[student@workstation ~]$ echo 'Hello World!' > \
/home/student/folder1/developer1-helloworld.txt
|
5. 在仪表板上,将 developer1-helloworld.txt 文件上传到对象仓库容器中名为 developer1-container1 的名为 folder1 的文件夹。
5.1. 必要时从 workstation 中打开 Firefox, 并登入仪表板为 developer1 并浏览到对象存储 > 容器。单击 developer1 - container1 容器名称以激活其管理界面。
5.2. 单击文件夹小节中的 folder1 文件夹名称。您应该看到介面文件夹区域上方的 developer1-container1: folder1。
5.3. 在接口的右侧,单击+Folder 按钮左侧的上传按钮。
5.4. 导航到上传文件到 : developer1-container1 : folder1 pop-up 对话框,然后在文件下使用浏览按钮在目录 /home/student/folder1 中定位文件 developer1-helloworld.txt。选择 developer1-helloworld.txt 单击打开,然后单击上传文件按钮上传文件。
6. 在 workstation 上,使用 命令行 接口删除 developer1-helloworld.txt 文件、 folder1 文件夹和 developer1-container1 容器。
6.1. 在 student 的主目录中,源于 /home/student/developer1-finance-rc 环境文件导出 developer1 用户身份。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
6.2. 核查对象储存库中的现有容器。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack container list
+-----------------------+
| Name |
+-----------------------+
| developer1-container1 |
+-----------------------+
|
6.3. 校验 developer1-container1 容器中可用的文件对象。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack object list \
developer1-container1
+-----------------------------------+
| Name |
+-----------------------------------+
| folder1/ |
| folder1/developer1-helloworld.txt |
+-----------------------------------+
|
6.4. 删除文件对象 developer1-helloworld.txt。
操作界面、表格与配置图
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack object delete \
developer1-container1/folder1 \
developer1-helloworld.txt
|
校验文件对象 developer1-helloworld.txt 已删除。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack object list \
developer1-container1
+----------------+
| Name |
+----------------+
| folder1/ |
+----------------+
|
6.5. 删除文件夹对象 folder1。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack object delete \
developer1-container1 \
folder1/
|
验证文件夹对象 folder1 已删除。输出中不应列出任何对象。
1
2
| [student@workstation ~(developer1-finance)]$ openstack object list \
developer1-container1
|
6.6. 删除容器 developer1-container1。
1
2
| [student@workstation ~(developer1-finance)]$ openstack container delete \
developer1-container1
|
核实容器 developer1-container1 已删除。
1
| [student@workstation ~(developer1-finance)]$ openstack container list
|
7. 在 workstation 上,使用 命令行 接口创建一个名为 developer1-container2 的容器,一个名为 folder2 的文件夹对象和一个名为 developer1-data.txt 的文件对象。
7.1.
创建一个名为 developer1-container2 的容器。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack container create \
developer1-container2
+------------------+---------------------------------------+
| account | container | x-trans-id |
+------------------+-----------------------+---------------+
| AUTH_35f2...6c07 | developer1-container2 | tx9935...6882 |
+------------------+-----------------------+---------------+
|
操作界面、表格与配置图
7.2. 为此练习,创建目录 folder2 和 student 主目录中文件 developer1-data.txt 的本地副本,以供上传到对象仓库。
1
2
3
| [student@workstation ~(developer1-finance)]$ mkdir /home/student/folder2
[student@workstation ~(developer1-finance)]$ echo "command-line interface \
directory environment" > /home/student/folder2/developer1-data.txt
|
7.3. 在名为 developer1-container2 的容器内创建名为 folder2 的文件夹对象和一个名为 developer1-data.txt 的文件对象。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack object create \
developer1-container2 folder2/developer1-data.txt
+-----------------------------+-----------------------+-------------+
| object | container | etag |
+-----------------------------+-----------------------+-------------+
| folder2/developer1-data.txt | developer1-container2 | b40b...e153 |
+-----------------------------+-----------------------+-------------+
|
8. 在 workstation 上,从对象存储处下载文件对象 hosts 至 student 的 /home/student/Downloads 目录。
8.1. 核查对象储存库中的现有容器。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack container list
+-----------------------+
| Name |
+-----------------------+
| developer1-container2 |
+-----------------------+
|
8.2. 校验 developer1-container2 容器中可用的文件对象。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack object list \
developer1-container2
+-----------------------------+
| Name |
+-----------------------------+
| folder2/developer1-data.txt |
+-----------------------------+
|
8.3. 将对象文件 developer1-data.txt 从对象存储保存到 /home/student/Downloads 中,以 data.txt 保存为对象文件 developer1-data.txt。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ openstack object save \
developer1-container2/folder2 \
developer1-data.txt \
--file /home/student/Downloads/data.txt
|
8.4. 验证文件对象 developer1-data.txt 是否已成功下载到 /home/student/Downloads/data.txt。
操作界面、表格与配置图
1
2
3
| [student@workstation ~(developer1-finance)]$ cat \
/home/student/Downloads/data.txt
command-line interface directory environment
|
在 workstation 运行 lab manage-objects cleanup,清理本练习资源。
1
| [student@workstation ~]$ lab manage-objects cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:管理对象存储#
在此实验中,创建一个容器,向容器添加一个文件夹对象,并在文件夹中添加一个文件对象。
学习目标#
完成后能够:
建立容器。
将文件夹和文件对象添加到容器中。
容器对象下载。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
使用 student 作为密码登录到 workstation 时为 student。从 workstation 运行 lab manage-objects-lab setup, 以确保先前创造的资源可用于完成这个实验。
1
| [student@workstation ~]$ lab manage-objects-lab setup
|
操作步骤#
1. 在 workstation 以 operator1 创建 production-container1,然后验证容器存在。
2. 创建两个对象,一个名为 html 的文件夹对象,和一个名为 index.html 的文本文件对象。在 index.html 文件里,包括单行 Hello world!。一旦创建,将把对象上传到 production-container1 容器。
3. 确认通过在 production-container1 容器中列出对象而成功上传的对象。将 index.html 对象保存到 /var/www/html 目录中。
在 workstation 上运行 lab manage-objects-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab manage-objects-lab grade
|
在 workstation 上运行 lab manage-objects-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab manage-objects-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
在此实验中,创建一个容器,向容器添加一个文件夹对象,并在文件夹中添加一个文件对象。
学习目标#
完成后能够:
建立容器。
将文件夹和文件对象添加到容器中。
容器对象下载。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
使用 student 作为密码登录到 workstation 时为 student。从 workstation 运行 lab manage-objects-lab setup, 以确保先前创造的资源可用于完成这个实验。
1
| [student@workstation ~]$ lab manage-objects-lab setup
|
操作步骤#
1. 在 workstation 以 operator1 创建 production-container1,然后验证容器存在。
1.1.
打开一个终端并加载 operator1 用户的环境文件。
1
| [student@workstation ~]$ source ~/operator1-production-rc
|
1.2. 创建一个名为 production-container1 的容器。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack container create \
production-container1
+------------------+-----------------------+-------------+
| account | container | x-trans-id |
+------------------+-----------------------+-------------+
| AUTH_3b33...246d | production-container1 | txbe...bb51 |
+------------------+-----------------------+-------------+
|
1.3. 核实 production-container1 容器是否通过列出现有容器清单而成功创建。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ openstack container list
+------------------------+
| Name |
+------------------------+
| production-container1 |
+------------------------+
|
2. 创建两个对象,一个名为 html 的文件夹对象,和一个名为 index.html 的文本文件对象。在 index.html 文件里,包括单行 Hello world!。一旦创建,将把对象上传到 production-container1 容器。
操作界面、表格与配置图
2.1. 在 student 的主目录中创建目录对象,名为 /home/student/html。
1
| [student@workstation ~(operator1-production)]$ mkdir /home/student/html
|
2.2. 创建文本文件 /home/student/html/index.html,写入一行 Hello world!。
1
2
| [student@workstation ~(operator1-production)]$ echo 'Hello world!' > \
/home/student/html/index.html
|
2.3. 将合并对象 html/index.html 上传到 production-container1 容器。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack object create \
production-container1 html/index.html
+-----------------+-----------------------+-------------+
| object | container | etag |
+-----------------+-----------------------+-------------+
| html/index.html | production-container1 | 8ddd...9858 |
+-----------------+-----------------------+-------------+
|
3. 确认通过在 production-container1 容器中列出对象而成功上传的对象。将 index.html 对象保存到 /var/www/html 目录中。
3.1. 使用 openstack object list 命令来识别 production-container1 容器中储存的对象。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack object list \
production-container1
+-----------------+
| Name |
+-----------------+
| html/index.html |
+-----------------+
|
3.2. 登录到 workstation 时为 root。密码是 student。
1
2
3
| [student@workstation (operator1-production)]$ sudo -i
[sudo] password for student: student
[root@workstation ~]#
|
3.3. 用 source 加载 /home/student/operator1-production-rc 环境文件。使用 openstack object save 命令将 index.html 对象下载到 /var/www/html 目录。请检查文件是否已下载。
1
2
3
4
5
6
7
| [root@workstation ~]# source /home/student/operator1-production-rc
[root@workstation (operator1-production)]# openstack object save \
--file /var/www/html/index.html production-container1 \
html/index.html
[root@workstation (operator1-production)]# ll /var/www/html
total 4
-rw-rw-r--. 1 root root 13 Jun 15 16:18 index.html
|
操作界面、表格与配置图
1
2
| [root@workstation (operator1-production)]# cat /var/www/html/index.html
Hello World!
|
在 workstation 上运行 lab manage-objects-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab manage-objects-lab grade
|
在 workstation 上运行 lab manage-objects-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab manage-objects-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- Swift 容器与 Docker 容器是否相同?
- 验证对象下载应检查什么?
自测答案#
- 不同,Swift 容器组织对象。对象容器不是服务进程运行环境。
- 目标路径、文件及内容。已有本地文件可能掩盖下载失败。
C9-准备实例公共访问#
外部访问的组成#
| 对象 | 解决什么问题 | 验证重点 |
|---|
| Provider 网络 | 接入实际外部网络 | 类型 flat、物理网络映射及外部标志 |
| 路由器 | 连接项目子网与外部网络 | 内部接口、外部网关 |
| 浮动 IP | 提供外部访问地址 | 地址分配与实例端口关联 |
| 安全组 | 允许指定协议和端口 | 方向、协议、端口与来源范围 |
| 密钥对 | 提供 SSH 认证材料 | 公钥注入、私钥位置与权限 |
地址规划#
外部子网的 CIDR、网关、地址池和 DNS 是不同参数。实验外部网络按实验要求禁用 DHCP,不能因为内部网络需要 DHCP 就照搬设置。路由器网关地址与浮动 IP 也不是同一个对象。
关联与释放#
解除浮动 IP 与实例的关联,不等于把地址归还地址池。Disassociate 解除关联,release 释放地址分配。清理后检查浮动 IP 列表,防止保留地址占用配额。
SSH 分层判断#
SSH 已建立连接但认证失败,通常应继续检查用户名、公钥和私钥,而不是马上改路由。连接超时则先检查地址、端口、路由与安全组。SSH 使用与实例公钥匹配的私钥,私钥文件权限应限制为仅所有者可读写。
公共访问路径#
1
2
3
| workstation → 外部网络 → Router 外部网关 / Floating IP 映射
→ 项目子网 → Port / Security Group
→ 实例网卡 → SSH / HTTP
|
外部网络:管理员配置#
下面是参数结构示例,物理网络映射、网关和地址池必须采用当前实验规划。
1
2
3
4
5
| openstack network create --external --provider-network-type flat \
--provider-physical-network <物理网络名称> demo-external
openstack subnet create --network demo-external --no-dhcp \
--subnet-range <外部CIDR> --gateway <外部网关> \
--allocation-pool start=<起始IP>,end=<结束IP> demo-external-subnet
|
Provider 网络说明底层如何接入物理网络,--external 表示可作为路由器外部网络;两者不是同一属性。
路由器:项目用户配置#
1
2
3
4
| openstack router create demo-router
openstack router add subnet demo-router demo-subnet
openstack router set --external-gateway demo-external demo-router
openstack router show demo-router
|
安全组与密钥对#
1
2
3
4
5
6
| openstack security group create demo-access
openstack security group rule create --ingress --protocol tcp \
--dst-port 22 --remote-ip 172.25.250.0/24 demo-access
openstack security group rule create --ingress --protocol icmp demo-access
openstack keypair create demo-key > demo-key.pem
chmod 600 demo-key.pem
|
私钥在创建时输出并保存;Keypair 名称写入实例配置不等于已有实例会自动补装公钥。安全组规则还需关联到实例端口才会生效。
浮动 IP#
1
2
3
4
5
| openstack floating ip create demo-external
openstack server add floating ip <实例UUID> <浮动IP>
openstack floating ip list
openstack server remove floating ip <实例UUID> <浮动IP>
openstack floating ip delete <浮动IP或其UUID>
|
最后两步分别是解除关联与释放分配,不能互相替代。固定 IP 通常出现在实例网卡内,浮动 IP 通常由网络层映射,不直接配在实例网卡上。
实验操作#
引导练习:管理外部网络#
在此练习中,使用仪表板和 OpenStack 统一的 CLI 来创建和配置外部网络。使用 命令行 界面来审查网络是如何实施的。
学习目标#
完成后能够:
开始之前#
以 student 为密码登录到 workstation 作为 student。运行 lab prep-deploy-ext setup 命令,以确保有所需的用户和项目以及身份环境文件存在。
1
| [student@workstation ~]$ lab prep-deploy-ext setup
|
操作步骤#
1. 在仪表板创建 provider-datacentre 外部网络。Project 选择 finance,网络类型为 Flat,物理网络为 datacentre,勾选共享和外部网络。
1.1.
从 workstation 打开网络浏览器并浏览到 http://dashboard.overcloud.example.com. 使用 architect1 作为用户名的日志,使用 redhat 作为密码。
1.2. 在管理员标签内,导航到网络 > 网络。
1.3. 点击 + Create Network。Network Name 输入 provider-datacentre,Project 选择 finance,Provider Network Type 选择 Flat,Physical Network 输入 datacentre。勾选 Shared 和 External Network。
1.4. 单击下一个按钮创建子网。请输入 provider-subnet-172.25.250 作为子网名。输入 172.25.250.0/24 作为网络地址。输入 172.25.250.254 作为网关 IP。单击下一个按钮为子网设定最终设置。
1.5. 通过取消单击“启用 DHCP” 复选框而禁用 DHCP。在地址池中输入以下 IP 地址 172.25.250.101,172.25.250.189。输入 172.25.250.254 为“DNS 命名服务器”。单击“创建”。
2. 从 workstation 加载 architect1 用户的身份环境,并删除 provider-datacentre 网络和 provider-subnet-172.25.250 子网。
2.1. 为 architect1 用户打开终端并用 source 加载身份环境,该用户位于 /home/student/ 目录中。
操作界面、表格与配置图
1
2
| [student@workstation ~]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
2.2. 删除子网 provider-subnet-172.25.250。
1
2
| [student@workstation ~(architect1-finance)]$ openstack subnet delete \
provider-subnet-172.25.250
|
2.3. 删除网络 provider-datacentre。
1
2
| [student@workstation ~(architect1-finance)]$ openstack network delete \
provider-datacentre
|
3. 使用 OpenStack 统一的 CLI 创建外部网络。命名网络 provider-datacentre 设置网络类型为 flat , 物理网络为 datacentre 设置网络为共享和外部。
3.1. 作为 architect1 用户,创建网络 provider-datacentre。
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
| [student@workstation ~(architect1-finance)]$ openstack network create \
--external \
--share \
--provider-network-type flat \
--provider-physical-network datacentre \
provider-datacentre
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T13:44:28Z |
| description | |
| dns_domain | None |
| id | 29840e5f-3c29-4937-b6f8-237b51c21899 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1500 |
| name | provider-datacentre |
| port_security_enabled | True |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| provider:network_type | flat |
| provider:physical_network | datacentre |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 6 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T13:44:28Z |
+---------------------------+--------------------------------------+
|
操作界面、表格与配置图
4. 作为 developer1 用户,为 provider-datacentre 网络创建子网 provider-subnet-172.25.250。给子网以 172.25.250.101 到 172.25.250.189 的范围。禁用子网的 DHCP 服务,使用 172.25.250.254 作为网关以及 DNS 名服务器。
4.1. 用 source 加载 developer1 用户的身份环境。
1
2
| [student@workstation ~(architect1-finance)]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
4.2. 在 provider-datacentre 网络中创建子网 provider-subnet-172.25.250。
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
| [student@workstation ~(developer1-finance)]$ openstack subnet create \
--subnet-range 172.25.250.0/24 \
--no-dhcp \
--gateway 172.25.250.254 \
--dns-nameserver 172.25.250.254 \
--allocation-pool start=172.25.250.101,end=172.25.250.189 \
--network provider-datacentre \
provider-subnet-172.25.250
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 172.25.250.101-172.25.250.189 |
| cidr | 172.25.250.0/24 |
| created_at | 2018-06-21T13:51:02Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | False |
| gateway_ip | 172.25.250.254 |
| host_routes | |
| id | 1f5e3ad7-25b0-4e49-ad7e-d6673e2882c9 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | provider-subnet-172.25.250 |
| network_id | 29840e5f-3c29-4937-b6f8-237b51c21899 |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T13:51:02Z |
+-------------------+--------------------------------------+
|
5. 审查 controller0 节点上的网络实施情况。
5.1. 使用 ssh 命令连接到 controller0 节点。
1
2
| [student@workstation ~(developer1-finance)]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$
|
操作界面、表格与配置图
5.2. 确认尽管 NetworkManager 正在运行,但它并不控制由 OpenStack 管理的网络接口。首先,确保 NetworkManager 服务运行并启用。
1
2
3
4
5
6
7
8
9
10
11
12
| [heat-admin@controller0 ~]$ systemctl status NetworkManager.service
● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled;
vendor preset: enabled)
Active: active (running) since Tue 2018-07-03 07:45:32 UTC; 1h 16min ago
Docs: man:NetworkManager(8)
Main PID: 861 (NetworkManager)
Tasks: 3
Memory: 7.1M
CGroup: /system.slice/NetworkManager.service
└─861 /usr/sbin/NetworkManager --no-daemon
...output omitted...
|
5.3. 在 /etc/sysconfig/network-scripts/ifcfg-* 文件中显示 NM_CONTROLLED 参数的值,以核实没有一个接口由网络管理器管理。
1
2
3
4
5
6
7
8
9
10
11
| [heat-admin@controller0 ~]$ cd /etc/sysconfig/network-scripts
[heat-admin@controller0 network-scripts]$ grep NM_CONTROLLED ifcfg-*
ifcfg-br-ex:NM_CONTROLLED=no
ifcfg-br-int:NM_CONTROLLED=no
ifcfg-br-trunk:NM_CONTROLLED=no
ifcfg-eth0:NM_CONTROLLED=no
ifcfg-eth1:NM_CONTROLLED=no
ifcfg-eth2:NM_CONTROLLED=no
...output omitted...
[heat-admin@controller0 network-scripts]$ cd
[heat-admin@controller0 ~]$
|
5.4. 使用 ovs-vsctl 命令审查网络配置。列出所有桥梁和端口。br-ex 桥包括三个端口: eth2, 即物理设备,phy-br-ex 和 br-ex, 即虚拟接口。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [heat-admin@controller0 ~]$ sudo ovs-vsctl show
...output omitted...
Bridge br-ex
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port "eth2"
Interface "eth2"
Port phy-br-ex
Interface phy-br-ex
type: patch
options: {peer=int-br-ex}
Port br-ex
Interface br-ex
type: internal
Bridge br-int
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port patch-tun
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| Interface patch-tun
type: patch
options: {peer=patch-int}
Port int-br-ex
Interface int-br-ex
type: patch
options: {peer=phy-br-ex}
...output omitted...
|
5.5. 运行 ip 命令以检查 IP 地址的分配。定位 br-ex 和 eth2 设备。br-ex 设备拥有 172.25.250.1 的 IP 地址。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [heat-admin@controller0 ~]$ ip a
...output omitted...
2: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-
system state UP qlen 1000
link/ether 52:54:00:00:fa:0b brd ff:ff:ff:ff:ff:ff
inet6 fe80::5054:ff:fe00:fa0b/64 scope link
valid_lft forever preferred_lft forever
...output omitted...
5: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
qlen 1000
link/ether 22:b3:01:d9:81:49 brd ff:ff:ff:ff:ff:ff
inet 172.25.250.1/24 brd 172.25.250.255 scope global br-ex
valid_lft forever preferred_lft forever
inet6 fe80::20b3:1ff:fed9:8149/64 scope link
valid_lft forever preferred_lft forever
|
5.6. 审查 eth2 设备网络配置文件。eth2 设置为 br-ex 网络设备 Open vSwitch 端口。
1
2
3
4
5
6
7
| [heat-admin@controller0 ~]$ cd /etc/sysconfig/network-scripts
[heat-admin@controller0 network-scripts]$ cat ifcfg-eth2
DEVICE=eth2
ONBOOT=yes
TYPE=OVSPort
DEVICETYPE=ovs
OVS_BRIDGE=br-ex
|
5.7. 审查 br-ex 设备的网络配置文件。br-ex 被宣布为 Open vSwitch 桥,并包含 IPv4 网络配置,确保 OpenStack 网络的外部路由。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [heat-admin@controller0 network-scripts]$ cat ifcfg-br-ex
DEVICE=br-ex
HOTPLUG=no
ONBOOT=yes
NM_CONTROLLED=no
PEERDNS=no
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=172.25.250.1
NETMASK=255.255.255.0
OVS_EXTRA="set bridge br-ex other-config:hwaddr=52:54:00:02:fa:01 -- set bridge
br-ex fail_mode=standalone -- del-controller br-ex"
|
操作界面、表格与配置图
5.8. 退出 controller0 虚拟机
1
2
| [heat-admin@controller0 network-scripts]$ exit
[student@workstation ~(developer1-finance)]$
|
从 workstation 运行 lab prep-deploy-ext 脚本,使用 cleanup 参数来清理此项练习。
1
| [student@workstation ~]$ lab prep-deploy-ext cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:准备 OpenStack 路由器#
在此练习中,创建和配置路由器,并使用 命令行 工具测试路由器的连接。
学习目标#
完成后能够:
利用仪表板创建路由器。
使用 openstack 命令管理路由器和网络。
使用命令行工具检查路由器的连接。
开始之前#
以 student 为密码登录到 workstation 时为 student。运行 lab prep-deploy-router setup 命令,以确保有所需的用户和项目,并且有身份环境文件。脚本还确保为练习设置网络环境。
1
| [student@workstation ~]$ lab prep-deploy-router setup
|
操作步骤#
1. 使用仪表板作为 developer1 用户创建名为 finance-router1 的路由器。利用现有 finance-network1 网络在路由器中添加一个界面。
1.1.
从 workstation 打开网络浏览器并浏览到 http://dashboard.overcloud.example.com. 使用 developer1 作为用户名的日志,使用 redhat 作为密码。
1.2. 在项目标签内,导航到网络 > 路由器。
1.3. 单击 + 创建路由器以创建新路由器。请输入 finance-router1 以作为路由器名称。从外部网络列表中选择 provider-datacentre 并单击 Create 路由器。
1.4. 单击路由器的名称,finance-router1 访问其细节。单击接口标签来管理路由器的接口。
1.5. 单击 + 添加接口以添加新接口。从子网列表中选择 finance-subnet1 作为子网,单击提交。
2. 从 workstation 中,使用 developer1 用户删除 finance-router1 路由器和私有网络 finance-network1。
2.1. 在 workstation 上打开终端,并加载位于/home/student/developer1-finance-rc 的 developer1 用户的身份环境。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
操作界面、表格与配置图
2.2. 删除路由器 finance-router1 的子网 finance-subnet1 的接口。
1
2
| [student@workstation ~(developer1-finance)]$ openstack router remove subnet \
finance-router1 finance-subnet1
|
2.3. 解开 provider-datacentre 网络作为路由器的网关。
1
2
| [student@workstation ~(developer1-finance)]$ openstack router unset \
--external-gateway finance-router1
|
2.4. 删除 finance-router1 路由器。
1
2
| [student@workstation ~(developer1-finance)]$ openstack router delete \
finance-router1
|
2.5. 删除 finance-network1 网络。
1
2
| [student@workstation ~(developer1-finance)]$ openstack network delete \
finance-network1
|
3. 作为 developer1 用户,创建路由器 finance-router2。设置 provider-datacentre 网络作为路由器的网关,并在现有的 finance-subnet2 子网中添加接口。
3.1. 创建一个名为 finance-router2 的路由器。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [student@workstation ~(developer1-finance)]$ openstack router create \
finance-router2
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-22T10:57:44Z |
| description | |
| distributed | False |
| external_gateway_info | None |
| flavor_id | None |
| ha | False |
| id | 2d7f0378-c0d4-425a-bfe3-edda8e51e12b |
| name | finance-router2 |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| revision_number | 1 |
| routes | |
| status | ACTIVE |
| tags | |
| updated_at | 2018-06-22T10:57:44Z |
+-------------------------+--------------------------------------+
|
3.2. 连接路由器到 finance-subnet2 子网
操作界面、表格与配置图
1
2
| [student@workstation ~(developer1-finance)]$ openstack router add subnet \
finance-router2 finance-subnet2
|
3.3. 设置外部网络 provider-datacentre 作为路由器的网关。
1
2
3
| [student@workstation ~(developer1-finance)]$ openstack router set \
--external-gateway provider-datacentre \
finance-router2
|
4. 审查 controller0 虚拟机路由器的实施情况。
4.1. 使用 ssh 连接到 controller0 虚拟机。使用 sudo -i 命令成为 root。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$ sudo -i
[root@controller0 ~]#
|
4.2. 使用 ip netns 命令列出网络命名空间。请注意,UUID 与先前一步创建的路由器相对应。
1
2
3
| [root@controller0 ~]# ip netns list
qrouter-2d7f0378-c0d4-425a-bfe3-edda8e51e12b
...output omitted...
|
4.3. 列出命名空间中的网络设备。输出显示路由器使用 IP 地址 192.168.2.1 连接到私人子网,并使用 IP 地址 172.25.250.N 连接到公共子网。通知名为 qr 的端口,其中标明路由器接口,以及名为 qg 的端口,其中显示一个网关。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [root@controller0 ~]# ip netns exec \
qrouter-d09d39ec-d787-463f-a0eb-a8b50974e6ea ip a
42: qr-952e3ebf-66: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue
state UNKNOWN group default qlen 1000
link/ether fa:16:3e:1b:02:b3 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.1/24 brd 192.168.2.255 scope global qr-952e3ebf-66
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe1b:2b3/64 scope link
valid_lft forever preferred_lft forever
44: qg-84cc8b4a-bc: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue
state UNKNOWN group default qlen 1000
link/ether fa:16:3e:a2:b8:68 brd ff:ff:ff:ff:ff:ff
inet 172.25.250.N/24 brd 172.25.250.255 scope global qg-84cc8b4a-bc
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fea2:b868/64 scope link
valid_lft forever preferred_lft forever
|
4.4. 使用 ping 命令到达 DNS 名服务器,该服务器拥有 172.25.250.254 的 IP 地址,通过网络端口,网络端口被定义为网关。
1
2
| [root@controller0 ~]# ip netns exec \
qrouter-2d7f0378-c0d4-425a-bfe3-edda8e51e12b \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| ping -c3 -I qg-84cc8b4a-bc 172.25.250.254
PING 172.25.250.254 (172.25.250.254) from 172.25.250.N qg-4654fa8b-42: 56(84)
bytes of data.
64 bytes from 172.25.250.254: icmp_seq=1 ttl=64 time=6.95 ms
64 bytes from 172.25.250.254: icmp_seq=2 ttl=64 time=0.868 ms
64 bytes from 172.25.250.254: icmp_seq=3 ttl=64 time=0.856 ms
--- 172.25.250.254 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.856/2.893/6.957/2.873 ms
|
4.5. 退出 controller0 虚拟机
1
2
3
| [root@controller0 ~]# exit
[heat-admin@controller0 ~]$ exit
[student@workstation ~(developer1-finance)]$
|
5. 从仪表板上注销
从 workstation 运行 lab prep-deploy-router 脚本,使用 cleanup 参数来清理此项练习。
1
| [student@workstation ~]$ lab prep-deploy-router cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:管理浮动 IP 地址#
在此练习中,创建一组浮动的 IP , 并将其分配到一个实例。
学习目标#
完成后能够:
开始之前#
登录到 workstation 时为 student , 使用 student 作为密码。运行 lab prep-deploy-ips setup 命令,以确保有所需的用户和项目。脚本还确保为练习设置网络环境,以及 finance-server1 实例正在运行。
1
| [student@workstation ~]$ lab prep-deploy-ips setup
|
操作步骤#
1. 在仪表板中,创建一个作为 developer1 用户的浮动 IP。将浮动 IP 地址与 finance-server1 实例联系起来。
1.1.
从 workstation 打开网络浏览器并浏览到 http://dashboard.overcloud.example.com. 使用 developer1 作为用户名的日志,使用 redhat 作为密码。
1.2. 在项目标签内,导航到网络 > 浮动 IP。单击分配 IP 到项目按钮。确保 provider-datacentre 设置为 Pool , 单击分配 IP。
1.3. 在浮动 IP 所在行点击 Associate。在 Manage Floating IP Associations 窗口的 Port to be associated 列表中选择 finance-server1: 192.168.1.S,再点击 Associate。
2. 将浮动 IP 从 finance-server1 实例中分离出来以释放地址。
2.1. 导航可计算 > 实例。单击创建快照按钮旁边的箭头,用于标记为 finance-server1 的行创建快照按钮。选择 Dissociate floating IP 将浮动 IP 从实例中除去。当确认分解浮动 IP 窗口出现时,请单击分离浮动 IP。
2.2. 导航到网络 > 浮动 IP。单击浮动 IP 行的关联按钮旁边的箭头,并选择释放浮动 IP 将浮动 IP 返回水池。当确认释放 IP 窗口出现时,请单击释放 IP。
2.3. 从仪表板上注销
操作界面、表格与配置图
3. 从 workstation 中打开一个终端,并加载 architect1 用户的身份环境。创建浮动 IP 172.25.250.103 并将其分配给 finance 项目。
3.1. 打开一个终端并用 source 加载位于/home/student/architect1-finance-rc 的 architect1 用户的身份环境。
1
2
| [student@workstation ~]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
3.2. 在 provider-datacentre 网络中创建浮动的 IP 172.25.250.103。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| [student@workstation ~(architect1-finance)]$ openstack floating ip create \
--floating-ip-address 172.25.250.103 \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-26T07:09:20Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.103 |
| floating_network_id | 95a56df3-a710-4bc6-b7c5-fc5d3e725df6 |
| id | d0147a80-6f42-4011-b191-c3fab63c0f50 |
| name | 172.25.250.103 |
| port_id | None |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-26T07:09:20Z |
+---------------------+--------------------------------------+
|
4. 作为 developer1 用户,创建三个浮动的 IP 地址。
4.1. 用 source 加载 developer1 的凭据文件。
1
2
| [student@workstation ~(architect1-finance)]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
4.2. 使用命令 openstack floating ip create 在 provider-datacentre 外部网络中创建一个浮动的 IP。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(developer1-finance)]$ openstack floating ip \
create provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-26T07:13:17Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.P |
| floating_network_id | 95a56df3-a710-4bc6-b7c5-fc5d3e725df6 |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| | id | 2d69c0d6-6b4c-4b01-abb5-e612e23792b6 |
| name | 172.25.250.P |
| port_id | None |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-26T07:13:17Z |
+---------------------+--------------------------------------+
|
4.3. 分配第二个浮动的 IP。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(developer1-finance)]$ openstack floating ip \
create provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-26T07:14:13Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.R |
| floating_network_id | 95a56df3-a710-4bc6-b7c5-fc5d3e725df6 |
| id | 9bc614ea-479c-4f5c-9e6e-393f61fb5136 |
| name | 172.25.250.R |
| port_id | None |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-26T07:14:13Z |
+---------------------+--------------------------------------+
|
4.4. 分配第三个浮动的 IP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(developer1-finance)]$ openstack floating ip \
create provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-26T07:14:56Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.N |
| floating_network_id | 95a56df3-a710-4bc6-b7c5-fc5d3e725df6 |
| id | 4314781e-088b-494d-b5a8-adb7f0b3d290 |
| name | 172.25.250.N |
| port_id | None |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-26T07:14:56Z |
+---------------------+--------------------------------------+
|
操作界面、表格与配置图
5. 作为 developer1 的用户,将第三个浮动 IP 与例 finance-server1 挂钩。
5.1. 将第三个浮动 IP 分配到 finance-server1 实例。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add \
floating ip finance-server1 172.25.250.N
|
5.2. 确保成功指定 IP 地址。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Networks
+-----------------+----------------------------------------------+
| Name | Networks |
+-----------------+----------------------------------------------+
| finance-server1 | finance-network1=192.168.1.S, 172.25.250.N |
+-----------------+----------------------------------------------+
|
6. 从 workstation ,使用 ping 和 ssh 命令测试与实例的外部连接。
6.1. 使用 ping 命令达到 finance-server1 实例。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ ping -c 1 172.25.250.N
PING 172.25.250.N (172.25.250.N) 56(84) bytes of data.
64 bytes from 172.25.250.N: icmp_seq=1 ttl=63 time=22.3 ms
--- 172.25.250.N ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 22.369/22.369/22.369/0.000 ms
|
6.2. 使用 ssh 命令启动远程连接。连接本身应该继续运行,而登录应该被拒绝,因为缺少私钥。将在下一节进一步讨论。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh 172.25.250.N
Warning: Permanently added '172.25.250.N' (ECDSA) to the list of known hosts.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
|
7. 将浮动 IP 从 finance-server1 实例中分离出来并释放浮动 IP。
7.1.
从 finance-server1 实例中分离 172.25.250.N 浮动 IP。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server remove \
floating ip finance-server1 172.25.250.N
|
7.2. 释放 172.25.250.N 浮动 IP
1
2
| [student@workstation ~(developer1-finance)]$ openstack floating ip \
delete 172.25.250.N
|
7.3. 列出可用的浮动 IP 以确认删除 172.25.250.N。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| [student@workstation ~(developer1-finance)]$ openstack floating ip \
list -c 'Floating IP Address'
+---------------------+
| Floating IP Address |
+---------------------+
| 172.25.250.103 |
| 172.25.250.P |
| 172.25.250.R |
+---------------------+
|
从 workstation 运行 lab prep-deploy-ips 脚本,使用 cleanup 参数来清理此项练习。
1
| [student@workstation ~]$ lab prep-deploy-ips cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:实施安全控制#
本练习管理密钥对和安全组。
学习目标#
完成后能够:
开始之前#
以 student 为密码登录到 workstation 时为 student。运行 lab prep-deploy-sec setup 命令,确保有所需的用户和项目。脚本还确保身份环境文件存在。
1
| [student@workstation ~]$ lab prep-deploy-sec setup
|
操作步骤#
1. 作为 developer1 用户,使用仪表板创建名为 developer1-keypair1 的密钥对。
1.1.
从 workstation 打开网络浏览器并浏览到 http://dashboard.overcloud.example.com. 使用 developer1 作为用户名的日志,使用 redhat 作为密码。
1.2. 在 Project 下打开 Compute > Key Pairs,点击 +Create Key Pair。Key Pair Name 输入 developer1-keypair1,再点击 +Create Key Pair。
1.3. 请求保存私钥文件的窗口应该出现。请选择保存文件项,并单击 OK。私钥将在 student 用户的 Downloads 目录中保存。
2. 作为 developer1 用户,使用仪表板创建 finance-secgroup1 安全组。添加一条规则,允许所有 ICMP 包进入实例。
2.1. 导航到网络 > 安全组。
2.2. 单击 + 创建安全组。当窗口创建安全组出现时,请输入 finance-secgroup1 作为名称并单击创建安全组。
2.3. 点击 finance-secgroup1 安全组行的管理规则。
2.4. 单击 + 添加规则可在安全组中添加新规则。当窗口添加规则出现时,从规则列表中选择 ALL ICMP 并单击添加。
2.5. 从仪表板上注销
操作界面、表格与配置图
3. 从 workstation 中,使用 developer1 凭据删除与 developer1-keypair1 密钥对相关的私钥。使用 openstack 命令删除 developer1-keypair1 密钥对。
3.1. 打开终端并删除 /home/student/Downloads/ 目录中的私钥。
1
| [student@workstation ~]$ rm -f ~/Downloads/developer1-keypair1.pem
|
3.2. 用 source 加载位于/home/student/developer1-finance-rc 的 developer1 用户的身份环境,并删除对键 developer1-keypair1。
1
2
3
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$ openstack keypair delete \
developer1-keypair1
|
4. 作为 developer1 用户,请删除您创建的安全组规则以及安全组。
4.1. 列出 finance-secgroup1 安全组的规则。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(developer1-finance)]$ openstack security group rule \
list finance-secgroup1 -c ID -c "IP Protocol"
+--------------------------------------+-------------+
| ID | IP Protocol |
+--------------------------------------+-------------+
| 36f1820e-6f8d-40f7-b768-9072a166c321 | None |
| 619640ff-b4ee-4041-ac6a-ec5725cd82d6 | icmp |
| eb116b13-2ce1-47aa-9cb7-165b8ad18df5 | None |
+--------------------------------------+-------------+
|
4.2. 复制 icmp 规则中的 UUID 来删除它。
1
2
| [student@workstation ~(developer1-finance)]$ openstack security group rule \
delete 619640ff-b4ee-4041-ac6a-ec5725cd82d6
|
4.3. 删去 finance-secgroup1 安全组。
1
2
| [student@workstation ~(developer1-finance)]$ openstack security group \
delete finance-secgroup1
|
5. 作为 developer1 用户,创建密钥对 developer1-keypair2 并将私钥导出至 /home/student/Downloads/developer1-keypair2.pem。使用 chmod 命令保护私钥文件。
5.1. 创建对对 developer1-keypair2 的密钥,并将私钥保存为 /home/student/Downloads/developer1-keypair2.pem。
1
2
| [student@workstation ~(developer1-finance)]$ openstack keypair create \
developer1-keypair2 > /home/student/Downloads/developer1-keypair2.pem
|
操作界面、表格与配置图
5.2. 使用带有 600 模式的 chmod 命令来保护私钥。
1
2
| [student@workstation ~(developer1-finance)]$ chmod 600 \
/home/student/Downloads/developer1-keypair2.pem
|
6. 作为 developer1 用户,创建 finance-secgroup2 安全组,并创建允许 ICMP 和 SSH 流量的规则。
6.1. 创建 finance-secgroup2 安全组。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(developer1-finance)]$ openstack security group \
create finance-secgroup2
+-----------------+--------------------------------------------+
| Field | Value |
+-----------------+--------------------------------------------+
| created_at | 2018-06-26T09:37:05Z |
| description | finance-secgroup2 |
| id | a7cab5cc-a12e-453b-bf95-b820d94a8c8a |
| name | finance-secgroup2 |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| revision_number | 2 |
| rules | created_at='2018-06-26T09:37:05Z', |
direction='egress', ethertype='IPv4', |
id='05b2ce9b-90b1-4962-b51b-58af4da73832', |
updated_at='2018-06-26T09:37:05Z' |
| | created_at='2018-06-26T09:37:05Z', |
direction='egress', ethertype='IPv6', |
id='38594c0d-4092-49ed-b312-04a7b556dad8', |
updated_at='2018-06-26T09:37:05Z' |
| updated_at | 2018-06-26T09:37:05Z |
+-----------------+--------------------------------------------+
|
6.2. 在 finance-secgroup2 安全组中添加一个安全组规则,允许远程的 ICMP 流量。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| [student@workstation ~(developer1-finance)]$ openstack security group rule \
create \
--protocol icmp \
finance-secgroup2
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-26T09:44:35Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 1933f8dd-1194-4ac8-a0f7-e74a6a63711c |
| name | None |
| port_range_max | None |
| port_range_min | None |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| protocol | icmp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | a7cab5cc-a12e-453b-bf95-b820d94a8c8a |
| updated_at | 2018-06-26T09:44:35Z |
|
操作界面、表格与配置图
1
| +-------------------+--------------------------------------+
|
6.3. 添加一项安全规则,允许使用 SSH 进行远程连接。
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 ~(developer1-finance)]$ openstack security group rule \
create \
--protocol tcp \
--dst-port 22 \
finance-secgroup2
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-26T09:45:55Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | e1664aea-cdeb-45bd-85c6-69d7c09b9d2a |
| name | None |
| port_range_max | 22 |
| port_range_min | 22 |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | a7cab5cc-a12e-453b-bf95-b820d94a8c8a |
| updated_at | 2018-06-26T09:45:55Z |
+-------------------+--------------------------------------+
|
从 workstation 运行 lab prep-deploy-sec 脚本,使用 cleanup 参数来清理此项练习。
1
| [student@workstation ~]$ lab prep-deploy-sec cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:准备实例公共访问#
在这个实验中,你会创建一个公共网络和一个路由器。你会创建一些浮动 IP,一个密钥对,以及各种安全组规则。
学习目标#
完成后能够:
建立公共网络及其相关子网。
创建和配置路由器。
创建密钥对。
在安全组中制定安全组规则。
开始之前#
以 student 为密码登录到 workstation 时为 student。运行 lab prep-deploy-ext-lab setup 命令,该命令可以验证 OpenStack 服务正在运行,且前几节所创建的资源已经可用。实验脚本删除所有浮动的 IP 地址,并删除以前创建的外部网络。
1
| [student@workstation ~]$ lab prep-deploy-ext-lab setup
|
操作步骤#
1. 作为 architect1 用户,创建外部网络 provider-datacentre 和子网 provider-subnet-172.25.250。使用以下规格 :
| OpenStack 网络资源 | |
|---|
| 资源 | 详情 |
| 外部网络 | - 名称:provider-datacentre - 共享:是 - 外部:是 - 提供者网络类型:flat - 提供者网络名称:datacentre - 子网名称:provider-subnet-172.25.250 - 网络子网:172.25.250.0/24 - 网络网关:172.25.250.254 - DNS 名称服务器:172.25.250.254 - 地址池:172.25.250.101,172.25.250.189 - DHCP:禁用 |
2. 作为 operator1, 创建路由器 production-router1 并将其连接到项目子网 production-subnet1 上。
3. 作为 architect1 用户,将路由器 production-router1 设定为 172.25.250.125 IP 地址的网关,在 provider-datacentre 网络中创建浮动 IP 172.25.250.128。
操作界面、表格与配置图
4. 作为 operator1 用户,在 provider-datacentre 网络中另创建两个浮动 IP。
5. 作为 operator1 用户,创建安全组 production-secgroup1 并添加下表所列规则。
| OpenStack 安全资源 | |
|---|
| 资源 | 详情 |
| 安全组 | 安全组名称: production-secgroup1 规则: - 协议:TCP,端口 22 - 协议:TCP,端口 80 - 协议:TCP,端口 443 |
6. 作为 operator1 用户,请创建对 production-keypair1 的密钥,并将私钥保存到 /home/student/Downloads/production-keypair1.pem。使用 chmod 命令来保护私钥文件。
在 workstation 上运行 lab prep-deploy-ext-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab prep-deploy-ext-lab grade
|
在 workstation 上运行 lab prep-deploy-ext-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab prep-deploy-ext-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
在这个实验中,你会创建一个公共网络和一个路由器。你会创建一些浮动 IP,一个密钥对,以及各种安全组规则。
学习目标#
完成后能够:
建立公共网络及其相关子网。
创建和配置路由器。
创建密钥对。
在安全组中制定安全组规则。
开始之前#
以 student 为密码登录到 workstation 时为 student。运行 lab prep-deploy-ext-lab setup 命令,该命令可以验证 OpenStack 服务正在运行,且前几节所创建的资源已经可用。实验脚本删除所有浮动的 IP 地址,并删除以前创建的外部网络。
1
| [student@workstation ~]$ lab prep-deploy-ext-lab setup
|
操作步骤#
1. 作为 architect1 用户,创建外部网络 provider-datacentre 和子网 provider-subnet-172.25.250。使用以下规格 :
| OpenStack 网络资源 | |
|---|
| 资源 | 详情 |
| 外部网络 | - 名称:provider-datacentre - 共享:是 - 外部:是 - 提供者网络类型:flat - 提供者网络名称:datacentre - 子网名称:provider-subnet-172.25.250 - 网络子网:172.25.250.0/24 - 网络网关:172.25.250.254 - DNS 名称服务器:172.25.250.254 - 地址池:172.25.250.101,172.25.250.189 - DHCP:禁用 |
1.1.
从 workstation 获取 architect1 用户的身份环境文件。
1
2
| [student@workstation ~]$ source ~/architect1-production-rc
[student@workstation ~(architect1-production)]$
|
1.2. 创建名为 provider-datacentre 的外部网络。
1
2
| [student@workstation ~(architect1-production)]$ openstack network create \
--external \
|
操作界面、表格与配置图
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
| --share \
--provider-network-type flat \
--provider-physical-network datacentre \
provider-datacentre
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-27T07:19:48Z |
| description | |
| dns_domain | None |
| id | 84f36592-b94b-411a-be5e-811d55335169 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1500 |
| name | provider-datacentre |
| port_security_enabled | True |
| project_id | ddc7e84587e84e90afe1c1f6b2ccd86d |
| provider:network_type | flat |
| provider:physical_network | datacentre |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 6 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-27T07:19:48Z |
+---------------------------+--------------------------------------+
|
1.3. 为外部网络创建 provider-subnet-172.25.250 子网,地址池范围为 172.25.250.101–172.25.250.189。禁用 DHCP;网关和 DNS 均为 172.25.250.254。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(architect1-production)]$ openstack subnet create \
--subnet-range 172.25.250.0/24 \
--no-dhcp \
--gateway 172.25.250.254 \
--dns-nameserver 172.25.250.254 \
--allocation-pool start=172.25.250.101,end=172.25.250.189 \
--network provider-datacentre \
provider-subnet-172.25.250
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 172.25.250.101-172.25.250.189 |
| cidr | 172.25.250.0/24 |
| created_at | 2018-06-27T07:27:27Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | False |
| gateway_ip | 172.25.250.254 |
| host_routes | |
| id | bac706ff-e176-4f97-98f2-1684edcd98fe |
| ip_version | 4 |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| | ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | provider-subnet-172.25.250 |
| network_id | 84f36592-b94b-411a-be5e-811d55335169 |
| project_id | ddc7e84587e84e90afe1c1f6b2ccd86d |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-27T07:27:27Z |
+-------------------+--------------------------------------+
|
2. 作为 operator1, 创建路由器 production-router1 并将其连接到项目子网 production-subnet1 上。
2.1. 用 source 加载 operator1 的凭据文件。
1
2
| [student@workstation ~(architect1-production)]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$
|
2.2. 创建 production-router1 路由器
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [student@workstation ~(operator1-production)]$ openstack router create \
production-router1
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-27T07:35:48Z |
| description | |
| distributed | False |
| external_gateway_info | None |
| flavor_id | None |
| ha | False |
| id | 19792e97-698f-42b5-aa9b-bfd5be667864 |
| name | production-router1 |
| project_id | adcf826c851145638d2f49e9fe56d074 |
| revision_number | 1 |
| routes | |
| status | ACTIVE |
| tags | |
| updated_at | 2018-06-27T07:35:48Z |
+-------------------------+--------------------------------------+
|
2.3. 将路由器连接到项目子网 production-subnet1。
1
2
| [student@workstation ~(operator1-production)]$ openstack router add \
subnet production-router1 production-subnet1
|
3. 作为 architect1 用户,将路由器 production-router1 设定为 172.25.250.125 IP 地址的网关,在 provider-datacentre 网络中创建浮动 IP 172.25.250.128。
3.1. 用 source 加载 architect1 用户的凭据文件。
操作界面、表格与配置图
1
2
| [student@workstation ~(operator1-production)]$ source ~/architect1-production-rc
[student@workstation ~(architect1-production)]$
|
3.2. 将路由器 production-router1 设为外部网络 provider-datacentre 的网关。
1
2
3
4
| [student@workstation ~(architect1-production)]$ openstack router set \
--external-gateway provider-datacentre \
--fixed-ip ip-address=172.25.250.125 \
production-router1
|
3.3. 在 provider-datacentre 网络中创建 172.25.250.128 浮动 IP。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(architect1-production)]$ openstack floating ip create \
--floating-ip-address 172.25.250.128 provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-27T07:49:00Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.128 |
| floating_network_id | 84f36592-b94b-411a-be5e-811d55335169 |
| id | f9663984-7e72-4a3d-a094-282141f4edc7 |
| name | 172.25.250.128 |
| port_id | None |
| project_id | adcf826c851145638d2f49e9fe56d074 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-27T07:49:00Z |
+---------------------+--------------------------------------+
|
4. 作为 operator1 用户,在 provider-datacentre 网络中另创建两个浮动 IP。
4.1. 用 source 加载 operator1 的凭据文件。
1
2
| [student@workstation ~(architect1-production)]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$
|
4.2. 从浮动 IP 池 provider-datacentre, 创建浮动 IP。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(operator1-production)]$ openstack floating ip create \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-27T07:52:07Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.N |
| floating_network_id | 84f36592-b94b-411a-be5e-811d55335169 |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| | id | 4458ee3b-acdc-43c3-b37e-9fb25eaef623 |
| name | 172.25.250.N |
| port_id | None |
| project_id | adcf826c851145638d2f49e9fe56d074 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-27T07:52:07Z |
+---------------------+--------------------------------------+
|
4.3. 从 provider-datacentre 浮动 IP 池中创建第二个浮动 IP。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(operator1-production)]$ openstack floating ip create \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-27T07:53:01Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.P |
| floating_network_id | 84f36592-b94b-411a-be5e-811d55335169 |
| id | f8f66727-05a4-4259-9293-176cd7f3e3a2 |
| name | 172.25.250.P |
| port_id | None |
| project_id | adcf826c851145638d2f49e9fe56d074 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-27T07:53:01Z |
+---------------------+--------------------------------------+
|
5. 作为 operator1 用户,创建安全组 production-secgroup1 并添加下表所列规则。
| OpenStack 安全资源 | |
|---|
| 资源 | 详情 |
| 安全组 | 安全组名称: production-secgroup1 规则: - 协议:TCP,端口 22 - 协议:TCP,端口 80 - 协议:TCP,端口 443 |
5.1. 作为 operator1 用户,创建安全组 production-secgroup1
1
2
3
| [student@workstation ~(operator1-production)]$ openstack security group create \
production-secgroup1
...output omitted...
|
5.2. 在安全组 production-secgroup1 中添加一条规则,允许 ssh 访问。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(operator1-production)]$ openstack security group \
rule create --protocol tcp --dst-port 22 production-secgroup1
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-27T07:57:13Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 9f4a3e64-1b0f-4815-a00e-1d84808a55ac |
| name | None |
| port_range_max | 22 |
| port_range_min | 22 |
| project_id | adcf826c851145638d2f49e9fe56d074 |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 90d1cdb7-85fb-4e3f-891b-b8f036e300ce |
| updated_at | 2018-06-27T07:57:13Z |
+-------------------+--------------------------------------+
|
5.3. 添加一项安全规则,允许使用 80 默认端口连接 HTTP。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(operator1-production)]$ openstack security group \
rule create --protocol tcp --dst-port 80 production-secgroup1
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-27T07:57:43Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 1eca2a86-03ec-486d-84cd-2a49f4d1e244 |
| name | None |
| port_range_max | 80 |
| port_range_min | 80 |
| project_id | adcf826c851145638d2f49e9fe56d074 |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 90d1cdb7-85fb-4e3f-891b-b8f036e300ce |
| updated_at | 2018-06-27T07:57:43Z |
+-------------------+--------------------------------------+
|
5.4. 添加一项安全规则,允许使用 443 的默认端口连接 HTTPS。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(operator1-production)]$ openstack security group \
rule create --protocol tcp --dst-port 443 production-secgroup1
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-27T08:00:19Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 40018b0c-1100-414c-8489-adbf69e47083 |
| name | None |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
| | port_range_max | 443 |
| port_range_min | 443 |
| project_id | adcf826c851145638d2f49e9fe56d074 |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 90d1cdb7-85fb-4e3f-891b-b8f036e300ce |
| updated_at | 2018-06-27T08:00:19Z |
+-------------------+--------------------------------------+
|
6. 作为 operator1 用户,请创建对 production-keypair1 的密钥,并将私钥保存到 /home/student/Downloads/production-keypair1.pem。使用 chmod 命令来保护私钥文件。
6.1. 创建对对 production-keypair1 的密钥,并将私钥保存为 /home/student/Downloads/production-keypair1.pem。
1
2
| [student@workstation ~(operator1-production)]$ openstack keypair create \
production-keypair1 > /home/student/Downloads/production-keypair1.pem
|
6.2. 使用带有 600 模式的 chmod 命令来保护私钥。
1
2
| [student@workstation ~(operator1-production)]$ chmod 600 \
/home/student/Downloads/production-keypair1.pem
|
在 workstation 上运行 lab prep-deploy-ext-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab prep-deploy-ext-lab grade
|
在 workstation 上运行 lab prep-deploy-ext-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab prep-deploy-ext-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 解除浮动 IP 关联是否等于归还地址池?
- SSH 能连接但提示公钥认证失败,应优先检查什么?
自测答案#
- 不是,还需释放地址。解除关联和释放是不同操作。
- 用户名、私钥与公钥注入。网络连通后还要通过认证。
C10-部署可公开访问的实例#
资源组合#
启动前核对镜像、规格、项目网络、安全组和密钥对。实例 ACTIVE 后再创建或关联浮动 IP,确认 server show 中出现预期的固定地址与浮动地址。
验证顺序#
先从 workstation ping 浮动 IP,再以 cloud-user 和指定私钥执行 SSH。在实例中测试 materials.example.com 的连通性,最后从 workstation 测试 HTTP、HTTPS。
| 现象 | 下一步检查 |
|---|
| 浮动 IP 不出现 | 关联对象、实例端口、项目和地址池 |
| ping 不通但 SSH 可用 | ICMP 安全组规则,而非直接断定实例断网 |
| SSH 认证失败 | cloud-user、指定私钥、公钥注入 |
| SSH 正常但网页失败 | httpd、监听端口、安全组及实例内配置 |
多租户边界#
不同项目可以有同名资源或重叠的私有地址,身份与网络隔离决定你实际访问哪个对象。实验记录应同时写项目、实例 UUID、固定 IP 和浮动 IP,避免只凭服务器名称定位。
公共访问实例部署#
前提:demo-image、demo-small、demo-net、demo-access 和 demo-key 均已存在,且当前项目有权使用。
1
2
3
4
5
6
7
| openstack server create --image demo-image --flavor demo-small \
--nic net-id=demo-net --security-group demo-access \
--key-name demo-key --wait demo-public
openstack server show demo-public
openstack floating ip create demo-external
openstack server add floating ip demo-public <新分配的浮动IP>
ssh -i demo-key.pem cloud-user@<新分配的浮动IP>
|
镜像默认用户名不总是 cloud-user;此处按示例 RHEL 镜像理解。
服务验证#
1
2
3
4
5
6
| # 实例内部
ip route
sudo ss -lntp
sudo systemctl status httpd
# workstation:实例已安装并启动 Web 服务,安全组已放行 80 时
curl -v http://<浮动IP>/
|
| 错误现象 | 优先判断 |
|---|
| SSH 超时 | 地址、路由、端口安全组、目标监听 |
| Connection refused | 网络已到达拒绝点,继续看服务监听与防火墙 |
| Permission denied (publickey) | 登录用户名、私钥、公钥注入 |
| HTTP 403 / 404 | 已有 HTTP 应答,继续查站点权限或路径 |
不能用 ping 是否成功代替 TCP 服务测试,也不能只凭 HTTP 状态码断定业务正文正确。
实验操作#
引导练习:启动可公开访问的实例#
在此练习中,使用先前创建的资源来启动一个实例。
学习目标#
能够使用先前创造的资源,在公众可以访问的情况下启动一个实例。
开始之前#
以 student 登录 workstation,密码为 student。
在 workstation 上,使用 setup 参数运行 lab public-instance-deploy 脚本。它为此项练习创建了所需的组件,如用户、 密码、 镜像和网络。
1
| [student@workstation ~]$ lab public-instance-deploy setup
|
操作步骤#
1. 作为 developer1 用户,删除 finance 项目中现有的所有实例(如果有的话)。
1.1.
在 workstation 上,加载 developer1 身份环境文件。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
1.2. 列出项目中的所有实例。这应该是空列表。
1
| [student@workstation ~(developer1-finance)]$ openstack server list
|
1.3. 如果有任何实例正在运行,请删除它们。为每个实例运行以下命令。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server delete \
instance-name
|
2. 使用 rhel7 镜像、 default 规格、 example-keypair 密钥对、 finance-network1 网络和 default 安全组启动一个名为 finance-server1 的实例。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack server create \
--image rhel7 \
--flavor default \
--key-name example-keypair \
--nic net-id=finance-network1 \
--security-group default \
--wait finance-server1
...output omitted...
|
操作界面、表格与配置图
3. 作为项目管理员(architect1),将 provider-datacentre 网络设为 finance-router1 路由器的网关。
3.1. 用 source 加载 architect1 身份环境文件。
1
2
| [student@workstation ~(developer1-finance)]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
3.2. 设置 provider-datacentre 网络作为路由器的网关。
1
2
| [student@workstation ~(architect1-finance)]$ openstack router set \
--external-gateway provider-datacentre finance-router1
|
4. 作为 developer1 用户,为此项目创建三个浮动 IP 地址。
4.1. 用 source 加载 developer1 身份环境文件。
1
2
| [student@workstation ~(architect1-finance)]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
4.2. 创建第一个浮动 IP 地址。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(developer1-finance)]$ openstack floating ip create \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-14T16:50:09Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.N |
| floating_network_id | d2b4cff4-2444-4b65-ae40-c503a4f14980 |
| id | a5fc67cc-8531-4d67-a6b7-e04c38d19132 |
| name | 172.25.250.N |
| port_id | None |
| project_id | 438f276649894dcdbedb36ba1dc5296f |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-14T16:50:09Z |
+---------------------+--------------------------------------+
|
4.3. 创建第二个浮动 IP 地址。
1
2
3
4
5
| [student@workstation ~(developer1-finance)]$ openstack floating ip create \
provider-datacentre
...output omitted...
| floating_ip_address | 172.25.250.P |
...output omitted...
|
4.4. 创建第三个浮动 IP 地址。
操作界面、表格与配置图
1
2
3
4
5
| [student@workstation ~(developer1-finance)]$ openstack floating ip create \
provider-datacentre
...output omitted...
| floating_ip_address | 172.25.250.R |
...output omitted...
|
5. 将其中一个浮动 IP 关联到 finance-server1,并验证关联成功。
5.1. 将其中一个浮动 IP 关联到 finance-server1。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add floating ip \
finance-server1 172.25.250.N
|
5.2. 验证是否指定了此实例为浮动 IP 地址。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name \
-c Networks
+-----------------+----------------------------------------------+
| Name | Networks |
+-----------------+----------------------------------------------+
| finance-server1 | finance-network1=192.168.1.S, 172.25.250.N |
+-----------------+----------------------------------------------+
|
在 workstation 上运行 lab public-instance-deploy cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab public-instance-deploy cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:验证可公开访问的实例#
在此练习中,使用 ssh 和 ping 来测试外部网络,以验证一个公众访问实例的功能。
此练习使用上一个练习中创建的实例。如果您没有完成上一个练习,请现在就完成。
学习目标#
你应能够验证可公开访问的实例正常运行。
开始之前#
以 student 登录 workstation,密码为 student。
在 workstation 上,使用 setup 参数运行 lab public-instance-verify 脚本。它确保 OpenStack 服务正在运行,以前创造的资源可用于完成这项工作。
1
| [student@workstation ~]$ lab public-instance-verify setup
|
操作步骤#
1. Ping 实例,先前创建为 developer1 用户,使用浮动 IP 地址。
1.1.
在 workstation 上,加载 developer1 身份环境文件。
1
2
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
1.2. 查找与实例相关的浮动 IP 地址。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name \
-c Networks
+-----------------+----------------------------------------------+
| Name | Networks |
+-----------------+----------------------------------------------+
| finance-server1 | finance-network1=192.168.1.S, 172.25.250.N |
+-----------------+----------------------------------------------+
|
1.3. 使用 ping 测试实例。
1
2
3
| [student@workstation ~(developer1-finance)]$ ping -c 3 172.25.250.N
PING 172.25.250.N (172.25.250.N) 56(84) bytes of data.
64 bytes from 172.25.250.N: icmp_seq=1 ttl=64 time=0.365 ms
|
操作界面、表格与配置图
1
2
3
4
5
| 64 bytes from 172.25.250.N: icmp_seq=2 ttl=64 time=0.250 ms
64 bytes from 172.25.250.N: icmp_seq=3 ttl=64 time=0.239 ms
--- 172.25.250.N ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.239/0.284/0.365/0.060 ms
|
2. 以 cloud-user 用户身份登录,使用 SSH 密钥对进行验证。
1
2
3
| [student@workstation ~]$ ssh -i /home/student/.ssh/example-keypair \
cloud-user@172.25.250.N
[cloud-user@finance-server1 ~]$
|
3. 从实例 ping materials.example.com。从实例退出。
3.1. 从实例,ping materials.example.com。
1
2
3
4
5
6
7
8
9
10
11
| [cloud-user@finance-server1 ~]$ ping -c 3 materials.example.com
PING materials.example.com (172.25.254.254) 56(84) bytes of data.
64 bytes from classroom.example.com (172.25.254.254): icmp_seq=1 ttl=62
time=0.632 ms
64 bytes from classroom.example.com (172.25.254.254): icmp_seq=2 ttl=62
time=0.852 ms
64 bytes from classroom.example.com (172.25.254.254): icmp_seq=3 ttl=62
time=0.752 ms
--- materials.example.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.632/0.745/0.852/0.092 ms
|
3.2. 退出实例。
1
2
3
4
| [cloud-user@finance-server1 ~]$ exit
logout
Connection to 172.25.250.N closed.
[student@workstation ~(developer1-finance)]$
|
在 workstation 运行 lab public-instance-verify cleanup 清理本练习。该脚本会删除实例。
1
| [student@workstation ~]$ lab public-instance-verify cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:部署可公开访问的实例#
在这个实验中,利用上一个实验中创造的资源来启动一个实例,并验证这个实例是否正确启动。
学习目标#
完成后能够:
启动可公开访问的实例。
验证可公开访问的实例正常运行。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。
在 workstation 上,使用 setup 参数运行 lab public-instance-lab 脚本。它为这个实验创造所需的资源。
1
| [student@workstation ~]$ lab public-instance-lab setup
|
操作步骤#
1. 从 workstation 作为 operator1 用户,使用上一章或由实验 setup 脚本创建的以下资源创建一个名为 production-server1 的实例:
| 实例设置 | |
|---|
| 类型 | 值 |
| 实例名称 | production-server1 |
| 镜像 | rhel7-web |
| 规格 | default |
| 密钥对 | production-keypair1 |
| 项目网络 | production-network1 |
| 安全组 | production-secgroup1 |
| 浮动 IP 地址 | 172.25.250.142 |
2. 将 172.25.250.142 浮动 IP 关联到 production-server1。使用 /home/student/.ssh/production-keypair1 私钥,以 cloud-user 通过 SSH 登录实例,再从实例 ping 外部服务器 materials.example.com。
3. 从 workstation,核实该实例响应了Web 服务器请求(HTTP 和 HTTPS)。
在 workstation 上运行 lab public-instance-lab grade,检查本实验是否成功。
操作界面、表格与配置图
1
| [student@workstation ~]$ lab public-instance-lab grade
|
在 workstation 上运行 lab public-instance-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab public-instance-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
在这个实验中,利用上一个实验中创造的资源来启动一个实例,并验证这个实例是否正确启动。
学习目标#
完成后能够:
启动可公开访问的实例。
验证可公开访问的实例正常运行。
开始之前#
确认 workstation 和 Overcloud 虚拟机已启动。
以 student 登录 workstation,密码为 student。
在 workstation 上,使用 setup 参数运行 lab public-instance-lab 脚本。它为这个实验创造所需的资源。
1
| [student@workstation ~]$ lab public-instance-lab setup
|
操作步骤#
1. 从 workstation 作为 operator1 用户,使用上一章或由实验 setup 脚本创建的以下资源创建一个名为 production-server1 的实例:
| 实例设置 | |
|---|
| 类型 | 值 |
| 实例名称 | production-server1 |
| 镜像 | rhel7-web |
| 规格 | default |
| 密钥对 | production-keypair1 |
| 项目网络 | production-network1 |
| 安全组 | production-secgroup1 |
| 浮动 IP 地址 | 172.25.250.142 |
1.1.
在 workstation 上,打开一个终端作为 student 并加载 operator1 身份环境文件 /home/student/operator1-production-rc。
1
2
| [student@workstation ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$
|
1.2. 使用表格的资源创建 production-server1 实例。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ openstack server create \
--image rhel7-web \
--flavor default \
--key-name production-keypair1 \
--nic net-id=production-network1 \
--security-group production-secgroup1 \
|
操作界面、表格与配置图
1
2
3
| --wait \
production-server1
...output omitted...
|
2. 将 172.25.250.142 浮动 IP 关联到 production-server1。使用 /home/student/.ssh/production-keypair1 私钥,以 cloud-user 通过 SSH 登录实例,再从实例 ping 外部服务器 materials.example.com。
2.1. 将浮动 IP 地址与实例联系起来。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-server1 172.25.250.142
|
2.2. 使用 SSH 私钥将 SSH 登录到实例中。
1
2
3
4
| [student@workstation ~(operator1-production)]$ ssh \
-i ~/.ssh/production-keypair1 \
cloud-user@172.25.250.142
[cloud-user@production-server1 ~]$
|
2.3. 从实例 ping materials.example.com。
1
2
3
4
5
6
7
8
9
10
11
| [cloud-user@production-server1 ~]$ ping -c 3 materials.example.com
PING materials.example.com (172.25.254.254) 56(84) bytes of data.
64 bytes from classroom.example.com (172.25.254.254): icmp_seq=1 ttl=62
time=0.851 ms
64 bytes from classroom.example.com (172.25.254.254): icmp_seq=2 ttl=62
time=0.589 ms
64 bytes from classroom.example.com (172.25.254.254): icmp_seq=3 ttl=62
time=0.839 ms
--- materials.example.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.589/0.759/0.851/0.124 ms
|
2.4. 退出实例。
1
2
| [cloud-user@production-server1 ~]$ exit
[student@workstation ~(operator1-production)]$
|
3. 从 workstation,核实该实例响应了Web 服务器请求(HTTP 和 HTTPS)。
3.1. 从 workstation 中核实该案例响应了 HTTP 的要求。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ curl http://172.25.250.142
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/
DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test Page for the Apache HTTP Server on Red Hat Enterprise Linux</
title>
|
操作界面、表格与配置图
3.2. 核实该实例是否响应 HTTPS 的要求。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ curl -k https://172.25.250.142
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/
DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test Page for the Apache HTTP Server on Red Hat Enterprise Linux</
title>
...output omitted...
|
在 workstation 上运行 lab public-instance-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab public-instance-lab grade
|
在 workstation 上运行 lab public-instance-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab public-instance-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 浮动 IP 已关联,HTTP 失败但 SSH 成功,应继续检查什么?
- 不同项目出现相同私有地址时如何定位实例?
自测答案#
- HTTP 安全规则与应用监听。不同协议有各自的访问规则和服务状态。
- 结合项目、网络、UUID 和浮动 IP 身份和网络上下文决定实际对象。
C11-定制实例#
用户数据的两种形式#
用户数据可通过 Horizon 提交,也可通过 CLI 的 --user-data 指定文件。Shell 脚本和 cloud-config 文档的格式不同,开头标记、缩进和语法必须匹配;不能把说明文字直接复制进 YAML。
验证初始化结果#
| 目标 | 检查证据 |
|---|
| 写入文件 | 文件是否存在、内容是否正确 |
| 安装软件包 | 包是否已安装 |
| 启动并启用服务 | 当前运行状态与开机启用状态 |
| 初始化流程完成 | cloud-init 日志及服务结果 |
实例 ACTIVE 时,cloud-init 可能仍在下载软件包或执行脚本。先等待并查看 /var/log/cloud-init.log,再判定失败。浮动 IP 中 XX、YY 是占位符,必须替换为实际地址。
排错入口#
对照提交的用户数据文件和日志,检查 YAML 缩进、软件源访问、服务名与目标路径。
cloud-init 的两个入口#
Shell 脚本#
保存为 user-data.sh:
1
2
3
4
| #!/bin/bash
yum -y install httpd
printf 'OpenStack demo\n' > /var/www/html/index.html
systemctl enable --now httpd
|
cloud-config#
保存为 user-data.yaml,YAML 顶部必须有识别标记:
1
2
3
4
5
6
7
8
9
10
| #cloud-config
packages:
- httpd
write_files:
- path: /var/www/html/index.html
permissions: '0644'
content: |
OpenStack demo
runcmd:
- [systemctl, enable, --now, httpd]
|
两种示例择一使用;均依赖镜像已安装 cloud-init、能取得 user-data,并能访问可用软件源。
1
2
3
| openstack server create --image demo-image --flavor demo-small \
--nic net-id=demo-net --security-group demo-access \
--key-name demo-key --user-data user-data.yaml --wait demo-init
|
验证与排错#
1
2
3
4
5
6
7
| # 实例内
sudo tail -n 100 /var/log/cloud-init.log
sudo tail -n 100 /var/log/cloud-init-output.log
rpm -q httpd
systemctl is-active httpd
systemctl is-enabled httpd
curl http://127.0.0.1/
|
本机 curl 成功后,还需放行安全组与实例防火墙的 HTTP 访问。cloud-init 的各模块有执行频率,不应把普通重启当作必然重跑全部 user-data 的方法。
实验操作#
引导练习:创建定制实例#
本练习使用 cloud-init 定制两个实例,并登录第一个实例确认 cloud-init 已运行。
学习目标#
完成后能够:
使用 cloud-config 脚本定制实例。
使用 cloud-config 文件自定义实例。
开始之前#
以 student 为密码登录到 workstation 时为 student。从 workstation 运行 lab customize-instance setup, 保证 OpenStack 服务运行,并存在所需的 OpenStack 资源。
1
| [student@workstation ~]$ lab customize-instance setup
|
操作步骤#
1. 使用仪表板定制实例。以 developer1 登录 Horizon,密码为 redhat。创建 finance-server1,使用 rhel7 镜像、default 规格、finance-network1 网络、default 安全组及 example-keypair 密钥对。定制脚本应在实例的 /root/hello.txt 写入 Hello world!。
1.1.
从 workstation 打开网络浏览器并浏览到 http://dashboard.overcloud.example.com. 使用 developer1 用户的日志,以及使用 redhat 密码。
1.2. 用于计算 > 实例的导航。
1.3. 点击Launch Instance
1.4. 在详细选项卡中,输入 finance-server1 作为实例名称。
1.5. 在 Source 的 Select Boot Source 中选择 Image。在 Available 部分点击 rhel7 同行的向上箭头选用镜像;Create New Volume 选择 No。
1.6. 在 Flavor 标签中,单击 default 行的向上箭头。
1.7.
在网络标签中,单击 finance-network1 行上的箭头。
1.8. 在安全组标签中,确保 default 安全组被选中。
1.9. 在密钥对标签中,确保选中 example-keypair 密钥对。
1.10. 在配置标签中,以以下内容填充自定义脚本字段 :
操作界面、表格与配置图
1
2
| #!/bin/sh
echo 'Hello world!' > /root/hello.txt
|
1.11. 点击Launch Instance
2. 在激活此例后,在 finance-server1 实例中附加一个浮动 IP 地址。
2.1. 一旦实例状态为 Active, 则附上一个浮动的 IP 地址。从行中的 Action 菜单中选择协理浮动 IP。
点击 IP 地址区域中的 + 按钮创建新的浮动 IP 地址。点击分配 IP , 然后单击 Associate。
2.2. 退出仪表板。
3. 在 workstation 上创建一个名为 install_httpd 的 user-data 文件,以定制实例。脚本将安装Web 服务器并启用此服务。
1
2
3
4
5
| [student@workstation ~(developer1-finance)]$ vim /home/student/install_httpd
#!/bin/bash
# web server with a postgres backend
yum -y install httpd python-psycopg2
systemctl enable httpd --now
|
4. 使用命令行自定义一个实例。使用 developer1 用户以 rhel7 镜像、 default 规格、 finance-network1 网络、 default 安全组和 example-keypair 密钥对启动一个名为 finance-server2 的例。包括 user-data 脚本 /home/student/install_httpd。
4.1. 使用 –user-data 选项启动一个实例来进行定制。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack server create \
--image rhel7 \
--flavor default \
--nic net-id=finance-network1 \
--security-group default \
--key-name example-keypair \
--user-data /home/student/install_httpd \
--wait finance-server2
|
4.2. 核实 finance-server2 号案例的状态是 active。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Status -c Networks
+-----------------+--------+----------------------------------------------+
| Name | Status | Networks |
+-----------------+--------+----------------------------------------------+
| finance-server2 | ACTIVE | finance-network1=192.168.1.11 |
| finance-server1 | ACTIVE | finance-network1=192.168.1.7, 172.25.250.104 |
+-----------------+--------+----------------------------------------------+
|
5. 实例状态为 active 时,创建一个新的浮动 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
26
27
28
29
30
31
| [student@workstation ~(developer1-finance)]$ openstack floating ip create \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-25T06:13:50Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.YY |
| floating_network_id | 95a56df3-a710-4bc6-b7c5-fc5d3e725df6 |
| id | 57d2d3b2-f206-45e3-ad9c-14fecefabd79 |
| name | 172.25.250.YY |
| port_id | None |
| project_id | e6b7f37fadf943e1aae06a5c2e55d646 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-25T06:13:50Z |
+---------------------+--------------------------------------+
[student@workstation ~(developer1-finance)]$ openstack server add floating ip \
finance-server2 172.25.250.YY
[student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Networks
+-----------------+-----------------------------------------------+
| Name | Networks |
+-----------------+-----------------------------------------------+
| finance-server2 | finance-network1=192.168.1.11, 172.25.250.YY |
| finance-server1 | finance-network1=192.168.1.7, 172.25.250.NN |
+-----------------+-----------------------------------------------+
|
在 workstation 上运行 lab customize-instance cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab customize-instance cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:验证定制实例#
在此练习中,核实 cloud-init 是否正确定制了上一节中创建的两个实例。
学习目标#
能够通过检查 /var/log/cloud-init.log 文件或确认已进行了所要求的定制来验证 cloud-init 操作。
开始之前#
确保启动 workstation 和 overcloud 虚拟机。
以 student 为密码登录到 workstation 时为 student。从 workstation 使用 setup 参数运行 lab customization-instance-verify 脚本,以确保上一节中生成的实例仍在运行。
1
| [student@workstation ~]$ lab customize-instance-verify setup
|
操作步骤#
1. 从 workstation 打开终端,加载 developer1-finance-rc 环境文件,然后确定分配给 finance-server1 实例的浮动 IP 地址。记住浮动 IP 地址在 172.25.250.0/24 子网中。
1
2
3
4
5
6
7
8
9
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Networks
+-----------------+-----------------------------------------------+
| Name | Networks |
+-----------------+-----------------------------------------------+
| finance-server2 | finance-network1=192.168.1.NN, 172.25.250.YY |
| finance-server1 | finance-network1=192.168.1.MM, 172.25.250.XX |
+-----------------+-----------------------------------------------+
|
本书用 172.25.250.XX 表示 finance-server1 的浮动 IP。将 XX 替换为你上方输出中的实际末段地址。
2. 登录到 finance-server1 以核实 cloud-init 定制脚本创建了 /root/hello.txt 文件。
2.1. 使用 example-keypair 私钥使用 ssh 登录到 finance-server1 和 ssh。
1
2
| [student@workstation ~(developer1-finance)]$ ssh -i ~/.ssh/example-keypair \
cloud-user@172.25.250.XX
|
2.2. 请检查 /var/log/cloud-init.log 确认 cloud-init 运行。
1
2
3
4
| [cloud-user@finance-server1 ~]$ sudo less /var/log/cloud-init.log
...output omitted...
...util.py[DEBUG]: Cloud-init v. 0.7.9 finished at Sat, 23 Jun 2018 02:26:02
+0000. Datasource DataSourceOpenStack [net,ver=2]. Up 21.25 seconds
|
操作界面、表格与配置图
2.3. 确保 /root/hello.txt 文件存在,并且内容正确。
1
2
| [cloud-user@finance-server3 ~]$ sudo cat /root/hello.txt
Hello world!
|
2.4. 从 finance-server1 中退出。
1
2
3
| [cloud-user@finance-server1 ~]$ exit
logout
Connection to 172.25.250.XX closed.
|
3. 登录到 finance-server2 以核实 /home/student/install_httpd 用户数据脚本是否安装并启用了 httpd 服务。
3.1. 确定分配给 finance-server2 实例的浮动 IP 地址。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ openstack server show finance-
server2 \
-c addresses -f value
finance-server2=192.168.1.MM, 172.25.250.YY
|
本书用 172.25.250.YY 表示 finance-server2 的浮动 IP。将 YY 替换为你上方输出中的实际末段地址。
3.2. 使用 ssh 和 example-keypair 私密密钥登录到 finance-server2。
1
2
| [student@workstation ~(developer1-finance)]$ ssh -i ~/.ssh/example-keypair \
cloud-user@172.25.250.YY
|
3.3. 请检查 /var/log/cloud-init.log 确认 cloud-init 运行。
1
2
3
4
| [cloud-user@finance-server2 ~]$ sudo less /var/log/cloud-init.log
...output omitted...
...util.py[DEBUG]: Cloud-init v. 0.7.9 finished at Sat, 23 Jun 2018 02:26:02
+0000. Datasource DataSourceOpenStack [net,ver=2]. Up 88.48 seconds
|
3.4. 确认 httpd 起作用了
1
2
3
| [cloud-user@finance-server2 ~]$ curl http://localhost | grep Test
<title>Test Page for the Apache HTTP Server on Red Hat Enterprise Linux</title>
<h1>Red Hat Enterprise Linux <strong>Test Page</strong></h1>
|
3.5. 在 workstation 上,使用 curl 导航到 http://172.25.250.YY. 连接必须成功。
1
2
| [student@workstation ~(developer1-finance)]$ curl http://172.25.250.YY
...output omitted...
|
操作界面、表格与配置图
在 workstation 上运行 lab customize-instance-verify cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab customize-instance-verify cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:定制实例#
在此实验中,运行一个实例的脚本,在实例中添加一个文件,然后校验您的工作。
学习目标#
能够使用 cloud-init 在实例上安装软件包或文件,然后使用 cloud-init 日志文件来验证您的工作。
开始之前#
以 student 为密码,登录到 workstation 作为 student。
从 workstation,运行 lab customize-instance-lab setup,确保 OpenStack 服务运行,并具备所需的 OpenStack 资源。
1
| [student@workstation ~]$ lab customize-instance-lab setup
|
操作步骤#
1. 创建一个带有 cloud-init 指令的文件,以安装 mariadb-server 软件包。这些指令还应该启动并启用 mariadb 服务。
2. 启动 production-server1,使用 rhel7 镜像、default 规格、production-network1 网络、example-keypair 密钥对、default 安全组及 install_mariadb 用户数据文件。在 provider-datacentre 创建浮动 IP,并关联到此实例。
3. 使用 SSH 和 example-keypair 密钥对登录 production-server1。
4. 验证 cloud-init 运行成功。
在 workstation 上运行 lab customize-instance-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab customize-instance-lab grade
|
在 workstation 上运行 lab customize-instance-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab customize-instance-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
在此实验中,运行一个实例的脚本,在实例中添加一个文件,然后校验您的工作。
学习目标#
能够使用 cloud-init 在实例上安装软件包或文件,然后使用 cloud-init 日志文件来验证您的工作。
开始之前#
以 student 为密码,登录到 workstation 作为 student。
从 workstation,运行 lab customize-instance-lab setup,确保 OpenStack 服务运行,并具备所需的 OpenStack 资源。
1
| [student@workstation ~]$ lab customize-instance-lab setup
|
操作步骤#
1. 创建一个带有 cloud-init 指令的文件,以安装 mariadb-server 软件包。这些指令还应该启动并启用 mariadb 服务。
1.1.
用 source 加载 operator1-production-rc 环境文件。在 /home/student 目录中创建名为 install_mariadb 的指示文件,并有以下指示。
1
2
3
4
5
| [student@workstation ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$ vim /home/student/install_mariadb
#!/bin/bash
yum -y install mariadb-server
systemctl enable mariadb --now
|
2. 启动 production-server1,使用 rhel7 镜像、default 规格、production-network1 网络、example-keypair 密钥对、default 安全组及 install_mariadb 用户数据文件。在 provider-datacentre 创建浮动 IP,并关联到此实例。
2.1. 启动 production-server1 实例。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--image rhel7 \
--nic net-id=production-network1 \
--key-name example-keypair \
--user-data /home/student/install_mariadb \
--wait production-server1
+-----------------------------+-------------------------------------+
| Field | Value |
+-----------------------------+-------------------------------------+
| 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-06-20T07:24:34.000000 |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| | OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | production-network1=192.168.1.9 |
| adminPass | 7SyNrmSpURsD |
| config_drive | |
| created | 2018-06-20T07:24:15Z |
| flavor | default (a2db...064c) |
| hostId | 159f...4955 |
| id | 17d0...840d |
| image | rhel7 (2078...25a2) |
| key_name | example-keypair |
| name | production-server1 |
| progress | 0 |
| project_id | adcf...d074 |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-20T07:24:34Z |
| user_id | 0f80...4b82 |
| volumes_attached | |
+-----------------------------+-------------------------------------+
|
2.2. 在 provider-datacentre 网络中创建浮动 ip 地址。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(operator1-production)]$ openstack floating ip create \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-20T07:31:08Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.XX |
| floating_network_id | 6d845ef5-8844-490e-a944-cbd22a453c78 |
| id | d4c9ebcc-c443-4fb7-8ecd-e5ec446c311d |
| name | 172.25.250.111 |
| port_id | None |
| project_id | adcf826c851145638d2f49e9fe56d074 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-20T07:31:08Z |
+---------------------+--------------------------------------+
|
2.3. 将浮动 ip 地址附加到 production-server1 实例。
1
2
3
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-server1 172.25.250.XX
[student@workstation ~(operator1-production)]$
|
2.4. 确保浮动 ip 被分配到 production-server1
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack server list \
-c Name -c Networks
+--------------------+-------------------------------------------------+
| Name | Networks |
|
操作界面、表格与配置图
1
2
3
| +--------------------+-------------------------------------------------+
| production-server1 | production-network1=192.168.1.9, 172.25.250.XX |
+--------------------+-------------------------------------------------+
|
3. 使用 SSH 和 example-keypair 密钥对登录 production-server1。
3.1. 验证 production-server1 实例是活动的。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ openstack server show \
production-server1
...output omitted...
| OS-EXT-STS:vm_state | active
...output omitted...
|
3.2. 使用在~/.ssh/example-keypair 和浮动的 IP 地址发现的 example-keypair 私钥,将 production-server1 作为 cloud-user 登录入 production-server1 实例。
1
2
3
4
| [student@workstation ~(operator1-production)]$ ssh -i ~/.ssh/example-keypair \
cloud-user@172.25.250.XX
Warning: Permanently added '172.25.250.111' (ECDSA) to the list of known hosts.
[cloud-user@production-server1 ~]$
|
4. 验证 cloud-init 运行成功。
4.1. 检查 /var/log/cloud-init.log 确认 cloud-init 成功运行。
1
2
3
4
5
| [cloud-user@production-server1 ~]$ sudo less /var/log/cloud-init.log
...output omitted...
2018-06-23 00:11:40,287 - util.py[DEBUG]: Cloud-init v. 0.7.9 finished at Sat,
23 Jun 2018 04:11:40 +0000. Datasource DataSourceOpenStack [net,ver=2]. Up
46.99 seconds
|
4.2. 确认 mariadb 已安装并运行。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [cloud-user@production-server1 ~]$ rpm -q mariadb-server
mariadb-server-10.1.20-2.el7ost.x86_64
[cloud-user@production-server1 ~]$ systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor
preset: disabled)
Active: active (running) since Tue 2018-06-19 18:29:50 EST; 2min 53s ago
Process: 1196 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID
(code=exited, status=0/SUCCESS)
Process: 1116 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n
(code=exited, status=0/SUCCESS)
Main PID: 1195 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─1195 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─1359 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --
plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb...
...output omitted...
|
操作界面、表格与配置图
在 workstation 上运行 lab customize-instance-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab customize-instance-lab grade
|
在 workstation 上运行 lab customize-instance-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab customize-instance-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 实例 ACTIVE 时 cloud-init 是否必然已执行完成?
- 用户数据 YAML 的缩进应如何处理?
自测答案#
- 不一定,应等待并检查日志和结果。初始化过程可能仍在安装包或执行脚本。
- 用空格并遵循结构。结构和缩进错误会影响解析与配置。
C12-部署可伸缩应用栈#
模板与环境文件#
模板描述参数、资源关系和输出;环境文件提供本次部署参数与自定义资源映射。检查模板要求,再查询当前镜像、规格、网络、子网和密钥对,填写对应值。dry run 用于审查预期资源,不证明部署一定成功。
观察栈生命周期#
创建后查看状态、资源和事件;失败时从事件中定位具体资源,不要只重跑整套模板。启用回滚会影响失败后留下的资源。CREATE_COMPLETE 后继续验证输出 URL 和应用响应。
遥测与自动伸缩#
| 组成 | 职责 |
|---|
| metric、measure | 指标定义与按时间记录的测量值 |
| archive policy | 聚合粒度与保留策略 |
| alarm | 依据条件与评估周期判断状态 |
| scaling policy | 定义增加或减少容量的动作 |
| AutoScalingGroup | 管理期望数量、上下限及资源模板 |
CPU 告警不是瞬时命令。实验收集、聚合和评估需要等待,insufficient data 与真正报警不同。增加负载后观察高阈值告警、实例数变化;负载结束后观察低阈值告警和缩容。以实际时间戳与状态为证据。
负载均衡实验#
先部署负载均衡器栈,再部署后端成员栈。环境文件中的网络、子网和资源类型别名必须对应。连续发出 HTTP 请求,确认请求分配到两个后端;仅看到负载均衡地址存在不算完成。
Heat 模板的骨架#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| heat_template_version: 2016-10-14
description: One server for learning Heat
parameters:
image:
type: string
flavor:
type: string
network:
type: string
resources:
web:
type: OS::Nova::Server
properties:
image: {get_param: image}
flavor: {get_param: flavor}
networks:
- network: {get_param: network}
outputs:
server_id:
value: {get_resource: web}
|
此最小模板只创建一台实例,不提供公共访问和自动伸缩。将它保存为 server.yaml,环境文件 env.yaml 中写入实际资源:
1
2
3
4
| parameters:
image: rhel7
flavor: default
network: finance-network1
|
1
2
3
4
5
6
| openstack orchestration template validate -t server.yaml -e env.yaml
openstack stack create -t server.yaml -e env.yaml demo-stack
openstack stack show demo-stack
openstack stack resource list demo-stack
openstack stack event list demo-stack
openstack stack output show demo-stack server_id
|
三个内置函数#
get_param:使用输入参数。get_resource:取得模板中资源标识,建立资源依赖。get_attr:读取资源的某个属性,属性名由资源类型定义。
自动伸缩链路#
1
2
3
4
5
| Ceilometer 收集样本 → Gnocchi 保存与聚合指标
→ Aodh 评估告警
→ Heat ScalingPolicy
→ AutoScalingGroup 改变容量
→ 后端成员加入/退出负载均衡
|
| 参数 | 决定什么 |
|---|
| granularity | 聚合时间粒度,例如 60 秒 |
| evaluation periods | 连续评估多少个周期 |
| threshold | 触发阈值 |
| cooldown | 伸缩动作间的冷却时间 |
| min / max / desired capacity | 容量下限、上限与期望值 |
insufficient data 表示没有足够数据判断,不等于 alarm。CPU 指标究竟是百分比还是累积 CPU 时间,需要看指标定义与聚合方式。
自动伸缩验证#
查看指标和时间戳 → 确认正常容量 → 产生测试负载 → 等待采集与评估 → 查看高阈值告警和扩容 → 测试多个后端响应 → 停止负载 → 查看缩容。记录每个阶段的实例数与告警状态。
实验操作#
引导练习:分析自动伸缩的云指标#
在此练习中,查看和分析 自动伸缩 所需的通用度量。
学习目标#
完成后能够:
列出与资源有关的现有计量指标。
分析指标,以观察总数值。
开始之前#
确保 workstation 和Overcloud的虚拟机启动。
在 workstation 上运行 lab stacks-metrics setup 命令。此脚本确保环境为此练习配置正确。此脚本还创建了一个名为 finance-server1 的例子。
1
| [student@workstation ~]$ lab stacks-metrics setup
|
操作步骤#
1. 在 workstation 用 source 加载 /home/student/developer1-finance-rc。列出遥测服务的资源类型,再列出 image 资源类型关联的指标。
1.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
25
26
27
| [student@workstation ~]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$ openstack metric resource-type \
list -c name
+----------------------------+
| name |
+----------------------------+
| ceph_account |
| generic |
| host |
| host_disk |
| host_network_interface |
| identity |
| image |
| instance |
| instance_disk |
| instance_network_interface |
| ipmi |
| manila_share |
| network |
| nova_compute |
| port |
| stack |
| swift_account |
| switch |
| switch_port |
| switch_table |
| volume |
|
操作界面、表格与配置图
1
2
3
| | volume_provider |
| volume_provider_pool |
+----------------------------+
|
1.2. 列出 developer1 用户可访问的资源。注意 image 资源类型的资源 ID。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~(developer1-finance)]$ openstack metric resource list \
-c id -c type
+--------------------------------------+----------------------------+
| id | type |
+--------------------------------------+----------------------------+
| b9f90067-0c8c-4144-81de-8b0fa55b791c | image |
| 05a6a936-4a4c-5d1b-b355-2fd6e2e47647 | instance_disk |
| cef757c0-6137-5905-9edc-ce9c4d2b9003 | instance_network_interface |
| 6776f92f-0706-54d8-94a1-2dd8d2397825 | instance_disk |
| dbf53681-540f-5ee1-9b00-c06bb53cbd62 | instance_disk |
| cebc8e2f-3c8f-45a1-8f71-6f03f017c623 | swift_account |
| a2b3bda7-1d9e-4ad0-99fe-b4f7774deda0 | instance |
| ... | ... |
+--------------------------------------+----------------------------+
|
1.3. 核实 rhel7 镜像的 ID 与资源 ID 相同。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack image list \
-c ID -c Name
+--------------------------------------+-----------+
| ID | Name |
+--------------------------------------+-----------+
| b9f90067-0c8c-4144-81de-8b0fa55b791c | rhel7 |
| ... | ... |
+--------------------------------------+-----------+
|
1.4. 列出与 image 资源 ID 有关的计量标准。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| [student@workstation ~(developer1-finance)]$ openstack metric resource show \
b9f90067-0c8c-4144-81de-8b0fa55b791c
+-----------------------+------------------------------------------------------+
| Field | Value |
+-----------------------+------------------------------------------------------+
| created_by_project_id | 553a5434e63842eb80513c9e740b61e7 |
| created_by_user_id | ef6cde08413746d6b0a1dea1a8565522 |
| creator | ef6cde08413746d6b0a1dea1a8565522:553a5434e63842eb805 |
| | 13c9e740b61e7 |
| ended_at | None |
| id | b9f90067-0c8c-4144-81de-8b0fa55b791c |
| metrics | image.download: 19c10cb6-dd57-43aa-8bce-e3a1ee4c9039 |
| | image.serve: 6317f1e6-ce0c-41fc-b8c9-266beddc2738 |
| | image.size: 149da247-1911-4073-a296-77350324606f |
| original_resource_id | b9f90067-0c8c-4144-81de-8b0fa55b791c |
| project_id | 3b328fd576c84f098df8a605e71bdf59 |
| revision_end | None |
| revision_start | 2018-07-02T09:34:15.213043+00:00 |
| started_at | 2018-07-02T09:34:15.213029+00:00 |
| type | image |
| user_id | None |
+-----------------------+------------------------------------------------------+
|
操作界面、表格与配置图
2. 使用适当的资源 ID 列出与 finance-server1 实例相关的所有度量。列出 disk.read.requests.rate 计量的详情。
2.1. 列出与 finance-server1 实例相关的所有度量。
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
55
56
57
58
| [student@workstation ~(developer1-finance)]$ openstack server list -c ID -c Name
+--------------------------------------+-----------------+
| ID | Name |
+--------------------------------------+-----------------+
| 8e8ca3d6-6b1c-4a97-a242-ec8549f6628e | finance-server1 |
+--------------------------------------+-----------------+
[student@workstation ~(developer1-finance)]$ openstack metric resource show \
8e8ca3d6-6b1c-4a97-a242-ec8549f6628e -f json
{
"created_by_user_id": "ef6cde08413746d6b0a1dea1a8565522",
"user_id": "630d039328fb44b79c97685d335b833f",
"started_at": "2018-07-04T10:23:43.925033+00:00",
"ended_at": null,
"revision_end": null,
"creator":
"41fa2761227c4722b2676baa9cd451cc:553a5434e63842eb80513c9e740b61e7",
"created_by_project_id": "553a5434e63842eb80513c9e740b61e7",
"metrics": {
"cpu_l3_cache": "608d3cab-01d8-4c2a-aeec-dc7bbd449c60",
"disk.write.requests.rate": "3dbd5011-7dfc-44d3-a13d-8d3fb8f0cc45",
"perf.cache.misses": "6fed6e38-b2ef-455e-973d-ea7a1b382116",
"perf.cache.references": "c9ff224b-512a-42e4-9ab7-e26cbfae53d6",
"disk.latency": "993bab86-e5dd-44b8-8539-9dd450eee260",
"disk.ephemeral.size": "7aa3a359-2bd6-47ef-9df0-5e70cdde9d8d",
"disk.read.requests": "5126c317-32d3-4484-803a-8ae1c387e74c",
"perf.cpu.cycles": "cd95c496-f9ea-4ead-9e7c-8ffe9cdc1776",
"disk.write.bytes": "e63186be-e043-4d1c-a5a1-49225b4a83a0",
"memory.resident": "4451aec5-93ba-4e72-bb61-ba0c40e683e4",
"disk.capacity": "6d3a7c24-4fee-47ae-bd13-ed0a197b1800",
"disk.root.size": "0757cc68-0e90-4820-99c3-96a3377fcc10",
"disk.usage": "d6e607b2-6889-47c4-af4b-6b0686f07957",
"disk.read.bytes.rate": "0d2e1264-a82d-4f8c-9663-0896d12e5baf",
"cpu_util": "9de294d4-42da-464f-bdfa-4724852e2192",
"memory.bandwidth.total": "51e5a704-92b5-4e00-adbb-60e48b571a21",
"memory": "f2c2c55d-b646-42af-b194-d3f9fa2c5364",
"disk.write.bytes.rate": "82ad14e3-5de2-4bc8-840b-ab791c9dc5ac",
"memory.usage": "87222d08-7607-4f49-9ad8-a63cc8ddf82a",
"memory.swap.in": "50c506a4-dc6b-41e0-9def-8cb2590c2f92",
"cpu.delta": "6367665e-f578-4173-8a0a-97920dc3ae3a",
"compute.instance.booting.time": "ac442b38-53a0-4d03-92e3-b9fb348192b8",
"perf.instructions": "d741dabf-91d5-4a0a-84a3-9a302f3d25b8",
"disk.read.requests.rate": "74678be7-239c-455d-8eba-da6ea9ea7392",
"disk.iops": "b7b13aac-a62e-4083-9c1a-3a20e215af9c",
"memory.bandwidth.local": "e36a12c7-00f0-4fba-bc95-5fc28046ed94",
"disk.allocation": "b080148e-091d-40f2-b1b9-3f15fabad69e",
"disk.write.requests": "8189e670-7f79-4389-abac-f0b7750f5dc9",
"vcpus": "9b3ee688-6b05-4386-b699-e081502d0d56",
"disk.read.bytes": "c55b7c82-6739-4b27-8871-110031824730",
"memory.swap.out": "2aeca7c5-1103-4b6b-a2df-a9f905757762",
"cpu": "8b1e749d-c055-44a8-845e-1d8f7d30cbda"
},
"original_resource_id": "8e8ca3d6-6b1c-4a97-a242-ec8549f6628e",
"revision_start": "2018-07-04T10:23:43.925047+00:00",
"project_id": "3b328fd576c84f098df8a605e71bdf59",
"type": "instance",
"id": "8e8ca3d6-6b1c-4a97-a242-ec8549f6628e"
}
},
|
操作界面、表格与配置图
2.2. 列出 disk.read.requests.rate 衡量标准的细节。
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-finance)]$ openstack metric show \
--resource-id 8e8ca3d6-6b1c-4a97-a242-ec8549f6628e \
disk.read.requests.rate
+--------------------------------+---------------------------------------------+
| Field | Value |
+--------------------------------+---------------------------------------------+
| archive_policy/name | high |
| creator | ef6cde08413746d6b0a1dea1a8565522:553a5434e6 |
| | 3842eb80513c9e740b61e7 |
| id | 74678be7-239c-455d-8eba-da6ea9ea7392 |
| name | disk.read.requests.rate |
| resource/created_by_project_id | 553a5434e63842eb80513c9e740b61e7 |
| resource/created_by_user_id | ef6cde08413746d6b0a1dea1a8565522 |
| resource/creator | ef6cde08413746d6b0a1dea1a8565522:553a5434e6 |
| | 3842eb80513c9e740b61e7 |
| resource/ended_at | None |
| resource/id | 8e8ca3d6-6b1c-4a97-a242-ec8549f6628e |
| resource/original_resource_id | 8e8ca3d6-6b1c-4a97-a242-ec8549f6628e |
| resource/project_id | 3b328fd576c84f098df8a605e71bdf59 |
| resource/revision_end | None |
| resource/revision_start | 2018-07-04T05:01:08.201559+00:00 |
| resource/started_at | 2018-07-04T05:01:08.201548+00:00 |
| resource/type | instance |
| resource/user_id | e676507192d848a19f067ccdc0a20bd0 |
| unit | None |
+--------------------------------+---------------------------------------------+
|
disk.read.requests.rate 使用 high 归档策略。该策略的最小聚合粒度为 1 秒,聚合数据最长保留 365 天。
2.3. 显示与 finance-server1 实例相关的 disk.read.requests.rate 度量收集和汇总的测量。输出中返回的记录数量可能有所不同。在输出屏幕中,8e8ca3d6-6b1c-4a97-a242-ec8549f6628e 是 finance-server1 度量的 ID。
在课堂环境中,衡量服务需要 15 分钟收集和计算第一组计量样本。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack metric measures show \
--resource-id 8e8ca3d6-6b1c-4a97-a242-ec8549f6628e \
disk.read.requests.rate
+---------------------------+-------------+---------------+
| timestamp | granularity | value |
+---------------------------+-------------+---------------+
| 2018-07-04T10:30:00+05:30 | 3600.0 | 0.00166716985 |
| 2018-07-04T10:42:00+05:30 | 60.0 | 0.0016675937 |
| 2018-07-04T10:52:00+05:30 | 60.0 | 0.001666746 |
| 2018-07-04T10:42:50+05:30 | 1.0 | 0.0016675937 |
| 2018-07-04T10:52:50+05:30 | 1.0 | 0.001666746 |
|
操作界面、表格与配置图
1
| +---------------------------+-------------+---------------+
|
观察 value 列,该列显示根据与标准相关的归档策略得出的总计值。3600、 60 和 granularity 列数值中的 1 分别代表 1 日、 1 小时和 1 分钟的汇总期。
2.4. 使用资源 ID,以一分钟粒度列出 cpu_util 的最大测量值。实际返回的记录数可能不同。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(developer1-finance)]$ openstack metric measures show \
--resource-id 8e8ca3d6-6b1c-4a97-a242-ec8549f6628e \
--aggregation max \
--granularity 60 \
cpu_util
+---------------------------+-------------+--------------+
| timestamp | granularity | value |
+---------------------------+-------------+--------------+
| 2018-07-04T10:42:00+05:30 | 60.0 | 0.2609810508 |
| 2018-07-04T10:52:00+05:30 | 60.0 | 0.2350065626 |
| 2018-07-04T11:02:00+05:30 | 60.0 | 0.248329562 |
+---------------------------+-------------+--------------+
|
3. 列出所有实例的平均 CPU 利用率,并将查询限制在过去的 60 分钟数据。查询属于 finance 服务器组的所有实例。
3.1. 列出由 instance 资源类型支持的属性。命令返回可用于查询此资源类型的属性。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [student@workstation ~(developer1-finance)]$ openstack metric resource-type \
show instance
+-------------------------+----------------------------------------------------+
| Field | Value |
+-------------------------+----------------------------------------------------+
| attributes/display_name | max_length=255, min_length=0, required=True, |
| | type=string |
| attributes/flavor_id | max_length=255, min_length=0, required=True, |
| | type=string |
| attributes/flavor_name | max_length=255, min_length=0, required=True, |
| | type=string |
| attributes/host | max_length=255, min_length=0, required=True, |
| | type=string |
| attributes/image_ref | max_length=255, min_length=0, required=False, |
| | type=string |
| attributes/server_group | max_length=255, min_length=0, required=False, |
| | type=string |
| name | instance |
| state | active |
+-------------------------+----------------------------------------------------+
|
3.2. 只有具有 admin 角色的用户才能按资源属性查询测量值。用 source 加载 /home/student/architect1-finance-rc 中的 architect1 凭据,再执行命令。
1
2
| [student@workstation ~(developer1-finance)]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
操作界面、表格与配置图
3.3. 列出与 finance-server1 实例相关的元数据属性。
1
2
3
4
5
6
7
| [student@workstation ~(architect1-finance)]$ openstack server show \
-c properties finance-server1
+------------+---------------------------------+
| Field | Value |
+------------+---------------------------------+
| properties | metering.server_group='finance' |
+------------+---------------------------------+
|
3.4. 使用 openstack metric measures aggregation 命令来列出所有实例的平均 CPU 利用率。使用 –start 选项来限制查询时间,将查询时间限制为过去的 60 分钟数据。使用 –query 选项来过滤实例。
instance 资源类型有 server_group 属性。server_group 属性指定了 instance 元数据属性。使用 –refresh 选项强制汇总所有已知计量。
时间序列数据库服务预计时间序列有一定百分比的时标相同。此百分比默认为 100%。使用 –needed-overlap 选项将百分比定为 0。
输出中返回的记录数量可能不同。
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
| [student@workstation ~(architect1-finance)]$ openstack metric measures \
aggregation \
--metric cpu_util \
--aggregation mean \
--resource-type instance \
--start $(date -u --iso=seconds -d "-60mins") \
--query "server_group='finance'" \
--needed-overlap 0 \
--refresh
+---------------------------+-------------+----------------+
| timestamp | granularity | value |
+---------------------------+-------------+----------------+
| 2018-07-04T13:30:00+05:30 | 3600.0 | 0.255832388217 |
| 2018-07-04T14:30:00+05:30 | 3600.0 | 0.184584744158 |
| 2018-07-04T14:32:00+05:30 | 60.0 | 0.1858290391 |
| 2018-07-04T14:42:00+05:30 | 60.0 | 0.1401828896 |
| 2018-07-04T14:52:00+05:30 | 60.0 | 0.0891666539 |
| 2018-07-04T15:02:00+05:30 | 60.0 | 0.1041650796 |
| 2018-07-04T15:12:00+05:30 | 60.0 | 0.10374118845 |
| 2018-07-04T15:22:00+05:30 | 60.0 | 0.4758452247 |
| 2018-07-04T14:32:50+05:30 | 1.0 | 0.1858290391 |
| 2018-07-04T14:42:48+05:30 | 1.0 | 0.1401828896 |
| 2018-07-04T14:52:48+05:30 | 1.0 | 0.0891666539 |
| 2018-07-04T15:02:48+05:30 | 1.0 | 0.0858325314 |
| 2018-07-04T15:02:50+05:30 | 1.0 | 0.1224976278 |
| 2018-07-04T15:12:48+05:30 | 1.0 | 0.088331848 |
| 2018-07-04T15:12:50+05:30 | 1.0 | 0.1191505289 |
| 2018-07-04T15:22:48+05:30 | 1.0 | 0.8291784493 |
| 2018-07-04T15:22:50+05:30 | 1.0 | 0.1225120001 |
+---------------------------+-------------+----------------+
|
操作界面、表格与配置图
在 workstation 上运行 lab stacks-metrics cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab stacks-metrics cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:部署应用栈#
本练习使用 Heat 编排模板部署应用栈,启动 Web 服务器实例,并从仪表板查看栈信息。
学习目标#
完成后能够:
检查确定所需参数的模板。
创建一个环境文件,并附有必要的参数。
使用模板部署编排栈。
列出应用栈所部署的资源。
查看仪表板上的应用栈资料。
开始之前#
确保 workstation 和Overcloud的虚拟机启动。
在 workstation 上运行 lab stacks-deploy setup 命令,以确保环境为此项练习配置得当。
1
| [student@workstation ~]$ lab stacks-deploy setup
|
操作步骤#
1. 在 workstation 上,从 http://materials.example.com/heat/web_server_withfloatingip.yaml 下载 Heat 模板。将模板保存在 /home/student/ 之下。
1
2
3
4
| [student@workstation ~]$ wget \
http://materials.example.com/heat/web_server_withfloatingip.yaml
...output omitted...
2018-07-03 09:32:01 (713 MB/s) - 'web_server_withfloatingip.yaml' saved [3972/3972]
|
2. 打开文件并检查 web_server_withfloatingip.yaml 模板要求的参数。以下输出突出显示环境文件中需要值的相关资源。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| heat_template_version: queens
description: launching a custom web server
parameters:
image_name:
type: string
default: web-image
description: Image used for servers
instance_name:
type: string
default: web-server
description: Name for the web server
key_name:
type: string
default: web-keypair
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| description: SSH key to connect to the servers
instance_flavor:
type: string
default: m2.small
description: flavor used by the servers
public_net:
type: string
default: public
description: Name of public network into which servers get deployed
private_net:
type: string
default: private
description: Name of private network into which servers get deployed
private_subnet:
type: string
default: private_subnet
description: Name of private subnet into which servers get deployed
metadata:
type: json
default: { }
instance_metadata:
type: json
default: { }
...output omitted...
|
3. 为 developer1 用户提供用 source 加载 /home/student/developer1-finance-rc 身份环境文件。
使用 openstack 命令获取环境信息。在下一步使用此信息来填充 environment.yaml Heat 环境文件,供 web_server_withfloatingip.yaml 模板使用。
3.1. 用 source 加载 developer1 用户身份环境文件 :
1
| [student@workstation ~]$ source ~/developer1-finance-rc
|
3.2. 获取用于提供实例的镜像名称 :
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack image list \
-c Name
+-------+
| Name |
+-------+
| rhel7 |
| ... |
+-------+
|
3.3. 获取要连接到此实例的密钥对的名称 :
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack keypair list \
-c Name
+-----------------+
| Name |
+-----------------+
| example-keypair |
+-----------------+
|
操作界面、表格与配置图
3.4. 获取规格列表( 使用 default 规格) :
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack flavor list \
-c Name
+---------+
| Name |
+---------+
| default |
+---------+
|
3.5. 获取外部网络的名称 :
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack network list \
-c Name --external
+---------------------+
| Name |
+---------------------+
| provider-datacentre |
+---------------------+
|
3.6. 获取项目网络的名称 :
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack network list \
-c Name
+---------------------+
| Name |
+---------------------+
| provider-datacentre |
| finance-network1 |
+---------------------+
|
3.7. 为项目网络检索子网的名称 :
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack subnet list \
-c Name
+----------------------------+
| Name |
+----------------------------+
| finance-subnet1 |
| provider-subnet-172.25.250 |
+----------------------------+
|
4. 为堆栈创建环境文件,名为 /home/student/environment.yaml。在环境文件中包含以下资源 :
| 发射应用栈的参数 | |
|---|
| 参数 | 值 |
| image_name | rhel7 |
| instance_name | finance-server1 |
| key_name | example-keypair |
| instance_flavor | default |
操作界面、表格与配置图
| 参数 | 值 |
|---|
| public_net | provider-datacentre |
| private_net | finance-network1 |
| private_subnet | finance-subnet1 |
| instance_metadata | { “project.name”: { “finance” } } |
4.1. 创建 /home/student/environment.yaml 环境文件并添加以下参数:
1
2
3
4
5
6
7
8
9
| parameters:
image_name: "rhel7"
instance_name: "finance-server1"
key_name: "example-keypair"
instance_flavor: "default"
public_net: "provider-datacentre"
private_net: "finance-network1"
private_subnet: "finance-subnet1"
instance_metadata: { "project.name": { "finance" } }
|
确认环境文件已适当缩进。
5. 使用 environment.yaml 环境文件和 web_server_withfloatingip.yaml 模板,执行一个模拟运行来测试创建堆栈。命名堆栈 webstack。
分析试运行的输出; 检查启动堆栈时将创建的资源和属性。在试运行的输出中查看 outputs 字段以确定堆栈的输出参数。
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
| [student@workstation ~(developer1-finance)]$ openstack stack create \
--environment ~/environment.yaml \
--template ~/web_server_withfloatingip.yaml \
--dry-run \
webstack
+----------+-----------------------------------------------------+
| Field | Value |
+----------+-----------------------------------------------------+
| outputs | [ |
| | { |
| | "output_value": null, |
| | "output_key": "web_private_ip", |
| | "description": "IP address of first web server |
| | in private network" |
| | }, |
| | { |
| | "output_value": null, |
| | "output_key": "web_public_ip", |
| | "description": "Floating IP address of the web |
server" |
| | }, |
| | { |
| | "output_value": "http:///", |
| | "output_key": "website_url", |
| | "description": "This URL is the \"external\" URL|
that can be used to |
| | access the web server.\n" |
|
操作界面、表格与配置图
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
| | | } |
| | ] |
...output omitted...
| resources| [ |
| | { |
| | "resource_name": "web_server", |
| | "resource_identity": { |
| | "stack_name": "webstack", |
| | "stack_id": "None", |
| | "project": "2b4e9e9cc9854c28b34fa9ee40a636fb",|
| | "path": "/resources/web_server" |
| | },
...output omitted...
| | "properties": { |
| | "rules": [ |
| | { |
| | "remote_group_id": null, |
| | "direction": "ingress", |
| | "protocol": "tcp", |
| | "ethertype": "IPv4", |
| | "port_range_max": 22, |
| | "remote_mode": "remote_ip_prefix", |
| | "port_range_min": 22, |
| | "remote_ip_prefix": "0.0.0.0/0" |
| | }, |
| | { |
| | "remote_group_id": null, |
| | "direction": "ingress", |
| | "protocol": "tcp", |
| | "ethertype": "IPv4", |
| | "port_range_max": 80, |
| | "remote_mode": "remote_ip_prefix", |
| | "port_range_min": 80, |
| | "remote_ip_prefix": "0.0.0.0/0" |
| | }, |
| | { |
| | "remote_group_id": null, |
| | "direction": "ingress", |
| | "protocol": "icmp", |
| | "ethertype": "IPv4", |
| | "port_range_max": null, |
| | "remote_mode": "remote_ip_prefix", |
| | "port_range_min": null, |
| | "remote_ip_prefix": "0.0.0.0/0" |
| | } |
| | ], |
| | "name": "dev-secgroup", |
| | "description": "Add security group rules for |
| | the multi-tier ar...re" |
| | }, |
| | "resource_type": "OS::Neutron::SecurityGroup", |
| | "metadata": {} |
| | },
...output omitted...
|
6. 使用 /home/student/web_server_withfloatingip.yaml 模板和 /home/student/environment.yaml 环境文件启动堆栈。调用堆栈 webstack。
使用 –enable-rollback 选项将失败时创建的资源倒转。
1
| [student@workstation ~(developer1-finance)]$ openstack stack create \
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| --environment ~/environment.yaml \
--template ~/web_server_withfloatingip.yaml \
--enable-rollback \
--wait \
webstack
...output omitted...
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| id | 85407ca4-893a-4e83-b902-59373f58d7f7 |
| stack_name | webstack |
| description | launching a custom web server |
| creation_time | 2018-06-28T08:34:30Z |
| updated_time | None |
| stack_status | CREATE_COMPLETE |
| stack_status_reason | Stack CREATE completed successfully |
+---------------------+--------------------------------------+
|
7. 列出由 webstack 堆栈创建的资源。
7.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| [student@workstation ~(developer1-finance)]$ openstack stack resource list \
webstack -f json
[
{
"resource_status": "CREATE_COMPLETE",
"resource_name": "web_server",
"resource_type": "OS::Nova::Server",
"physical_resource_id": "f14e45ce-23eb-4f4a-a14b-1ffca61ed0ca",
"updated_time": "2018-06-28T08:34:31Z"
},
{
"resource_status": "CREATE_COMPLETE",
"resource_name": "web_net_port",
"resource_type": "OS::Neutron::Port",
"physical_resource_id": "366fdd55-27d9-4d87-bbc6-9a986a1d2078",
"updated_time": "2018-06-28T08:34:31Z"
},
{
"resource_status": "CREATE_COMPLETE",
"resource_name": "wait_condition",
"resource_type": "OS::Heat::WaitCondition",
"physical_resource_id": "",
"updated_time": "2018-06-28T08:34:31Z"
},
{
"resource_status": "CREATE_COMPLETE",
"resource_name": "web_security_group",
"resource_type": "OS::Neutron::SecurityGroup",
"physical_resource_id": "c2d57d54-6f13-4d19-944c-135607121678",
"updated_time": "2018-06-28T08:34:31Z"
},
{
"resource_status": "CREATE_COMPLETE",
"resource_name": "wait_handle",
"resource_type": "OS::Heat::WaitConditionHandle",
"physical_resource_id": "ddc40fac5caf4cd3ad20013c050f4bf2",
"updated_time": "2018-06-28T08:34:31Z"
},
{
"resource_status": "CREATE_COMPLETE",
|
操作界面、表格与配置图
1
2
3
4
5
6
| "resource_name": "web_floating_ip",
"resource_type": "OS::Neutron::FloatingIP",
"physical_resource_id": "f996d2bb-9cf9-4877-ae90-ca0a74f0bf41",
"updated_time": "2018-06-28T08:34:31Z"
}
]
|
7.2. 列出堆栈产生的事件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [student@workstation ~(developer1-finance)]$ openstack stack event list \
webstack
2018-06-28 08:34:31Z [webstack]: CREATE_IN_PROGRESS Stack CREATE started
2018-06-28 08:34:31Z [webstack.web_security_group]: CREATE_IN_PROGRESS state
changed
2018-06-28 08:34:32Z [webstack.wait_handle]: CREATE_IN_PROGRESS state changed
2018-06-28 08:34:32Z [webstack.web_security_group]: CREATE_COMPLETE state
changed
2018-06-28 08:34:32Z [webstack.web_net_port]: CREATE_IN_PROGRESS state changed
2018-06-28 08:34:34Z [webstack.wait_handle]: CREATE_COMPLETE state changed
2018-06-28 08:34:34Z [webstack.wait_condition]: CREATE_IN_PROGRESS state
changed
2018-06-28 08:34:34Z [webstack.web_net_port]: CREATE_COMPLETE state changed
2018-06-28 08:34:35Z [webstack.web_floating_ip]: CREATE_IN_PROGRESS state
changed
2018-06-28 08:34:38Z [webstack.web_floating_ip]: CREATE_COMPLETE state changed
2018-06-28 08:34:38Z [webstack.web_server]: CREATE_IN_PROGRESS state changed
2018-06-28 08:35:21Z [webstack.web_server]: CREATE_COMPLETE state changed
2018-06-28 08:35:57Z [webstack.wait_handle]: SIGNAL_COMPLETE Signal:
status:SUCCESS reason:Signal 1 received
2018-06-28 08:35:58Z [webstack.wait_condition]: CREATE_COMPLETE state changed
2018-06-28 08:35:58Z [webstack]: CREATE_COMPLETE Stack CREATE completed
successfully
|
8. 验证 web_server 资源是否由 webstack 应用栈创建。使用 curl 查看此实例所服务的网页。
8.1. 列出在环境中检查 finance-server1 实例状态的示例 :
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name -c Status
+-----------------+--------+
| Name | Status |
+-----------------+--------+
| finance-server1 | ACTIVE |
+-----------------+--------+
|
8.2. 等到 finance-server1 实例状态更改为 ACTIVE。查看由堆栈创建的 web_server 资源的全部细节。注意分配给实例和实例名称的浮动 IP 地址。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack stack resource show \
-f json webstack web_server
{
"resource_name": "web_server",
"description": "",
...output omitted...
"attributes": {
|
操作界面、表格与配置图
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
| "OS-EXT-STS:task_state": null,
"addresses": {
"finance-network1": [
{
"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:45:67:84",
"version": 4,
"addr": "192.168.1.X",
"OS-EXT-IPS:type": "fixed"
},
{
"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:45:67:84",
"version": 4,
"addr": "172.25.250.P",
"OS-EXT-IPS:type": "floating"
}
]
},
...output omitted...
"status": "ACTIVE",
"updated": "2018-06-28T08:35:20Z",
"hostId": "06910493c3dd091345b9cfa5273d2e4e4f8be9f40185119c8911ac28",
"OS-SRV-USG:terminated_at": null,
"key_name": "example-keypair",
"os_collect_config": {},
"name": "finance-server1",
"created": "2018-06-28T08:34:40Z",
"tenant_id": "91d634a8c1534bc1a105994bf434e53b",
"os-extended-volumes:volumes_attached": [],
"metadata": {
"project.name": "{\"finance\": null}"
}
},
"resource_type": "OS::Nova::Server"
}
|
8.3. 查看 webstack 堆栈的输出参数及其值 :
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(developer1-finance)]$ openstack stack output list \
webstack
+----------------+---------------------------------------------------+
| output_key | description |
+----------------+---------------------------------------------------+
| web_private_ip | IP address of first web server in private network |
| web_public_ip | Floating IP address of the web server |
| website_url | This URL is the "external" URL |
| | can be used to access the web server. |
+----------------+---------------------------------------------------+
|
查看 website_url 输出参数的值 :
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(developer1-finance)]$ openstack stack output show \
webstack website_url
+--------------+--------------------------------------------+
| Field | Value |
+--------------+--------------------------------------------+
| description | This URL is the "external" URL |
| | that can be used to access the web server. |
| | |
| output_key | website_url |
| output_value | http://172.25.250.P/ |
|
操作界面、表格与配置图
1
| +--------------+--------------------------------------------+
|
8.4. 使用 website_url 参数返回的输出值查看 finance-server1 实例所服务的网页 :
1
2
3
4
| [student@workstation ~(developer1-finance)]$ curl http://172.25.250.P
<h1>You are connected to 172.25.250.P</h1>
<h2>The private IP address is:192.168.1.N</h2>
Red Hat Training
|
9. 以 developer1 作为用户和 redhat 作为密码登录到 http://dashboard.overcloud.example.com 的仪表板。从仪表板查看 webstack 应用栈信息。
9.1. 打开 Project > Orchestration > Stacks。
9.2. 单击 Webstack 链接查看堆栈信息。
9.3. 点击 Topology(拓扑)、Overview、Resources、Events 和 Template 标签,查看栈信息。
10. 退出仪表板。
在 workstation 上运行 lab stacks-deploy cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab stacks-deploy cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:配置应用栈自动伸缩#
本练习根据 Web 实例的 CPU 利用率指标,自动伸缩 Web 服务器。
学习目标#
你应能够使用遥测指标,自动伸缩 Web 服务器池。
开始之前#
确保 workstation 和Overcloud的虚拟机启动。
从 workstation 运行 lab stacks-autoscale setup 命令,该命令确保 OpenStack 服务正在运行,并且可以使用先前实验的资源。该脚本使用 environment.yaml 环境文件和 webserver-autoscale.yaml 模板文件,启动 autoscale-stack 应用栈。该脚本还更改配置以收集每 15 秒的度量。
1
| [student@workstation ~]$ lab stacks-autoscale setup
|
操作步骤#
1. 在 workstation 检查 setup 脚本下载的 webserver-autoscale.yaml。查看模板参数和栈资源,检查定义扩容和缩容规则的 OS::Heat::AutoScalingGroup 部分。
1.1.
OS::Heat::AutoScalingGroup 类型的 web_scaler 资源定义扩容时创建的资源,其属性如下:
1
2
3
4
5
6
7
8
9
| resources:
...output omitted...
web_scaler:
type: OS::Heat::AutoScalingGroup
properties:
desired_capacity: { get_param: initial_capacity }
cooldown: { get_param: cooldown_policy_seconds }
max_size: { get_param: asg_group_max_size }
min_size: { get_param: asg_group_min_size }
|
1.2. web_scaler 自动缩放组定义了在缩放时创建的资源。My::Server::Custom::WebServer 自定义资源类型定义了
操作界面、表格与配置图
要使用的 HOT 模板。资源类型与启动此实例指定属性一起被引用。
1
2
3
4
5
6
7
8
9
10
11
12
13
| resource:
type: My::Server::Custom::WebServer
properties:
instance_name: { list_join: [ '-', [ {get_param: instance_name},
{get_attr: [random, value]} ] ] }
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 }
instance_metadata: { "metering.server_group": {get_param:
"OS::stack_id"} }
|
1.3. scaleup_policy 和 scaledown_policy 均为 OS::Heat::ScalingPolicy 类型,分别定义扩容和缩容策略。
下列属性定义了策略:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| scaleup_policy:
type: OS::Heat::ScalingPolicy
properties:
adjustment_type: change_in_capacity
auto_scaling_group_id: { get_resource: web_scaler }
cooldown: {get_param: cooldown_policy_seconds}
scaling_adjustment: 1
scaledown_policy:
type: OS::Heat::ScalingPolicy
properties:
adjustment_type: change_in_capacity
auto_scaling_group_id: { get_resource: web_scaler }
cooldown: {get_param: cooldown_policy_seconds}
scaling_adjustment: -1
|
1.4. cpu_alarm_high 和 cpu_alarm_low 资源定义了警示服务提醒。alarm_actions 属性定义了自动缩放策略,以在警示启动时使用。
1
2
3
4
| cpu_alarm_high:
type: OS::Aodh::GnocchiAggregationByResourcesAlarm
properties:
description: Scale-up if the average CPU > 30% for 1 minute
|
操作界面、表格与配置图
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
| resource_type: instance
metric: cpu_util
aggregation_method: mean
comparison_operator: gt
evaluation_periods: 1
granularity: 60
threshold: 30
alarm_actions:
- str_replace:
template: trust+url
params:
url: {get_attr: [scaleup_policy, signal_url]}
query:
str_replace:
template: '{"=": {"server_group": "stack_id"}}'
params:
stack_id: {get_param: "OS::stack_id"}
cpu_alarm_low:
type: OS::Aodh::GnocchiAggregationByResourcesAlarm
properties:
description: Scale-down if the average CPU < 15% for 1 minute
resource_type: instance
metric: cpu_util
aggregation_method: mean
comparison_operator: lt
evaluation_periods: 1
granularity: 60
threshold: 15
alarm_actions:
- str_replace:
template: trust+url
params:
url: {get_attr: [scaledown_policy, signal_url]}
query:
str_replace:
template: '{"=": {"server_group": "stack_id"}}'
params:
stack_id: {get_param: "OS::stack_id"}
|
2. 使用 environment.yaml 环境文件审查传给 webserver-autoscale 模板的参数。
resource_registry 区域定义由 web_server_withfloatingip.yaml 模板创建的自定义Web 服务器实例为应用栈资源。自定义资源被识别为应用栈中的 My::Server::Custom::WebServer 资源类型别名。
1
2
3
4
5
6
7
8
9
10
11
12
13
| resource_registry:
My::Server::Custom::WebServer: "web_server_withfloatingip.yaml"
parameters:
key_name: "example-keypair"
image_name: "rhel7"
instance_name: "finance-server"
instance_flavor: "default"
public_net: "provider-datacentre"
private_net: "finance-network1"
private_subnet: "finance-subnet1"
initial_capacity: 1
cooldown_policy_seconds: 60
asg_group_min_size: 1
|
操作界面、表格与配置图
3. 在 workstation 上源为 developer1 用户的 /home/student/developer1-finance-rc 身份环境。
1
| [student@workstation ~]$ source ~/developer1-finance-rc
|
4. 列出由实验设置脚本创建的应用栈。
1
2
3
4
5
6
| [student@workstation ~(developer1-finance)]$ openstack stack list --short
+--------------------------------------+-----------------+-----------------+
| ID | Stack Name | Stack Status |
+--------------------------------------+-----------------+-----------------+
| a841c1bf-f395-4f6c-ab7e-0cd352aae74a | autoscale-stack | CREATE_COMPLETE |
+--------------------------------------+-----------------+-----------------+
|
5. 列出 autoscale-stack 堆栈的输出参数。使用 website_url_asg 输出参数列出的 URL 来验证 Web 服务器是否可到达。
5.1. 查看 autoscale-stack 堆栈的输出参数 :
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack stack output list \
autoscale-stack
+--------------------+-----------------------------------------------------+
| output_key | description |
+--------------------+-----------------------------------------------------+
| website_url_asg | This URL is the "external" URL that can be used to |
| | access the web server. |
| | |
| web_public_ip_asg | Floating IP address of the web server |
| web_private_ip_asg | IP address of first web server in private network |
+--------------------+-----------------------------------------------------+
|
5.2. 列出 autoscale-stack stack 返回的 website_url_asg 参数值 :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~(developer1-finance)]$ openstack stack output show \
autoscale-stack \
website_url_asg
+--------------+--------------------------------------------------+
| Field | Value |
+--------------+--------------------------------------------------+
| description | This URL is the "external" URL that can be used |
| | to access the web server. |
| | |
| output_key | website_url_asg |
| output_value | [ |
| | "http://172.25.250.P/" |
| | ] |
+--------------+--------------------------------------------------+
|
5.3. 验证 website_url_asg 返回的网站 URL 可访问。参数值和 curl 输出可能与你的环境不同。
操作界面、表格与配置图
1
2
3
4
| [student@workstation ~(developer1-finance)]$ curl http://172.25.250.P
<h1>You are connected to 172.25.250.P</h1>
<h2>The private IP address is:192.168.1.N</h2>
Red Hat Training
|
6. 列出由 autoscale-stack 堆栈创建的提醒。
两个提醒状态都显示 insufficient data。这是因为默认的提醒评价间隔设为 60 秒,在课堂环境里,需要 15 分钟,才能通过测量服务收集和计算。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [student@workstation ~(developer1-finance)]$ openstack alarm list -f json
[student@workstation ~(developer1-finance)]$ openstack alarm list -f json
[
{
"name": "autoscale-stack-cpu_alarm_high-b7syzmgsh625",
"enabled": true,
"alarm_id": "e3291a6f-b579-4f81-bd33-1258f7cae951",
"state": "insufficient data",
"type": "gnocchi_aggregation_by_resources_threshold",
"severity": "low"
},
{
"name": "autoscale-stack-cpu_alarm_low-j2v3sjjnmrqi",
"enabled": true,
"alarm_id": "45c94c15-f4f2-4b03-a9b8-82915128cc6e",
"state": "insufficient data",
"type": "gnocchi_aggregation_by_resources_threshold",
"severity": "low"
}
]
|
CPU 使用率持续一分钟低于 15% 时,触发 autoscale-stack-cpu_alarm_low-j2v3sjjnmrqi;持续一分钟高于 30% 时,触发 autoscale-stack-cpu_alarm_high-b7syzmgsh625。编排服务用这两个告警执行缩容和扩容。
7. 使用 openstack 命令显示与 finance-server-XX 实例相关的浮动 IP 地址。XX 的值是一个随机值。示例输出显示的是 172.25.250.P 的浮动 IP 地址,但实际的 IP 地址可能有所不同。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ openstack server list \
-c Name \
-c Networks
+-----------------------+----------------------------------------------+
| Name | Networks |
+-----------------------+----------------------------------------------+
| finance-server-XX | finance-network1=192.168.1.N, 172.25.250.P |
+-----------------------+----------------------------------------------+
|
操作界面、表格与配置图
8. 使用 ssh 命令使用其公共 IP 地址连接到实例。日志为 cloud-user。
1
2
3
| [student@workstation ~(developer1-finance)]$ ssh cloud-user@172.25.250.P
Warning: Permanently added '172.25.250.P' (ECDSA) to the list of known hosts.
[cloud-user@finance-server-XX ~]$
|
9. 模板文件安装了一个名为 scaling_launchme.sh 的脚本。脚本对服务器有压力,并触发警示服务提醒,用于监视 CPU 的高使用量。运行脚本。
1
2
| [cloud-user@finance-server-XX ~]$ ./scaling_launchme.sh
Stressing the server...
|
10. 从 workstation 中打开一个新的终端和用 source 加载 /home/student/developer1-finance-rc 环境文件。使用 watch 命令监测提醒。等待 autoscale-stack-cpu_alarm_high-lggn7h4allsx alarm 将其状态从 ok 转换为 alarm。
在课堂环境中,测量服务需要 10 分钟收集和计算测量样品。alarm 状态从 insufficientdata 状态向 alarm 或 ok 状态的过渡在 10 分钟之后。
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 ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$ watch -d -n 60 \
openstack alarm list -f json
Every 60.0s: openstack alarm list -f json Tue Jul 3 18:42:22 2018
[
{
"name": "autoscale-stack-cpu_alarm_high-b7syzmgsh625",
"enabled": true,
"alarm_id": "e3291a6f-b579-4f81-bd33-1258f7cae951",
"state": "alarm",
"type": "gnocchi_aggregation_by_resources_threshold",
"severity": "low"
},
{
"name": "autoscale-stack-cpu_alarm_low-j2v3sjjnmrqi",
"enabled": true,
"alarm_id": "45c94c15-f4f2-4b03-a9b8-82915128cc6e",
"state": "ok",
"type": "gnocchi_aggregation_by_resources_threshold",
"severity": "low"
}
]
|
按 Ctrl+C 键停止 watch 命令。
11. 等待一两分钟,结合 watch 和 openstack 监视实例。编排引擎会启动一个新实例以自动扩容。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| [student@workstation ~(developer1-finance)]$ watch -d -n 5 \
openstack server list -c Name -c Status
Every 5.0s: openstack server list -c Name -c Status Tue Jul 3 18:52:34 2018
+-------------------+--------+
| Name | Status |
+-------------------+--------+
| finance-server-XX | BUILD |
| finance-server-XX | ACTIVE |
+-------------------+--------+
|
按 Ctrl+C 键停止 watch 命令。
12. 脚本创建的后台进程停止后,编排引擎会删除一个已创建的实例以缩容。
返回到连接到 finance-server-XX 实例的终端会话。运行 ps 命令以确保名为 yes 的进程不再运行。完成后,请退出该实例。
1
2
3
| [cloud-user@finance-server-XX ~]$ ps -ef | grep yes
cloud-u+ 11331 11308 0 10:05 pts/0 00:00:00 grep --color=auto yes
[cloud-user@finance-server-XX ~]$ exit
|
13. 当 yes 进程结束时,返回 workstation 终端,并使用 openstack 命令运行。当创建的两个实例被删除时,观察输出。在一个实例被删除后,按 Ctrl+C 键退出 watch 命令。
课堂环境中,autoscale-stack-cpu_alarm_low 转为 alarm 后,终止实例约需 10 分钟。等待第二个实例终止后,再清理练习。
1
2
3
4
5
6
7
8
| [student@workstation ~(developer1-finance)]$ watch -d -n 5 \
openstack server list -c Name -c Status
Every 5.0s: openstack server list -c Name -c Status Tue Jul 3 19:03:20 2018
+-------------------+--------+
| Name | Status |
+-------------------+--------+
| finance-server-XX | ACTIVE |
+-------------------+--------+
|
按 Ctrl+C 键停止 watch 命令。
14. 审查警报器的状况。
1
2
3
4
| [student@workstation ~(developer1-finance)]$ openstack alarm list
[
{
"name": "autoscale-stack-cpu_alarm_high-b7syzmgsh625",
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| "enabled": true,
"alarm_id": "e3291a6f-b579-4f81-bd33-1258f7cae951",
"state": "ok",
"type": "gnocchi_aggregation_by_resources_threshold",
"severity": "low"
},
{
"name": "autoscale-stack-cpu_alarm_low-j2v3sjjnmrqi",
"enabled": true,
"alarm_id": "45c94c15-f4f2-4b03-a9b8-82915128cc6e",
"state": "alarm",
"type": "gnocchi_aggregation_by_resources_threshold",
"severity": "low"
}
]
|
15. 使用 autoscale-stack-cpu_alarm_low-j2v3sjjnmrqi 提醒的提醒 ID 查看提醒历史。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~(developer1-finance)]$ openstack alarm-history search \
--query alarm_id="45c94c15-f4f2-4b03-a9b8-82915128cc6e" \
-f json
[
...output omitted...
{
"alarm_id": "45c94c15-f4f2-4b03-a9b8-82915128cc6e",
"type": "state transition",
"detail": "{\"transition_reason\":
\"Transition to alarm due to 1 samples outside threshold, most recent:
0.124166956\",
\"state\": \"alarm\"}",
"timestamp": "2018-07-03T14:19:22.704476"
},
...output omitted...
]
|
在 workstation 上运行 lab stacks-autoscale cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab stacks-autoscale cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:部署可伸缩应用栈#
本实验使用编排模板部署带负载均衡器的 Web 应用栈。
学习目标#
完成后能够:
检查确定所需参数的模板。
部署编排栈,创建负载均衡器。
使用编排栈在负载均衡器后添加 Web 服务器。
开始之前#
确保 workstation 和Overcloud的虚拟机启动。
在 workstation 上运行 lab stacks-lab setup 命令,确保提供所需资源。
1
| [student@workstation ~]$ lab stacks-lab setup
|
操作步骤#
1. 在 workstation 上从 http://materials.example.com/heat/load-balancer.yaml 下载编排模板文件。将模板保存为 /home/student/load-balancer.yaml 并检查其内容。
2. 用 source 加载 /home/student/operator1-production-rc operator1 用户的身份环境文件。
使用 openstack 命令来检索环境信息。在下一步使用此信息来填充/home/student/load-balancer.yaml 模板所使用的编排环境文件。
3. 在检查资源后,创建所需的环境文件,/home/student/lb-create-environment.yaml。使用 provider-datacentre 用于公共网络,production-subnet1 用于私人子网,production-webpool 用于负载均衡器池。
4. 使用 /home/student/load-balancer.yaml 模板文件和 /home/student/lb-create-environment.yaml 环境文件启动堆栈。将堆栈的名称设置为 production-lb-stack。
5. 下载第二个应用栈的编排模板 production-webstack。应用栈需要两个文件,web_server_withoutfloatingip.yaml 和 lb-add-members.yaml , 位于 http://materials.example.com/heat。保存 /home/student 目录中的这两个文件。
6. 创建 production-webstack 堆栈的环境文件为 /home/student/lb-members-environment.yaml。在环境文件中包含以下资源 :
包含 web_server_withoutfloatingip.yaml 模板文件中定义的堆栈资源。指定类型为 My::Server::Custom::WebServer。
操作界面、表格与配置图
| production-webstack 参数 | |
|---|
| 参数名称 | 参数值 |
| key_name | example-keypair |
| image_name | rhel7-web |
| instance_name | production-server |
| instance_flavor | default |
| public_net | provider-datacentre |
| private_net | production-network1 |
| private_subnet | production-subnet1 |
| pool_name | production-webpool |
| servercount | 2 |
7. 启动第二堆,production-webstack, 使用 /home/student/lb-members-environment.yaml 环境文件和 /home/student/lb-add-members.yaml 模板文件。
8. 核实在负载均衡器后启动两个实例。
读取 production-lb-stack 的 website_url 输出参数,获取负载均衡器的公共 IP。
9. 验证负载均衡器是否在两个Web 服务器之间分配了收到的 HTTP 请求。请使用与负载均衡器相关的公共 IP 地址。
在 workstation 上运行 lab stacks-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab stacks-lab grade
|
在 workstation 上运行 lab stacks-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab stacks-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
本实验使用编排模板部署带负载均衡器的 Web 应用栈。
学习目标#
完成后能够:
检查确定所需参数的模板。
部署编排栈,创建负载均衡器。
使用编排栈在负载均衡器后添加 Web 服务器。
开始之前#
确保 workstation 和Overcloud的虚拟机启动。
在 workstation 上运行 lab stacks-lab setup 命令,确保提供所需资源。
1
| [student@workstation ~]$ lab stacks-lab setup
|
操作步骤#
1. 在 workstation 上从 http://materials.example.com/heat/load-balancer.yaml 下载编排模板文件。将模板保存为 /home/student/load-balancer.yaml 并检查其内容。
1.1.
从 http://materials.example.com/heat/load-balancer.yaml 下载编排模板文件。在 /home/student 目录中保存模板文件。
1
2
3
4
| [student@workstation ~]$ wget \
http://materials.example.com/heat/load-balancer.yaml
...output omitted...
2018-07-03 10:45:48 (186 MB/s) - 'load-balancer.yaml' saved [1546/1546]
|
1.2. 打开文件并检查模板要求的参数。以下输出突出显示环境文件中需要值的相关资源。
1
2
3
4
5
6
7
8
9
10
| heat_template_version: queens
description: Create a Load Balancer with round-robin algorithm
parameters:
public_net:
type: string
private_subnet:
type: string
pool_name:
type: string
default: web-pool
|
2. 用 source 加载 /home/student/operator1-production-rc operator1 用户的身份环境文件。
使用 openstack 命令来检索环境信息。在下一步使用此信息来填充/home/student/load-balancer.yaml 模板所使用的编排环境文件。
操作界面、表格与配置图
2.1. 用 source 加载 operator1 用户环境文件 :
1
2
| [student@workstation ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$
|
2.2. 检索公共网络的名称 :
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack network list \
--external \
-c Name
+---------------------+
| Name |
+---------------------+
| provider-datacentre |
+---------------------+
|
2.3. 获取项目子网的名称 :
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack subnet list -c Name
+----------------------------+
| Name |
+----------------------------+
| production-subnet1 |
| provider-subnet-172.25.250 |
+----------------------------+
|
3. 在检查资源后,创建所需的环境文件,/home/student/lb-create-environment.yaml。使用 provider-datacentre 用于公共网络,production-subnet1 用于私人子网,production-webpool 用于负载均衡器池。
创建 /home/student/lb-create-environment.yaml 文件并添加以下参数:
1
2
3
4
| parameters:
public_net: "provider-datacentre"
private_subnet: "production-subnet1"
pool_name: "production-webpool"
|
4. 使用 /home/student/load-balancer.yaml 模板文件和 /home/student/lb-create-environment.yaml 环境文件启动堆栈。将堆栈的名称设置为 production-lb-stack。
4.1. 作为 operator1, 使用 /home/student/load-balancer.yaml 编排模板文件和 /home/student/lb-create-environment.yaml 环境文件启动应用栈。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ openstack stack create \
--environment ~/lb-create-environment.yaml \
--template ~/load-balancer.yaml \
production-lb-stack
+---------------------+---------------------------------------------------+
| Field | Value |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
| +---------------------+---------------------------------------------------+
| id | 0a709c1c-37a3-4974-96ee-8496921cb09d |
| stack_name | production-lb-stack |
| description | Create a Load Balancer with round-robin algorithm |
| creation_time | 2018-07-03T05:24:39Z |
| updated_time | None |
| stack_status | CREATE_IN_PROGRESS |
| stack_status_reason | Stack CREATE started |
+---------------------+---------------------------------------------------+
|
4.2. 从 CREATE_IN_PROGRESS 状态到 CREATE_COMPLETE 状态的几分钟后应用栈状态发生变化。验证应用栈状态显示为 CREATE_COMPLETE。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack stack show \
production-lb-stack -c stack_status
+--------------+-----------------+
| Field | Value |
+--------------+-----------------+
| stack_status | CREATE_COMPLETE |
+--------------+-----------------+
|
5. 下载第二个应用栈的编排模板 production-webstack。应用栈需要两个文件,web_server_withoutfloatingip.yaml 和 lb-add-members.yaml , 位于 http://materials.example.com/heat。保存 /home/student 目录中的这两个文件。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ wget \
http://materials.example.com/heat/web_server_withoutfloatingip.yaml
...output omitted...
[student@workstation ~(operator1-production)]$ wget \
http://materials.example.com/heat/lb-add-members.yaml
...output omitted...
|
6. 创建 production-webstack 堆栈的环境文件为 /home/student/lb-members-environment.yaml。在环境文件中包含以下资源 :
包含 web_server_withoutfloatingip.yaml 模板文件中定义的堆栈资源。指定类型为 My::Server::Custom::WebServer。
| production-webstack 参数 | |
|---|
| 参数名称 | 参数值 |
| key_name | example-keypair |
| image_name | rhel7-web |
| instance_name | production-server |
| instance_flavor | default |
| public_net | provider-datacentre |
| private_net | production-network1 |
| private_subnet | production-subnet1 |
| pool_name | production-webpool |
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| resource_registry:
My::Server::Custom::WebServer: "web_server_withoutfloatingip.yaml"
parameters:
key_name: "example-keypair"
image_name: "rhel7-web"
instance_name: "production-server"
instance_flavor: "default"
public_net: "provider-datacentre"
private_net: "production-network1"
private_subnet: "production-subnet1"
pool_name: "production-webpool"
servercount: 2
|
7. 启动第二堆,production-webstack, 使用 /home/student/lb-members-environment.yaml 环境文件和 /home/student/lb-add-members.yaml 模板文件。
7.1.
启动第二个应用栈并指定 production-webstack 为名称。使用 /hoem/student/lb-members-environment.yaml 环境文件和 /home/student/lb-add-members.yaml 模板文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(operator1-production)]$ openstack stack create \
--environment ~/lb-members-environment.yaml \
--template ~/lb-add-members.yaml \
production-webstack
+---------------------+---------------------------------------+
| Field | Value |
+---------------------+---------------------------------------+
| id | ff76f841-f1dc-40bd-ba37-5ef1254a2dcb |
| stack_name | production-webstack |
| description | Custom webservers behind a Octavia LB |
| creation_time | 2018-07-03T06:07:22Z |
| updated_time | None |
| stack_status | CREATE_IN_PROGRESS |
| stack_status_reason | Stack CREATE started |
+---------------------+---------------------------------------+
|
7.2. 应用栈状态将在几分钟后改变,从 CREATE_IN_PROGRESS 状态到 CREATE_COMPLETE 状态。验证应用栈状态显示 CREATE_COMPLETE 状态。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack stack show \
production-webstack -c stack_status
+--------------+-----------------+
| Field | Value |
+--------------+-----------------+
| stack_status | CREATE_COMPLETE |
+--------------+-----------------+
|
8. 核实在负载均衡器后启动两个实例。
读取 production-lb-stack 的 website_url 输出参数,获取负载均衡器的公共 IP。
操作界面、表格与配置图
8.1. 查看负载均衡器后面的编排模版启动的实例。
1
2
3
4
5
6
7
8
9
10
| [student@workstation ~(operator1-production)]$ openstack server list \
-c Name \
-c Status \
-c Networks
+--------------------+--------+---------------------------------+
| Name | Status | Networks |
+--------------------+--------+---------------------------------+
| production-server0 | ACTIVE | production-network1=192.168.1.R |
| production-server1 | ACTIVE | production-network1=192.168.1.S |
+--------------------+--------+---------------------------------+
|
8.2. 使用 production-lb-stack 应用栈的 website_url 输出参数,检索启动的负载均衡器所附的公开 IP 地址。示例输出显示 172.25.250.P 的公开 IP 地址,但实际的 IP 地址可能有所不同。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~(operator1-production)]$ openstack stack output list \
production-lb-stack
+-------------+-----------------------------------------------------------+
| output_key | description |
+-------------+-----------------------------------------------------------+
| website_url | This is the URL that is used to access the load balancer. |
+-------------+-----------------------------------------------------------+
[student@workstation ~(operator1-production)]$ openstack stack output show \
production-lb-stack website_url
+--------------+-----------------------------------------------------------+
| Field | Value |
+--------------+-----------------------------------------------------------+
| description | This is the URL that is used to access the load balancer. |
| output_key | website_url |
| output_value | http://172.25.250.P |
+--------------+-----------------------------------------------------------+
|
9. 验证负载均衡器是否在两个Web 服务器之间分配了收到的 HTTP 请求。请使用与负载均衡器相关的公共 IP 地址。
9.1. 两次使用 curl 命令访问负载均衡器的公众 URL。验证负载均衡器是否在两个Web 服务器之间分配了收到的 HTTP 请求。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ curl http://172.25.250.P
<h1>You are connected to 192.168.1.R</h1>
Red Hat Training
[student@workstation ~(operator1-production)]$ curl http://172.25.250.P
<h1>You are connected to 192.168.1.S</h1>
Red Hat Training
|
在 workstation 上运行 lab stacks-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab stacks-lab grade
|
操作界面、表格与配置图
在 workstation 上运行 lab stacks-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab stacks-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 模板与环境文件如何分工?
- 告警为 insufficient data 应怎样理解?
自测答案#
- 模板定义资源关系,环境文件提供参数和映射。部署前需把参数与实际资源对应。
- 当前评估所需数据不足。采样、聚合与告警评估需要时间。
C13-部署 OpenStack Overcloud#
Undercloud 与 Overcloud#
Undercloud 的 Director 管理裸机节点、部署计划和 Overcloud 生命周期;Overcloud 提供用户使用的云服务。stack 用户、stackrc 和 overcloudrc 对应不同管理层,操作前确认环境文件,不用提示符名称代替核对。
计划与节点角色#
基础 Heat 模板、plan-environment.yaml 和环境文件共同定义部署。导入或修改计划不会自动执行部署。重新部署前应明确保留的数据、节点角色和网络配置。
| 检查项 | 配置项 |
|---|
| 网络 | 单网卡 VLAN 隔离、默认路由、外部接口 |
| 容器源 | 本地镜像仓库与服务镜像位置 |
| 角色 | Controller 与 Compute 节点分配 |
| 可用性 | 单控制节点实验方案关闭 HA |
| 完成状态 | 栈 CREATE_COMPLETE、节点 ACTIVE |
部署后验证#
查看服务目录、端点、计算服务和 Hypervisor,再创建项目、用户、规格、镜像、网络、安全组及密钥对,启动实例验证 SSH。部署完成只证明编排过程完成,业务测试用于证明用户侧操作链可用。
Director 部署流程#
1
2
3
4
5
6
7
8
| 部署网络与镜像准备
→ 裸机登记 / 电源管理 / 内省
→ 节点能力与角色匹配
→ Heat 模板 + 环境文件 + 网络配置
→ 创建部署计划 / 审核
→ 部署 Overcloud
→ 服务检查
→ 普通项目创建实例验证
|
Undercloud 与 Overcloud 凭据#
执行位置:director,stack 用户。
1
2
3
4
5
6
7
8
9
| source ~/stackrc
openstack baremetal node list
openstack server list
openstack stack list
source ~/overcloudrc
openstack endpoint list
openstack compute service list
openstack hypervisor list
|
Undercloud 中的 server 与 Overcloud 中的业务实例处于不同管理层。切换 RC 后即使使用相同命令,查询对象也会改变。
计划中应检查的内容#
- Controller、Compute 等角色的数量和节点匹配。
- NIC / VLAN、物理网络映射、网关和部署网络地址池。
- 容器镜像仓库、镜像名称与可达性。
- 基础模板、环境文件和
plan-environment.yaml 的引用关系。 - 实验单控制节点与高可用方案的不同配置。
Overcloud 部署验证#
部署计划用于保存模板和参数,执行部署是独立操作。完成后先查 Stack 状态,再加载 Overcloud RC,建立项目用户、镜像、规格和网络,启动实例并验证 SSH。不能只把 CREATE_COMPLETE 当作租户业务验证。
实验操作#
引导练习:使用 Director Web 界面创建部署计划#
在此练习中,使用 director Web UI 生成部署计划并部署 Red Hat OpenStack 平台。
学习目标#
完成后能够:
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 作为密码,登录到 workstation 的 student。运行 lab create-overcloudplan setup 命令以确保 overcloud 计划存在。
1
| [student@workstation ~]$ lab create-overcloudplan setup
|
操作步骤#
1. 从 workstation 登录到使用 stack 用户的 director 虚拟机。导出 overcloud 计划。
1.1.
使用 SSH 登录到 director 虚拟机为 stack 用户。
1
2
| [student@workstation ~]$ ssh stack@director
(undercloud) [stack@director ~]$
|
1.2. 使用 openstack overcloud plan list 列出计划。
1
2
3
4
5
6
| (undercloud) [stack@director ~]$ openstack overcloud plan list
+-----------+
| Plan Name |
+-----------+
| overcloud |
+-----------+
|
1.3. 使用 openstack overcloud plan export 导出 overcloud 计划。
1
2
3
4
5
6
| (undercloud) [stack@director ~]$ openstack overcloud plan export overcloud
Exporting plan overcloud...
Started Mistral Workflow tripleo.plan_management.v1.export_deployment_plan.
Execution ID: 5700...0f91
https://172.25.249.201:13808/v1/AUTH_.../plan-exports/overcloud.tar.gz?
temp_url_sig=...
|
1.4. 登录出 director 虚拟机。
操作界面、表格与配置图
1
2
3
| (undercloud) [stack@director ~]$ logout
Connection to director closed.
[student@workstation ~]$
|
2. 在 workstation 上将导出归档复制到 /home/student/overcloudplan 目录。在 /home/student/overcloudplan 目录中提取导出归档。
2.1. 在 student 主目录中创建一个名为 overcloudplan 的目录。在 /home/student/overcloudplan 目录中将 /home/stack/overcloud.tar.gz 文件从 director 复制到 workstation。
1
2
3
4
| [student@workstation ~]$ mkdir ~/overcloudplan
[student@workstation ~]$ cd ~/overcloudplan
[student@workstation overcloudplan]$ scp stack@director:~/overcloud.tar.gz .
...output omitted...
|
2.2. 在 /home/student/overcloudplan 目录中提取 /home/stack/overcloud.tar.gz 文件。
1
2
| [student@workstation overcloudplan]$ tar xzvf overcloud.tar.gz
...output omitted...
|
3. 查看 /home/student/overcloudplan/plan-environment.yaml,确认各 Overcloud 节点的网络和 VLAN,以及部署时拉取服务容器镜像的位置。
3.1. 查看 /home/student/overcloudplan/plan-environment.yaml。计划包含各 Overcloud 节点的网络和 VLAN;以下为控制节点 IP 地址和 VLAN 配置示例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation overcloudplan]$ grep -A12 -e "ControllerIPs" \
plan-environment.yaml
ControllerIPs:
external:
- 172.25.250.1
internal_api:
- 172.24.1.1
management:
- 172.24.5.1
storage:
- 172.24.3.1
storage_mgmt:
- 172.24.4.1
tenant:
- 172.24.2.1
[student@workstation overcloudplan]$ grep -e "VlanID" plan-environment.yaml
InternalApiNetworkVlanID: 10
ManagementNetworkVlanID: 50
StorageMgmtNetworkVlanID: 40
StorageNetworkVlanID: 30
TenantNetworkVlanID: 20
|
3.2. 审查 /home/student/overcloudplan/plan-environment.yaml 文件以查看指定 Docker 登记册位置的配置以查找原始
操作界面、表格与配置图
OpenStack 服务容器镜像将在Overcloud 部署期间使用,例如,这里是 dashboard (horizon) 容器镜像的登记地点条目,dashboard (horizon) 容器服务将使用。
1
2
3
| [student@workstation overcloudplan]$ grep -e "DockerHorizonImage" \
plan-environment.yaml
DockerHorizonImage: 172.25.249.200:8787/rhosp13/openstack-horizon:latest
|
4. 在 workstation 上使用 director 的编排模版创建 /home/student/overcloud-poc Overcloud计划目录。
4.1. 使用 scp 命令将 /usr/share/openstack-tripleo-heat-templates 目录从 director 虚拟机复制到 workstation 上的 /home/student/overcloud-poc。
1
2
3
| [student@workstation overcloudplan]$ scp -r \
stack@director:/usr/share/openstack-tripleo-heat-templates ~/overcloud-poc
...output omitted...
|
5. 使用 https://director-ui.lab.example.com URL 访问 director Web UI. 使用管理员用户名和密码访问 Web UI。默认管理员用户名为 admin。
5.1. 从 director 中,使用 sudo hiera admin_password 命令获取默认用户 admin 的密码。
1
2
3
| [student@workstation overcloudplan]$ ssh stack@director sudo hiera \
admin_password
redhat
|
5.2. 打开 https://director-ui.lab.example.com URL 访问 director Web UI。如果出现证书错误,请接受 自签名 证书。
5.3. 使用 admin 作为用户名和 redhat 作为密码的日志。
6. 在 Red Hat OpenStack 平台 director Web UI 中,通过上传存储在 /home/student/overcloudplan 目录中的文件,导入一个Overcloud计划。输入Overcloud计划名称为 overcloud-poc。
6.1. 从 director Web UI 点击计划标签中的导入计划。
6.2. 在新计划选项卡中,输入 overcloud-poc 作为计划名称。
6.3. 选择上传类型为本地文件夹。
6.4. 单击浏览按钮来选择计划文件。浏览并选择 overcloud-poc 在 student 主目录中的目录。单击上传。
6.5. 单击上传文件并创建计划。等到Overcloud计划文件上传并创建计划。完成后,屏幕上将出现一个通知框。
7. 在 director 网络 UI 中,编辑 overcloud-poc 部署计划,以便能够在单一 NIC 上创建孤立的 OpenStack 网络 VLANs。
操作界面、表格与配置图
7.1.
从计划选项卡中单击 overcloud-poc 计划卡。网页显示部署 overcloud-poc 计划的四个步骤。
7.2. 在指定部署配置部分下,单击编辑配置以修改基底覆盖配置。
7.3. 在 Deployment Configuration 的 Overall Settings 中打开 Network Configuration。选择 Network Isolation;在 NICs, Bonding, VLANs Configuration 中选择 Single NIC with Vlans No External Ports,点击 Save Changes。
8. overcloud-poc 基计划在一个控制器和一个计算节点上部署。高可用性至少需要三个控制器节点。编辑 overcloud-poc 部署计划配置,禁用高可用性配置,用于高频控制节点。
在 Overall Settings 选择 General Deployment Options。取消 High Availability 下的 HA services via Docker,点击两次 Save Changes。
9. 在部署配置屏幕中,设置控制平面网络的默认路径。
在 Deployment Configuration 的 Parameters 中点击 Single NIC with Vlans No External Ports。将 ControlPlaneDefaultRoute 设为 172.25.249.200,匹配课堂网络,再点击 Save Changes。
10. 在参数标签中,审查默认的容器镜像。
单击默认容器镜像。查看容器镜像位置。各种 OpenStack 服务的容器镜像指向 Red Hat 容器目录。单击取消。
11. 在配置角色和指定节点区域中,确保选择两个节点。一个节点被指定为 Controller 角色。另一个被指定为 Compute 角色。
12. 不要部署 overcloud-poc overcloud 计划。已经部署了一个名为 overcloud 的 overcloud 计划。Red Hat OpenStack 平台 director 目前不支持部署多个Overcloud层。
点击注销。
从 workstation 运行 lab create-overcloudplan 脚本,使用 cleanup 参数来清理此项练习。
1
| [student@workstation ~]$ lab create-overcloudplan cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
引导练习:验证 OpenStack Overcloud 部署#
在此过程中,通过询问服务并启动实例来验证 OpenStack 部署的功能。
学习目标#
完成后能够:
连接 Undercloud 节点,列出 Overcloud 节点。
连接 Overcloud 节点,验证已安装的 OpenStack 服务状态。
创造一个由镜像、网络环境和配对钥匙组成的基础环境。
在环境方面发起一个实例。
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 为密码登录到 workstation 时为 student。运行 lab verify-overcloud setup 命令以确保 OpenStack 服务正在运行。
1
| [student@workstation ~]$ lab verify-overcloud setup
|
操作步骤#
1. 使用 SSH 连接 stack 用户到 director。审查编排 stack 状态。列出Overcloud虚拟机,确保状态为 ACTIVE。
1.1.
从 workstation,打开一个终端,连接 stack 用户到 director。
1
2
| [student@workstation ~]$ ssh stack@director
(undercloud) [stack@director ~]$
|
1.2. 运行 openstack stack list 命令以列出编排堆栈。确保 overcloud 堆栈的状态为 CREATE_COMPLETE。
1
2
3
4
5
6
7
| (undercloud) [stack@director ~]$ openstack stack list \
-c "Stack Name" -c "Stack Status"
+------------+-----------------+
| Stack Name | Stack Status |
+------------+-----------------+
| overcloud | CREATE_COMPLETE |
+------------+-----------------+
|
1.3. 列出Overcloud节点和状态。确保所有Overcloud节点的地位为 ACTIVE。
1
2
3
| (undercloud) [stack@director ~]$ openstack server list \
-c "Name" -c "Status"
+-------------+--------+
|
操作界面、表格与配置图
1
2
3
4
5
6
7
| | Name | Status |
+-------------+--------+
| controller0 | ACTIVE |
| compute1 | ACTIVE |
| compute0 | ACTIVE |
| ceph0 | ACTIVE |
+-------------+--------+
|
2. 登录到 controller0 和 compute0 的Overcloud节点,以查看每个节点上的独特服务,使用部署期间提供的 heat-admin 账户。每个节点上的 heat-admin 用户配置为 SSH 密钥,用于 director 上的 stack 用户,允许无密码访问。使用 docker ps 命令来验证 OpenStack 服务的状况。
2.1. 使用 SSH, 登录到 controller0 Overcloud 节点。列出网络配置并核实 OpenStack 服务状态,然后退出。
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
| (undercloud) [stack@director ~]$ ssh heat-admin@controller0
[heat-admin@controller0 ~]$ ip addr | grep -E 'eth0|vlan|br-ex'
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state
inet 172.25.249.58/24 brd 172.25.249.255 scope global eth0
inet 172.25.249.50/32 brd 172.25.249.255 scope global eth0
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
12: vlan10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.1.1/24 brd 172.24.1.255 scope global vlan10
inet 172.24.1.51/32 brd 172.24.1.255 scope global vlan10
inet 172.24.1.50/32 brd 172.24.1.255 scope global vlan10
13: 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
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 vlan40
inet 172.24.4.50/32 brd 172.24.4.255 scope global vlan40
15: 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
16: vlan50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
inet 172.24.5.1/24 brd 172.24.5.255 scope global vlan50
[heat-admin@controller0 ~]$ sudo ovs-vsctl list-ifaces br-ex
eth2
phy-br-ex
[heat-admin@controller0 ~]$ sudo docker ps \
--format 'table {{.Names}}\t{{.Status}}'
NAMES STATUS
...output omitted...
neutron_l3_agent Up 2 hours (healthy)
neutron_metadata_agent Up 2 hours (healthy)
neutron_dhcp Up 2 hours (healthy)
...output omitted...
[heat-admin@controller0 ~]$ logout
Connection to controller0 closed.
(undercloud) [stack@director ~]$
|
2.2. 使用 SSH, 登录到 compute0 节点。列出网络配置并核实 OpenStack 服务状态,然后退出。
1
2
| (undercloud) [stack@director ~]$ ssh heat-admin@compute0
[heat-admin@compute0 ~]$ ip addr | grep -E 'eth0|vlan|br-ex'
|
操作界面、表格与配置图
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
| 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default qlen 1000
inet 172.25.249.59/24 brd 172.25.249.255 scope global eth0
11: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
inet 172.25.250.2/24 brd 172.25.250.255 scope global br-ex
13: vlan10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
inet 172.24.1.2/24 brd 172.24.1.255 scope global vlan10
14: vlan20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
inet 172.24.2.2/24 brd 172.24.2.255 scope global vlan20
15: vlan30: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
inet 172.24.3.2/24 brd 172.24.3.255 scope global vlan30
16: vlan50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UNKNOWN group default qlen 1000
inet 172.24.5.2/24 brd 172.24.5.255 scope global vlan50
[heat-admin@compute0 ~]$ sudo ovs-vsctl list-ifaces br-trunk
eth1
vlan10
vlan20
vlan30
vlan50
[heat-admin@compute0 ~]$ sudo docker ps \
--format 'table {{.Names}}\t{{.Status}}'
NAMES STATUS
...output omitted...
nova_compute Up 2 hours (healthy)
...output omitted...
[heat-admin@compute0 ~]$ exit
Connection to compute0 closed.
(undercloud) [stack@director ~]$ exit
Connection to director closed.
[student@workstation ~]$
|
3. 使用管理员的环境文件来列出服务,以及由Overcloud 部署创建的端点。
3.1. 在 workstation 上,加载 /home/student/admin-rc 环境文件。
1
2
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$
|
3.2. 在服务目录中列出 OpenStack 服务。输出显示名称、 服务类型和端点。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~]$ openstack catalog list
+------------+----------------+--------------------------------------+
| Name | Type | Endpoints |
+------------+----------------+--------------------------------------+
| aodh | alarming | regionOne |
| | | internal: http://172.24.1.50:8042 |
| | | regionOne |
| | | admin: http://172.24.1.50:8042 |
| | | regionOne |
| | | public: http://172.25.250.50:8042 |
| | | |
| panko | event | regionOne |
| | | admin: http://172.24.1.50:8977 |
|
操作界面、表格与配置图
1
2
3
4
5
| | | | regionOne |
| | | public: http://172.25.250.50:8977 |
| | | regionOne |
| | | internal: http://172.24.1.50:8977 |
...output omitted...
|
3.3. 使用 openstack service list 命令以服务 ID 列出服务。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~]$ openstack service list
+----------------------------------+------------+----------------+
| ID | Name | Type |
+----------------------------------+------------+----------------+
| 25f5213e9bbd4222874921c40e7dd358 | aodh | alarming |
| 27c52b60f4c540aab3068a947ff6b4bf | panko | event |
| 2f17dbd266004ebb9d3aea88f3087feb | placement | placement |
| 436e7d268db14726a2d6af3a244c0a63 | heat-cfn | cloudformation |
| 4e8365473ebb4d05949ae3012867b0a8 | swift | object-store |
| 5e8386b8feb04c50a2885029b184512f | cinderv3 | volumev3 |
| 5ed96d46365f4bd7a0a82a43ddaeed45 | nova | compute |
| 7482a03f42bd4b628286ee1147e323a5 | neutron | network |
| 9383173e7b9c42a5b2a2e0ba5044d6cb | glance | image |
| c4f2867b98444348b03105c434691311 | keystone | identity |
| d26394447bf24012b46d0f7a7a618759 | octavia | load-balancer |
| d8581ea347f240e1922227eab04f9a78 | cinder | volume |
| f3b6c9c52879418691a9ceb13abddc5a | gnocchi | metric |
| f99ea7c2f9eb4e1388f77cea105c7810 | cinderv2 | volumev2 |
| fd0eb883a100449098088d1a7a8afe44 | ceilometer | metering |
| ff3b69668f484f039d3354430e69c4d0 | heat | orchestration |
+----------------------------------+------------+----------------+
|
3.4. 使用 openstack endpoint list 命令来列出端点 URL 和端点 ID。验证所有端点都启用。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~]$ openstack endpoint list \
-c "ID" -c "Service Name" -c "Enabled" -c "URL"
+-------------+--------------+---------+-------------------------------+
| ID | Service Name | Enabled | URL |
+-------------+--------------+---------+-------------------------------+
| 04ed...0fe1 | nova | True | http://172.24.1.50:8774/v2.1 |
| cf57...19a3 | nova | True | http://172.25.250.50:8774/v2.1|
| 0dd8...dc61 | gnocchi | True | http://172.24.1.50:8041 |
| 1295...a377 | swift | True | http://172.24.3.50:8080 |
| 12c1...5484 | heat-cfn | True | http://172.24.1.50:8000/v1 |
...output omitted...
|
4. 使用管理员环境文件列出 Hypervisor 节点及统计信息,确认其计算服务已启用且状态为 up。
4.1. 列出 Hypervisor 节点。
1
2
3
4
5
6
7
| [student@workstation ~]$ openstack hypervisor list
+----+--------------------------------+-----------------+-------------+-------+
| ID | Hypervisor Hostname | Hypervisor Type | Host IP | State |
+----+--------------------------------+-----------------+-------------+-------+
| 1 | compute1.overcloud.example.com | QEMU | 172.24.1.12 | up |
| 2 | compute0.overcloud.example.com | QEMU | 172.24.1.2 | up |
+----+--------------------------------+-----------------+-------------+-------+
|
操作界面、表格与配置图
4.2. 列出 Hypervisor 统计信息。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~]$ openstack hypervisor stats show
+----------------------+-------+
| Field | Value |
+----------------------+-------+
| count | 2 |
| current_workload | 0 |
| disk_available_least | 110 |
| free_disk_gb | 112 |
| free_ram_mb | 4094 |
| local_gb | 112 |
| local_gb_used | 0 |
| memory_mb | 12286 |
| memory_mb_used | 8192 |
| running_vms | 0 |
| vcpus | 8 |
| vcpus_used | 0 |
+----------------------+-------+
|
4.3. 列出在Overcloud节点上运行的计算服务。验证服务是否启用,并在 up 状态中。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~]$ openstack compute service list \
-c "ID" -c "Binary" -c "Host" -c "Status" -c "State"
+----+------------------+-----------------------------------+---------+-------+
| ID | Binary | Host | Status | State |
+----+------------------+-----------------------------------+---------+-------+
| 1 | nova-scheduler | controller0.overcloud.example.com | enabled | up |
| 2 | nova-consoleauth | controller0.overcloud.example.com | enabled | up |
| 3 | nova-conductor | controller0.overcloud.example.com | enabled | up |
| 4 | nova-compute | compute1.overcloud.example.com | enabled | up |
| 5 | nova-compute | compute0.overcloud.example.com | enabled | up |
+----+------------------+-----------------------------------+---------+-------+
|
5. 为 architect1 和 developer1 用户创建身份环境文件。
| OpenStack 项目资源 | |
|---|
| 资源 | 名称 |
| 项目 | finance |
| 管理员用户 | - 名称:architect1 - 项目:finance - 角色:admin - 密码:redhat - 身份环境档案:/home/student/architect1-finance-rc |
| 用户 | - 名称:developer1 - 项目:finance - 角色:_member_ - 密码:redhat - 身份环境档案:/home/student/developer1-finance-rc |
5.1. 创建 finance 项目。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~]$ openstack project create finance
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | |
| domain_id | default |
| enabled | True |
| id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| is_domain | False |
| name | finance |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
|
5.2. 创建 developer1 和 architect1 用户,密码为 redhat。
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
| [student@workstation ~]$ openstack user create \
--project finance \
--password redhat architect1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| domain_id | default |
| enabled | True |
| id | c729dfb7ae4f4391b1f09a9c0a23e57b |
| name | architect1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[student@workstation ~]$ openstack user create \
--project finance \
--password redhat developer1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| domain_id | default |
| enabled | True |
| id | 0f4a95f9fe1549bb9cc8ef76d39b2a30 |
| name | developer1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
|
5.3. 将 admin 角色指派给 architect1 用户。
1
2
3
4
| [student@workstation ~]$ openstack role add \
--project finance \
--user architect1 admin
[student@workstation ~]$
|
5.4. 将 member 角色指派给 developer1 用户。
1
2
3
| [student@workstation ~]$ openstack role add \
--project finance \
--user developer1 _member_
|
操作界面、表格与配置图
1
| [student@workstation ~]$
|
5.5. 为 architect1 用户创建身份环境文件。将文件另存为 /home/student/architect1-finance-rc。文件应如下:
1
2
3
4
5
6
7
8
9
| unset OS_SERVICE_TOKEN
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export OS_PROJECT_NAME="finance"
export OS_PROJECT_DOMAIN_NAME="Default"
export OS_USERNAME="architect1"
export OS_USER_DOMAIN_NAME="Default"
export OS_PASSWORD=redhat
export OS_IDENTITY_API_VERSION=3
export PS1='[\u@\h \W(architect1-finance)]\$ '
|
5.6. 为 developer1 用户创建身份环境文件。将文件另存为 /home/student/developer1-finance-rc。文件应如下:
1
2
3
4
5
6
7
8
9
| unset OS_SERVICE_TOKEN
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export OS_PROJECT_NAME="finance"
export OS_PROJECT_DOMAIN_NAME="Default"
export OS_USERNAME="developer1"
export OS_USER_DOMAIN_NAME="Default"
export OS_PASSWORD=redhat
export OS_IDENTITY_API_VERSION=3
export PS1='[\u@\h \W(developer1-finance)]\$ '
|
6. 作为 architect1 用户,根据下表将 rhel7-web 镜像导入并创建到镜像储存库。
6.1. 用 source 加载 /home/student/architect1-finance-rc 环境文件。
1
2
| [student@workstation ~]$ source ~/architect1-finance-rc
[student@workstation ~(architect1-finance)]$
|
6.2. 从 http://materials.example.com/osp-small.qcow2 下载 QCOW2 镜像。
1
2
3
| [student@workstation ~(architect1-finance)]$ wget \
http://materials.example.com/osp-small.qcow2
...output omitted...
|
6.3. 创建名为 rhel7 的镜像。
1
2
| [student@workstation ~(architect1-finance)]$ openstack image create \
--disk-format qcow2 --file osp-small.qcow2 rhel7
|
操作界面、表格与配置图
7. 作为 architect1 用户,使用以下规格创建一种名为 default 的规格:
名称:small
VCPUs: 2
RAM: 1024 MB
根盘:10 GB
Public: true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [student@workstation ~(architect1-finance)]$ openstack flavor create \
--vcpus 2 \
--ram 1024 \
--disk 10 \
default
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 10 |
| id | 6b9afa45-0d82-40f6-bcf1-8347a81fe0a3 |
| name | default |
| os-flavor-access:is_public | True |
| properties | |
| ram | 1024 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 2 |
+----------------------------+--------------------------------------+
|
8. 作为 architect1 用户,创建一个名为 provider-datacentre 及其相关子网 provider-subnet-172.25.250 的外部网络。将网络标为外部。创建下表所列网络资源 :
| OpenStack 网络资源 | |
|---|
| 资源 | 名称 |
| 项目网络 | - 名称:finance-network1 - 子网名称:finance-subnet1 - 网络子网:192.168.1.0/24 - DNS 服务器:172.25.250.254 |
| 外部网络 | - 名称:provider-datacentre - 外部:是 - 提供者网络类型:flat - 提供商有形网络:datacentre - 共享:是 - 子网名称:provider-subnet-172.25.250 - 网络子网:172.25.250.0/24 - 网络网关:172.25.250.254 - 地址池:172.25.250.101,172.25.250.189 - DNS 服务器:172.25.250.254 |
| 路由器名称 | finance-router1 |
操作界面、表格与配置图
| 资源 | 名称 |
|---|
| 将路由器的网关设为外部网络,并定义私有网络中的接口。 |
8.1. 作为 architect1 用户,创建 provider-datacentre 网络。
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
| [student@workstation ~(architect1-finance)]$ openstack network create \
--external --share \
--provider-network-type flat \
--provider-physical-network datacentre \
provider-datacentre
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T15:15:39Z |
| description | |
| dns_domain | None |
| id | f4b402ab-fe9f-4b4a-8dc5-495979133315 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1500 |
| name | provider-datacentre |
| port_security_enabled | True |
| project_id | cbb8de56066b4d40afb9f44bd1cd0af3 |
| provider:network_type | flat |
| provider:physical_network | datacentre |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 6 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T15:15:40Z |
+---------------------------+--------------------------------------+
|
8.2. 创建 provider-subnet-172.25.250 子网。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~(architect1-finance)]$ openstack subnet create \
--subnet-range 172.25.250.0/24 \
--no-dhcp \
--gateway 172.25.250.254 \
--allocation-pool start=172.25.250.101,end=172.25.250.189 \
--dns-nameserver 172.25.250.254 \
--network provider-datacentre \
provider-subnet-172.25.250
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 172.25.250.101-172.25.250.189 |
| cidr | 172.25.250.0/24 |
| created_at | 2018-06-21T15:17:11Z |
| description | |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| | dns_nameservers | 172.25.250.254 |
| enable_dhcp | False |
| gateway_ip | 172.25.250.254 |
| host_routes | |
| id | 0ddd461c-4e8f-44df-87f1-fa43f755a5a6 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | provider-subnet-172.25.250 |
| network_id | f4b402ab-fe9f-4b4a-8dc5-495979133315 |
| project_id | cbb8de56066b4d40afb9f44bd1cd0af3 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T15:17:11Z |
+-------------------+--------------------------------------+
|
8.3. 创建 finance-router1 路由器
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [student@workstation ~(architect1-finance)]$ openstack router create \
finance-router1
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T15:45:44Z |
| description | |
| distributed | False |
| external_gateway_info | None |
| flavor_id | None |
| ha | False |
| id | 20515fcf-54c8-4a4a-8c77-c0c3f953cc7a |
| name | finance-router1 |
| project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| revision_number | 1 |
| routes | |
| status | ACTIVE |
| tags | |
| updated_at | 2018-06-21T15:45:44Z |
+-------------------------+--------------------------------------+
|
8.4. 创建 finance-network1 项目网络。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~(architect1-finance)]$ openstack network create \
finance-network1
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T15:47:07Z |
| description | |
| dns_domain | None |
| id | 36d73642-f152-4c8e-a2ec-bd12e43c335a |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| | is_default | False |
| is_vlan_transparent | None |
| mtu | 1450 |
| name | finance-network1 |
| port_security_enabled | True |
| project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| provider:network_type | vxlan |
| provider:physical_network | None |
| provider:segmentation_id | 69 |
| qos_policy_id | None |
| revision_number | 3 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T15:47:07Z |
+---------------------------+--------------------------------------+
|
8.5. 创建 finance-subnet1 项目子网。
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
| [student@workstation ~(architect1-finance)]$ openstack subnet create \
--subnet-range 192.168.1.0/24 \
--dhcp \
--dns-nameserver 172.25.250.254 \
--network finance-network1 \
finance-subnet1
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.1.2-192.168.1.254 |
| cidr | 192.168.1.0/24 |
| created_at | 2018-06-21T15:47:48Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | True |
| gateway_ip | 192.168.1.1 |
| host_routes | |
| id | 2112b3c2-58d1-48aa-ab4d-f2ab657c1a15 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | finance-subnet1 |
| network_id | 36d73642-f152-4c8e-a2ec-bd12e43c335a |
| project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T15:47:48Z |
+-------------------+--------------------------------------+
|
8.6. 将路由器连接到项目网络 finance-subnet1。
1
2
3
| [student@workstation ~(architect1-finance)]$ openstack router add \
subnet finance-router1 finance-subnet1
[student@workstation ~(architect1-finance)]$
|
操作界面、表格与配置图
8.7. 将路由器设为外部网络的外部网关 provider-datacentre。
1
2
3
| [student@workstation ~(architect1-finance)]$ openstack router set \
--external-gateway provider-datacentre finance-router1
[student@workstation ~(architect1-finance)]$
|
9. 作为 developer1 用户,在 default 安全组中创建安全规则,default 允许 SSH 端口。使用 http://materials.example.com/keypairs/example-keypair.pub 中存储的公共密钥创建 example-keypair 键对。下表列出资源的细节。
| OpenStack 安全资源 | |
|---|
| 资源 | 名称 |
| 安全组规则 | - 安全组:default - 协议:TCP - 端口:22 |
| 密钥对 | - 名称:example-keypair - 公钥:example-keypair.pub |
9.1. 用 source 加载 developer1 身份环境文件。
1
2
| [student@workstation ~(architect1-finance)]$ source ~/developer1-finance-rc
[student@workstation ~(developer1-finance)]$
|
9.2. 在 default 安全组中添加一个安全组规则,允许使用端口进入
22.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| [student@workstation ~(developer1-finance)]$ openstack security group rule \
create --protocol tcp --dst-port 22 \
default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T15:49:52Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 5735dd6a-629c-411e-9331-87941eab01f5 |
| name | None |
| port_range_max | 22 |
| port_range_min | 22 |
| project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | b00d9c6f-8c5b-4f10-888b-13d1417079cf |
| updated_at | 2018-06-21T15:49:52Z |
+-------------------+--------------------------------------+
|
操作界面、表格与配置图
9.3. 从 http://materials.example.com/keypairs/example-keypair.pub 下载公钥,并使用 example-keypair.pub 公钥创建密钥对 example-keypair。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(developer1-finance)]$ wget \
http://materials.example.com/keypairs/example-keypair.pub
...output omitted...
[student@workstation ~(developer1-finance)]$ openstack keypair create \
--public-key example-keypair.pub example-keypair
+-------------+-------------------------------------------------+
| Field | Value |
+-------------+-------------------------------------------------+
| fingerprint | 31:b5:bb:2c:a0:e7:39:5d:5f:5e:0e:20:8b:a5:c2:1f |
| name | example-keypair |
| user_id | 0f4a95f9fe1549bb9cc8ef76d39b2a30 |
+-------------+-------------------------------------------------+
|
10. a 根据下表在环境中发射实例。
| OpenStack 实例资源 | |
|---|
| 资源 | 名称 |
| 实例名称 | finance-server1 |
| 镜像名称 | rhel7 |
| 规格名称 | default |
| 密钥对 | example-keypair |
| 网络名称 | finance-network1 |
10.1. 使用 developer1 环境文件启动实例。
1
2
3
4
5
6
7
| [student@workstation ~(developer1-finance)]$ openstack server create \
--image rhel7 \
--flavor default \
--key-name example-keypair \
--nic net-id=finance-network1 \
--wait finance-server1
...output omitted...
|
10.2. 查看实例状态,确认标记为 ACTIVE。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server1",
"Image": "rhel7-web",
"ID": "efb26df0-6fe3-490c-89ef-4889ed9f975c",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.N"
}
]
|
操作界面、表格与配置图
11. 作为 operator1 用户,创建一个浮动 IP。将浮动 IP 与 finance-server1 实例联系起来。
11.1. 从浮动 IP 池 provider-datacentre 创建浮动 IP。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(developer1-finance)]$ openstack floating ip create \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-21T15:56:36Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.P |
| floating_network_id | f4b402ab-fe9f-4b4a-8dc5-495979133315 |
| id | 7404fea7-566b-4bd8-a636-d33319521f8b |
| name | 172.25.250.P |
| port_id | None |
| project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-21T15:56:36Z |
+---------------------+--------------------------------------+
|
11.2. 将浮动的 IP 与实例联系起来。
1
2
| [student@workstation ~(developer1-finance)]$ openstack server add \
floating ip finance-server1 172.25.250.P
|
11.3. 确保成功指定 IP 地址。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(developer1-finance)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "finance-server1",
"Image": "rhel7-web",
"ID": "efb26df0-6fe3-490c-89ef-4889ed9f975c",
"Flavor": "default",
"Networks": "finance-network1=192.168.1.N, 172.25.250.P"
}
]
|
12. 使用 SSH 连接到实例并退出实例。
允许用几分钟完成 cloud-init 服务。
1
2
| [student@workstation ~(developer1-finance)]$ ssh cloud-user@172.25.250.P
[cloud-user@finance-server1 ~]$ exit
|
操作界面、表格与配置图
1
| [student@workstation ~(developer1-finance)]$
|
从 workstation 运行 lab verify-overcloud 脚本,使用 cleanup 参数来清理此项练习。
1
| [student@workstation ~]$ lab verify-overcloud cleanup
|
本引导练习到此结束。
操作界面、表格与配置图
实验:部署 OpenStack Overcloud#
本实验向 Director Web 界面导入 Overcloud 计划,使用一个控制节点和一个计算节点部署。确认 OpenStack 服务运行,再启动实例,通过 SSH 验证连通性。
学习目标#
完成后能够:
使用 Director 基础模板创建 Overcloud 计划目录,加入特定部署架构的计划环境文件。
使用 Web 界面导入以单网卡 VLAN 隔离内部网络的 Overcloud 计划。
使用 Director Web 界面部署 OpenStack Overcloud。
在部署 OpenStack Overcloud后,审查系统配置。
验证 OpenStack Overcloud 部署。
创造一个由镜像、网络环境和配对钥匙组成的基础环境。
在新部署的 Overcloud 中启动实例。
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 为密码,登录到 workstation 的 student。运行执行以下任务的 lab deploy-overcloud-lab setup 命令 :
1
| [student@workstation ~]$ lab deploy-overcloud-lab setup
|
操作步骤#
1. 将/usr/share/openstack-tripleo-heat-templates 从 director 作为 stack 用户复制到 workstation 上的/home/student/overcloud-poc。
2. 在 /home/student/overcloud-poc 中下载并提取 http://materials.example.com/classroom-plan.tar.gz。classroom-plan.tar.gz 包含 plan-environment.yaml 和环境文件,其中使用单 NIC VLANs 来定义Overcloud网络隔离。Overcloud计划是定制的,提供以下功能 :
使用单一的 NICVLANs 来隔离Overcloud网络。
通过控制节点虚拟机的 eth2 提供 Overcloud 外部访问。
OpenStack 服务的公共端点使用固定虚拟 IP 地址。
使用 director 上存在的当地容器存放处。
禁用控制节点高可用性。
禁用遥测服务。
操作界面、表格与配置图
3. 使用 https://director-ui.lab.example.com 访问 Director 网络 UI。在初始登录屏幕中,使用 admin 作为用户名,使用 redhat 作为访问 Web UI 的密码。
4. 在 Red Hat OpenStack 平台 director Web UI 中,通过上传存储在 /home/student/overcloud-poc 中的文件来导入一个Overcloud计划。输入Overcloud计划名称为 overcloud-poc。
5. 确保将 1 个 Controller 角色和 1 个 Compute 角色分配给裸机节点。
6. 一旦Overcloud计划被导入和配置后就开始Overcloud部署
若部署前验证未全部通过,会显示警告。课堂部署中出现此情况符合预期。
7. 校验 overcloud-poc 应用栈是否显示 CREATE_COMPLETE 状态,以及Overcloud节点是否处于 ACTIVE 状态。
8. 使用 OpenStack 仪表板下载 admin 身份环境文件。修改环境文件以使用 admin 在 director Web UI 的Overcloud部署后列出的密码。
9. 用 source 加载是位于 /home/student/Downloads/admin-openrc.sh 的身份环境文件,并创建下表显示的资源。为 architect1 和 operator1 用户创建身份环境文件。
| OpenStack 项目资源 | |
|---|
| 资源 | 名称 |
| 项目 | production |
| 管理员用户 | - 名称:architect1 - 项目:production - 角色:admin - 密码:redhat - 身份环境档案:/home/student/architect1-production-rc |
| 用户 | - 名称:operator1 - 项目:production - 角色:_member_ - 密码:redhat - 身份环境档案:/home/student/operator1-production-rc |
10. 作为 architect1 用户,根据下表将 rhel7-web 镜像导入并创建到镜像储存库。
操作界面、表格与配置图
11. 作为 architect1 用户,使用以下规格创建 default 规格 :
名称:small
VCPUs: 2
RAM: 1024 MB
根盘:10 GB
Public: true
12. 作为 architect1 用户,创建一个名为 provider-datacentre 及其相关子网 provider-subnet-172.25.250 的外部网络。将网络标为外部。创建下表所列网络资源 :
| OpenStack 网络资源 | |
|---|
| 资源 | 名称 |
| 私有网络 | - 名称:production-network1 - 子网名称:production-subnet1 - 网络子网:192.168.1.0/24 - DNS 服务器:172.25.250.254 |
| 外部网络 | - 名称:provider-datacentre - 外部:是 - 提供者网络类型:flat - 提供商有形网络:datacentre - 共享:是 - 子网名称:provider-subnet-172.25.250 - 网络子网:172.25.250.0/24 - 网络网关:172.25.250.254 - 地址池:172.25.250.101,172.25.250.189 - DNS 服务器:172.25.250.254 |
| 路由器名称 | production-router1 定义路由器为外部网络的网关,并定义私有网络中的接口。 |
13. 作为 operator1 用户,在 default 安全组中创建安全规则,default 允许 SSH 端口。使用 http://materials.example.com/keypairs/example-keypair.pub 中存储的公共密钥创建 example-keypair 键对。下表列出资源的细节。
| OpenStack 安全资源 | |
|---|
| 资源 | 名称 |
| 安全组规则 | - 安全组:default - 协议:TCP - 端口:22 |
操作界面、表格与配置图
| 资源 | 名称 |
|---|
| 密钥对 | - 名称:example-keypair - 公钥:example-keypair.pub |
14. 作为 operator1 用户,使用以下资源在环境中启动 production-server1 实例:
| OpenStack 实例资源 | |
|---|
| 资源 | 名称 |
| 名称 | production-server1 |
| 镜像 | rhel7-web |
| 规格 | default |
| 密钥对 | example-keypair |
| 网络名称 | production-network1 |
15. 作为 developer1 用户,创建浮动 IP。将浮动 IP 与 production-server1 相联系。
16. 使用 SSH 连接到实例并退出实例。
允许用几分钟完成 cloud-init 服务。
在 workstation 上运行 lab deploy-overcloud-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab deploy-overcloud-lab grade
|
在 workstation 上运行 lab deploy-overcloud-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab deploy-overcloud-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
本实验向 Director Web 界面导入 Overcloud 计划,使用一个控制节点和一个计算节点部署。确认 OpenStack 服务运行,再启动实例,通过 SSH 验证连通性。
学习目标#
完成后能够:
使用 Director 基础模板创建 Overcloud 计划目录,加入特定部署架构的计划环境文件。
使用 Web 界面导入以单网卡 VLAN 隔离内部网络的 Overcloud 计划。
使用 Director Web 界面部署 OpenStack Overcloud。
在部署 OpenStack Overcloud后,审查系统配置。
验证 OpenStack Overcloud 部署。
创造一个由镜像、网络环境和配对钥匙组成的基础环境。
在新部署的 Overcloud 中启动实例。
开始之前#
确认 workstation 和Overcloud的虚拟机已经启动
以 student 为密码,登录到 workstation 的 student。运行执行以下任务的 lab deploy-overcloud-lab setup 命令 :
1
| [student@workstation ~]$ lab deploy-overcloud-lab setup
|
操作步骤#
1. 将/usr/share/openstack-tripleo-heat-templates 从 director 作为 stack 用户复制到 workstation 上的/home/student/overcloud-poc。
1
2
3
4
| [student@workstation ~]$ scp -r \
stack@director:/usr/share/openstack-tripleo-heat-templates \
~/overcloud-poc
...output omitted...
|
2. 在 /home/student/overcloud-poc 中下载并提取 http://materials.example.com/classroom-plan.tar.gz。classroom-plan.tar.gz 包含 plan-environment.yaml 和环境文件,其中使用单 NIC VLANs 来定义Overcloud网络隔离。Overcloud计划是定制的,提供以下功能 :
操作界面、表格与配置图
2.1. 审查/home/student/overcloud-poc 中的 plan-environment.yaml。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~]$ cd overcloud-poc
[student@workstation overcloud-poc]$ cat plan-environment.yaml
version: 1.0
name: overcloud
description: >
Default Deployment plan
template: overcloud.yaml
environments:
- path: overcloud-resource-registry-puppet.yaml
- path: environments/docker.yaml
- path: environments/docker-ha.yaml
|
2.2. 在 /home/student/overcloud-poc 中下载 http://materials.example.com/classroom-plan.tar.gz。
1
2
3
| [student@workstation overcloud-poc]$ wget \
http://materials.example.com/classroom-plan.tar.gz
...output omitted...
|
2.3. 提取 classroom-plan.tar.gz
1
2
3
| [student@workstation overcloud-poc]$ tar xzvf \
classroom-plan.tar.gz
...output omitted...
|
2.4. 审查 plan-environment.yaml 在/home/student/overcloud-poc 下载和提取的 plan-environment.yaml。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation overcloud-poc]$ cat plan-environment.yaml
description: 'Default Deployment plan
'
environments:
- path: overcloud-resource-registry-puppet.yaml
- path: environments/docker.yaml
- path: classroom-environments/net-single-nic-with-vlans.yaml
- path: environments/network-isolation.yaml
- path: environments/fixed-ip-vips.yaml
- path: environments/disable-telemetry.yaml
name: overcloud-poc
parameter_defaults:
...output omitted...
|
3. 使用 https://director-ui.lab.example.com 访问 Director 网络 UI。在初始登录屏幕中,使用 admin 作为用户名,使用 redhat 作为访问 Web UI 的密码。
操作界面、表格与配置图
3.1. 打开 https://director-ui.lab.example.com 以访问 Director Web UI。如果出现证书错误,请接受 自签名 证书。
3.2. 使用 admin 作为用户名和 redhat 作为密码登录到 director Web UI。
4. 在 Red Hat OpenStack 平台 director Web UI 中,通过上传存储在 /home/student/overcloud-poc 中的文件来导入一个Overcloud计划。输入Overcloud计划名称为 overcloud-poc。
4.1. 从 Red Hat OpenStack 平台 director Web UI 点击计划标签中的导入计划。
4.2. 在新计划选项卡中,输入 overcloud-poc 作为计划名称。
4.3. 选择上传类型为本地文件夹。
4.4. 单击浏览以选择计划文件。浏览并在 student 主目录中选择 overcloud-poc 目录。单击上传。
4.5. 点击 Upload Files and Create Plan,等待计划文件上传并在 director 上创建计划。完成后屏幕会显示通知。
5. 确保将 1 个 Controller 角色和 1 个 Compute 角色分配给裸机节点。
5.1. 从计划选项卡中单击 overcloud-poc 计划卡。网页显示部署 overcloud-poc 计划的四个步骤。
5.2. 在配置角色和指定节点区域,确保选择两个节点。其中一个节点被指定为 Controller 角色,另一个被指定为 Compute 角色。
6. 一旦Overcloud计划被导入和配置后就开始Overcloud部署
若部署前验证未全部通过,会显示警告。课堂部署中出现此情况符合预期。
6.1. 单击验证并部署以启动部署验证。
若部署前验证未全部通过,会显示警告。课堂部署中出现此情况符合预期。
6.2. 点击部署以启动Overcloud 部署。
6.3. Director Web 界面通过进度条监视 Overcloud 部署的整体进度。若 Plan overcloud-poc
操作界面、表格与配置图
部署页面已关闭,可使用 View detailed information 链接,列出或筛选编排栈部署创建的资源。
在过滤文本框中输入 PROGRESS 以过滤在 CREATE_IN_PROGRESS 状态中的资源。
6.4. 部署完成后,Deploy 部分显示 Overcloud IP、用户名和密码,用于访问仪表板。你的管理员密码可能与示例不同。
1
2
3
4
| Overcloud information:
Overcloud IP address: 172.25.250.50
Username: admin
Password: NQH329y7PHcyM6HPTu2MHUBvM
|
7. 校验 overcloud-poc 应用栈是否显示 CREATE_COMPLETE 状态,以及Overcloud节点是否处于 ACTIVE 状态。
7.1.
使用 SSH, 登录到 director。
1
2
| [student@workstation overcloud-poc]$ ssh stack@director
(undercloud) [stack@director ~]$
|
7.2. 使用 openstack stack list 验证 overcloud-poc 应用栈的状态。
1
2
3
4
5
6
7
| (undercloud) [stack@director ~]$ openstack stack list \
-c "Stack Name" -c "Stack Status"
+---------------+-----------------+
| Stack Name | Stack Status |
+---------------+-----------------+
| overcloud-poc | CREATE_COMPLETE |
+---------------+-----------------+
|
7.3. 使用 openstack server list 校验Overcloud节点的状态。
1
2
3
4
5
6
7
8
| (undercloud) [stack@director ~]$ openstack server list \
-c "Name" -c "Status"
+----------------------------+--------+
| Name | Status |
+----------------------------+--------+
| overcloud-poc-compute-0 | ACTIVE |
| overcloud-poc-controller-0 | ACTIVE |
+----------------------------+--------+
|
退出 director。
1
2
3
| (undercloud) [stack@director ~]$ logout
Connection to director closed.
[student@workstation overcloud-poc]$
|
8. 使用 OpenStack 仪表板下载 admin 身份环境文件。修改环境文件以使用 admin 在 director Web UI 的Overcloud部署后列出的密码。
操作界面、表格与配置图
8.1. 从浏览器中的新标签,使用 admin 登录到 http://dashboard.overcloud.example.com, 以及 director Web UI Overcloud 部署后列出的密码。
8.2. 单击页面顶部的项目标签。导航到项目 > API 访问。
8.3. 在 API 访问页面上,导航到下载 OpenStack RC 文件 > OpenStack RC 文件 (身份 API v3) 保存环境文件。
退出仪表板。
8.4. 编辑 /home/student/Downloads/admin-openrc.sh 文件,以便使用从 director 网络 UI 检索到的管理员密码。屏幕输出中突出显示的文字代表已经编辑的文字。您的管理员密码可能有所不同。
1
2
3
4
5
6
7
8
9
10
| [student@workstation overcloud-poc]$ cd
[student@workstation ~]$ vi ~/Downloads/admin-openrc.sh
...output omitted...
export OS_USERNAME="admin"
# With Keystone you pass the keystone password.
# echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as
user $OS_USERNAME: "
# read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=NQH329y7PHcyM6HPTu2MHUBvM
...output omitted...
|
将更改保存到文件。
8.5. 从 director 网络 UI 中注销。
9. 用 source 加载是位于 /home/student/Downloads/admin-openrc.sh 的身份环境文件,并创建下表显示的资源。为 architect1 和 operator1 用户创建身份环境文件。
| OpenStack 项目资源 | |
|---|
| 资源 | 名称 |
| 项目 | production |
| 管理员用户 | - 名称:architect1 - 项目:production - 角色:admin - 密码:redhat - 身份环境档案:/home/student/architect1-production-rc |
| 用户 | - 名称:operator1 - 项目:production - 角色:_member_ - 密码:redhat - 身份环境档案:/home/student/operator1-production-rc |
操作界面、表格与配置图
9.1. 用 source 加载 /home/student/Downloads/admin-openrc.sh 中的 admin 环境文件。
1
2
| [student@workstation ~]$ source ~/Downloads/admin-openrc.sh
[student@workstation ~]$
|
9.2. 创建 production 项目。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~]$ openstack project create production
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | |
| domain_id | default |
| enabled | True |
| id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| is_domain | False |
| name | production |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
|
9.3. 创建 operator1 和 architect1 用户,密码为 redhat。
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
| [student@workstation ~]$ openstack user create \
--project production \
--password redhat architect1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| domain_id | default |
| enabled | True |
| id | c729dfb7ae4f4391b1f09a9c0a23e57b |
| name | architect1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[student@workstation ~]$ openstack user create \
--project production \
--password redhat operator1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| domain_id | default |
| enabled | True |
| id | 0f4a95f9fe1549bb9cc8ef76d39b2a30 |
| name | operator1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
|
9.4. 将 admin 角色指派给 architect1 用户。
1
2
| [student@workstation ~]$ openstack role add \
--project production \
|
操作界面、表格与配置图
1
2
| --user architect1 admin
[student@workstation ~]$
|
9.5. 将 member 角色指派给 operator1 用户。
1
2
3
4
| [student@workstation ~]$ openstack role add \
--project production \
--user operator1 _member_
[student@workstation ~]$
|
9.6. 为 architect1 用户创建身份环境文件。将文件另存为 /home/student/architect1-production-rc。文件应如下:
1
2
3
4
5
6
7
8
9
10
| unset OS_SERVICE_TOKEN
unset OS_PROJECT_ID
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export OS_PROJECT_NAME="production"
export OS_PROJECT_DOMAIN_NAME="Default"
export OS_USERNAME="architect1"
export OS_USER_DOMAIN_NAME="Default"
export OS_PASSWORD=redhat
export OS_IDENTITY_API_VERSION=3
export PS1='[\u@\h \W(architect1-production)]\$ '
|
9.7. 为 operator1 用户创建身份环境文件。将文件另存为 /home/student/operator1-production-rc。文件应如下:
1
2
3
4
5
6
7
8
9
10
| unset OS_SERVICE_TOKEN
unset OS_PROJECT_ID
export OS_AUTH_URL=http://172.25.250.50:5000/v3
export OS_PROJECT_NAME="production"
export OS_PROJECT_DOMAIN_NAME="Default"
export OS_USERNAME="operator1"
export OS_USER_DOMAIN_NAME="Default"
export OS_PASSWORD=redhat
export OS_IDENTITY_API_VERSION=3
export PS1='[\u@\h \W(operator1-production)]\$ '
|
10. 作为 architect1 用户,根据下表将 rhel7-web 镜像导入并创建到镜像储存库。
10.1. 用 source 加载 /home/student/architect1-production-rc 环境文件。
1
2
| [student@workstation ~]$ source ~/architect1-production-rc
[student@workstation ~(architect1-production)]$
|
操作界面、表格与配置图
10.2. 下载QCOW2 镜像来自 http://materials.example.com/osp-web.qcow2。
1
2
3
| [student@workstation ~(architect1-production)]$ wget \
http://materials.example.com/osp-web.qcow2
...output omitted...
|
10.3. 创建一个名为 rhel7-web 的镜像。
1
2
3
| [student@workstation ~(architect1-production)]$ openstack image create \
--disk-format qcow2 --file osp-web.qcow2 rhel7-web
...output omitted...
|
11. 作为 architect1 用户,使用以下规格创建 default 规格 :
名称:small
VCPUs: 2
RAM: 1024 MB
根盘:10 GB
Public: true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [student@workstation ~(architect1-production)]$ openstack flavor create \
--vcpus 2 \
--ram 1024 \
--disk 10 \
default
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 10 |
| id | 6b9afa45-0d82-40f6-bcf1-8347a81fe0a3 |
| name | default |
| os-flavor-access:is_public | True |
| properties | |
| ram | 1024 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 2 |
+----------------------------+--------------------------------------+
|
12. 作为 architect1 用户,创建一个名为 provider-datacentre 及其相关子网 provider-subnet-172.25.250 的外部网络。将网络标为外部。创建下表所列网络资源 :
| OpenStack 网络资源 | |
|---|
| 资源 | 名称 |
| 私有网络 | - 名称:production-network1 - 子网名称:production-subnet1 - 网络子网:192.168.1.0/24 - DNS 服务器:172.25.250.254 |
| 外部网络 | - 名称:provider-datacentre |
操作界面、表格与配置图
| 资源 | 名称 |
|---|
| - 外部:是 - 提供者网络类型:flat - 提供商有形网络:datacentre - 共享:是 - 子网名称:provider-subnet-172.25.250 - 网络子网:172.25.250.0/24 - 网络网关:172.25.250.254 - 地址池:172.25.250.101,172.25.250.189 - DNS 服务器:172.25.250.254 |
| 路由器名称 | production-router1 定义路由器为外部网络的网关,并定义私有网络中的接口。 |
12.1. 作为 architect1 用户,创建 provider-datacentre 网络。
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
| [student@workstation ~(architect1-production)]$ openstack network create \
--external --share \
--provider-network-type flat \
--provider-physical-network datacentre \
provider-datacentre
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T15:15:39Z |
| description | |
| dns_domain | None |
| id | f4b402ab-fe9f-4b4a-8dc5-495979133315 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1500 |
| name | provider-datacentre |
| port_security_enabled | True |
| project_id | cbb8de56066b4d40afb9f44bd1cd0af3 |
| provider:network_type | flat |
| provider:physical_network | datacentre |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 6 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T15:15:40Z |
+---------------------------+--------------------------------------+
|
12.2. 创建provider-subnet-172.25.250 子网
1
2
| [student@workstation ~(architect1-production)]$ openstack subnet create \
--subnet-range 172.25.250.0/24 \
|
操作界面、表格与配置图
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
| --no-dhcp \
--gateway 172.25.250.254 \
--allocation-pool start=172.25.250.101,end=172.25.250.189 \
--dns-nameserver 172.25.250.254 \
--network provider-datacentre \
provider-subnet-172.25.250
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 172.25.250.101-172.25.250.189 |
| cidr | 172.25.250.0/24 |
| created_at | 2018-06-21T15:17:11Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | False |
| gateway_ip | 172.25.250.254 |
| host_routes | |
| id | 0ddd461c-4e8f-44df-87f1-fa43f755a5a6 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | provider-subnet-172.25.250 |
| network_id | f4b402ab-fe9f-4b4a-8dc5-495979133315 |
| project_id | cbb8de56066b4d40afb9f44bd1cd0af3 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T15:17:11Z |
+-------------------+--------------------------------------+
|
12.3. 创建production-router1 路由器
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [student@workstation ~(architect1-production)]$ openstack router create \
production-router1
-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T15:45:44Z |
| description | |
| distributed | False |
| external_gateway_info | None |
| flavor_id | None |
| ha | False |
| id | 20515fcf-54c8-4a4a-8c77-c0c3f953cc7a |
| name | production-router1 |
| project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| revision_number | 1 |
| routes | |
| status | ACTIVE |
| tags | |
| updated_at | 2018-06-21T15:45:44Z |
+-------------------------+--------------------------------------+
|
12.4. 创建production-network1 项目网络。
1
| [student@workstation ~(architect1-production)]$ openstack network create \
|
操作界面、表格与配置图
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
| production-network1
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T15:47:07Z |
| description | |
| dns_domain | None |
| id | 36d73642-f152-4c8e-a2ec-bd12e43c335a |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1450 |
| name | production-network1 |
| port_security_enabled | True |
| project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| provider:network_type | vxlan |
| provider:physical_network | None |
| provider:segmentation_id | 69 |
| qos_policy_id | None |
| revision_number | 3 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T15:47:07Z |
+---------------------------+--------------------------------------+
|
12.5. 创建production-subnet1 项目子网。
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
| [student@workstation ~(architect1-production)]$ openstack subnet create \
--subnet-range 192.168.1.0/24 \
--dhcp \
--dns-nameserver 172.25.250.254 \
--network production-network1 \
production-subnet1
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.1.2-192.168.1.254 |
| cidr | 192.168.1.0/24 |
| created_at | 2018-06-21T15:47:48Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | True |
| gateway_ip | 192.168.1.1 |
| host_routes | |
| id | 2112b3c2-58d1-48aa-ab4d-f2ab657c1a15 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | production-subnet1 |
| network_id | 36d73642-f152-4c8e-a2ec-bd12e43c335a |
| project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
|
操作界面、表格与配置图
1
2
3
4
| | subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T15:47:48Z |
+-------------------+--------------------------------------+
|
12.6. 连接项目网络的路由器 production-subnet1。
1
2
3
| [student@workstation ~(architect1-production)]$ openstack router add \
subnet production-router1 production-subnet1
[student@workstation ~(architect1-production)]$
|
12.7. 将路由器设为外部网络的外部网关 provider-datacentre。
1
2
3
| [student@workstation ~(architect1-production)]$ openstack router set \
--external-gateway provider-datacentre production-router1
[student@workstation ~(architect1-production)]$
|
13. 作为 operator1 用户,在 default 安全组中创建安全规则,default 允许 SSH 端口。使用 http://materials.example.com/keypairs/example-keypair.pub 中存储的公共密钥创建 example-keypair 键对。下表列出资源的细节。
| OpenStack 安全资源 | |
|---|
| 资源 | 名称 |
| 安全组规则 | - 安全组:default - 协议:TCP - 端口:22 |
| 密钥对 | - 名称:example-keypair - 公钥:example-keypair.pub |
13.1. 用 source 加载 operator1 身份环境文件。
1
2
| [student@workstation ~(architect1-production)]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$
|
13.2. 添加default 安全组中的安全组规则,允许使用端口进入
22.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~(operator1-production)]$ openstack security group rule \
create --protocol tcp --dst-port 22 \
default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T15:49:52Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 5735dd6a-629c-411e-9331-87941eab01f5 |
| name | None |
| port_range_max | 22 |
| port_range_min | 22 |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
| | project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | b00d9c6f-8c5b-4f10-888b-13d1417079cf |
| updated_at | 2018-06-21T15:49:52Z |
+-------------------+--------------------------------------+
|
13.3. 下载是 http://materials.example.com/keypairs/example-keypair.pub 的公钥使用 example-keypair.pub 公钥创建 example-keypair 密钥对。
1
2
3
4
5
6
7
8
9
10
11
12
| [student@workstation ~(operator1-production)]$ wget \
http://materials.example.com/keypairs/example-keypair.pub
...output omitted...
[student@workstation ~(operator1-production)]$ openstack keypair create \
--public-key example-keypair.pub example-keypair
+-------------+-------------------------------------------------+
| Field | Value |
+-------------+-------------------------------------------------+
| fingerprint | 31:b5:bb:2c:a0:e7:39:5d:5f:5e:0e:20:8b:a5:c2:1f |
| name | example-keypair |
| user_id | 0f4a95f9fe1549bb9cc8ef76d39b2a30 |
+-------------+-------------------------------------------------+
|
14. 作为 operator1 用户,使用以下资源在环境中启动 production-server1 实例:
| OpenStack 实例资源 | |
|---|
| 资源 | 名称 |
| 名称 | production-server1 |
| 镜像 | rhel7-web |
| 规格 | default |
| 密钥对 | example-keypair |
| 网络名称 | production-network1 |
14.1. 在环境中启动一个名为 production-server1 的实例。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack server create \
--image rhel7-web \
--flavor default \
--key-name example-keypair \
--nic net-id=production-network1 \
--wait production-server1
...output omitted...
|
14.2. 检查实例状态,确认其为 ACTIVE。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "production-server1",
|
操作界面、表格与配置图
1
2
3
4
5
6
| "Image": "rhel7-web",
"ID": "efb26df0-6fe3-490c-89ef-4889ed9f975c",
"Flavor": "default",
"Networks": "production-network1=192.168.1.N"
}
]
|
15. 作为 developer1 用户,创建浮动 IP。将浮动 IP 与 production-server1 相联系。
15.1. 从浮动 IP 池 provider-datacentre 创建浮动 IP 172.25.250.P。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(operator1-production)]$ openstack floating ip create \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-21T15:56:36Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.P |
| floating_network_id | f4b402ab-fe9f-4b4a-8dc5-495979133315 |
| id | 7404fea7-566b-4bd8-a636-d33319521f8b |
| name | 172.25.250.P |
| port_id | None |
| project_id | 5fe43cde6253439b88f2e16cfcb25ff9 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-21T15:56:36Z |
+---------------------+--------------------------------------+
|
15.2. 关联浮动 IP 到实例。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-server1 172.25.250.P
|
15.3. 确保IP 地址已成功指定。
1
2
3
4
5
6
7
8
9
10
11
| [student@workstation ~(operator1-production)]$ openstack server list -f json
[
{
"Status": "ACTIVE",
"Name": "production-server1",
"Image": "rhel7-web",
"ID": "efb26df0-6fe3-490c-89ef-4889ed9f975c",
"Flavor": "default",
"Networks": "production-network1=192.168.1.N, 172.25.250.P"
}
]
|
16. 使用 SSH 连接到实例并退出实例。
操作界面、表格与配置图
允许用几分钟完成 cloud-init 服务。
1
2
3
| [student@workstation ~(operator1-production)]$ ssh cloud-user@172.25.250.P
[cloud-user@production-server1 ~]$ exit
[student@workstation ~(operator1-production)]$
|
在 workstation 上运行 lab deploy-overcloud-lab grade,检查本实验是否成功。
1
| [student@workstation ~]$ lab deploy-overcloud-lab grade
|
在 workstation 上运行 lab deploy-overcloud-lab cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab deploy-overcloud-lab cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 导入 Director 部署计划是否已完成 Overcloud 部署?
- stackrc 与 Overcloud 用户 RC 文件为什么不能混用?
自测答案#
- 否,还要验证、分配角色并执行部署。导入、配置和部署是不同阶段。
- 对应不同管理层和认证上下文 Undercloud 部署管理与 Overcloud 业务资源管理不同。
C14-综合复习#
综合实验一:FTP 服务与持久数据#
创建项目用户、网络、路由、安全规则和密钥对,启动运行 FTP 的实例,附加卷作为上传目录。匿名上传、SELinux 配置和主动模式按访问策略执行。再卸载、分离并创建快照,从快照建卷,最后将图片保存到对象容器。
检查重点是服务能访问、文件确实上传、卷与快照中的数据对应、对象位置正确。不要把能连接 FTP 控制端口当成上传成功。
综合实验二:Web 服务#
在同样的身份和网络基础上,用用户数据定制 Web 实例。从 workstation 测试 HTTP。确认普通用户与管理员分工,安全组放行对应端口,实际服务已启动。
综合实验三:部署云平台与应用栈#
从 Director 模板和实验定制文件建立计划,部署 Overcloud,下载并整理管理员 RC 文件。创建后续栈需要的资源,按要求授予 heat_stack_owner,最后使用 review-template.yaml 和环境文件启动 review-stack,验证实例可访问。
实施顺序与验收记录#
- 保存前序练习结果,核对数据保留范围后重置实验环境。
- 建立资源清单:用户、项目、角色、镜像、规格、网络、子网、路由、安全组、密钥和实例。
- 先完成依赖资源,再启动实例或栈;每一步记下 UUID 和状态。
- 验证业务访问与数据,而不是只检查对象存在。
- 核对业务结果和数据内容,清理临时资源。
操作记录包括身份、节点、地址、关键输出、验证结果和清理状态。失败记录保留最初报错及修复依据,避免只留下最后一次成功截图。
综合实验实施图#
1
2
3
4
5
6
| 身份与配额
→ 镜像 / Flavor / Keypair
→ 私有网络 / 子网 / 路由 / 外部网络 / 安全组
→ 实例 + user-data
→ 浮动 IP + 应用访问
→ 持久卷 / 快照恢复 / 对象保存
|
FTP 与持久数据#
- 配置 FTP 软件、匿名上传目录和 SELinux;分清 FTP 控制连接与数据连接。
- 把新卷挂载到要求的数据目录,验证目录权限与应用写入。
- 实际上传文件,核对内容,然后卸载并分离卷。
- 建立快照与恢复卷,再挂载验证;将指定文件上传到对象容器。
Web 与初始化#
编写 user-data → 启动实例 → 核对 cloud-init 日志 → 核对 httpd → 从 workstation 读取页面。HTTP 返回成功但正文不符合要求,仍不算验收完成。
部署云平台与应用栈#
先完成 Director 部署并验证服务,再准备 Stack 所依赖的镜像、网络和角色。heat_stack_owner 按访问策略授权,不能用管理员成功执行代替目标用户验收。
综合验收#
| 目标 | 自己应能展示的证据 |
|---|
| 用户权限正确 | 目标用户的项目访问与角色分配 |
| 公共访问正常 | 浮动 IP、SSH 与业务请求 |
| 持久数据存在 | 卷分离 / 重挂载 / 快照恢复后的文件内容 |
| 初始化有效 | 软件包、配置、服务与日志 |
| 编排完成 | Stack 状态、失败事件排除、输出与业务 |
故障记录保留首次错误、修复依据和回归结果。
实验操作#
实验:综合实验:部署 FTP 服务器#
综合实验:部署 FTP 服务器#
在此审查中,在 OpenStack 中部署 FTP 服务器。
学习目标#
完成后能够:
开始之前#
开始前,保存此前练习中需要保留的数据。在 foundation 上以 kiosk 用户重置 Undercloud 与 Overcloud 节点组:
1
2
| [kiosk@foundation ~]$ rht-vmctl reset undercloud
[kiosk@foundation ~]$ rht-vmctl reset overcloud
|
一起重置 director、controller0、compute0、compute1 和 ceph0。classroom、workstation 和 power 不属于本次重置范围。director 同时重置,避免其数据库保留上一套 Overcloud 的管理状态。
设置用于此项练习的计算机,将其登录为 workstation 的 student , 并运行以下命令 :
1
| [student@workstation ~]$ lab compreview-s1 setup
|
操作说明:本综合实验部署 FTP 服务器,创建外部网络、项目网络、特权和普通用户,以及允许 FTP 的安全规则。为实例关联浮动 IP 以便外部访问,用卷存储 FTP 数据,最后在对象容器中保存伪文件夹和文件。
环境已经为您提供了以下资源:
配置环境以满足以下要求:
- 根据下列信息为 production 项目创建一个用户。
操作界面、表格与配置图
| 类型 | 值 |
|---|
| 用户项目 | production |
| 用户角色 | _member_和 swiftoperator |
| 特权用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | architect1 |
| 用户项目 | production |
| 用户角色 | admin |
| 项目网络设置 | |
|---|
| 网络对象 | 值 |
| 项目网络 | ◦ 名称:production-network1 项目:production |
| 项目子网 | ◦ 名称:production-subnet1 网络地址:192.168.1.0/24 ◦ DHCP 范围:192.168.1.2 至 192.168.1.254 ◦ DNS 服务器:172.25.250.254 ◦ DHCP:启用 ◦ IP 版本:IPv4 |
| 外部网络设置 | |
|---|
| 网络对象 | 值 |
| 外部网络 | ◦ 名称:provider-datacentre 外部网络:yes 分享:yes 提供者网络类型: flat 提供物理网络:datacentre |
| 外部子网 | ◦ 名称:provider-subnet-172.25.250 网络地址:172.25.250.0/24 ◦ 范围:172.25.250.101 至 172.25.250.189 ◦ 网关 IP:172.25.250.254 |
操作界面、表格与配置图
| 网络对象 | 值 |
|---|
| ◦ DNS 服务器:172.25.250.254 ◦ DHCP:禁用 ◦ IP 版本:IPv4 |
- 为 production 项目创建一个新的路由器。
| 路由器设置 | |
|---|
| 类型 | 值 |
| 路由器名称 | production-router1 |
| 外部网络 | provider-datacentre |
| 内部接口 | production-subnet1 子网 |
- 确定一个新的安全组,default, 由你附在实例中。安全组必须包含三个规则,即 SSH、ICMP 和 FTP 访问权限。
| 安全组设置 | |
|---|
| 类型 | 值 |
| 安全组名称 | default |
| 项目 | production |
| 安全组规则 | ◦ 来自所有网络的 SSH 流量(端口 22) ◦ 来自所有网络的 FTP 流量(端口范围 20:21) ◦ 来自所有网络的 ICMP 流量 |
| 实例设置 | | |
|---|
| 类型 | 值 | |
| 实例名称 | production-server1 | |
| 项目 | production | |
| 规格 | default | |
| 源镜像 | rhel7 | |
| 安全组 | default | |
| 密钥对 | example-keypair1 | |
| 网络 | production-network1 | |
| 自定义脚本 | | #cloud-config runcmd: - echo “Instance customized by cloud-init” > /etc/motd packages: |
操作界面、表格与配置图
| 卷设置 | |
|---|
| 类型 | 值 |
| 卷名 | production-volume1 |
| 项目 | production |
| 大小 | 1 GB |
| 分区设置(在实例内部操作) | ◦ 分区类型:主分区 ◦ 分区编号:1 ◦ 分区大小:整个磁盘 ◦ 文件系统格式:XFS ◦ 挂载点:/var/ftp/pub |
- 登录到 production-server1 实例,并配置 vsftpd 如下:
◦ 以 root 运行 setsebool -P ftpd_full_access on,配置 SELinux 允许完整 FTP 访问。
在 /etc/vsftpd/vsftpd.conf 结尾处添加 anon_upload_enable=YES, 允许 FTP 匿名上传。
◦ 以 root 运行 chown ftp:ftp /var/ftp/pub/,设置 FTP 上传目录的所有者。
◦ 以 root 运行 systemctl enable vsftpd ; systemctl restart vsftpd,启用并重启服务。
在 workstation 上安装 FTP 客户端( ftp 软件包提供此客户端 )。使用此 FTP 客户端测试您的服务器,在 pub 下存储文件。对于此测试,登录为 anonymous FTP 用户,禁用 passive 模式( passive 命令 )。
准备卷快照:在 production-server1 内卸载 production-volume1,再从实例分离该卷。创建名为 production-volume1-snap 的快照。
从 production-volume1-snap 快照中创建新卷名为 production-volume2。
将 production-volume1 和 production-volume2 两卷与 production-server1 案联系起来。
操作界面、表格与配置图
在 production-server1,在/var/ftp/pub 下装载 production-volume1 卷,并重新开始 vsftpd 服务。
在 production 项目中创建一个名为 production-container1 的容器,在该新容器中,将/usr/share/anaconda/pixmaps/sidebar-bg.png 文件储存在 pictures伪文件夹 中。
作为 workstation 上的 student 用户,使用 grade 参数运行 lab compreview-s1 脚本,以确认此操作是否成功。纠正任何报告的失败,重新运行脚本直到成功。
1
| [student@workstation ~]$ lab compreview-s1 grade
|
在 workstation 上运行 lab compreview-s1 cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab compreview-s1 cleanup
|
本实验到此结束。
操作界面、表格与配置图
在此审查中,在 OpenStack 中部署 FTP 服务器。
学习目标#
完成后能够:
开始之前#
开始前,保存此前练习中需要保留的数据。在 foundation 上以 kiosk 用户重置 Undercloud 与 Overcloud 节点组:
1
2
| [kiosk@foundation ~]$ rht-vmctl reset undercloud
[kiosk@foundation ~]$ rht-vmctl reset overcloud
|
一起重置 director、controller0、compute0、compute1 和 ceph0。classroom、workstation 和 power 不属于本次重置范围。director 同时重置,避免其数据库保留上一套 Overcloud 的管理状态。
设置用于此项练习的计算机,将其登录为 workstation 的 student , 并运行以下命令 :
1
| [student@workstation ~]$ lab compreview-s1 setup
|
操作说明:本综合实验部署 FTP 服务器,创建外部网络、项目网络、特权和普通用户,以及允许 FTP 的安全规则。为实例关联浮动 IP 以便外部访问,用卷存储 FTP 数据,最后在对象容器中保存伪文件夹和文件。
环境已经为您提供了以下资源:
配置环境以满足以下要求:
- 根据下列信息为 production 项目创建一个用户。
| 用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | operator1 |
| 用户项目 | production |
| 用户角色 | _member_和 swiftoperator |
操作界面、表格与配置图
| 特权用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | architect1 |
| 用户项目 | production |
| 用户角色 | admin |
| 项目网络设置 | |
|---|
| 网络对象 | 值 |
| 项目网络 | ◦ 名称:production-network1 项目:production |
| 项目子网 | ◦ 名称:production-subnet1 网络地址:192.168.1.0/24 ◦ DHCP 范围:192.168.1.2 至 192.168.1.254 ◦ DNS 服务器:172.25.250.254 ◦ DHCP:启用 ◦ IP 版本:IPv4 |
| 外部网络设置 | |
|---|
| 网络对象 | 值 |
| 外部网络 | ◦ 名称:provider-datacentre 外部网络:yes 分享:yes 提供者网络类型: flat 提供物理网络:datacentre |
| 外部子网 | ◦ 名称:provider-subnet-172.25.250 网络地址:172.25.250.0/24 ◦ 范围:172.25.250.101 至 172.25.250.189 ◦ 网关 IP:172.25.250.254 ◦ DNS 服务器:172.25.250.254 ◦ DHCP:禁用 |
操作界面、表格与配置图
- 为 production 项目创建一个新的路由器。
| 路由器设置 | |
|---|
| 类型 | 值 |
| 路由器名称 | production-router1 |
| 外部网络 | provider-datacentre |
| 内部接口 | production-subnet1 子网 |
- 确定一个新的安全组,default, 由你附在实例中。安全组必须包含三个规则,即 SSH、ICMP 和 FTP 访问权限。
| 安全组设置 | |
|---|
| 类型 | 值 |
| 安全组名称 | default |
| 项目 | production |
| 安全组规则 | ◦ 来自所有网络的 SSH 流量(端口 22) ◦ 来自所有网络的 FTP 流量(端口范围 20:21) ◦ 来自所有网络的 ICMP 流量 |
| 实例设置 | | |
|---|
| 类型 | 值 | |
| 实例名称 | production-server1 | |
| 项目 | production | |
| 规格 | default | |
| 源镜像 | rhel7 | |
| 安全组 | default | |
| 密钥对 | example-keypair1 | |
| 网络 | production-network1 | |
| 自定义脚本 | | #cloud-config runcmd: - echo “Instance customized by cloud-init” > /etc/motd packages: - vsftpd |
操作界面、表格与配置图
| 卷设置 | |
|---|
| 类型 | 值 |
| 卷名 | production-volume1 |
| 项目 | production |
| 大小 | 1 GB |
| 分区设置(在实例内部操作) | ◦ 分区类型:主分区 ◦ 分区编号:1 ◦ 分区大小:整个磁盘 ◦ 文件系统格式:XFS ◦ 挂载点:/var/ftp/pub |
- 登录到 production-server1 实例,并配置 vsftpd 如下:
◦ 以 root 运行 setsebool -P ftpd_full_access on,配置 SELinux 允许完整 FTP 访问。
在 /etc/vsftpd/vsftpd.conf 结尾处添加 anon_upload_enable=YES, 允许 FTP 匿名上传。
◦ 以 root 运行 chown ftp:ftp /var/ftp/pub/,设置 FTP 上传目录的所有者。
◦ 以 root 运行 systemctl enable vsftpd ; systemctl restart vsftpd,启用并重启服务。
在 workstation 上安装 FTP 客户端( ftp 软件包提供此客户端 )。使用此 FTP 客户端测试您的服务器,在 pub 下存储文件。对于此测试,登录为 anonymous FTP 用户,禁用 passive 模式( passive 命令 )。
准备卷快照:在 production-server1 内卸载 production-volume1,再从实例分离该卷。创建名为 production-volume1-snap 的快照。
从 production-volume1-snap 快照中创建新卷名为 production-volume2。
将 production-volume1 和 production-volume2 两卷与 production-server1 案联系起来。
在 production-server1,在/var/ftp/pub 下装载 production-volume1 卷,并重新开始 vsftpd 服务。
操作界面、表格与配置图
- 在 production 项目中创建一个名为 production-container1 的容器,在该新容器中,将/usr/share/anaconda/pixmaps/sidebar-bg.png 文件储存在 pictures伪文件夹 中。
1. 在 production 项目中创建 operator1 用户。
1.1.
用 source 加载 admin 环境文件,创建 operator1,并在 production 项目中授予 member 和 swiftoperator 角色。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$ openstack user create --project production \
--password redhat operator1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| domain_id | default |
| enabled | True |
| id | 7d063fb0138349948a2611956bafb868 |
| name | operator1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[student@workstation ~]$ openstack role add --project production \
--user operator1 _member_
[student@workstation ~]$ openstack role add --project production \
--user operator1 swiftoperator
|
1.2. 通过将 /home/student/admin-rc 文件复制到 /home/student/operator1-production-rc 并更新该文件,为新用户创建身份环境文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~]$ cp ~/admin-rc ~/operator1-production-rc
[student@workstation ~]$ vim ~/operator1-production-rc
export CLOUDPROMPT_ENABLED=0
export OS_NO_CACHE=True
export COMPUTE_API_VERSION=1.1
export OS_USERNAME=operator1
export no_proxy=,172.25.250.50,172.25.249.50
export OS_USER_DOMAIN_NAME=Default
export OS_VOLUME_API_VERSION=3
export OS_CLOUDNAME=overcloud
export OS_AUTH_URL=http://172.25.250.50:5000//v3
export NOVA_VERSION=1.1
export OS_IMAGE_API_VERSION=2
export OS_PASSWORD=redhat
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
export OS_PROJECT_NAME=production
export OS_AUTH_TYPE=password
export PYTHONWARNINGS="ignore:Certificate has no, ignore:A true SSLContext
object is not available"
export PS1='[\u@\h \W(operator1-production)]\$ '
|
操作界面、表格与配置图
1
2
3
4
5
6
| # Add OS_CLOUDNAME to PS1
if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then
export PS1=${PS1:-""}
export PS1=\${OS_CLOUDNAME:+"(\$OS_CLOUDNAME)"}\ $PS1
export CLOUDPROMPT_ENABLED=1
fi
|
注意上述屏幕中粗体字中提到的参数。
2. 在 production 项目中创建 architect1 特权用户。
2.1. 用 source 加载 admin 管理员账户的身份环境文件,创建 architect1 用户,并赋予用户 admin 在 production 项目中的角色。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$ openstack user create --project production \
--password redhat architect1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| domain_id | default |
| enabled | True |
| id | aa3b2365a3b947ef91b37aba64b31d91 |
| name | architect1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[student@workstation ~]$ openstack role add --project production \
--user architect1 admin
|
2.2. 通过将 /home/student/admin-rc 文件复制到 /home/student/architect1-production-rc 并更新该文件,为新用户创建身份环境文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~]$ cp ~/admin-rc ~/architect1-production-rc
[student@workstation ~]$ vim ~/architect1-production-rc
export CLOUDPROMPT_ENABLED=0
export OS_NO_CACHE=True
export COMPUTE_API_VERSION=1.1
export OS_USERNAME=architect1
export no_proxy=,172.25.250.50,172.25.249.50
export OS_USER_DOMAIN_NAME=Default
export OS_VOLUME_API_VERSION=3
export OS_CLOUDNAME=overcloud
export OS_AUTH_URL=http://172.25.250.50:5000//v3
export NOVA_VERSION=1.1
export OS_IMAGE_API_VERSION=2
export OS_PASSWORD=redhat
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
| export OS_PROJECT_NAME=production
export OS_AUTH_TYPE=password
export PYTHONWARNINGS="ignore:Certificate has no, ignore:A true SSLContext
object is not available"
export PS1='[\u@\h \W(architect1-production)]\$ '
# Add OS_CLOUDNAME to PS1
if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then
export PS1=${PS1:-""}
export PS1=\${OS_CLOUDNAME:+"(\$OS_CLOUDNAME)"}\ $PS1
export CLOUDPROMPT_ENABLED=1
fi
|
注意上述屏幕中粗体字中提到的参数。
3. 为 production 项目创建 production-network1 项目网络和 production-subnet1 子网。
3.1. 用 source 加载 operator1 账户的身份环境文件,并创建 production-network1 网络。
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
| [student@workstation ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$ openstack network create \
production-network1
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T10:37:57Z |
| description | |
| dns_domain | None |
| id | 7fdc48c7-6f12-4f00-8e70-b0db418ec8ee |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1450 |
| name | production-network1 |
| port_security_enabled | True |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| provider:network_type | None |
| provider:physical_network | None |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 3 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T10:37:57Z |
|
操作界面、表格与配置图
1
| +---------------------------+--------------------------------------+
|
3.2. 创建 production-subnet1 子网。
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
| [student@workstation ~(operator1-production)]$ openstack subnet create \
--subnet-range 192.168.1.0/24 \
--dhcp \
--allocation-pool start=192.168.1.2,end=192.168.1.254 \
--dns-nameserver 172.25.250.254 \
--network production-network1 \
production-subnet1
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.1.2-192.168.1.254 |
| cidr | 192.168.1.0/24 |
| created_at | 2018-06-21T10:42:00Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | True |
| gateway_ip | 192.168.1.1 |
| host_routes | |
| id | 754c622c-6258-4e88-940f-0ae30c39a1a2 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | production-subnet1 |
| network_id | 7fdc48c7-6f12-4f00-8e70-b0db418ec8ee |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T10:42:00Z |
+-------------------+--------------------------------------+
|
4. 创建外部 provider-datacentre 提供商网络和 provider-subnet-172.25.250 子网。
4.1. 用 source 加载 admin 管理员账户的身份环境文件,并创建 provider-datacentre 网络。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$ openstack network create \
--external \
--share \
--provider-network-type flat \
--provider-physical-network datacentre \
provider-datacentre
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T10:47:44Z |
| description | |
| dns_domain | None |
| id | 2256afc6-4c24-4942-b419-1d975d06d18a |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| | ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1500 |
| name | provider-datacentre |
| port_security_enabled | True |
| project_id | 50f29df5b0144794a4db5dad1eb12d9a |
| provider:network_type | flat |
| provider:physical_network | datacentre |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 6 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T10:47:45Z |
+---------------------------+--------------------------------------+
|
4.2. 创建 provider-subnet-172.25.250 子网。
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
| [student@workstation ~]$ openstack subnet create \
--no-dhcp \
--subnet-range 172.25.250.0/24 \
--gateway 172.25.250.254 \
--dns-nameserver 172.25.250.254 \
--allocation-pool start=172.25.250.101,end=172.25.250.189 \
--network provider-datacentre \
provider-subnet-172.25.250
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 172.25.250.101-172.25.250.189 |
| cidr | 172.25.250.0/24 |
| created_at | 2018-06-21T10:52:51Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | False |
| gateway_ip | 172.25.250.254 |
| host_routes | |
| id | 3cfac2f2-a200-4264-acfb-28f0e96d2c3d |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | provider-subnet-172.25.250 |
| network_id | 2256afc6-4c24-4942-b419-1d975d06d18a |
| project_id | 50f29df5b0144794a4db5dad1eb12d9a |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T10:52:51Z |
+-------------------+--------------------------------------+
|
5. 在 production 项目中创建 production-router1 路由器。连接到 production-subnet1 私有子网,并将其定义为 provider-datacentre 外部网络的网关。
操作界面、表格与配置图
5.1. 用 source 加载 operator1 账户的身份环境文件,并创建 production-router1 路由器。
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 ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$ openstack router create \
production-router1
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T11:36:01Z |
| description | |
| distributed | False |
| external_gateway_info | None |
| flavor_id | None |
| ha | False |
| id | 74cc9507-f70a-4e39-bd6c-1f3289e54b33 |
| name | production-router1 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| revision_number | 1 |
| routes | |
| status | ACTIVE |
| tags | |
| updated_at | 2018-06-21T11:36:01Z |
+-------------------------+--------------------------------------+
|
5.2. 连接 production-router1 路由器到 production-subnet1 私有子网。将其定义为 provider-datacentre 外部网络的网关。
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack router add subnet \
production-router1 production-subnet1
[student@workstation ~(operator1-production)]$ openstack router set \
--external-gateway provider-datacentre production-router1
|
6. 在 production 项目中定义 default 安全组。添加 SSH、 ICMP 和 FTP 的规则。
6.1. 创建 default 安全组。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ openstack security group \
create default
Error while executing command: HttpException: Unknown error, {"NeutronError":
{"message": "Default security group already exists.", "type":
"SecurityGroupDefaultAlreadyExists", "detail": ""}}
|
请注意,default 安全组已经存在,因为所有项目在创建时都有一个名为 default 的 default 安全组。
6.2. 将规则添加到安全组:
所有网络的 SSH 运输(端口 22)
所有网络的 FTP 流量(端口范围 20:21)
操作界面、表格与配置图
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
55
56
57
58
59
60
| [student@workstation ~(operator1-production)]$ openstack security group rule \
create --proto tcp --dst-port 22:22 default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T11:49:45Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 9e955c89-3835-4170-a61e-2e50d0176b20 |
| name | None |
| port_range_max | 22 |
| port_range_min | 22 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 694e9d59-1c53-40a8-82bf-11c5c169460d |
| updated_at | 2018-06-21T11:49:45Z |
+-------------------+--------------------------------------+
[student@workstation ~(operator1-production)]$ openstack security group rule \
create --proto tcp --dst-port 20:21 default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T11:50:55Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 792b9f3a-334c-4c1b-8cad-2ae77e425454 |
| name | None |
| port_range_max | 21 |
| port_range_min | 20 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 694e9d59-1c53-40a8-82bf-11c5c169460d |
| updated_at | 2018-06-21T11:50:55Z |
+-------------------+--------------------------------------+
[student@workstation ~(operator1-production)]$ openstack security group rule \
create --proto icmp default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T11:51:57Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | c5aa51d9-70b3-4c72-a7a6-95fe1997d433 |
| name | None |
| port_range_max | None |
| port_range_min | None |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| protocol | icmp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
|
操作界面、表格与配置图
1
2
3
| | security_group_id | 694e9d59-1c53-40a8-82bf-11c5c169460d |
| updated_at | 2018-06-21T11:51:57Z |
+-------------------+--------------------------------------+
|
7. 在 production 项目中创建 example-keypair1 密钥对。在 /home/student/.ssh/example-keypair1 中将私钥保存在 workstation 上并保护它。
1
2
3
| [student@workstation ~(operator1-production)]$ openstack keypair create \
example-keypair1 > ~/.ssh/example-keypair1
[student@workstation ~(operator1-production)]$ chmod 600 ~/.ssh/example-keypair1
|
8. 创建 cloud-init 定制脚本,在 production 项目中启动 production-server1 实例。
8.1. 在文件中创建定制脚本。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ vim ./script
#cloud-config
runcmd:
- echo "Instance customized by cloud-init" > /etc/motd
packages:
- vsftpd
|
注意缩进:只能使用空格,不能使用 Tab 制表符。语法错误可能导致实例配置错误。
8.2. 启动 production-server1 实例。
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 ~(operator1-production)]$ openstack server create \
--flavor default \
--image rhel7 \
--security-group default \
--key-name example-keypair1 \
--nic net-id=production-network1 \
--user-data ./script \
--wait \
production-server1
+-----------------------------+------------------------------------------------+
| Field | Value |
+-----------------------------+------------------------------------------------+
| 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-06-21T12:08:49.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | production-network1=192.168.1.P |
| adminPass | Mq9jyxVfgfiw |
| config_drive | |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| | created | 2018-06-21T12:08:03Z |
| flavor | default (f1821919-11ee-4a7f-804e-e01d0a996be8) |
| hostId | 7b05...0fee |
| id | 1a3ca00d-8d9c-44a1-848f-b392dfe0bd1a |
| image | rhel7 (ca945799-f778-45f0-938f-d72a998ee959) |
| key_name | example-keypair1 |
| name | production-server1 |
| progress | 0 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-21T12:08:49Z |
| user_id | 7d063fb0138349948a2611956bafb868 |
| volumes_attached | |
+-----------------------------+------------------------------------------------+
|
9. 从 provider-datacentre 网络中分配一个浮动 IP 地址并将其与 production-server1 实例连接。
9.1. 为 production 项目分配一个浮动 IP 地址。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(operator1-production)]$ openstack floating ip create \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-21T12:14:23Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.N |
| floating_network_id | 2256afc6-4c24-4942-b419-1d975d06d18a |
| id | 4000ad64-8295-4f56-8043-29fffef66781 |
| name | 172.25.250.N |
| port_id | None |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-21T12:14:23Z |
+---------------------+--------------------------------------+
|
注意您在上一个输出中的浮动 IP 地址 172.25.250.N。在以下步骤中使用它。
9.2. 与 production-server1 实例连接新的浮动 IP 地址。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-server1 172.25.250.N
|
9.3. 使用 openstack server show 命令来验证关联。
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack server show \
production-server1 -c addresses
+-----------+------------------------------------------------+
| Field | Value |
|
操作界面、表格与配置图
1
2
3
| +-----------+------------------------------------------------+
| addresses | production-network1=192.168.1.P, 172.25.250.N |
+-----------+------------------------------------------------+
|
10. 创建并附加 production-volume1 持久性卷到 production-server1 实例。登录到 production-server1 和分区、 格式和挂载新卷。
10.1. 创建 production-volume1 卷。
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 create \
--size 1 production-volume1
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2018-06-21T12:21:35.000000 |
| description | None |
| encrypted | False |
| id | 00532980-6f2a-401d-96a1-8767aee46177 |
| multiattach | False |
| name | production-volume1 |
| properties | |
| replication_status | None |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| type | None |
| updated_at | None |
| user_id | 7d063fb0138349948a2611956bafb868 |
+---------------------+--------------------------------------+
|
10.2. 等待卷状态变为 available,再将其附加到 production-server1。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list
+-------------+--------------------+-----------+------+-------------+
| ID | Name | Status | Size | Attached to |
+-------------+--------------------+-----------+------+-------------+
| 0053...6177 | production-volume1 | available | 1 | |
+-------------+--------------------+-----------+------+-------------+
[student@workstation ~(operator1-production)]$ openstack server add volume \
production-server1 production-volume1
|
10.3. 使用openstack volume list 命令再次验证您的工作。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name -c Status -c "Attached to"
+--------------------+--------+---------------------------------------------+
| Name | Status | Attached to |
+--------------------+--------+---------------------------------------------+
| production-volume1 | in-use | Attached to production-server1 on /dev/vdb |
+--------------------+--------+---------------------------------------------+
|
操作界面、表格与配置图
10.4. 以 cloud-user 通过 SSH 登录 production-server1,对 production-volume1 分区、格式化并挂载。完成后退出实例。
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
| [student@workstation ~(operator1-production)]$ ssh -i ~/.ssh/example-keypair1 \
cloud-user@172.25.250.N
Instance customized by cloud-init
[cloud-user@production-server1 ~]$ sudo -i
[root@production-server1 ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x24fcf997.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048): Enter
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): Enter
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@production-server1 ~]# mkfs.xfs /dev/vdb1
...output omitted...
[root@production-server1 ~]# mount /dev/vdb1 /var/ftp/pub
[root@production-server1 ~]# exit
[cloud-user@production-server1 ~]$ exit
[student@workstation ~(operator1-production)]$
|
11. 在 production-server1 上配置 vsftpd FTP 服务器。完成后,从 production-server1 中注销。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [student@workstation ~(operator1-production)]$ ssh -i ~/.ssh/example-keypair1 \
cloud-user@172.25.250.N
Instance customized by cloud-init
[cloud-user@production-server1 ~]$ sudo -i
[root@production-server1 ~]# setsebool -P ftpd_full_access on
[root@production-server1 ~]# echo anon_upload_enable=YES >> \
/etc/vsftpd/vsftpd.conf
[root@production-server1 ~]# chown -R ftp:ftp /var/ftp/pub
[root@production-server1 ~]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /
usr/lib/systemd/system/vsftpd.service.
[root@production-server1 ~]# systemctl restart vsftpd
[root@production-server1 ~]# exit
[cloud-user@production-server1 ~]$ exit
|
操作界面、表格与配置图
1
| [student@workstation ~(operator1-production)]$
|
12. 从 workstation 验证 FTP 服务器功能。
12.1. 在 workstation 上创建一个文本文件,例如 test_file.txt, 并添加一些内容。
1
2
| [student@workstation ~(operator1-production)]$ echo "This is my file" > \
test_file.txt
|
12.2. 安装获取 FTP 客户端的 ftp 软件包。
1
2
3
| [student@workstation ~(operator1-production)]$ sudo yum -y install ftp
[sudo] password for student: student
...output omitted...
|
12.3. 打开a FTP 会话到 FTP 服务器,禁用被动模式,并将您的 test_file.txt 文件存入 pub。完成后,关闭 FTP 会话。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| [student@workstation ~(operator1-production)]$ ftp 172.25.250.N
Connected to 172.25.250.N (172.25.250.N).
220 (vsFTPd 3.0.2)
Name (172.25.250.N:student): anonymous
331 Please specify the password.
Password: Enter
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> passive
Passive mode off.
ftp> cd pub
250 Directory successfully changed.
ftp> put test_file.txt
local: test_file.txt remote: test_file.txt
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
16 bytes sent in 5.6e-05 secs (285.71 Kbytes/sec)
ftp> quit
221 Goodbye.
[student@workstation ~(operator1-production)]$
|
13. 从 production-server1 卸载并卸除 production-volume1 卷,并截取卷的快照。速记名为 production-volume1-snap。
13.1. 登录到 production-server1 实例并卸载卷。完成后,从 production-server1 中注销。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ ssh -i ~/.ssh/example-keypair1 \
cloud-user@172.25.250.N
Instance customized by cloud-init
[cloud-user@production-server1 ~]$ sudo umount /var/ftp/pub
[cloud-user@production-server1 ~]$ exit
[student@workstation ~(operator1-production)]$
|
操作界面、表格与配置图
13.2. 分离production-volume1 卷并截取卷的快照。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~(operator1-production)]$ openstack server remove volume \
production-server1 production-volume1
[student@workstation ~(operator1-production)]$ openstack volume snapshot \
create --volume production-volume1 production-volume1-snap
+-------------+--------------------------------------+
| Field | Value |
+-------------+--------------------------------------+
| created_at | 2018-06-21T13:25:03.386367 |
| description | None |
| id | 84d977f9-ddd8-450a-9c93-99990a357c21 |
| name | production-volume1-snap |
| properties | |
| size | 1 |
| status | creating |
| updated_at | None |
| volume_id | 00532980-6f2a-401d-96a1-8767aee46177 |
+-------------+--------------------------------------+
|
13.3. 等待快照完成。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ openstack volume snapshot list
+-------------+-------------------------+-------------+-----------+------+
| ID | Name | Description | Status | Size |
+-------------+-------------------------+-------------+-----------+------+
| 84d9...7c21 | production-volume1-snap | None | available | 1 |
+-------------+-------------------------+-------------+-----------+------+
|
14. 从 production-volume1-snap 快照中创建 production-volume2 卷。等待卷创建完成。
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
| [student@workstation ~(operator1-production)]$ openstack volume create \
--snapshot production-volume1-snap production-volume2
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2018-06-21T13:29:08.000000 |
| description | None |
| encrypted | False |
| id | f64b9035-65d7-488f-b702-b2c7bde144fd |
| multiattach | False |
| name | production-volume2 |
| properties | |
| replication_status | None |
| size | 1 |
| snapshot_id | 84d977f9-ddd8-450a-9c93-99990a357c21 |
| source_volid | None |
| status | creating |
| type | None |
| updated_at | None |
| user_id | 7d063fb0138349948a2611956bafb868 |
+---------------------+--------------------------------------+
[student@workstation ~(operator1-production)]$ openstack volume list
+-------------+--------------------+-----------+------+-------------+
|
操作界面、表格与配置图
1
2
3
4
5
| | ID | Name | Status | Size | Attached to |
+-------------+--------------------+-----------+------+-------------+
| f64b...44fd | production-volume2 | available | 1 | |
| 0053...6177 | production-volume1 | available | 1 | |
+-------------+--------------------+-----------+------+-------------+
|
15. 将 production-volume1 和 production-volume2 两卷与 production-server1 案联系起来。
15.1. 在实例中添加卷数。
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack server add volume \
production-server1 production-volume1
[student@workstation ~(operator1-production)]$ openstack server add volume \
production-server1 production-volume2
|
15.2. 使用openstack volume list 命令来验证您的工作。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack volume list \
-c Name -c Status -c "Attached to"
+--------------------+--------+---------------------------------------------+
| Name | Status | Attached to |
+--------------------+--------+---------------------------------------------+
| production-volume2 | in-use | Attached to production-server1 on /dev/vdc |
| production-volume1 | in-use | Attached to production-server1 on /dev/vdb |
+--------------------+--------+---------------------------------------------+
|
16. 登录到 production-server1, 在 /var/ftp/pub 下挂载 production-volume1 卷。重新启动 vsftpd 服务,完成后从 production-server1 中退出。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(operator1-production)]$ ssh -i ~/.ssh/example-keypair1 \
cloud-user@172.25.250.N
Instance customized by cloud-init
[cloud-user@production-server1 ~]$ sudo -i
[root@production-server1 ~]# mount /dev/vdb1 /var/ftp/pub
[root@production-server1 ~]# systemctl restart vsftpd
[root@production-server1 ~]# exit
[cloud-user@production-server1 ~]$ exit
[student@workstation ~(operator1-production)]$
|
17. 在 production 项目中创建 production-container1 容器。在这一新容器中,将 /usr/share/anaconda/pixmaps/sidebar-bg.png 文件存储在 pictures 伪文件夹 中。
17.1. 创建 production-container1 容器
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack container create \
production-container1
+------------------+-----------------------+-------------+
| account | container | x-trans-id |
+------------------+-----------------------+-------------+
| AUTH_83aa...26da | production-container1 | txb3...aaa0 |
+------------------+-----------------------+-------------+
|
操作界面、表格与配置图
17.2. 准备存储为容器中对象的文件和文件夹。
1
2
3
| [student@workstation ~(operator1-production)]$ mkdir pictures
[student@workstation ~(operator1-production)]$ cp \
/usr/share/anaconda/pixmaps/sidebar-bg.png pictures
|
17.3. 将文件夹及其文件存放在 production-container1 容器中。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack object create \
production-container1 pictures/sidebar-bg.png
+-------------------------+-----------------------+-------------+
| object | container | etag |
+-------------------------+-----------------------+-------------+
| pictures/sidebar-bg.png | production-container1 | d88c...f32e |
+-------------------------+-----------------------+-------------+
|
作为 workstation 上的 student 用户,使用 grade 参数运行 lab compreview-s1 脚本,以确认此操作是否成功。纠正任何报告的失败,重新运行脚本直到成功。
1
| [student@workstation ~]$ lab compreview-s1 grade
|
在 workstation 上运行 lab compreview-s1 cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab compreview-s1 cleanup
|
本实验到此结束。
操作界面、表格与配置图
实验:综合实验:部署 Web 服务器#
综合实验:部署 Web 服务器#
在此审查中,在 OpenStack 中部署一个Web 服务器。
学习目标#
完成后能够:
开始之前#
开始前,保存此前练习中需要保留的数据。在 foundation 上以 kiosk 用户重置 Undercloud 与 Overcloud 节点组:
1
2
| [kiosk@foundation ~]$ rht-vmctl reset undercloud
[kiosk@foundation ~]$ rht-vmctl reset overcloud
|
一起重置 director、controller0、compute0、compute1 和 ceph0。classroom、workstation 和 power 不属于本次重置范围。director 同时重置,避免其数据库保留上一套 Overcloud 的管理状态。
设置用于此项练习的计算机,将其登录为 workstation 的 student , 并运行以下命令 :
1
| [student@workstation ~]$ lab compreview-s2 setup
|
操作说明:本综合实验部署 Web 服务器。创建外部网络、项目网络、特权用户和普通用户,以及允许 HTTP 访问的安全规则。给实例关联浮动 IP,提供外部连通性。
环境已经为您提供了以下资源:
配置环境以满足以下要求:
- 根据下列信息为 production 项目创建一个用户。
| 用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | operator1 |
| 用户项目 | production |
| 用户角色 | member |
操作界面、表格与配置图
| 特权用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | architect1 |
| 用户项目 | production |
| 用户角色 | admin |
| 项目网络设置 | |
|---|
| 网络对象 | 值 |
| 项目网络 | ◦ 名称:production-network1 项目:production |
| 项目子网 | ◦ 名称:production-subnet1 网络地址:192.168.1.0/24 ◦ DHCP 范围:192.168.1.2 至 192.168.1.254 ◦ DNS 服务器:172.25.250.254 ◦ DHCP:启用 ◦ IP 版本:IPv4 |
| 外部网络设置 | |
|---|
| 网络对象 | 值 |
| 外部网络 | ◦ 名称:provider-datacentre 外部网络:yes 分享:yes 提供者网络类型: flat 提供物理网络:datacentre |
| 外部子网 | ◦ 名称:provider-subnet-172.25.250 网络地址:172.25.250.0/24 ◦ 范围:172.25.250.101 至 172.25.250.189 ◦ 网关 IP:172.25.250.254 ◦ DNS 服务器:172.25.250.254 ◦ DHCP:禁用 ◦ IP 版本:IPv4 |
操作界面、表格与配置图
- 为 production 项目创建一个新的路由器。
| 路由器设置 | |
|---|
| 类型 | 值 |
| 路由器名称 | production-router1 |
| 外部网络 | provider-datacentre |
| 内部接口 | production-subnet1 子网 |
- 确定一个新的安全组,default, 由你附在实例中。安全组必须包含三个规则,即 SSH、ICMP 和 HTTP 访问权限。
| 安全组设置 | |
|---|
| 类型 | 值 |
| 安全组名称 | default |
| 项目 | production |
| 安全组规则 | ◦ 来自所有网络的 SSH 流量(端口 22) ◦ 来自所有网络的 HTTP 流量(端口 80) ◦ 来自所有网络的 ICMP 流量 |
| 实例设置 | | |
|---|
| 类型 | 值 | |
| 实例名称 | production-server1 | |
| 项目 | production | |
| 规格 | default | |
| 源镜像 | rhel7 | |
| 安全组 | default | |
| 密钥对 | example-keypair1 | |
| 网络 | production-network1 | |
| 自定义脚本 | | #!/bin/bash yum -y install httpd systemctl enable httpd –now cd /var/www/html echo “Hello World!” > index.html |
- 从 provider-datacentre 网络中分配一个浮动 IP 地址,并将其与 production-server1 实例联系起来。
操作界面、表格与配置图
作为 workstation 上的 student 用户,使用 grade 参数运行 lab compreview-s2 脚本,以确认此操作是否成功。纠正任何报告的失败,重新运行脚本直到成功。
1
| [student@workstation ~]$ lab compreview-s2 grade
|
在 workstation 上运行 lab compreview-s2 cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab compreview-s2 cleanup
|
本实验到此结束。
操作界面、表格与配置图
在此审查中,在 OpenStack 中部署一个Web 服务器。
学习目标#
完成后能够:
开始之前#
开始前,保存此前练习中需要保留的数据。在 foundation 上以 kiosk 用户重置 Undercloud 与 Overcloud 节点组:
1
2
| [kiosk@foundation ~]$ rht-vmctl reset undercloud
[kiosk@foundation ~]$ rht-vmctl reset overcloud
|
一起重置 director、controller0、compute0、compute1 和 ceph0。classroom、workstation 和 power 不属于本次重置范围。director 同时重置,避免其数据库保留上一套 Overcloud 的管理状态。
设置用于此项练习的计算机,将其登录为 workstation 的 student , 并运行以下命令 :
1
| [student@workstation ~]$ lab compreview-s2 setup
|
操作说明:本综合实验部署 Web 服务器。创建外部网络、项目网络、特权用户和普通用户,以及允许 HTTP 访问的安全规则。给实例关联浮动 IP,提供外部连通性。
环境已经为您提供了以下资源:
配置环境以满足以下要求:
- 根据下列信息为 production 项目创建一个用户。
| 用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | operator1 |
| 用户项目 | production |
| 用户角色 | member |
操作界面、表格与配置图
| 特权用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | architect1 |
| 用户项目 | production |
| 用户角色 | admin |
| 项目网络设置 | |
|---|
| 网络对象 | 值 |
| 项目网络 | ◦ 名称:production-network1 项目:production |
| 项目子网 | ◦ 名称:production-subnet1 网络地址:192.168.1.0/24 ◦ DHCP 范围:192.168.1.2 至 192.168.1.254 ◦ DNS 服务器:172.25.250.254 ◦ DHCP:启用 ◦ IP 版本:IPv4 |
| 外部网络设置 | |
|---|
| 网络对象 | 值 |
| 外部网络 | ◦ 名称:provider-datacentre 外部网络:yes 分享:yes 提供者网络类型: flat 提供物理网络:datacentre |
| 外部子网 | ◦ 名称:provider-subnet-172.25.250 网络地址:172.25.250.0/24 ◦ 范围:172.25.250.101 至 172.25.250.189 ◦ 网关 IP:172.25.250.254 ◦ DNS 服务器:172.25.250.254 ◦ DHCP:禁用 ◦ IP 版本:IPv4 |
操作界面、表格与配置图
- 为 production 项目创建一个新的路由器。
| 路由器设置 | |
|---|
| 类型 | 值 |
| 路由器名称 | production-router1 |
| 外部网络 | provider-datacentre |
| 内部接口 | production-subnet1 子网 |
- 确定一个新的安全组,default, 由你附在实例中。安全组必须包含三个规则,即 SSH、ICMP 和 HTTP 访问权限。
| 安全组设置 | |
|---|
| 类型 | 值 |
| 安全组名称 | default |
| 项目 | production |
| 安全组规则 | ◦ 来自所有网络的 SSH 流量(端口 22) ◦ 来自所有网络的 HTTP 流量(端口 80) ◦ 来自所有网络的 ICMP 流量 |
| 实例设置 | | |
|---|
| 类型 | 值 | |
| 实例名称 | production-server1 | |
| 项目 | production | |
| 规格 | default | |
| 源镜像 | rhel7 | |
| 安全组 | default | |
| 密钥对 | example-keypair1 | |
| 网络 | production-network1 | |
| 自定义脚本 | | #!/bin/bash yum -y install httpd systemctl enable httpd –now cd /var/www/html echo “Hello World!” > index.html |
- 从 provider-datacentre 网络中分配一个浮动 IP 地址,并将其与 production-server1 实例联系起来。
1. 在 production 项目中创建 operator1 用户。
操作界面、表格与配置图
1.1.
用 source 加载 admin 管理员账户的身份环境文件,创建 operator1 用户,并给予用户 member 在 production 项目中的角色。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$ openstack user create --project production \
--password redhat operator1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| domain_id | default |
| enabled | True |
| id | 7d063fb0138349948a2611956bafb868 |
| name | operator1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[student@workstation ~]$ openstack role add --project production \
--user operator1 _member_
|
1.2. 通过将 /home/student/admin-rc 文件复制到 /home/student/operator1-production-rc 并更新该文件,为新用户创建身份环境文件。
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
| [student@workstation ~]$ cp ~/admin-rc ~/operator1-production-rc
[student@workstation ~]$ vim ~/operator1-production-rc
export CLOUDPROMPT_ENABLED=0
export OS_NO_CACHE=True
export COMPUTE_API_VERSION=1.1
export OS_USERNAME=operator1
export no_proxy=,172.25.250.50,172.25.249.50
export OS_USER_DOMAIN_NAME=Default
export OS_VOLUME_API_VERSION=3
export OS_CLOUDNAME=overcloud
export OS_AUTH_URL=http://172.25.250.50:5000//v3
export NOVA_VERSION=1.1
export OS_IMAGE_API_VERSION=2
export OS_PASSWORD=redhat
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
export OS_PROJECT_NAME=production
export OS_AUTH_TYPE=password
export PYTHONWARNINGS="ignore:Certificate has no, ignore:A true SSLContext
object is not available"
export PS1='[\u@\h \W(operator1-production)]\$ '
# Add OS_CLOUDNAME to PS1
if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then
export PS1=${PS1:-""}
export PS1=\${OS_CLOUDNAME:+"(\$OS_CLOUDNAME)"}\ $PS1
export CLOUDPROMPT_ENABLED=1
fi
|
操作界面、表格与配置图
注意上述屏幕中粗体字中提到的参数。
2. 在 production 项目中创建 architect1 特权用户。
2.1. 用 source 加载 admin 管理员账户的身份环境文件,创建 architect1 用户,并赋予用户 admin 在 production 项目中的角色。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~]$ source ~/admin-rc
[student@workstation ~]$ openstack user create --project production \
--password redhat architect1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| domain_id | default |
| enabled | True |
| id | aa3b2365a3b947ef91b37aba64b31d91 |
| name | architect1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[student@workstation ~]$ openstack role add --project production \
--user architect1 admin
|
2.2. 通过将 /home/student/admin-rc 文件复制到 /home/student/architect1-production-rc 并更新该文件,为新用户创建身份环境文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~]$ cp ~/admin-rc ~/architect1-production-rc
[student@workstation ~]$ vim ~/architect1-production-rc
export CLOUDPROMPT_ENABLED=0
export OS_NO_CACHE=True
export COMPUTE_API_VERSION=1.1
export OS_USERNAME=architect1
export no_proxy=,172.25.250.50,172.25.249.50
export OS_USER_DOMAIN_NAME=Default
export OS_VOLUME_API_VERSION=3
export OS_CLOUDNAME=overcloud
export OS_AUTH_URL=http://172.25.250.50:5000//v3
export NOVA_VERSION=1.1
export OS_IMAGE_API_VERSION=2
export OS_PASSWORD=redhat
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
export OS_PROJECT_NAME=production
export OS_AUTH_TYPE=password
export PYTHONWARNINGS="ignore:Certificate has no, ignore:A true SSLContext
object is not available"
export PS1='[\u@\h \W(architect1-production)]\$ '
|
操作界面、表格与配置图
1
2
3
4
5
6
| # Add OS_CLOUDNAME to PS1
if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then
export PS1=${PS1:-""}
export PS1=\${OS_CLOUDNAME:+"(\$OS_CLOUDNAME)"}\ $PS1
export CLOUDPROMPT_ENABLED=1
fi
|
注意上述屏幕中粗体字中提到的参数。
3. 为 production 项目创建 production-network1 项目网络和 production-subnet1 子网。
3.1. 用 source 加载 operator1 账户的身份环境文件,并创建 production-network1 网络。
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
| [student@workstation ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$ openstack network create \
production-network1
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T10:37:57Z |
| description | |
| dns_domain | None |
| id | 7fdc48c7-6f12-4f00-8e70-b0db418ec8ee |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1450 |
| name | production-network1 |
| port_security_enabled | True |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| provider:network_type | None |
| provider:physical_network | None |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 3 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T10:37:57Z |
+---------------------------+--------------------------------------+
|
3.2. 创建 production-subnet1 子网。
1
2
| [student@workstation ~(operator1-production)]$ openstack subnet create \
--subnet-range 192.168.1.0/24 \
|
操作界面、表格与配置图
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
| --dns-nameserver 172.25.250.254 \
--dhcp \
--allocation-pool start=192.168.1.2,end=192.168.1.254 \
--network production-network1 \
production-subnet1
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.1.2-192.168.1.254 |
| cidr | 192.168.1.0/24 |
| created_at | 2018-06-21T10:42:00Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | True |
| gateway_ip | 192.168.1.1 |
| host_routes | |
| id | 754c622c-6258-4e88-940f-0ae30c39a1a2 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | production-subnet1 |
| network_id | 7fdc48c7-6f12-4f00-8e70-b0db418ec8ee |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T10:42:00Z |
+-------------------+--------------------------------------+
|
4. 创建外部 provider-datacentre 提供商网络和 provider-subnet-172.25.250 子网。
4.1. 用 source 加载 admin 管理员账户的身份环境文件,并创建 provider-datacentre 网络。
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 ~(operator1-production)]$ source ~/admin-rc
[student@workstation ~]$ openstack network create \
--external \
--share \
--provider-network-type flat \
--provider-physical-network datacentre \
provider-datacentre
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T10:47:44Z |
| description | |
| dns_domain | None |
| id | 2256afc6-4c24-4942-b419-1d975d06d18a |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1500 |
| name | provider-datacentre |
| port_security_enabled | True |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| | project_id | 50f29df5b0144794a4db5dad1eb12d9a |
| provider:network_type | flat |
| provider:physical_network | datacentre |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 6 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T10:47:45Z |
+---------------------------+--------------------------------------+
|
4.2. 创建 provider-subnet-172.25.250 子网。
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
| [student@workstation ~]$ openstack subnet create \
--no-dhcp \
--subnet-range 172.25.250.0/24 \
--gateway 172.25.250.254 \
--dns-nameserver 172.25.250.254 \
--allocation-pool start=172.25.250.101,end=172.25.250.189 \
--network provider-datacentre \
provider-subnet-172.25.250
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 172.25.250.101-172.25.250.189 |
| cidr | 172.25.250.0/24 |
| created_at | 2018-06-21T10:52:51Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | False |
| gateway_ip | 172.25.250.254 |
| host_routes | |
| id | 3cfac2f2-a200-4264-acfb-28f0e96d2c3d |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | provider-subnet-172.25.250 |
| network_id | 2256afc6-4c24-4942-b419-1d975d06d18a |
| project_id | 50f29df5b0144794a4db5dad1eb12d9a |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T10:52:51Z |
+-------------------+--------------------------------------+
|
5. 在 production 项目中创建 production-router1 路由器。连接到 production-subnet1 私有子网,并将其定义为 provider-datacentre 外部网络的网关。
5.1. 用 source 加载 operator1 账户的身份环境文件,并创建 production-router1 路由器。
1
| [student@workstation ~]$ source ~/operator1-production-rc
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [student@workstation ~(operator1-production)]$ openstack router create \
production-router1
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T11:36:01Z |
| description | |
| distributed | False |
| external_gateway_info | None |
| flavor_id | None |
| ha | False |
| id | 74cc9507-f70a-4e39-bd6c-1f3289e54b33 |
| name | production-router1 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| revision_number | 1 |
| routes | |
| status | ACTIVE |
| tags | |
| updated_at | 2018-06-21T11:36:01Z |
+-------------------------+--------------------------------------+
|
5.2. 连接 production-router1 路由器到 production-subnet1 私有子网。将其定义为 provider-datacentre 外部网络的网关。
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack router add subnet \
production-router1 production-subnet1
[student@workstation ~(operator1-production)]$ openstack router set \
--external-gateway provider-datacentre production-router1
|
6. 在 production 项目中定义 default 安全组。添加 SSH、 ICMP 和 HTTP 的规则。
6.1. 创建 default 安全组。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ openstack security group \
create default
Error while executing command: HttpException: Unknown error, {"NeutronError":
{"message": "Default security group already exists.", "type":
"SecurityGroupDefaultAlreadyExists", "detail": ""}}
|
请注意,default 安全组已经存在,因为所有项目在创建时都有一个名为 default 的 default 安全组。
6.2. 将规则添加到安全组:
所有网络的 SSH 运输(端口 22)
所有网络的 HTTP 运输(端口 80)
ICMP 所有网络的通信量
1
2
3
| [student@workstation ~(operator1-production)]$ openstack security group rule \
create --proto tcp --dst-port 22:22 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
| | Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T11:49:45Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 9e955c89-3835-4170-a61e-2e50d0176b20 |
| name | None |
| port_range_max | 22 |
| port_range_min | 22 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 694e9d59-1c53-40a8-82bf-11c5c169460d |
| updated_at | 2018-06-21T11:49:45Z |
+-------------------+--------------------------------------+
[student@workstation ~(operator1-production)]$ openstack security group rule \
create --proto tcp --dst-port 80:80 default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T11:50:55Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 792b9f3a-334c-4c1b-8cad-2ae77e425454 |
| name | None |
| port_range_max | 80 |
| port_range_min | 80 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 694e9d59-1c53-40a8-82bf-11c5c169460d |
| updated_at | 2018-06-21T11:50:55Z |
+-------------------+--------------------------------------+
[student@workstation ~(operator1-production)]$ openstack security group rule \
create --proto icmp default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T11:51:57Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | c5aa51d9-70b3-4c72-a7a6-95fe1997d433 |
| name | None |
| port_range_max | None |
| port_range_min | None |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| protocol | icmp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 694e9d59-1c53-40a8-82bf-11c5c169460d |
| updated_at | 2018-06-21T11:51:57Z |
+-------------------+--------------------------------------+
|
7. 在 production 项目中创建 example-keypair1 密钥对。在 /home/student/.ssh/example-keypair1 中将私钥保存在 workstation 上并保护它。
操作界面、表格与配置图
1
2
3
| [student@workstation ~(operator1-production)]$ openstack keypair create \
example-keypair1 > ~/.ssh/example-keypair1
[student@workstation ~(operator1-production)]$ chmod 600 ~/.ssh/example-keypair1
|
8. 创建自定义脚本并在 production 项目中启动 production-server1 实例。
8.1. 在文件中创建定制脚本。
1
2
3
4
5
6
| [student@workstation ~(operator1-production)]$ vim ./myscript
#!/bin/bash
yum -y install httpd
systemctl enable httpd --now
cd /var/www/html
echo "Hello World!" > index.html
|
8.2. 启动 production-server1 实例。
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
| [student@workstation ~(operator1-production)]$ openstack server create \
--flavor default \
--image rhel7 \
--security-group default \
--key-name example-keypair1 \
--nic net-id=production-network1 \
--user-data ./myscript \
--wait \
production-server1
+-----------------------------+------------------------------------------------+
| Field | Value |
+-----------------------------+------------------------------------------------+
| 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-06-21T12:08:49.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | production-network1=192.168.1.P |
| adminPass | Mq9jyxVfgfiw |
| config_drive | |
| created | 2018-06-21T12:08:03Z |
| flavor | default (f1821919-11ee-4a7f-804e-e01d0a996be8) |
| hostId | 7b05...0fee |
| id | 1a3ca00d-8d9c-44a1-848f-b392dfe0bd1a |
| image | rhel7 (ca945799-f778-45f0-938f-d72a998ee959) |
| key_name | example-keypair1 |
| name | production-server1 |
| progress | 0 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2018-06-21T12:08:49Z |
| user_id | 7d063fb0138349948a2611956bafb868 |
| volumes_attached | |
+-----------------------------+------------------------------------------------+
|
操作界面、表格与配置图
9. 从 provider-datacentre 网络中分配一个浮动 IP 地址并将其与 production-server1 实例连接。
9.1. 为 production 项目分配一个浮动 IP 地址。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~(operator1-production)]$ openstack floating ip create \
provider-datacentre
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2018-06-21T12:14:23Z |
| description | |
| fixed_ip_address | None |
| floating_ip_address | 172.25.250.N |
| floating_network_id | 2256afc6-4c24-4942-b419-1d975d06d18a |
| id | 4000ad64-8295-4f56-8043-29fffef66781 |
| name | 172.25.250.N |
| port_id | None |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| updated_at | 2018-06-21T12:14:23Z |
+---------------------+--------------------------------------+
|
注意您在上一个输出中的浮动 IP 地址 172.25.250.N。在以下步骤中使用它。
9.2. 与 production-server1 实例连接新的浮动 IP 地址。
1
2
| [student@workstation ~(operator1-production)]$ openstack server add \
floating ip production-server1 172.25.250.N
|
9.3. 使用 openstack server show 命令来验证关联。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack server show \
production-server1 -c addresses
+-----------+------------------------------------------------+
| Field | Value |
+-----------+------------------------------------------------+
| addresses | production-network1=192.168.1.P, 172.25.250.N |
+-----------+------------------------------------------------+
|
10. 使用 curl 命令从 workstation 测试您的Web 服务器。
1
2
| [student@workstation ~(operator1-production)]$ curl http://172.25.250.N
Hello World!
|
作为 workstation 上的 student 用户,使用 grade 参数运行 lab compreview-s2 脚本,以确认此操作是否成功。纠正任何报告的失败,重新运行脚本直到成功。
操作界面、表格与配置图
1
| [student@workstation ~]$ lab compreview-s2 grade
|
在 workstation 上运行 lab compreview-s2 cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab compreview-s2 cleanup
|
本实验到此结束。
操作界面、表格与配置图
实验:综合实验:部署 OpenStack 并启动应用栈#
综合实验:部署 OpenStack 并启动应用栈#
在此审查中,使用 director 网络 UI 部署 OpenStack 并启动一个编排应用栈。
学习目标#
完成后能够:
使用 Director 基础模板创建 Overcloud 计划目录,加入特定部署架构的计划环境文件。
使用 Web 界面导入 Overcloud 计划。
利用 director 网络 UI,部署 Red Hat OpenStack 平台。
为编排栈创造资源。
启动一个编排栈。
开始之前#
确认 workstation 和Overcloud的虚拟机启动
设置用于此项练习的计算机,将其登录为 workstation 的 student , 并运行以下命令 :
1
| [student@workstation ~]$ lab compreview-s3 setup
|
此命令 :
操作说明:本综合实验向 Director 导入 Overcloud 计划,使用一个控制节点和一个计算节点部署。完成后用编排模板部署应用栈,根据 CPU 利用率自动伸缩 Web 服务器。
环境已经为您提供了以下资源:
操作界面、表格与配置图
配置环境以满足以下要求:
将 director 的 /usr/share/openstack-tripleo-heat-templates 复制到 workstation 的 /home/student/overcloud-poc,并在该目录应用 http://materials.example.com/classroom-plan.tar.gz 中的定制内容。
更新/home/student/overcloud-poc 中自定义的 plan-environment.yaml 文件,强制将Overcloud admin 用户密码输入 redhat。为此,在 parameter_defaults 部分增加 AdminPassword: redhat。
使用 director 网络 UI, 导入 /home/student/overcloud-poc 目录提供的Overcloud计划。director 网络 UI 可在 https://director-ui.lab.example.com 使用 admin 作为用户名,redhat 作为访问密码。
确保将 1 个 Controller 角色和 1 个 Compute 角色分配给裸机节点。
部署Overcloud层:在Overcloud层部署过程完成后,应在 http://dashboard.overcloud.example.com 中提供Overcloud层 Red HatOpenStack 平台仪表板。在 workstation 中创建/home/student/admin-rc 中的 admin 身份环境文件。
创建后续部署自动伸缩栈所需的资源。先按下表在 Overcloud 创建规格。
| 规格设置 | |
|---|
| 类型 | 值 |
| 规格名称 | default-no-swap |
| RAM | 1024 MB |
| 根磁盘 | 10 GB |
| VCPU 数目 | 2 |
| 临时磁盘 | 0 |
| 交换 | 0 |
操作界面、表格与配置图
| 类型 | 值 |
|---|
| 公开 | yes |
| 最小磁盘大小 | 10 GB |
| 最小内存 | 1024 MB |
在 Overcloud 创建 production 项目。
在 Overcloud 创建 heat_stack_owner 角色。
根据下列信息为 production 项目创建一个用户。
| 用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | operator1 |
| 用户项目 | production |
| 用户角色 | member, heat_stack_owner |
| 特权用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | architect1 |
| 用户项目 | production |
| 用户角色 | admin |
| 外部网络设置 | |
|---|
| 网络对象 | 值 |
| 公共网络 | ◦ 名称:provider-datacentre 外部网络:yes 分享:yes 提供者网络类型: flat 提供物理网络:datacentre |
| 公共子网 | ◦ 名称:provider-subnet-172.25.250 网络地址:172.25.250.0/24 ◦ 范围:172.25.250.101 至 172.25.250.189 ◦ 网关 IP:172.25.250.254 ◦ DNS 服务器:172.25.250.254 ◦ DHCP:禁用 |
操作界面、表格与配置图
| 项目网络设置 | |
|---|
| 网络对象 | 值 |
| 项目网络 | ◦ 名称:production-network1 项目:production |
| 项目子网 | ◦ 名称:production-subnet1 网络地址:192.168.1.0/24 ◦ DHCP 范围:192.168.1.2 至 192.168.1.254 ◦ DHCP:启用 ◦ IP 版本:IPv4 |
- 为 production 项目创建一个新的路由器。
| 路由器设置 | |
|---|
| 类型 | 值 |
| 路由器名称 | production-router1 |
| 外部网络 | provider-datacentre |
| 内部接口 | production-subnet1 子网 |
- 确定一个新的安全组 default。安全组必须包含 SSH、ICMP 和 HTTP 准入的三项规则。
| 安全组设置 | |
|---|
| 类型 | 值 |
| 安全组名称 | default |
| 项目 | production |
| 安全组规则 | ◦ 来自所有网络的 SSH 流量(端口 22) ◦ 来自所有网络的 HTTP 流量(端口 80) ◦ 来自所有网络的 ICMP 流量 |
从 http://materials.example.com/heat/review-template.yaml 下载编排模板。使用环境文件启动 review-stack 编排堆栈。
操作界面、表格与配置图
使用 ssh 命令校验编排堆所启动的实例可从 workstation 进入。
作为 workstation 上的 student 用户,使用 grade 参数运行 lab compreview-s3 脚本,以确认此操作是否成功。纠正任何报告的失败,重新运行脚本直到成功。
1
| [student@workstation ~]$ lab compreview-s3 grade
|
在 workstation 上运行 lab compreview-s3 cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab compreview-s3 cleanup
|
本实验到此结束。
操作界面、表格与配置图
在此审查中,使用 director 网络 UI 部署 OpenStack 并启动一个编排应用栈。
学习目标#
完成后能够:
使用 Director 基础模板创建 Overcloud 计划目录,加入特定部署架构的计划环境文件。
使用 Web 界面导入 Overcloud 计划。
利用 director 网络 UI,部署 Red Hat OpenStack 平台。
为编排栈创造资源。
启动一个编排栈。
开始之前#
确认 workstation 和Overcloud的虚拟机启动
设置用于此项练习的计算机,将其登录为 workstation 的 student , 并运行以下命令 :
1
| [student@workstation ~]$ lab compreview-s3 setup
|
此命令 :
操作说明:本综合实验向 Director 导入 Overcloud 计划,使用一个控制节点和一个计算节点部署。完成后用编排模板部署应用栈,根据 CPU 利用率自动伸缩 Web 服务器。
环境已经为您提供了以下资源:
操作界面、表格与配置图
配置环境以满足以下要求:
将 director 的 /usr/share/openstack-tripleo-heat-templates 复制到 workstation 的 /home/student/overcloud-poc,并在该目录应用 http://materials.example.com/classroom-plan.tar.gz 中的定制内容。
更新/home/student/overcloud-poc 中自定义的 plan-environment.yaml 文件,强制将Overcloud admin 用户密码输入 redhat。为此,在 parameter_defaults 部分增加 AdminPassword: redhat。
使用 director 网络 UI, 导入 /home/student/overcloud-poc 目录提供的Overcloud计划。director 网络 UI 可在 https://director-ui.lab.example.com 使用 admin 作为用户名,redhat 作为访问密码。
确保将 1 个 Controller 角色和 1 个 Compute 角色分配给裸机节点。
部署Overcloud层:在Overcloud层部署过程完成后,应在 http://dashboard.overcloud.example.com 中提供Overcloud层 Red HatOpenStack 平台仪表板。在 workstation 中创建/home/student/admin-rc 中的 admin 身份环境文件。
创建后续部署自动伸缩栈所需的资源。先按下表在 Overcloud 创建规格。
| 规格设置 | |
|---|
| 类型 | 值 |
| 规格名称 | default-no-swap |
| RAM | 1024 MB |
| 根磁盘 | 10 GB |
| VCPU 数目 | 2 |
| 临时磁盘 | 0 |
| 交换 | 0 |
操作界面、表格与配置图
- 根据下列信息为 production 项目创建一个用户。
| 用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | operator1 |
| 用户项目 | production |
| 用户角色 | member, heat_stack_owner |
| 特权用户设置 | |
|---|
| 类型 | 值 |
| 用户名 | architect1 |
| 用户项目 | production |
| 用户角色 | admin |
| 外部网络设置 | |
|---|
| 网络对象 | 值 |
| 公共网络 | ◦ 名称:provider-datacentre 外部网络:yes 分享:yes 提供者网络类型: flat 提供物理网络:datacentre |
| 公共子网 | ◦ 名称:provider-subnet-172.25.250 网络地址:172.25.250.0/24 ◦ 范围:172.25.250.101 至 172.25.250.189 ◦ 网关 IP:172.25.250.254 ◦ DNS 服务器:172.25.250.254 ◦ DHCP:禁用 ◦ IP 版本:IPv4 |
| 项目网络设置 | |
|---|
| 网络对象 | 值 |
| 项目网络 | ◦ 名称:production-network1 项目:production |
操作界面、表格与配置图
| 网络对象 | 值 |
|---|
| 项目子网 | ◦ 名称:production-subnet1 网络地址:192.168.1.0/24 ◦ DHCP 范围:192.168.1.2 至 192.168.1.254 ◦ DHCP:启用 ◦ IP 版本:IPv4 |
- 为 production 项目创建一个新的路由器。
| 路由器设置 | |
|---|
| 类型 | 值 |
| 路由器名称 | production-router1 |
| 外部网络 | provider-datacentre |
| 内部接口 | production-subnet1 子网 |
- 确定一个新的安全组 default。安全组必须包含 SSH、ICMP 和 HTTP 准入的三项规则。
| 安全组设置 | |
|---|
| 类型 | 值 |
| 安全组名称 | default |
| 项目 | production |
| 安全组规则 | ◦ 来自所有网络的 SSH 流量(端口 22) ◦ 来自所有网络的 HTTP 流量(端口 80) ◦ 来自所有网络的 ICMP 流量 |
从 http://materials.example.com/heat/review-template.yaml 下载编排模板。使用环境文件启动 review-stack 编排堆栈。
使用 ssh 命令校验编排堆所启动的实例可从 workstation 进入。
1. 将 director 的 /usr/share/openstack-tripleo-heat-templates 复制到 workstation 的 /home/student/overcloud-poc;在该目录应用 http://materials.example.com/classroom-plan.tar.gz 中的定制内容。
1.1.
将 director 的 /usr/share/openstack-tripleo-heat-templates 目录复制到 workstation 的 /home/student/overcloud-poc。
操作界面、表格与配置图
1
2
3
4
| [student@workstation ~]$ scp -r \
stack@director:/usr/share/openstack-tripleo-heat-templates \
/home/student/overcloud-poc
...output omitted...
|
1.2. 在 /home/student/overcloud-poc 中下载并提取 http://materials.example.com/classroom-plan.tar.gz。
1
2
3
4
5
6
| [student@workstation ~]$ cd /home/student/overcloud-poc
[student@workstation overcloud-poc]$ wget \
http://materials.example.com/classroom-plan.tar.gz
...output omitted...
[student@workstation overcloud-poc]$ tar xvf classroom-plan.tar.gz
...output omitted...
|
2. 编辑 /home/student/overcloud-poc/plan-environment.yaml,在 parameter_defaults 下加入 AdminPassword: redhat,将 Overcloud 的 admin 密码设为 redhat。
1
2
3
4
5
6
7
8
| [student@workstation overcloud-poc]$ vim plan-environment.yaml
...output omitted...
parameter_defaults:
AdminPassword: redhat
NodeRootPassword: redhat
OvercloudComputeFlavor: baremetal
OvercloudControllerFlavor: baremetal
...output omitted...
|
注意缩进:只能用空格,不能用 Tab 制表符。语法错误可能导致 Overcloud 部署失败。
3. 使用 director Web UI 导入 /home/student/overcloud-poc 目录提供的Overcloud计划。director Web UI 可在 https://director-ui.lab.example.com 使用 admin 作为用户名和 redhat 作为访问密码。
3.1. 打开 https://director-ui.lab.example.com URL 访问 director Web UI。如果出现证书错误,请接受 自签名 证书。登录到 director UI 时,使用 admin 作为用户名和 redhat 作为密码。
3.2. 从“计划”标签中的 Red Hat OpenStack 平台 director Web UI 点击“计划”导入计划。
3.3. 在新计划选项卡中,输入 overcloud-poc 作为计划名称。
3.4. 选择本地文件夹为上传类型。
3.5. 单击浏览… 浏览并在 student 主目录中选择 overcloud-poc 目录。
操作界面、表格与配置图
3.6. 单击上传文件并创建计划。等到Overcloud计划文件上传并在 director 节点上创建计划。
4. 确保将 1 个 Controller 角色和 1 个 Compute 角色分配给裸机节点。
4.1. 从计划选项卡中单击 overcloud-poc 计划卡。网页显示部署 overcloud-poc 计划的四个步骤。
4.2. 在配置角色和指定节点区域,确保选择两个节点。一个被指定 Controller 角色,另一个被指定 Compute 角色。您可能需要等待几分钟才能显示任务。
5. 部署 overcloud。在 overcloud 部署进程完成后,在 workstation 上的 /home/student/admin-rc 创建 admin 身份环境文件。
5.1. 单击验证并部署以启动部署验证。
如果任何 pre-deployment 验证失败,就会出现警告信息。对于课堂部署,预料会发生。
5.2. 点击部署以启动Overcloud 部署。
5.3. 部署完成后,Deploy 部分显示访问 Overcloud 仪表板的 IP、用户名和密码。
1
2
3
4
| Overcloud information:
Overcloud IP address: 172.25.250.50
Username: admin
Password: redhat
|
5.4. 使用超叠 Red Hat OpenStack 平台仪表板下载 admin 身份环境文件。在浏览器中,使用 admin 用户和 redhat 密码登录到 http://dashboard.overcloud.example.com。
5.5. 打开 Project > API Access,选择 Download OpenStack RC File > OpenStack RC File (Identity API v3)。保存环境文件并退出仪表板。
5.6. 复制下载的文件到 /home/student/admin-rc 并编辑文件。
1
2
3
4
5
6
7
8
| [student@workstation overcloud-poc]$ cd
[student@workstation ~]$ cp ~/Downloads/admin-openrc.sh ~/admin-rc
[student@workstation ~]$ vim ~/admin-rc
...output omitted...
export OS_AUTH_URL=http://172.25.250.50:5000/v3
# With the addition of Keystone we have standardized on the term **project**
# as the entity that owns the resources.
#export OS_PROJECT_ID=9e5bda8d6661470ca2fce55326b0f50a
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
| export OS_PROJECT_NAME="admin"
export OS_USER_DOMAIN_NAME="Default"
...output omitted...
export OS_USERNAME="admin"
# With Keystone you pass the keystone password.
# echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as
user $OS_USERNAME: "
# read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=redhat
...output omitted...
|
注释掉 OS_PROJECT_ID 变量和交互询问密码的两行,再用 OS_PASSWORD 定义密码。
6. 在 Overcloud 创建 default-no-swap 规格。
6.1. 用 source 加载 admin 管理员账户的身份环境文件。
1
| [student@workstation ~]$ source ~/admin-rc
|
6.2. 创造 default-no-swap 的规格
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~]$ openstack flavor create default-no-swap \
--ram 1024 --vcpus 2 --disk 10 --swap 0 --ephemeral 0
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 10 |
| id | 87d1f723-b264-4f56-bc6c-04aca241ca99 |
| name | default-no-swap |
| os-flavor-access:is_public | True |
| properties | |
| ram | 1024 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 2 |
+----------------------------+--------------------------------------+
|
7. 从 http://materials.example.com/osp-web.qcow2 磁盘镜像创建 rhel7-web 公共镜像。
7.1.
下载镜像。
1
2
| [student@workstation ~]$ wget http://materials.example.com/osp-web.qcow2
...output omitted...
|
7.2. 创建 rhel7-web 镜像。
1
2
3
4
5
| [student@workstation ~]$ openstack image create \
--protected \
--public \
--min-disk 10 \
--min-ram 1024 \
|
操作界面、表格与配置图
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
| --disk-format qcow2 \
--file osp-web.qcow2 \
rhel7-web
+------------------+-------------------------------------------------------+
| Field | Value |
+------------------+-------------------------------------------------------+
| checksum | 0bd99215aa4360c02af6a291f0fa6b39e |
| container_format | bare |
| created_at | 2018-06-26T06:27:35Z |
| disk_format | qcow2 |
| file | /v2/images/0860d85f-29cb-4b64-94e6-598b9f620a4f/file |
| id | 0860d85f-29cb-4b64-94e6-598b9f620a4f |
| min_disk | 10 |
| min_ram | 1024 |
| name | rhel7-web |
| owner | 277a119da27344809451b271e3f7a5db |
| properties | direct_url='...' |
| protected | True |
| schema | /v2/schemas/image |
| size | 971636736 |
| status | active |
| tags | |
| updated_at | 2018-06-26T06:27:47Z |
| virtual_size | None |
| visibility | public |
+------------------+-------------------------------------------------------+
|
8. 在Overcloud中创建 production 项目。
1
2
3
4
5
6
7
8
9
10
11
12
13
| [student@workstation ~]$ openstack project create production
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | |
| domain_id | default |
| enabled | True |
| id | dba264c627b84094b468d19714fbab61 |
| is_domain | False |
| name | production |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
|
9. 在Overcloud中创建 heat_stack_owner 角色。
1
2
3
4
5
6
7
8
| [student@workstation ~]$ openstack role create heat_stack_owner
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| domain_id | default |
| id | cfgfd64c627b84094b468d19714fb413 |
| name | heat_stack_owner |
+-------------+----------------------------------+
|
10. 为 production 项目创建 operator1 用户。
10.1. 创建 operator1 用户,并给用户 member 和 heat_stack_owner 在 production 项目中的角色。
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [student@workstation ~]$ openstack user create --project production \
--password redhat operator1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| domain_id | default |
| enabled | True |
| id | 7d063fb0138349948a2611956bafb868 |
| name | operator1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[student@workstation ~]$ openstack role add --project production \
--user operator1 _member_
[student@workstation ~]$ openstack role add --project production \
--user operator1 heat_stack_owner
|
10.2. 创建通过将 /home/student/admin-rc 文件复制到 /home/student/operator1-production-rc 并更新该文件,为新用户提供身份环境文件。
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
| [student@workstation ~]$ cp ~/admin-rc ~/operator1-production-rc
[student@workstation ~]$ vim ~/operator1-production-rc
export CLOUDPROMPT_ENABLED=0
export OS_NO_CACHE=True
export COMPUTE_API_VERSION=1.1
export OS_USERNAME=operator1
export no_proxy=,172.25.250.50,172.25.249.50
export OS_USER_DOMAIN_NAME=Default
export OS_VOLUME_API_VERSION=3
export OS_CLOUDNAME=overcloud
export OS_AUTH_URL=http://172.25.250.50:5000//v3
export NOVA_VERSION=1.1
export OS_IMAGE_API_VERSION=2
export OS_PASSWORD=redhat
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
export OS_PROJECT_NAME=production
export OS_AUTH_TYPE=password
export PYTHONWARNINGS="ignore:Certificate has no, ignore:A true SSLContext
object is not available"
export PS1='[\u@\h \W(operator1-production)]\$ '
# Add OS_CLOUDNAME to PS1
if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then
export PS1=${PS1:-""}
export PS1=\${OS_CLOUDNAME:+"(\$OS_CLOUDNAME)"}\ $PS1
export CLOUDPROMPT_ENABLED=1
fi
|
操作界面、表格与配置图
注意上述屏幕中粗体字中提到的参数。
11. 在 production 项目中创建 architect1 特权用户。
11.1. 创建 architect1 用户,并给予用户 admin 在 production 项目中的角色。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [student@workstation ~]$ openstack user create --project production \
--password redhat architect1
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| default_project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| domain_id | default |
| enabled | True |
| id | aa3b2365a3b947ef91b37aba64b31d91 |
| name | architect1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[student@workstation ~]$ openstack role add --project production \
--user architect1 admin
|
11.2. 通过将 /home/student/admin-rc 文件复制到 /home/student/architect1-production-rc 并更新该文件,为新用户创建身份环境文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| [student@workstation ~]$ cp ~/admin-rc ~/architect1-production-rc
[student@workstation ~]$ vim ~/architect1-production-rc
export CLOUDPROMPT_ENABLED=0
export OS_NO_CACHE=True
export COMPUTE_API_VERSION=1.1
export OS_USERNAME=architect1
export no_proxy=,172.25.250.50,172.25.249.50
export OS_USER_DOMAIN_NAME=Default
export OS_VOLUME_API_VERSION=3
export OS_CLOUDNAME=overcloud
export OS_AUTH_URL=http://172.25.250.50:5000//v3
export NOVA_VERSION=1.1
export OS_IMAGE_API_VERSION=2
export OS_PASSWORD=redhat
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
export OS_PROJECT_NAME=production
export OS_AUTH_TYPE=password
export PYTHONWARNINGS="ignore:Certificate has no, ignore:A true SSLContext
object is not available"
export PS1='[\u@\h \W(architect1-production)]\$ '
|
操作界面、表格与配置图
1
2
3
4
5
6
| # Add OS_CLOUDNAME to PS1
if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then
export PS1=${PS1:-""}
export PS1=\${OS_CLOUDNAME:+"(\$OS_CLOUDNAME)"}\ $PS1
export CLOUDPROMPT_ENABLED=1
fi
|
注意上述屏幕中粗体字中提到的参数。
12. 创建公共 provider-datacentre 提供商网络和 provider-subnet-172.25.250 子网。
12.1. 使用 admin 环境文件创建公共 provider-datacentre 网络。
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
| [student@workstation ~]$ openstack network create \
--external \
--share \
--provider-network-type flat \
--provider-physical-network datacentre \
provider-datacentre
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T10:47:44Z |
| description | |
| dns_domain | None |
| id | 2256afc6-4c24-4942-b419-1d975d06d18a |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1500 |
| name | provider-datacentre |
| port_security_enabled | True |
| project_id | 50f29df5b0144794a4db5dad1eb12d9a |
| provider:network_type | flat |
| provider:physical_network | datacentre |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 6 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T10:47:45Z |
+---------------------------+--------------------------------------+
|
12.2. 创建provider-subnet-172.25.250 子网
1
| [student@workstation ~]$ openstack subnet create \
|
操作界面、表格与配置图
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
| --no-dhcp \
--subnet-range 172.25.250.0/24 \
--gateway 172.25.250.254 \
--dns-nameserver 172.25.250.254 \
--allocation-pool start=172.25.250.101,end=172.25.250.189 \
--network provider-datacentre \
provider-subnet-172.25.250
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 172.25.250.101-172.25.250.189 |
| cidr | 172.25.250.0/24 |
| created_at | 2018-06-21T10:52:51Z |
| description | |
| dns_nameservers | 172.25.250.254 |
| enable_dhcp | False |
| gateway_ip | 172.25.250.254 |
| host_routes | |
| id | 3cfac2f2-a200-4264-acfb-28f0e96d2c3d |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | provider-subnet-172.25.250 |
| network_id | 2256afc6-4c24-4942-b419-1d975d06d18a |
| project_id | 50f29df5b0144794a4db5dad1eb12d9a |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T10:52:51Z |
+-------------------+--------------------------------------+
|
13. 为 production 项目创建 production-network1 项目网络和 production-subnet1 子网。
13.1. 用 source 加载 operator1 账户的身份环境文件,并创建 production-network1 网络。
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-rc
[student@workstation ~(operator1-production)]$ openstack network create \
production-network1
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T10:37:57Z |
| description | |
| dns_domain | None |
| id | 7fdc48c7-6f12-4f00-8e70-b0db418ec8ee |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1450 |
| name | production-network1 |
| port_security_enabled | True |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| provider:network_type | None |
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
| | provider:physical_network | None |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 3 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-06-21T10:37:57Z |
+---------------------------+--------------------------------------+
|
13.2. 创建production-subnet1 子网
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
| [student@workstation ~(operator1-production)]$ openstack subnet create \
--subnet-range 192.168.1.0/24 \
--dhcp \
--allocation-pool start=192.168.1.2,end=192.168.1.254 \
--network production-network1 \
production-subnet1
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.1.2-192.168.1.254 |
| cidr | 192.168.1.0/24 |
| created_at | 2018-06-21T10:42:00Z |
| description | |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 192.168.1.1 |
| host_routes | |
| id | 754c622c-6258-4e88-940f-0ae30c39a1a2 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | production-subnet1 |
| network_id | 7fdc48c7-6f12-4f00-8e70-b0db418ec8ee |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2018-06-21T10:42:00Z |
+-------------------+--------------------------------------+
|
14. 在 production 项目中创建 production-router1 路由器。连接到 production-subnet1 私有子网,并将其定义为 provider-datacentre 外部网络的网关。
14.1. 用 source 加载 operator1 账户的身份环境文件,并创建 production-router1 路由器。
1
2
3
4
5
6
| [student@workstation ~]$ source ~/operator1-production-rc
[student@workstation ~(operator1-production)]$ openstack router create \
production-router1
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
|
操作界面、表格与配置图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| | admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-06-21T11:36:01Z |
| description | |
| distributed | False |
| external_gateway_info | None |
| flavor_id | None |
| ha | False |
| id | 74cc9507-f70a-4e39-bd6c-1f3289e54b33 |
| name | production-router1 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| revision_number | 1 |
| routes | |
| status | ACTIVE |
| tags | |
| updated_at | 2018-06-21T11:36:01Z |
+-------------------------+--------------------------------------+
|
14.2. 连接production-router1 进入 production-subnet1 私有子网路由器。将其定义为 provider-datacentre 外部网络的网关。
1
2
3
4
| [student@workstation ~(operator1-production)]$ openstack router add subnet \
production-router1 production-subnet1
[student@workstation ~(operator1-production)]$ openstack router set \
--external-gateway provider-datacentre production-router1
|
15. 在 production 项目中定义 default 安全组。添加 SSH、 ICMP 和 HTTP 的规则。
15.1. 创建 default 安全组。
1
2
3
4
5
| [student@workstation ~(operator1-production)]$ openstack security group \
create default
Error while executing command: HttpException: Unknown error, {"NeutronError":
{"message": "Default security group already exists.", "type":
"SecurityGroupDefaultAlreadyExists", "detail": ""}}
|
请注意,default 安全组已经存在,因为所有项目在创建时都有一个名为 default 的 default 安全组。
15.2. 添加安全组的规则:
所有网络的 SSH 运输(端口 22)
所有网络的 HTTP 运输(端口 80)
ICMP 所有网络的通信量
1
2
3
4
5
6
7
8
9
| [student@workstation ~(operator1-production)]$ openstack security group rule \
create --proto tcp --dst-port 22:22 default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T11:49:45Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
|
操作界面、表格与配置图
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
| | id | 9e955c89-3835-4170-a61e-2e50d0176b20 |
| name | None |
| port_range_max | 22 |
| port_range_min | 22 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 694e9d59-1c53-40a8-82bf-11c5c169460d |
| updated_at | 2018-06-21T11:49:45Z |
+-------------------+--------------------------------------+
[student@workstation ~(operator1-production)]$ openstack security group rule \
create --proto tcp --dst-port 80:80 default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T11:50:55Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 792b9f3a-334c-4c1b-8cad-2ae77e425454 |
| name | None |
| port_range_max | 80 |
| port_range_min | 80 |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 694e9d59-1c53-40a8-82bf-11c5c169460d |
| updated_at | 2018-06-21T11:50:55Z |
+-------------------+--------------------------------------+
[student@workstation ~(operator1-production)]$ openstack security group rule \
create --proto icmp default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-06-21T11:51:57Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | c5aa51d9-70b3-4c72-a7a6-95fe1997d433 |
| name | None |
| port_range_max | None |
| port_range_min | None |
| project_id | 83aaf87d7d0b4f49a27b7c7e597d26da |
| protocol | icmp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 694e9d59-1c53-40a8-82bf-11c5c169460d |
| updated_at | 2018-06-21T11:51:57Z |
+-------------------+--------------------------------------+
|
16. 在 production 项目中创建 example-keypair1 密钥对。在 /home/student/.ssh/example-keypair1 中将私钥保存在 workstation 上并保护它。
1
2
3
| [student@workstation ~(operator1-production)]$ openstack keypair create \
example-keypair1 > ~/.ssh/example-keypair1
[student@workstation ~(operator1-production)]$ chmod 600 ~/.ssh/example-keypair1
|
操作界面、表格与配置图
17. 部署编排栈以启动实例、验证 Overcloud。下载 http://materials.example.com/heat/review-template.yaml,结合环境文件启动 review-stack。
使用 ssh 命令校验编排堆所启动的实例可从 workstation 进入。
17.1. 从 http://materials.example.com/heat/review-template.yaml 下载编排模板。
1
2
3
| [student@workstation ~(operator1-production)]$ wget \
http://materials.example.com/heat/review-template.yaml
...output omitted...
|
17.2. 审查 review-template.yaml 文件并创建一个环境文件,/home/student/review-environment.yaml。
1
2
3
4
5
6
7
8
| parameters:
keypair: "example-keypair1"
image: "rhel7-web"
flavor: "default-no-swap"
instance_name: "production-server1"
external_network: "provider-datacentre"
internal_network: "production-network1"
internal_subnet: "production-subnet1"
|
17.3. 启动以 review-stack 命名的编排应用栈。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [student@workstation ~(operator1-production)]$ openstack stack create \
--environment ~/review-environment.yaml \
--template ~/review-template.yaml \
--wait review-stack
...output omitted...
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| id | 85407ca4-893a-4e83-b902-59373f58d7f7 |
| stack_name | review-stack |
| description | launching a custom instance |
| creation_time | 2018-06-28T08:34:30Z |
| updated_time | None |
| stack_status | CREATE_COMPLETE |
| stack_status_reason | Stack CREATE completed successfully |
+---------------------+--------------------------------------+
|
17.4. 查看 review-stack 应用栈的输出参数和值。
1
2
3
4
5
6
7
8
| [student@workstation ~(operator1-production)]$ openstack stack output list \
review-stack
+---------------------+-------------------------------------+
| output_key | description |
+---------------------+-------------------------------------+
| instance_private_ip | Private IP address of the instance |
| instance_public_ip | Public IP address of the instance |
+---------------------+-------------------------------------+
|
操作界面、表格与配置图
查看 instance_public_ip 输出参数的值。
1
2
3
4
5
6
7
8
9
| [student@workstation ~(developer1-finance)]$ openstack stack output show \
review-stack instance_public_ip
+--------------+--------------------------------------------+
| Field | Value |
+--------------+--------------------------------------------+
| description | Public IP address of the instance |
| output_key | instance_public_ip |
| output_value | 172.25.250.P |
+--------------+--------------------------------------------+
|
17.5. 列出环境中存在的示例,以检查 production-server1 实例的状态。
1
2
3
4
5
6
7
| [student@workstation ~(operator1-production)]$ openstack server list \
-c Name -c Status
+----------------------+--------+
| Name | Status |
+----------------------+--------+
| production-server1 | ACTIVE |
+----------------------+--------+
|
17.6. 验证 production-server1 可从 workstation 进入。
1
2
3
| [student@workstation ~(operator1-production)]$ ssh \
-i ~/.ssh/example-keypair1 cloud-user@172.25.250.P
[cloud-user@production-server1 ~]$
|
退出实例。
1
2
| [cloud-user@prduction-server1 ~]$ exit
[student@workstation ~(operator1-production)]$
|
作为 workstation 上的 student 用户,使用 grade 参数运行 lab compreview-s3 脚本,以确认此操作是否成功。纠正任何报告的失败,重新运行脚本直到成功。
1
| [student@workstation ~]$ lab compreview-s3 grade
|
在 workstation 上运行 lab compreview-s3 cleanup,清理本练习创建的资源。
1
| [student@workstation ~]$ lab compreview-s3 cleanup
|
本实验到此结束。
操作界面、表格与配置图
自测问题#
- 综合实验的完整验收应包含什么?
- 重新部署实验环境前应先做什么?
自测答案#
- 状态、服务访问及要求的数据验证。业务响应和数据证据构成完整验证。
- 保存需保留的数据和配置,再重置环境。重置会改变此前实验环境,需先保存工作。
命令索引#
| 要做的事 | 查阅章节 |
|---|
| 登录、查实例、启动停止 | C1、C6 |
| 用户、项目、角色、配额 | C2 |
| 网桥与接口 | C4 |
| 镜像、规格、私有网络 | C5 |
| 卷、快照、从卷启动 | C7 |
| 对象上传下载 | C8 |
| 外网、路由、安全组、SSH | C9–C10 |
| cloud-init | C11 |
| Heat、指标与伸缩 | C12 |
| Director 部署 | C13 |
| 综合验收 | C14 |