Nova组件详解
一、Nova组件概述
Nova 负责管理 Openstack 中云主机实例的创建、删除、启动、停止等,位于 Openstack 架构的中心,其他服务和组件对它提供支持。
计算节点通过Nova Computer进行虚拟机创建,通过libvirt调用kvm创建虚拟机,nova之间通信通过rabbitMQ队列进行通信。
1、作用
- Nova是OpenStack最核心的服务模块,负责管理和维护云计算环境的计算资源,负责整个云环境虚拟机生命周期的管理。
- Nova是OpenStack的计算服务,负责维护和管理的网络和存储,提供计算服务。
2、组件架构
Nova组件功能强大且结构复杂,由多种模块组成。模块分属若干单元,每个单元又是若干计算节点的集合。
3、模块功能介绍
Nova API
:负责接收和响应外部请求。支持Openstack API,EC2 API。外部访问Nova的唯一途径,接受外部请求并通过Message Queue将请求发送给其他的服务组件。
Nova Scheduler
:用于云主机调度,决策虚拟机创建应该创建在哪个计算节点上。决策一个虚拟机应该调度到某个物理节点上,需要两步:过滤,计算权值。
Nova Compute
:一般运行在计算节点上,通过Message Queue接收并管理KVM的生命周期,Nova compute通过libvirt管理 KVM,通过XenAPI管理Xen。管理虚机的核心服务,通过调用 Hypervisor API 实现虚机生命周期管理。
Hypervisor
:计算节点上跑的虚拟化管理程序,虚机管理最底层的程序。 不同虚拟化技术提供自己的 Hypervisor。常用的 Hypervisor 有 KVM,Xen, VMWare 等。
Nova Conductor
:计算节点访问数据库的中间件。nova-compute 经常需要更新数据库,比如更新虚机的状态。
出于安全性和伸缩性的考虑,nova-compute 并不会直接访问数据库,而是将这个任务委托给 nova-conductor。
Nova Consoleauth
:用于控制台的授权验证,需要打开vnc需要在Consoleauth进行授权认证。负责对访问虚机控制台请亲提供 Token 认证。
Nova Novncporxy
:提供一个代理,用于访问正在运行的实例。通过VNC协议,基于 Web 浏览器的 VNC 访问 。
Nova-spicehtml5proxy
:基于 HTML5 浏览器的 SPICE 访问
Nova-x***vncproxy
:基于 Java 客户端的 VNC 访问
Nova Cert
:服务器守护进程向Nova Cert服务提供X509证书。用来为euca-bundle-image生成证书。仅仅是在EC2 API的请求中使用。
消息队列
:在守护进程之间传递消息的中心。通常使用RabbitMQ实现,也可以使用另一个AMQP消息队列(如ZeroMQ)来实现。在前面我们了解到 Nova 包含众多的子服务,这些子服务之间需要相互协调和通信。 为解耦各个子服务,Nova 通过 Message Queue 作为子服务的信息中转站。
SQL数据库
:Nova 会有一些数据需要存放到数据库中。存储云主机在构建时和运行时的状态,为云基础设施,包括有:可用实例类型、使用中的实例、可用网络、项目。
4、基本工作流程
第1步,nova-api接收到用户通过管理界面或命令行发起的云主机创建请求,并将其发送到消息队列中。
第2步,nova-conductor从消息队列获得请求,从数据库获得如Cell单元的相关信息,再将请求和获得的数据放入消息队列。
第3步,nova-scheduler从消息队列获得请求和数据以后,与Placement组件配合选择创建云主机的物理机,选择完成后,请求转入消息队列等待nova-compute处理。
第4步,nova-compute从消息队列获得请求后,分别与Glance、Neutron和Cinder交互以获取镜像资源、网络资源和云存储资源。一切资源准备就绪后,nova-compute通过Hypervisor调用具体的虚拟化程序,如KVM、QEMU、Xen等,来创建虚拟机。
https://www.cnblogs.com/mh20131118/p/12939358.html
https://www.cnblogs.com/linuxk/p/9454258.html
二、Nova操作
1、安全组相关操作
(1)openstack命令行格式案例
openstack
# 安全组操作
security group create Create a new security group # 创建新安全组
security group delete Delete security group(s) # 删除安全组
security group list List security groups # 查看安全组列表
security group set Set security group properties # 修改安全组参数
security group show Display security group details # 查看安全组详情
security group unset Unset security group properties # 取消安全组参数设置
# 安全组规则操作
security group rule create Create a new security group rule # 创建安全组规则
security group rule delete Delete security group rule(s) # 删除安全组规则
security group rule list List security group rules # 查看安全组规则列表
security group rule show Display security group rule details # 查看安全组规则详情
# 安全组查看
[root@controller etc]# openstack security group list
+--------------------------------------+---------+------------------------+----------------------------------+------+
| ID | Name | Description | Project | Tags |
+--------------------------------------+---------+------------------------+----------------------------------+------+
| 28eef41f-54f8-4e99-b355-6799f2eedd2d | default | Default security group | 4188570a34464b938ed3fa7e08681df8 | [] |
| 63521bd0-623e-49aa-b25f-3d94ea4b1104 | default | Default security group | e3a549077f354998aa1a75677cfde62e | [] |
+--------------------------------------+---------+------------------------+----------------------------------+------+
# 安全组创建
[root@controller etc]# openstack security group create --description 'most great security group' my-secgroup
+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2022-11-30T09:28:13Z |
| description | most great security group |
| id | 5678ab2b-181a-4f20-a8c0-a047bcd8ecfa |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='4188570a34464b938ed3fa7e08681df8', project.name='admin', region_name='', zone= |
| name | my-secgroup |
| project_id | 4188570a34464b938ed3fa7e08681df8 |
| revision_number | 1 |
| rules | created_at='2022-11-30T09:28:13Z', direction='egress', ethertype='IPv6', id='19ad743b-f62c-4ccf-87ae-100691de0814', updated_at='2022-11-30T09:28:13Z' |
| | created_at='2022-11-30T09:28:13Z', direction='egress', ethertype='IPv4', id='c78c36c3-70a5-473f-85ba-ba17365f7621', updated_at='2022-11-30T09:28:13Z' |
| tags | [] |
| updated_at | 2022-11-30T09:28:13Z |
+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
# 安全组更新
[root@controller etc]# openstack security group set -h
usage: openstack security group set [-h] [--name <new-name>]
[--description <description>]
[--tag <tag>] [--no-tag]
<group>
Set security group properties
optional arguments:
-h, --help show this help message and exit
--name <new-name> New security group name # 安全组改名
--description <description> New security group description # 安全组新描述
--tag <tag> Tag to be added to the security group (repeat option to set multiple tags) # 添加标签
--no-tag Clear tags associated with the security group. Specify # 清理标签
both --tag and --no-tag to overwrite current tags
# 修改安全组名字和描述
[root@controller etc]# openstack security group set --name hqs-secgroup --description 'Be the CEO of your own life.' my-secgroup
# 删除安全组
[root@controller etc]# openstack security group delete hqs-secgroup
(2)nova命令行格式案例
nova
secgroup-add-default-rule Add a rule to the set of rules that will be
added to the 'default' security group for new
tenants (nova-network only).
secgroup-add-group-rule Add a source group rule to a security group.
secgroup-add-rule Add a rule to a security group.
secgroup-create Create a security group.
secgroup-delete Delete a security group.
secgroup-delete-default-rule
Delete a rule from the set of rules that will
be added to the 'default' security group for
new tenants (nova-network only).
secgroup-delete-group-rule Delete a source group rule from a security
group.
secgroup-delete-rule Delete a rule from a security group.
secgroup-list List security groups for the current tenant.
secgroup-list-default-rules
List rules that will be added to the 'default'
security group for new tenants.
secgroup-list-rules List rules for a security group.
secgroup-update Update a security group.
# 安全组查看:
[root@controller ~]# nova secgroup-list
+--------------------------------------+---------+------------------------+
| Id | Name | Description |
+--------------------------------------+---------+------------------------+
| 486eaa38-8e3d-4214-96bc-e6fee9b81be6 | default | Default security group |
+--------------------------------------+---------+------------------------+
# 安全组创建
[root@controller ~]# nova secgroup-create hqs 'Most great security group'
+--------------------------------------+------+---------------------------+
| Id | Name | Description |
+--------------------------------------+------+---------------------------+
| 1f2e9304-2fa0-45ac-a407-9816c72a1190 | hqs | Most great security group |
+--------------------------------------+------+---------------------------+
# 安全组更新
[root@controller ~]# nova secgroup-update 218faa36-c250-40d5-9775-534049e5771a hqs111 'One of the most great security group '
+--------------------------------------+--------+---------------------------------------+
| Id | Name | Description |
+--------------------------------------+--------+---------------------------------------+
| 218faa36-c250-40d5-9775-534049e5771a | hqs111 | One of the most great security group |
+--------------------------------------+--------+---------------------------------------+
# 安全组删除
[root@controller ~]# nova secgroup-delete hqs111
# 安全组规则查看
[root@controller ~]# nova secgroup-list-rules hqs
+-------------+-----------+---------+----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+----------+--------------+
+-------------+-----------+---------+----------+--------------+
[root@controller ~]# nova secgroup-list-rules default
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp | 1 | 65535 | 0.0.0.0/0 | |
| udp | 1 | 65535 | 0.0.0.0/0 | |
| icmp | -1 | -1 | 0.0.0.0/0 | |
| | | | | default |
| | | | | default |
+-------------+-----------+---------+-----------+--------------+
# 安全组规则添加
[root@controller ~]# nova secgroup-add-rule hqs icmp -1 -1 0.0.0.0/0
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| icmp | -1 | -1 | 0.0.0.0/0 | |
+-------------+-----------+---------+-----------+--------------+
[root@controller ~]# nova secgroup-add-rule hqs udp 1 65535 0.0.0.0/0
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| udp | 1 | 65535 | 0.0.0.0/0 | |
+-------------+-----------+---------+-----------+--------------+
[root@controller ~]# nova secgroup-add-rule hqs tcp 1 65535 0.0.0.0/0
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp | 1 | 65535 | 0.0.0.0/0 | |
+-------------+-----------+---------+-----------+--------------+
# 安全组规则删除
[root@controller ~]# nova secgroup-delete-rule hqs icmp -1 -1 0.0.0.0/0
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| icmp | -1 | -1 | 0.0.0.0/0 | |
+-------------+-----------+---------+-----------+--------------+
[root@controller ~]# nova secgroup-list-rules hqs
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| udp | 1 | 65535 | 0.0.0.0/0 | |
| tcp | 1 | 65535 | 0.0.0.0/0 | |
+-------------+-----------+---------+-----------+--------------+
2、云主机类型操作
云主机也称为实例,实例类型(Flavor)类似于云主机的虚拟硬件配置模板。
实例类型只能由具有Admin权限的用户管理。
(1)openstack命令行格式案例
# 常用操作
openstack
flavor create Create new flavor # 创建新实例类型
flavor delete Delete flavor(s) # 删除实例类型
flavor list List flavors # 查看实例类型列表
flavor set Set flavor properties # 设置实例类型参数
flavor show Display flavor details # 显示实例类型详情
flavor unset Unset flavor properties # 取消实例类型参数
# 创建实例类型
openstack flavor create
positional arguments:
<flavor-name> New flavor name
optional arguments:
--id <id> Unique flavor ID; 'auto' creates a UUID (default:auto) # 设置实例类型ID
--ram <size-mb> Memory size in MB (default 256M) # 设置内存大小,默认256M
--disk <size-gb> Disk size in GB (default 0G) # 设置硬盘大小
--ephemeral <size-gb> Ephemeral disk size in GB (default 0G) # 设置临时硬盘大小
--swap <size-mb> Additional swap space size in MB (default 0M) # 设置交换分区大小
--vcpus <vcpus> Number of vcpus (default 1) # 设置虚拟CPU个数
--public Flavor is available to other projects (default) # 公有的,可以被其他项目使用
--private Flavor is not available to other projects # 私有的,不能被其他项目使用
# 创建1核CPU、512M内存、1G硬盘的实例类型
[root@controller etc]# openstack flavor create --id auto --vcpus 1 --ram 512 --disk 1 m1.tiny
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 1 |
| id | dfc853ca-41fc-44b4-8d0a-a148bfb1376b |
| name | m1.tiny |
| os-flavor-access:is_public | True |
| properties | |
| ram | 512 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 1 |
+----------------------------+--------------------------------------+
# 查看当前实例类型列表
[root@controller etc]# openstack flavor list
+--------------------------------------+----------+-----+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+----------+-----+------+-----------+-------+-----------+
| aa3d8c9c-d553-4396-b8e9-73ac1df116d0 | m1.micro | 500 | 10 | 0 | 1 | True |
| dfc853ca-41fc-44b4-8d0a-a148bfb1376b | m1.tiny | 512 | 1 | 0 | 1 | True |
+--------------------------------------+----------+-----+------+-----------+-------+-----------
# 查看实例类型详情
[root@controller etc]# openstack flavor show m1.micro
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| access_project_ids | None |
| disk | 10 |
| id | aa3d8c9c-d553-4396-b8e9-73ac1df116d0 |
| name | m1.micro |
| os-flavor-access:is_public | True |
| properties | |
| ram | 500 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 1 |
+----------------------------+--------------------------------------+
# 删除实例类型
[root@controller etc]# openstack flavor delete m1.tiny
(2)nova命令行格式案例
nova
flavor-access-add Add flavor access for the given tenant.
flavor-access-list Print access information about the given
flavor.
flavor-access-remove Remove flavor access for the given tenant.
flavor-create Create a new flavor.
flavor-delete Delete a specific flavor
flavor-key Set or unset extra_spec for a flavor.
flavor-list Print a list of available 'flavors' (sizes of
servers).
flavor-show Show details about the given flavor.
# 云主机类型列表查看
[root@controller ~]# nova flavor-list
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1 | m1.tiny | 512 | 1 | 0 | | 1 | 1.0 | True |
| 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True |
| 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True |
| 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True |
| 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True |
| 7645393e-4f46-473a-85bf-6ea69669dac2 | m1-hqs | 512 | 10 | 0 | | 1 | 1.0 | True |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
# 云主机类型添加
[root@controller ~]# nova flavor-create m1.hqs 6 1024 10 1
+----+--------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+--------+-----------+------+-----------+------+-------+-------------+-----------+
| 6 | m1.hqs | 1024 | 10 | 0 | | 1 | 1.0 | True |
+----+--------+-----------+------+-----------+------+-------+-------------+-----------+
# 云主机类型详情查看
[root@controller ~]# nova flavor-show m1.hqs
+----------------------------+--------+
| Property | Value |
+----------------------------+--------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 10 |
| extra_specs | {} |
| id | 6 |
| name | m1.hqs |
| os-flavor-access:is_public | True |
| ram | 1024 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 1 |
+----------------------------+--------+
# 云主机类型删除
[root@controller ~]# nova flavor-delete m1-hqs
3、云主机实例操作
(1)openstack命令行格式案例
# 语法
openstack
server create Create a new server # 创建云主机
server delete Delete server(s) # 删除云主机
server start Start server(s). # 开启云主机
server stop Stop server(s). # 关闭云主机
server list List servers # 查看云主机列表
server show Show server details. # 查看云主机详情
server ssh SSH to server # ssh连接云主机
server migrate Migrate server to different host # 云主机迁移
server resize Scale server to a new flavor. # 调整云主机规格
server lock Lock server(s). # 锁定云主机
server unlock Unlock server(s) # 解锁云主机
server pause Pause server(s) # 暂停云主机
server unpause Unpause server(s) # 取消暂停云主机
server reboot Perform a hard or soft server reboot # 重启云主机
server restore Restore server(s) # 还原云主机
server rebuild Rebuild server # 重建云主机
server rescue Put server in rescue mode # 修复云主机
server unrescue Restore server from rescue mode # 取消修复云主机
server suspend Suspend server(s) # 挂起云主机,当前状态保存在磁盘中
server resume Resume server(s) # 取消挂起云主机
server set Set server properties # 设置云主机参数
server unset Unset server properties # 取消云主机参数设置
server shelve Shelve server(s) # 搁置云主机
server unshelve Unshelve server(s) # 取消搁置云主机
# 创建云主机语法
openstack server create [--option...] <server-name>
optional arguments:
--image <image> Create server boot disk from this image (name or ID)
--volume <volume> Create server using this volume as the boot disk (name or ID).
--flavor <flavor> Create server with this flavor (name or ID)
--security-group <security-group> # 创建云主机用到的安全组(名字或ID)
--availability-zone <zone-name> # 指定可用域
--host <host> Requested host to create servers. # 指定服务器创建云主机
--nic <net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,port-id=port-uuid,auto,none>
Create a NIC on the server. # 设置云主机网络属性net-id云主机网络;v4-fixed-ip:绑定的IP地址等等
--network <network> Create a NIC on the server and connect it to network. # 云主机连接的网络
--port <port> Create a NIC on the server and connect it to port. # 云主机连接的端口
--key-name <key-name> # 密钥注入云主机
# 创建云主机实例
[root@controller ~]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 7096885c-0a58-4086-8014-b92affceb0e8 | cirros | active |
+--------------------------------------+--------+--------+
[root@controller ~]# openstack flavor list
+--------------------------------------+----------+-----+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+----------+-----+------+-----------+-------+-----------+
| aa3d8c9c-d553-4396-b8e9-73ac1df116d0 | m1.micro | 500 | 10 | 0 | 1 | True |
+--------------------------------------+----------+-----+------+-----------+-------+-----------
[root@controller ~]# openstack server create --image cirros \
--flavor m1.micro \
--network vm-network \
VM_host
+-------------------------------------+-------------------------------------------------+
| Field | Value |
+-------------------------------------+-------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | None |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | |
| OS-EXT-STS:power_state | NOSTATE |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | None |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | |
| adminPass | X8RPvNvV77xN |
| config_drive | |
| created | 2022-12-02T08:20:59Z |
| flavor | m1.micro (aa3d8c9c-d553-4396-b8e9-73ac1df116d0) |
| hostId | |
| id | bdcc43ed-bf29-4d80-b3a6-9c9791047ed0 |
| image | cirros (7096885c-0a58-4086-8014-b92affceb0e8) |
| key_name | None |
| name | VM_host |
| progress | 0 |
| project_id | 4188570a34464b938ed3fa7e08681df8 |
| properties | |
| security_groups | name='default' |
| status | BUILD |
| updated | 2022-12-02T08:20:59Z |
| user_id | f4f16d960e0643d7b5a35db152c87dae |
| volumes_attached | |
+-------------------------------------+-------------------------------------------------+
# 查看已有的云主机列表
[root@controller ~]# openstack server list
+--------------------------------------+---------+--------+---------------------------+--------+----------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+---------+--------+---------------------------+--------+----------+
| bdcc43ed-bf29-4d80-b3a6-9c9791047ed0 | VM_host | ACTIVE | vm-network=192.168.20.158 | cirros | m1.micro |
+--------------------------------------+---------+--------+---------------------------+--------+----------+
# 重启云主机
# 软重启:尝试正常关机并重启云主机
[root@controller ~]# openstack server reboot VM_host
# 硬重启:直接将云主机“断电”并重启
[root@controller ~]# openstack server reboot VM_host --hard
# 暂停云主机
# 暂停:将云主机当前状态存入内存,并停用云主机。
[root@controller ~]# openstack server pause VM_host
[root@controller ~]# openstack server list
+--------------------------------------+---------+--------+---------------------------+--------+----------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+---------+--------+---------------------------+--------+----------+
| bdcc43ed-bf29-4d80-b3a6-9c9791047ed0 | VM_host | PAUSED | vm-network=192.168.20.158 | cirros | m1.micro |
+--------------------------------------+---------+--------+---------------------------+--------+----------+
# 暂停后可取消暂停,将云主机恢复到暂停前的状态并启用。
[root@controller ~]# openstack server unpause VM_host
# 挂起云主机
# 挂起:将云主机当前状态存放到磁盘中,并停用云主机。
[root@controller ~]# openstack server suspend VM_host
[root@controller ~]# openstack server list
+--------------------------------------+---------+-----------+---------------------------+--------+----------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+---------+-----------+---------------------------+--------+----------+
| bdcc43ed-bf29-4d80-b3a6-9c9791047ed0 | VM_host | SUSPENDED | vm-network=192.168.20.158 | cirros | m1.micro |
+--------------------------------------+---------+-----------+---------------------------+--------+----------+
# 挂起后可取消挂起,将云主机恢复到挂起前的状态并启用。
[root@controller ~]# openstack server resume VM_host
# 关闭云主机
[root@controller ~]# openstack server stop VM_host
[root@controller ~]# openstack server list
+--------------------------------------+---------+---------+---------------------------+--------+----------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+---------+---------+---------------------------+--------+----------+
| bdcc43ed-bf29-4d80-b3a6-9c9791047ed0 | VM_host | SHUTOFF | vm-network=192.168.20.158 | cirros | m1.micro |
+--------------------------------------+---------+---------+---------------------------+--------+----------+
# 启动云主机
[root@controller ~]# openstack server start VM_host
[root@controller ~]# openstack server list
+--------------------------------------+---------+--------+---------------------------+--------+----------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+---------+--------+---------------------------+--------+----------+
| bdcc43ed-bf29-4d80-b3a6-9c9791047ed0 | VM_host | ACTIVE | vm-network=192.168.20.158 | cirros | m1.micro |
+--------------------------------------+---------+--------+---------------------------+--------+----------+
# 重建云主机
# 如果云主机出现故障,可以用重建操作还原云主机。
# 连接云主机并创文件
[root@compute ~]# ssh cirros@192.168.20.158
cirros@192.168.20.158 password: gocubsgo
$ touch ttt
$ touch adadw2dads
$ ls
adadw2dads ttt
$ exit
# 重建云主机
[root@controller ~]# openstack server rebuild VM_host --image cirros
+-------------------+----------------------------------------------------------+
| Field | Value |
+-------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| accessIPv4 | |
| accessIPv6 | |
| addresses | vm-network=192.168.20.158 |
| adminPass | moKnvy9KkLFu |
| created | 2022-12-02T08:20:59Z |
| flavor | m1.micro (aa3d8c9c-d553-4396-b8e9-73ac1df116d0) |
| hostId | 49461bf9735b793190cb0fd91333233e7cea03174a465537f092e75e |
| id | bdcc43ed-bf29-4d80-b3a6-9c9791047ed0 |
| image | cirros (7096885c-0a58-4086-8014-b92affceb0e8) |
| name | VM_host |
| progress | 0 |
| project_id | 4188570a34464b938ed3fa7e08681df8 |
| properties | |
| status | REBUILD |
| updated | 2022-12-02T09:15:46Z |
| user_id | f4f16d960e0643d7b5a35db152c87dae |
+-------------------+----------------------------------------------------------+
# 重联云主机——重建的文件都已经清空
# 重联时地址没变但主机已经变了,需要将这个地址从已知地址中删除才能ssh联上
[root@compute ~]# vi /root/.ssh/known_hosts # 删除192.168.20.158对应的秘钥信息
[root@compute ~]# ssh cirros@192.168.20.158
Are you sure you want to continue connecting (yes/no)? yes
cirros@192.168.20.158 password:
$ ls
$ pwd
/home/cirros
# 删除云主机
[root@controller ~]# openstack server delete VM_host
(2)nova命令行格式案例
# 实例列表查看
nova list
# 实例详情查看
nova show <server>
# 实例创建
nova boot <实例名称>
# 可选参数:
--flavor <flavor> 虚拟机类型
--image <image> 可选用的镜像
--image-with <key=value> 镜像的元数据属性
--boot-volume <volume_id> 启动逻辑卷的ID
--snapshot <snapshot_id> 快照.
--min-count <number> Boot at least <number> servers (limited by
quota).
--max-count <number> Boot up to <number> servers (limited by
quota).
--meta <key=value> 元数据Record arbitrary key/value metadata to
/meta_data.json on the metadata server. Can be
specified multiple times.
--file <dst-path=src-path> 文件Store arbitrary files from <src-path> locally
to <dst-path> on the new server. Limited by
the injected_files quota value.
--key-name <key-name> 密钥名称Key name of keypair that should be created
earlier with the command keypair-add.
--user-data <user-data> 注入的用户数据user data file to pass to be exposed by the
metadata server.
--availability-zone <availability-zone>
可用域The availability zone for server placement.
--security-groups <security-groups>
安全组Comma separated list of security group names.
--block-device-mapping <dev-name=mapping>
块存储格式化Block device mapping in the format <dev-
name>=<id>:<type>:<size(GB)>:<delete-on-
terminate>.
--block-device key1=value1[,key2=value2...] 块设备参数
--swap <swap_size> 交换空间大小Create and attach a local swap block device of
<swap_size> MB.
--ephemeral size=<size>[,format=<format>]
连接块存储的大小Create and attach a local ephemeral block
device of <size> GB and format it to <format>.
--hint <key=value> 自定义数据Send arbitrary key/value pairs to the
scheduler for custom use.
--nic <net-id=net-uuid,net-name=network-name,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,port-id=port-uuid>
配置网络Create a NIC on the server. Specify option
multiple times to create multiple NICs. net-
id: attach NIC to network with this UUID net-
name: attach NIC to network with this name
(either port-id or net-id or net-name must be
provided), v4-fixed-ip: IPv4 fixed address for
NIC (optional), v6-fixed-ip: IPv6 fixed
address for NIC (optional), port-id: attach
NIC to port with this UUID (either port-id or
net-id must be provided).
--config-drive <value> 驱动配置Enable config drive.
--poll 显示创建进度Report the new server boot progress until it
completes.
--admin-pass <value> Admin password for the instance.
--access-ip-v4 <value> Alternative access IPv4 of the instance.
--access-ip-v6 <value> Alternative access IPv6 of the instance.
--description <description> Description for the server. (Supported by API
versions '2.19' - '2.latest')
# 1、查看镜像
glance image-list
# 2、查看规格
nova flavor-list
# 3、查看安全组
nova secgroup-list
# 4、查看可用的网络
neutron net-list
nova boot \
--image centos7.2 \
--availability-zone nova \
--flavor m1.hqs \
--security-groups hqs \
--nic net-id=64306052-bcec-4209-ac4c-45b9d2de4dde \
caocao-server1
# 5、实例创建
[root@controller images]# nova boot test-server --image centos7.2 --flavor m1.lxh --availability-zone nova --security-groups hqs --nic net-id=451fd2af-e1eb-4437-bf71-53b5f91c10b5
+--------------------------------------+--------------------------------------------------+
| Property | Value |
+--------------------------------------+--------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | - |
| OS-EXT-SRV-ATTR:hostname | test-server |
| OS-EXT-SRV-ATTR:hypervisor_hostname | - |
| OS-EXT-SRV-ATTR:instance_name | instance-0000000d |
| OS-EXT-SRV-ATTR:kernel_id | |
| OS-EXT-SRV-ATTR:launch_index | 0 |
| OS-EXT-SRV-ATTR:ramdisk_id | |
| OS-EXT-SRV-ATTR:reservation_id | r-zoria5fn |
| OS-EXT-SRV-ATTR:root_device_name | - |
| OS-EXT-SRV-ATTR:user_data | - |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | - |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | ejFD96k8DUkW |
| config_drive | |
| created | 2021-10-19T02:09:45Z |
| description | - |
| flavor | m1.lxh (111) |
| hostId | |
| host_status | |
| id | 22d0a54b-2a6f-4ea8-8729-dc07055c19e5 |
| image | centos7.2 (8aec8782-c6af-41d8-a225-ada5a2af13dc) |
| key_name | - |
| locked | False |
| metadata | {} |
| name | test-server |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | hqs |
| status | BUILD |
| tenant_id | 386dbfcf77e444c7872e4e23d5829fcc |
| updated | 2021-10-19T02:09:55Z |
| user_id | 0f217182b5af448c988f5464c706a337 |
+--------------------------------------+--------------------------------------------------+
# 实例停止
[root@controller ~]# nova stop hqs_server
Request to stop server hqs_server has been accepted.
# 实例启动
[root@controller ~]# nova start hqs_server
Request to start server hqs_server has been accepted.
# 实例重启
[root@controller ~]# nova reboot hqs_server
Request to reboot server <Server: hqs_server> has been accepted.
[root@controller ~]# nova list
+--------------------------------------+------------+---------+----------------+-------------+----------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------------+---------+----------------+-------------+----------------------------------+
| b51590fc-33cc-4d54-8e54-c0530e912d2b | hqs_server | REBOOT | reboot_started | Running | int-gre=172.25.2.8 |
| c6cabeed-1176-4634-b493-b6be7c351a03 | test | SHUTOFF | - | Shutdown | int-gre=172.25.2.3, 192.168.20.4 |
+--------------------------------------+------------+---------+----------------+-------------+----------------------------------+
# 实例挂起
[root@controller ~]# nova pause test
[root@controller ~]# nova list
+--------------------------------------+------------+--------+----------------+-------------+----------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------------+--------+----------------+-------------+----------------------------------+
| b51590fc-33cc-4d54-8e54-c0530e912d2b | hqs_server | REBOOT | reboot_started | Running | int-gre=172.25.2.8 |
| c6cabeed-1176-4634-b493-b6be7c351a03 | test | PAUSED | - | Paused | int-gre=172.25.2.3, 192.168.20.4 |
+--------------------------------------+------------+--------+----------------+-------------+----------------------------------+
# 实例删除
[root@controller ~]# nova delete hqs_server
Request to delete server hqs_server has been accepted.
[root@controller ~]# nova list
+--------------------------------------+------+--------+------------+-------------+----------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+----------------------------------+
| c6cabeed-1176-4634-b493-b6be7c351a03 | test | PAUSED | - | Paused | int-gre=172.25.2.3, 192.168.20.4 |
+--------------------------------------+------+--------+------------+-------------+----------------------------------+
4、浮动IP
nova
floating-ip-associate Associate a floating IP address to a server.
floating-ip-bulk-create Bulk create floating IPs
by range (nova-network only).
floating-ip-bulk-delete Bulk delete floating IPs by range (nova-
network only).
floating-ip-bulk-list List all floating IPs (nova-network only).
floating-ip-create Allocate a floating IP for the current tenant.
floating-ip-delete De-allocate a floating IP.
floating-ip-disassociate Disassociate a floating IP address from a
server.
floating-ip-list List floating IPs.
floating-ip-pool-list List all floating IP pools.
# 创建浮动IP
# 语法:nova floating-ip-create <pool>
[root@controller nova]# nova floating-ip-create net-gre
+--------------------------------------+--------------+-----------+----------+---------+
| Id | IP | Server Id | Fixed IP | Pool |
+--------------------------------------+--------------+-----------+----------+---------+
| fcb2439d-ba4f-4467-ad60-34726d57aba4 | 192.168.37.5 | - | - | net-gre |
+--------------------------------------+--------------+-----------+----------+---------+
# 浮动IP的列表信息
[root@controller nova]# nova floating-ip-list
+--------------------------------------+--------------+-----------+----------+---------+
| Id | IP | Server Id | Fixed IP | Pool |
+--------------------------------------+--------------+-----------+----------+---------+
| fcb2439d-ba4f-4467-ad60-34726d57aba4 | 192.168.37.5 | - | - | net-gre |
+--------------------------------------+--------------+-----------+----------+---------+
# 浮动IP地址池信息
[root@controller nova]# nova floating-ip-pool-list
+---------+
| name |
+---------+
| net-gre |
+---------+
# 查看浮动IP详细信息
[root@controller nova]# openstack ip floating show 192.168.37.5
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| description | |
| dns_domain | |
| dns_name | |
| fixed_ip_address | None |
| floating_ip_address | 192.168.37.5 |
| floating_network_id | 847163a4-65dd-456e-a839-4f810cce80cf |
| id | fcb2439d-ba4f-4467-ad60-34726d57aba4 |
| port_id | None |
| project_id | 386dbfcf77e444c7872e4e23d5829fcc |
| router_id | None |
| status | DOWN |
+---------------------+--------------------------------------+
# 浮动ip关联给实例
# 语法:nova floating-ip-associate [--fixed-address <fixed_address>] <server> <address>
# 参数:
# <server> Name or ID of server.(nova list)
# <address> IP Address.(nova floating-ip-list)
[root@controller nova]# nova floating-ip-associate caocao-server1 192.168.37.5
[root@controller nova]# nova list
+--------------------------------------+----------------+--------+------------+-------------+---------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------------+--------+------------+-------------+---------------------------------+
| e2c75e51-1a3b-4a0b-8765-d7ff6e8188e3 | caocao-server1 | ACTIVE | - | Running | int-gre=10.10.0.3, 192.168.37.5 |
+-----------------------
# 浮动IP解除关联实例
# 语法:nova floating-ip-disassociate <server> <address>
[root@controller nova]# nova floating-ip-disassociate caocao-server1 192.168.37.5
[root@controller nova]# nova list
+--------------------------------------+----------------+--------+------------+-------------+-------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------------+--------+------------+-------------+-------------------+
| e2c75e51-1a3b-4a0b-8765-d7ff6e8188e3 | caocao-server1 | ACTIVE | - | Running | int-gre=10.10.0.3 |
+--------------------------------------+----------------+--------+------------+-------------+-------------------+
# 解除关联并删除浮动IP
[root@controller nova]# nova floating-ip-associate caocao-server1 192.168.37.5
[root@controller nova]# nova floating-ip-delete 192.168.37.5
[root@controller nova]# nova list
+--------------------------------------+----------------+--------+------------+-------------+-------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------------+--------+------------+-------------+-------------------+
| e2c75e51-1a3b-4a0b-8765-d7ff6e8188e3 | caocao-server1 | ACTIVE | - | Running | int-gre=10.10.0.3 |
+---------
[root@controller nova]# nova floating-ip-list
+----+----+-----------+----------+------+
| Id | IP | Server Id | Fixed IP | Pool |
+----+----+-----------+----------+------+
+----+----+-----------+----------+------+
5、密钥管理
(1)openstack命令行格式案例
# 生成一个密钥对
-b #指定密钥长度
-e #读取openssh的私钥或者公钥文件
-C #添加注释
-f #指定用来保存密钥的文件名
-i #读取未加密的ssh-v2兼容的私钥/公钥文件,然后在标准输出设备上显示openssh兼容的私钥/公钥
-l #显示公钥文件的指纹数据
-N #提供一个新密语
-P #提供(旧)密语
-q #静默模式
-t #指定要创建的密钥类型
[root@controller ~]# ssh-keygen -q -N ""
Enter file in which to save the key (/root/.ssh/id_rsa): 《——直接回车
[root@controller ~]# ll /root/.ssh/
total 12
-rw------- 1 root root 1679 Dec 19 19:46 id_rsa
-rw-r--r-- 1 root root 397 Dec 19 19:46 id_rsa.pub
-rw-r--r-- 1 root root 176 Dec 19 16:37 known_hosts
# 导入公钥到云平台
[root@controller ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mkey
+-------------+-------------------------------------------------+
| Field | Value |
+-------------+-------------------------------------------------+
| fingerprint | fc:f7:bd:56:a5:4f:e2:cd:9a:d5:2b:f4:59:2f:d5:e4 |
| name | mkey |
| user_id | 16744fe5ad7042a4a0356f37cb02dda4 |
+-------------+-------------------------------------------------+
# 查看系统密钥对列表
[root@controller ~]# openstack keypair list
+------+-------------------------------------------------+
| Name | Fingerprint |
+------+-------------------------------------------------+
| mkey | fc:f7:bd:56:a5:4f:e2:cd:9a:d5:2b:f4:59:2f:d5:e4 |
+------+-------------------------------------------------+
# 查看mkey密钥的详情
[root@controller ~]# openstack keypair show mkey
+-------------+-------------------------------------------------+
| Field | Value |
+-------------+-------------------------------------------------+
| created_at | 2023-12-19T11:48:14.000000 |
| deleted | False |
| deleted_at | None |
| fingerprint | fc:f7:bd:56:a5:4f:e2:cd:9a:d5:2b:f4:59:2f:d5:e4 |
| id | 1 |
| name | mkey |
| updated_at | None |
| user_id | 16744fe5ad7042a4a0356f37cb02dda4 |
+-------------+-------------------------------------------------+
(2)nova命令行格式案例
nova
keypair-add Create a new key pair for use with servers.
keypair-delete Delete keypair given by its name. (Supported
by API versions '2.0' - '2.latest') [hint: use
'--os-compute-api-version' flag to show help
message for proper version]
keypair-list Print a list of keypairs for a user (Supported
by API versions '2.0' - '2.latest') [hint: use
'--os-compute-api-version' flag to show help
message for proper version]
keypair-show Show details about the given keypair.
(Supported by API versions '2.0' - '2.latest')
[hint: use '--os-compute-api-version' flag to
show help message for proper version]
# 查看密钥列表
[root@controller ~]# nova keypair-list
+------+------+-------------------------------------------------+
| Name | Type | Fingerprint |
+------+------+-------------------------------------------------+
| test | ssh | 5c:7e:d8:bd:b9:33:cb:f9:eb:b8:52:c4:04:7c:8c:1e |
+------+------+-------------------------------------------------+
# 查看密钥详情
[root@controller ~]# nova keypair-show test
+-------------+-------------------------------------------------+
| Property | Value |
+-------------+-------------------------------------------------+
| created_at | 2021-10-28T14:06:12.000000 |
| deleted | False |
| deleted_at | - |
| fingerprint | 5c:7e:d8:bd:b9:33:cb:f9:eb:b8:52:c4:04:7c:8c:1e |
| id | 1 |
| name | test |
| type | ssh |
| updated_at | - |
| user_id | 0f217182b5af448c988f5464c706a337 |
+-------------+-------------------------------------------------+
Public key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDc/qEc2ihvE7aLgSVH0lt5PDBwEYXW0CqMx8sGJPT1p3r0mxdJiti9pJxBRoX+oOhA/LFssaOGvtHDK79Njs3HynrXkxvKo6UfmBNQzt2z5C3nTP2U17JY2wrOh7YyYdhuuRirCLNHQk4hM1YY9BbPrCLjLlQ8Gms6vdgDCgT1gXuRppBTfQKrIKKRk6d5vIqBMoGM3fCaM34DiqwOS/uq8gQM8T/io9h6XrTKWznmZgzaFJ2S3XUZhAliSEgkraxZIM8L3QWumMlBVryYVUX6QEKv29hNWYZF/bxUqfQx50vBuIfHlKgkcccAVDy6OoZNmd6T1rdJXEdW+MWobHu7 Generated-by-Nova
# 创建密钥
[root@controller ~]# nova keypair-add hqs --key-type ssh
-----BEGIN RSA PRIVATE KEY-----
MIIEpwIBAAKCAQEAw3YnZk1ej5j3+CjpWalgmVWxrdAVZGfpC3Qklz+0RW7p4nTn
VlkGL7mWEgx7fmRaBzZuwUuSuvFB79zWhGZqh7Dt0Zeibyy48u3AtZtDY1ZVkvss
Vq7zOdUgg+2C8Em7KTAXsuf1I7KPxgJHX7j9pluN8zBQKiYYi4K+RPCVtisw3ev0
Ey5vi7e1IuUawXpjWnGe+/yzCZWgL8X2uhyYH0cJUmO3PbFuX0aoZr/JsLbMfkeL
0hCDkpKgkx8L/VD6C8FW+Z3mfJGxJtGwakb+BGyOYZ3j/Sv7bh03QKPgViqJ9CGa
WL5/y8dYmFLYM45Gb60FLWPSHWLmH9SFnmV7UwIDAQABAoIBABkiGUDbU/xs8/2x
7Qd9cxFkZntuFUIa5ml1nrrgEyMWdvaKh7Cfs97xIy3g8wQ2jSj+Q9GRESX+nbbl
E6RksvANvRbFQ7q96m46ShxQAaNFV62VpIbk6huWnx63rK2PHYTXTUTQ9MGJVVll
s53IYL1CaodJwBUbXu6ZejPNJ8MLoyom7cH89uaP5K8Ej7pHObaxMBCkSylU0vcG
qJp0Gu1NbnQ823EYm5QeEqUfG8xLyXKOvAq3scZHg5hqdD6SDVOYm3uQM8TF8zkY
SSTYrwktj7g7vP6ZQ0zY3k/s/zxMbTIurwwNm8L93tPcgtJUMw+fPYu3OHr9nhBt
aeFJ6AkCggCBANoJLHA6j5Jgj0uLy+ur8BmU8qSCJ7Nmx3JZFj2ELoZcLzjniHqH
14QHqnBgFxaUAvmpy8wCMnIKrk83FdEkgk2vwSlsr1uEiz+MNHKqapWwiezR87HB
5XsgtHpOsBlTpzQlOL7TJX7kCtZYgyGbQJvLMeek+cqy2YsNp28AgFulAoIAgQDl
fr5dBmEMBtTVaAjZFlyhJIXpf93QeC9KTtCLJ0QXAVPpCLlnulC8W4JfuZDTFqOr
gnx1y84DfyoZ4/K6zPNfqguRRzE2sxMNDLNZeyZiA10uZwEh+AJtCf54FU2xZtVP
1eZ7I4QMR2jaDSj5nWgF90DYHoWLxOEeIVnTnFoplwKCAIANyxrGls3SYs1t6BAk
fqIX3DZldd5xGQVxFHW1upD+6wIJxYv6xHE75wg/R7TuNrrhdH5yD4mFcWuJk2CL
9JVRuNatejS1w3LTuFjxEBriEWMIWlfiXPPZkD4aprO5RnODdv9aAx2SI3cUDFFv
ZNT3hilIEEXFLv9YLqry+MMmCQKCAIBpG+OUN5e7KmXQWBW1V8iVBWVPzICLOoBu
SCq7kQBeiP0lfhlsqKjRnBfaP+NUysmrg9f9G5r/fv6JXR2O8M+GwRsLLtAbfWj8
URTTptOtkFzdI9Ag/rYdurYRybAL0E1ig1VMkLep6Ard06kwqic6lEPeuBvyJ/nz
EtNRWArzgQKCAIAQDXQbP+20nzHoWqy1sFYIpOYrC+pZGX3tZb8DfAKrhrL+FkGe
PSe6bNwgWVDEUwTyvoPUexvAVi7nZ1sqMw/Ar+KxCXcti+dzZZZa3typLQMceOr2
wFfpNMT/Kq2DTrgkXN+jpFczv/R0kNn5bOB/DIm8JUeN44k97lMzIrD7TA==
-----END RSA PRIVATE KEY-----
# 删除密钥
[root@controller ~]# nova keypair-list
+------+------+-------------------------------------------------+
| Name | Type | Fingerprint |
+------+------+-------------------------------------------------+
| hqs | ssh | e2:cc:e9:8f:1d:06:45:b4:52:0b:38:68:0d:15:b8:b9 |
| test | ssh | 5c:7e:d8:bd:b9:33:cb:f9:eb:b8:52:c4:04:7c:8c:1e |
+------+------+-------------------------------------------------+
[root@controller ~]# nova keypair-delete hqs
[root@controller ~]# nova keypair-list
+------+------+-------------------------------------------------+
| Name | Type | Fingerprint |
+------+------+-------------------------------------------------+
| test | ssh | 5c:7e:d8:bd:b9:33:cb:f9:eb:b8:52:c4:04:7c:8c:1e |
+------+------+-------------------------------------------------+
6、配额管理
# 待补全
[root@controller ~]# openstack quota show admin
+----------------------+----------------------------------+
| Field | Value |
+----------------------+----------------------------------+
| backup_gigabytes | 1000 |
| backups | 10 |
| cores | 20 |
| firewall | 10 |
| firewall_policy | 10 |
| firewall_rule | 100 |
| fixed-ips | -1 |
| floating-ips | 50 |
| gigabytes | 1000 |
| health_monitor | -1 |
| injected-file-size | 10240 |
| injected-files | 5 |
| injected-path-size | 255 |
| instances | 10 |
| key-pairs | 100 |
| member | -1 |
| network | 10 |
| per_volume_gigabytes | -1 |
| pool | 10 |
| port | 50 |
| project | 386dbfcf77e444c7872e4e23d5829fcc |
| properties | 128 |
| ram | 51200 |
| rbac_policy | 10 |
| router | 10 |
| secgroup-rules | 100 |
| secgroups | 10 |
| server_group_members | 10 |
| server_groups | 10 |
| snapshots | 10 |
| subnet | 10 |
| subnetpool | -1 |
| vip | 10 |
| volumes | 10 |
+----------------------+----------------------------------+
三、nova和其他组件交互操作
1、云主机卷挂载操作
nova
volume-attach Attach a volume to a server. # 卷挂载到云主机
volume-attachments List all the volumes attached to a server. # 查看所有挂载到云主机上的卷
volume-detach Detach a volume from a server. # 卷从云主机上卸载
volume-update Update volume attachment. # 卷挂载状态更新
# 卷挂载到云主机
nova volume-attach <server> <volume> [<device>]
Positional arguments:
<server> Name or ID of server.
<volume> ID of the volume to attach.
<device> Name of the device e.g. /dev/vdb. Use "auto" for autoassign (if
supported). Libvirt driver will use default device name.
[root@controller cinder]# nova volume-attach test111 f594e936-05e2-4a8c-b4c9-b96bbe7e2c82 /dev/vdb
+----------+--------------------------------------+
| Property | Value |
+----------+--------------------------------------+
| device | /dev/vdb |
| id | f594e936-05e2-4a8c-b4c9-b96bbe7e2c82 |
| serverId | 4b3a90f0-4177-44cc-8ef2-34a0e5d56b33 |
| volumeId | f594e936-05e2-4a8c-b4c9-b96bbe7e2c82 |
+----------+--------------------------------------+
# 查看所有挂载到云主机上的卷
[root@controller cinder]# nova volume-attachments test111
+--------------------------------------+----------+--------------------------------------+--------------------------------------+
| ID | DEVICE | SERVER ID | VOLUME ID |
+--------------------------------------+----------+--------------------------------------+--------------------------------------+
| f594e936-05e2-4a8c-b4c9-b96bbe7e2c82 | /dev/vdb | 4b3a90f0-4177-44cc-8ef2-34a0e5d56b33 | f594e936-05e2-4a8c-b4c9-b96bbe7e2c82 |
+--------------------------------------+----------+--------------------------------------+--------------------------------------+
# 卷从云主机上卸载
nova volume-detach <server> <volume>
Positional arguments:
<server> Name or ID of server.
<volume> ID of the volume to detach.
[root@controller cinder]# nova volume-detach test111 f594e936-05e2-4a8c-b4c9-b96bbe7e2c82
[root@controller cinder]# nova volume-attachments test111
+----+--------+-----------+-----------+
| ID | DEVICE | SERVER ID | VOLUME ID |
+----+--------+-----------+-----------+
+----+--------+-----------+-----------+