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.


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Terry_Tsang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值