nova计算资源相关的命令,重点分为管理计算节点的命令和虚拟机生命周期的管理命令。
管理计算节点的命令:
- aggregate-add-host
功能: 将计算节点添加到指定的主机集合
用法: nova aggregate-add-host
参数: 聚合的名称或ID; 添加到指定聚合的主机
- aggregate-create
功能:创建一个新的主机集合
用法:nova aggregate-create []
参数: 集合的名称; 集合的可用域
- aggregate-delete
功能: 删除指定的主机集合
用法:nova aggregate-delete
参数: 聚合的名称或ID
- aggregate-list
功能:列举所有主机集合的详细信息usage: nova aggregate-list
用法: nova aggregate-list
参数:无
- aggregate-remove-host
功能:将计算节点从指定主机集合中移除
用法:nova aggregate-remove-host
参数: 聚合的名称或ID; 指定聚合的主机- evacuate
功能:从故障主机疏散撤离虚拟机
用法:nova evacuate [–password ] [–on-shared-storage]
server> []
参数:
故障主机中的虚拟机
目标主机的名称或ID。如果没有指定主机,则调度器将选择一个。
–password 设置已疏散服务器上的密码。不适用于共享存储标志
–on-shared-storage 指定服务器文件是否位于共享存储器上
- host-action
功能:开启、关闭或者重启计算节点
用法:nova host-action [–action ]
参数:
主机名.
–action A power action: startup, reboot, or shutdown. - hypervisor-list
功能:虚拟机监控程序列表
用法:nova hypervisor-list [–matching ]
参数:–matching 列表管理程序,匹配指定的<主机名> - hypervisor-servers
功能:列举出一个计算节点下的所有虚拟机
用法:nova hypervisor-servers
参数: 计算节点名(可通过’nova host-list | grep compute’ 获得) - hypervisor-show
功能: 显示指定的管理程序的详细信息
用法:nova hypervisor-show
参数: hypervisor的名称或ID,以显示详细信息(可通过’nova hypervisor-list’获得) - hypervisor-stats
功能:获得所有计算节点上的hypervisor统计信息。
用法:nova hypervisor-stats
参数:无
虚拟机生命周期的管理命令,包括:虚拟机的创建、开机、关机、迁移等。
1.backup
功能:通过创建一个backup类型的快照来备份虚拟机
用法:nova backup
参数: 虚拟机的名称或者UUID; 备份镜像的名称; 备份类型,如 “daily” or “weekly”; 整数用来代表轮询的数量
-
boot
功能:启动一个新的虚拟机
用法: nova boot [–flavor ] [–image ]
[–image-with <key=value>] [–boot-volume <volume_id>]
[–snapshot <snapshot_id>] [–min-count ]
[–max-count ] [–meta <key=value>]
[–file <dst-path=src-path>] [–key-name ]
[–user-data ]
[–availability-zone ]
[–security-groups ]
[–block-device-mapping <dev-name=mapping>]
[–block-device key1=value1[,key2=value2…]]
[–swap <swap_size>]
[–ephemeral size=[,format=]]
[–hint <key=value>]
[–nic <net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr ,port-id=port-uuid>]
[–config-drive ] [–poll]
参数:
–flavor flavor的名称或ID (通过’nova flavor-list’获得)
–image 镜像的名称或ID (通过’nova image-list’获得)
–image-with <key=value> 镜像元数据特性(通过’nova image-show’获得)
–boot-volume <volume_id> 从云硬盘启动的云硬盘ID
–snapshot <snapshot_id> 从快照中启动(将会创建一个云硬盘)
–min-count 创建虚机的最小个数(受配额限制)
–max-count 创建虚机额最大个数(受配额限制)
–meta <key=value> 虚拟机的元数据
–file <dst-path=src-path> 在新创建的虚拟机上从源地址到目的地址存储任意文件(受注入文件的配额值限制)
–key-name 密钥对的名称
–user-data 通过元数据服务器传输的用户数据文件
–availability-zone 可用域,用于承载虚拟机
–security-groups 安全组名称
–block-device-mapping <dev-name=mapping> 块设备映射的格式(挂载的云硬盘)
=:: <size(GB)>:.
–block-device key1=value1[,key2=value2…]
块设备映射键值: id=UUID
(image_id, snapshot_id or volume_id only if
using source image, snapshot or volume)
source=source type (image, snapshot, volume or
blank), dest=destination type of the block
device (volume or local), bus=device’s bus
(e.g. uml, lxc, virtio, …; if omitted,
hypervisor driver chooses a suitable default,
honoured only if device type is supplied)
type=device type (e.g. disk, cdrom, …;
defaults to ‘disk’) device=name of the device
(e.g. vda, xda, …; if omitted, hypervisor
driver chooses suitable device depending on
selected bus), size=size of the block device
in GB (if omitted, hypervisor driver
calculates size), format=device will be
formatted (e.g. swap, ntfs, …; optional),
bootindex=integer used for ordering the boot
disks (for image backed instances it is equal
to 0, for others need to be specified) and
shutdown=shutdown behaviour (either preserve
or remove, for local destination set to
remove).
–swap <swap_size> 创建并附加一个本地交换块设备<swap_size> MB.
–ephemeral size=[,format=]
创建并挂载本地临时的块设备 GB and format it to .
–hint <key=value> 向调度器发送任意键/值对以供自定义使用
–nic <net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,port-id=port-uu id>
配置驱动
–config-drive 启用配置驱动
–poll 报告最新虚机启动的过程直到完成 -
delete
功能:直接关闭并删除一个或者多个虚拟机
用法:nova delete [ …]
参数:虚拟机名称或ID -
diagnostics
功能:获取虚拟机CPU、内存等的使用情况
用法:nova diagnostics
参数:虚拟机名称或ID
- list
功能: 列举当前用户所有虚拟机
用法:nova list [–reservation-id ] [–ip ]
[–ip6 ] [–name ]
[–instance-name ] [–status ]
[–flavor ] [–image ] [–host ]
[–all-tenants [<0|1>]] [–tenant []] [–deleted]
[–fields ] [–minimal]
参数:
–reservation-id 只返回匹配预定id的服务器
–ip 搜索,用ip进行正则表达式匹配地址
–ip6 搜索与正则表达式匹配IPv6地址
–name 搜索,使用正则表达式匹配的名称
–instance-name
通过服务器名称搜索正则表达式匹配项
–status 搜索服务器状态
–flavor 搜索的flavor的名称或ID
–image 搜索image的名称或ID
–host 搜索服务器,主机名为它们所在的主机名指定(只管理)。
–all-tenants [<0|1>] 显示来自所有租户的信息 (Admin only).
–tenant [] 从单个租户显示信息(Admin only).
–deleted 仅显示已删除服务器 (Admin only).
–fields 逗号分隔的字段列表显示。使用show命令查看哪些字段可用
–minimal 只能得到虚拟机的uuid和名称
举例:nova list --all-tenants --tenant tenant_id 查看一个租户下的所有云主机信息- live-migration
功能: 执迁移
用法: nova live-migration [–block-migrate] [–disk-over-commit]
[]
参数:
–block-migrate 块迁移(Default=False:live_migration)
–disk-over-commit 允许过量使用(Default=False)
虚拟机名称或ID;
迁移到指定的主机名- force-delete
功能:强制删除虚拟机
用法: nova force-delete
参数: 要删除虚机的名称或者ID