閱讀594 返回首頁    go 阿裏雲 go 技術社區[雲棲]


openstack 命令行管理十七 - 宿主主機管理 (備忘)

幫助信息

[root@station140 ~(keystone_admin)]# nova help | grep hyper
    hypervisor-list     List hypervisors.
    hypervisor-servers  List instances belonging to specific hypervisors.
    hypervisor-show     Display the details of the specified hypervisor.
    hypervisor-stats    Get hypervisor statistics over all compute nodes.
    hypervisor-uptime   Display the uptime of the specified hypervisor.



查詢物理服務器

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova hypervisor-list | more
+-----+-----------------------------------+
| ID  | Hypervisor hostname               |
+-----+-----------------------------------+
| 1   | hh-yun-compute-130118.vclound.com |
| 3   | hh-yun-compute-130117.vclound.com |
| 5   | hh-yun-compute-130119.vclound.com |
| 7   | hh-yun-compute-130121.vclound.com |
| 9   | hh-yun-compute-130122.vclound.com |
| 11  | hh-yun-compute-130120.vclound.com |
| 13  | hh-yun-compute-130123.vclound.com |
| 15  | hh-yun-compute-130127.vclound.com |
| 17  | hh-yun-compute-130140.vclound.com |
| 19  | hh-yun-compute-130137.vclound.com |
| 21  | hh-yun-compute-130130.vclound.com |
| 39  | hh-yun-compute-130136.vclound.com |
| 25  | hh-yun-compute-130163.vclound.com |
| 23  | hh-yun-compute-130152.vclound.com |
| 27  | hh-yun-compute-130145.vclound.com |
+-----+-----------------------------------+



顯示某個物理主機詳細信息方法

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova hypervisor-show  hh-yun-compute-130228.vclound.com
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Property                  | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| cpu_info_arch             | x86_64                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| cpu_info_features         | ["ssse3", "pge", "avx", "clflush", "sep", "syscall", "vme", "dtes64", "tsc", "sse", "xsave", "vmx", "erms", "xtpr", "cmov", "smep", "pcid", "est", "pat", "monitor", "smx", "lm", "msr", "nx", "fxsr", "tm", "sse4.1", "pae", "sse4.2", "pclmuldq", "acpi", "tsc-deadline", "popcnt", "mmx", "osxsave", "cx8", "mce", "mtrr", "rdtscp", "ht", "dca", "lahf_lm", "pdcm", "mca", "pdpe1gb", "apic", "fsgsbase", "f16c", "pse", "ds", "invtsc", "pni", "tm2", "aes", "sse2", "ss", "pbe", "de", "fpu", "cx16", "pse36", "ds_cpl", "rdrand", "x2apic"] |
| cpu_info_model            | SandyBridge                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| cpu_info_topology_cores   | 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| cpu_info_topology_sockets | 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| cpu_info_topology_threads | 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| cpu_info_vendor           | Intel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| current_workload          | 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| disk_available_least      | 302                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| free_disk_gb              | 358                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| free_ram_mb               | 12538                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| host_ip                   | 10.199.130.228                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| hypervisor_hostname       | hh-yun-compute-130228.vclound.com                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| hypervisor_type           | QEMU                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| hypervisor_version        | 1005003                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| id                        | 661                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| local_gb                  | 1098                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| local_gb_used             | 740                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| memory_mb                 | 193274                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| memory_mb_used            | 180736                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| running_vms               | 24                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| service_host              | hh-yun-compute-130228.vclound.com                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| service_id                | 689                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| vcpus                     | 24                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| vcpus_used                | 109                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+


 


顯示某個主機當前使用的資源方法

[root@station140 ~(keystone_admin)]# nova hypervisor-stats
+----------------------+-------+
| Property             | Value |
+----------------------+-------+
| count                | 1     |
| vcpus_used           | 0     |
| local_gb_used        | 0     |
| memory_mb            | 7872  |
| current_workload     | 0     |
| vcpus                | 2     |
| running_vms          | 0     |
| free_disk_gb         | 15    |
| disk_available_least | 7     |
| local_gb             | 15    |
| free_ram_mb          | 7360  |
| memory_mb_used       | 512   |
+----------------------+-------+



 查詢某個主機下當前使用了多少個雲主機方法

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova hypervisor-servers hh-yun-compute-130228.vclound.com
+--------------------------------------+-------------------+---------------+-----------------------------------+
| ID                                   | Name              | Hypervisor ID | Hypervisor Hostname               |
+--------------------------------------+-------------------+---------------+-----------------------------------+
| 6f0848d4-f1e4-48ab-ac61-9381a623df8e | instance-00000575 | 661           | hh-yun-compute-130228.vclound.com |
| b804e517-8627-42e4-8ee3-147b85a45e49 | instance-0000057d | 661           | hh-yun-compute-130228.vclound.com |
| 3f21c3fb-582d-49a6-92e1-a6cd700b7771 | instance-00003a04 | 661           | hh-yun-compute-130228.vclound.com |
| 6d20c830-b58e-453d-a1ff-c3eaf922649c | instance-00003a88 | 661           | hh-yun-compute-130228.vclound.com |
| 0169068f-dc37-4374-8c8d-3ab522341971 | instance-00003a89 | 661           | hh-yun-compute-130228.vclound.com |
| 4047d7c9-53b0-44f4-8d24-4bece2490e5c | instance-000043c7 | 661           | hh-yun-compute-130228.vclound.com |
| b086b6ba-bce6-4538-8f48-277624f91388 | instance-000043c9 | 661           | hh-yun-compute-130228.vclound.com |
| ea3c9c00-6d75-4b32-84f5-ce8a8a9dee2c | instance-00004ea1 | 661           | hh-yun-compute-130228.vclound.com |
| b3de708c-fcfd-4bae-a40f-bb6c8ffd24cd | instance-0000597d | 661           | hh-yun-compute-130228.vclound.com |
| 632adb45-bc85-4357-8771-45aa86f9a30e | instance-000059b1 | 661           | hh-yun-compute-130228.vclound.com |
| a3c0a387-6c0f-48da-9088-577f72684730 | instance-00007597 | 661           | hh-yun-compute-130228.vclound.com |
| 56a15032-a9c0-4bfa-a8b4-198e527507b4 | instance-000089f7 | 661           | hh-yun-compute-130228.vclound.com |
| bd81ca6a-1c1e-48a6-94b4-22b5c2953e40 | instance-00009dbf | 661           | hh-yun-compute-130228.vclound.com |
| b285e1ef-c634-44ec-a299-487995cb29df | instance-00009e2b | 661           | hh-yun-compute-130228.vclound.com |
| b6daf848-ab91-453b-9015-c3d4b7d453f5 | instance-0000a1e5 | 661           | hh-yun-compute-130228.vclound.com |
| 17a1c5a6-e817-40a3-9f3d-dd94c8eb0151 | instance-0000a97f | 661           | hh-yun-compute-130228.vclound.com |
| fa65ab21-05c9-473f-8e7b-6bb40b2c6d58 | instance-0000bef9 | 661           | hh-yun-compute-130228.vclound.com |
| ec66f95f-7d37-4645-9ec0-769e60e530e3 | instance-0000e236 | 661           | hh-yun-compute-130228.vclound.com |
| d41a1bef-5ee7-4b70-b7c8-036465023f3b | instance-0000e3f8 | 661           | hh-yun-compute-130228.vclound.com |
| ab7e3a16-c9aa-4f9b-ba1a-6e79e58be40c | instance-0000f743 | 661           | hh-yun-compute-130228.vclound.com |
| ce42403a-5bcf-4141-9dce-5963f1651307 | instance-0001273d | 661           | hh-yun-compute-130228.vclound.com |
| e534f3be-007c-470c-9ebb-80ab73ce2ee2 | instance-00012967 | 661           | hh-yun-compute-130228.vclound.com |
| 62fdeda2-89a2-46c2-b522-c18495481a94 | instance-00012e35 | 661           | hh-yun-compute-130228.vclound.com |
| bab1461c-0c14-4845-8daa-c58a020be3b9 | instance-00012e37 | 661           | hh-yun-compute-130228.vclound.com |
+--------------------------------------+-------------------+---------------+-----------------------------------+


利用 nova 命令查詢正常工作中的計算節點

參考命令 nova service-list    (下麵是測試環境下的顯示)

+------------------+----------------------------------+----------------+---------+-------+----------------------------+-----------------+
| Binary           | Host                             | Zone           | Status  | State | Updated_at                 | Disabled Reason |
+------------------+----------------------------------+----------------+---------+-------+----------------------------+-----------------+
| nova-conductor   | gz-controller-209131.vclound.com | internal       | enabled | up    | 2016-03-14T03:47:04.000000 | -               |
| nova-scheduler   | gz-controller-209131.vclound.com | internal       | enabled | up    | 2016-03-14T03:47:03.000000 | -               |
| nova-cert        | gz-controller-209131.vclound.com | internal       | enabled | up    | 2016-03-14T03:47:03.000000 | -               |
| nova-cert        | gz-controller-209132.vclound.com | internal       | enabled | up    | 2016-03-14T03:46:58.000000 | -               |
| nova-scheduler   | gz-controller-209132.vclound.com | internal       | enabled | up    | 2016-03-14T03:46:58.000000 | -               |
| nova-conductor   | gz-controller-209132.vclound.com | internal       | enabled | up    | 2016-03-14T03:47:01.000000 | -               |
| nova-console     | gz-controller-209131.vclound.com | internal       | enabled | up    | 2016-03-14T03:46:57.000000 | -               |
| nova-console     | gz-controller-209132.vclound.com | internal       | enabled | up    | 2016-03-14T03:46:57.000000 | -               |
| nova-consoleauth | gz-controller-209131.vclound.com | internal       | enabled | down  | 2016-01-07T03:02:49.000000 | -               |
| nova-consoleauth | gz-controller-209132.vclound.com | internal       | enabled | up    | 2016-03-14T03:46:57.000000 | -               |
| nova-compute     | gz-compute-209126.vclound.com    | develop-zone   | enabled | down  | 2016-02-12T14:26:17.000000 | -               |
| nova-compute     | gz-compute-209127.vclound.com    | develop-zone   | enabled | up    | 2016-03-14T03:47:01.000000 | -               |
| nova-compute     | gz-compute-209230                | qa-zone        | enabled | up    | 2016-03-14T03:46:58.000000 | None            |
| nova-compute     | gz-compute-209232                | qa-master-zone | enabled | up    | 2016-03-14T03:47:00.000000 | -               |
| nova-compute     | gz-compute-209233                | develop-zone   | enabled | up    | 2016-03-14T03:46:59.000000 | -               |
+------------------+----------------------------------+----------------+---------+-------+----------------------------+-----------------+


說明:

Brinay

描述服務類型, 常見服務有
nova-conductor   nova 程序主控製器, 接受 api 請求

nova-scheduler   nova 調度器, 進行主機開啟, 關閉, 重啟調度

nova-cert        證書管理中心, 驗證用戶權限

nova-console     vnc 控製器

nova-consoleauth  vnc 認證中心(對用戶 token 進行認證)

nova-compute     計算節點

Host

主機名

Zone

把不同物理機劃分成不同分區

Internal         常見為 openstack 核心程序

develop-zone     供開發同事使用的計算節點集群

qa-zone          供測試同事使用的計算節點集群

Status

Up         服務可用

Down       服務不可用

(注, 在集群中, 隻能夠有一個 nova-console-auth 處於 up 狀態)

Updated

服務啟動時間

Disable
Reason

手動關閉服務時, 可以添加注釋, 注釋可在該列中進行顯示

 

Zone 說明

由於集群中機器比較多, 申請用戶也比較多, 為了更好地進行服務器規劃, 我們計劃把不同機櫃中的服務器劃分到不同 zone 中, 並限製不同部門的同事使用不同的 zone.

規劃:

開發同事隻在 develop-zone 中進行雲主機申請

測試同事隻在 qa-zone 中進行雲主機申請

Sandbox項目隻在 sandbox中進行雲主機申請

 

指定申請機器使用使用不同的 zone 方法

 

nova boot --flavor  b2c_web_1core --image Centos6.6_x86_64_1.12 --nic net-id=fe662a3d-dc73-48d2-ba0f-920cd15da5c2  terry.vclound.com--availability-zonedevelop-zone

 

機器 zone 規劃

zone

機器數量

Cpu core

Memory

Qa-zone

148(gz)

24 X 148 = 3552

192X148 = 28416

Qa-master-zone

47(gz)

24 X 47= 1128

192X47 = 9024

Develop-zone

121(gz)+ 68(sh)

24 X 189=  4536

192X189 = 36288

sandbox

8(gz)

24 X 8=  192

192X8 = 1536

 

查詢當前服務器中具有多少zone 的物理主機方法

[root@hh-yun-puppet-129021~(keystone_admin)]# nova aggregate-list

+----+----------------+-------------------+
| Id | Name           | Availability Zone |
+----+----------------+-------------------+
| 3  | develop-sas    | develop-zone      |
| 7  | develop-ssd    | develop-zone      |
| 9  | qa-glusterfs   | qa-zone           |
| 11 | qa-ssd         | qa-zone           |
| 13 | pre-release    | pre-zone          |
| 15 | qa-sas         | qa-zone           |
| 19 | qa-master-zone | qa-master-zone    |
| 20 | sandbox-zone   | sandbox-zone      |
+----+----------------+-------------------+


 

查詢在不同 zone 下的物理節點方法

留意 hosts 中列出的就是在該 zone 中可用的物理機

 

設定不同 zone 方法

[root@gz-controller-209131~(keystone_admin)]# nova aggregate-create new-zone cgroup-zone

+----+----------+-------------------+-------+---------------------------------+
| Id | Name     | Availability Zone | Hosts | Metadata                        |
+----+----------+-------------------+-------+---------------------------------+
| 20 | new-zone | cgroup-zone       |       | 'availability_zone=cgroup-zone' |
+----+----------+-------------------+-------+---------------------------------+


 

把主機定義到指定的 zone 中

[root@gz-controller-209131 ~(keystone_admin)]# nova aggregate-add-host new-zone gz-compute-209127.vclound.com
Host gz-compute-209127.vclound.com has been successfully added for aggregate 20
+----+----------+-------------------+---------------------------------+---------------------------------+
| Id | Name     | Availability Zone | Hosts                           | Metadata                        |
+----+----------+-------------------+---------------------------------+---------------------------------+
| 20 | new-zone | cgroup-zone       | 'gz-compute-209127.vclound.com' | 'availability_zone=cgroup-zone' |
+----+----------+-------------------+---------------------------------+---------------------------------+

 

在指定 zone 中刪除主機

[root@gz-controller-209131 ~(keystone_admin)]# nova aggregate-remove-host new-zone gz-compute-209127.vclound.com
Host gz-compute-209127.vclound.com has been successfully removed from aggregate 20
+----+----------+-------------------+-------+---------------------------------+
| Id | Name     | Availability Zone | Hosts | Metadata                        |
+----+----------+-------------------+-------+---------------------------------+
| 20 | new-zone | cgroup-zone       |       | 'availability_zone=cgroup-zone' |
+----+----------+-------------------+-------+---------------------------------+

 

刪除指定 zone

[root@gz-controller-209131~(keystone_admin)]# nova aggregate-delete new-zone
Aggregate 20 has beensuccessfully deleted.


最後更新:2017-04-03 12:55:10

  上一篇:go RabbitMQ消息隊列(二):”Hello, World“
  下一篇:go CentOS6.3添加nginx係統服務詳細說明