一、nova介紹:
-
客戶(可以是 OpenStack 最終用戶,也可以是其他程序)向 API(nova-api)發送請求:“幫我創建一個虛機”
-
API 對請求做一些必要處理后,向 Messaging(RabbitMQ)發送了一條消息:“讓 Scheduler 創建一個虛機”
-
Scheduler(nova-scheduler)從 Messaging 獲取到 API 發給它的消息,然后執行調度算法,從若干計算節點中選出節點 A
-
Scheduler 向 Messaging 發送了一條消息:“在計算節點 A 上創建這個虛機”
-
計算節點 A 的 Compute(nova-compute)從 Messaging 中獲取到 Scheduler 發給它的消息,然后在本節點的 Hypervisor 上啟動虛機。
-
在虛機創建的過程中,Compute 如果需要查詢或更新數據庫信息,會通過 Messaging 向 Conductor(nova-conductor)發送消息,Conductor 負責數據庫訪問。
1、界面或命令行通過RESTful API向keystone獲取認證信息。
2、keystone通過用戶請求認證信息,並生成auth-token返回給對應的認證請求。
3、界面或命令行通過RESTful API向nova-api發送一個boot instance的請求(攜帶auth-token)。
4、nova-api接受請求后向keystone發送認證請求,查看token是否為有效用戶和token。
5、keystone驗證token是否有效,如有效則返回有效的認證和對應的角色(注:有些操作需要有角色權限才能操作)。
6、通過認證后nova-api和數據庫通訊。
7、初始化新建虛擬機的數據庫記錄。
8、nova-api通過rpc.call向nova-scheduler請求是否有創建虛擬機的資源(Host ID)。
9、nova-scheduler進程偵聽消息隊列,獲取nova-api的請求。
10、nova-scheduler通過查詢nova數據庫中計算資源的情況,並通過調度算法計算符合虛擬機創建需要的主機。
11、對於有符合虛擬機創建的主機,nova-scheduler更新數據庫中虛擬機對應的物理主機信息。
12、nova-scheduler通過rpc.cast向nova-compute發送對應的創建虛擬機請求的消息。
13、nova-compute會從對應的消息隊列中獲取創建虛擬機請求的消息。
14、nova-compute通過rpc.call向nova-conductor請求獲取虛擬機消息。(Flavor)
15、nova-conductor從消息隊隊列中拿到nova-compute請求消息。
16、nova-conductor根據消息查詢虛擬機對應的信息。
17、nova-conductor從數據庫中獲得虛擬機對應信息。
18、nova-conductor把虛擬機信息通過消息的方式發送到消息隊列中。
19、nova-compute從對應的消息隊列中獲取虛擬機信息消息。
20、nova-compute通過keystone的RESTfull API拿到認證的token,並通過HTTP請求glance-api獲取創建虛擬機所需要鏡像。
21、glance-api向keystone認證token是否有效,並返回驗證結果。
22、token驗證通過,nova-compute獲得虛擬機鏡像信息(URL)。
23、nova-compute通過keystone的RESTfull API拿到認證k的token,並通過HTTP請求neutron-server獲取創建虛擬機所需要的網絡信息。
24、neutron-server向keystone認證token是否有效,並返回驗證結果。
25、token驗證通過,nova-compute獲得虛擬機網絡信息。
26、nova-compute通過keystone的RESTfull API拿到認證的token,並通過HTTP請求cinder-api獲取創建虛擬機所需要的持久化存儲信息。
27、cinder-api向keystone認證token是否有效,並返回驗證結果。
28、token驗證通過,nova-compute獲得虛擬機持久化存儲信息。
29、nova-compute根據instance的信息調用配置的虛擬化驅動來創建虛擬機。
1、控制節點上操作查看計算節點,刪除node1
openstack host list nova service-list

2、將node1上的計算服務設置為down,然后disabled
systemctl stop openstack-nova-compute nova service-list

nova service-disable node1 nova-compute nova service-list

3、在數據庫里清理(nova庫)
(1)參看現在數據庫狀態
[root@node1 ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 90 Server version: 10.1.20-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> use nova; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [nova]> select host from nova.services; +---------+ | host | +---------+ | 0.0.0.0 | | 0.0.0.0 | | node1 | | node1 | | node1 | | node1 | | node2 | +---------+ 7 rows in set (0.00 sec) MariaDB [nova]> select hypervisor_hostname from compute_nodes; +---------------------+ | hypervisor_hostname | +---------------------+ | node1 | | node2 | +---------------------+ 2 rows in set (0.00 sec)
(2)刪除數據庫中的node1節點信息
MariaDB [nova]> delete from nova.services where host="node1"; Query OK, 4 rows affected (0.01 sec) MariaDB [nova]> delete from compute_nodes where hypervisor_hostname="node1"; Query OK, 1 row affected (0.00 sec) MariaDB [nova]> MariaDB [nova]> MariaDB [nova]> MariaDB [nova]> select host from nova.services; +---------+ | host | +---------+ | 0.0.0.0 | | 0.0.0.0 | | node2 | +---------+ 3 rows in set (0.00 sec) MariaDB [nova]> select hypervisor_hostname from compute_nodes; +---------------------+ | hypervisor_hostname | +---------------------+ | node2 | +---------------------+ 1 row in set (0.00 sec) MariaDB [nova]>
