一、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、密鑰管理
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 |
+----+--------+-----------+-----------+
+----+--------+-----------+-----------+
