分享

openstack 命令行管理九:宿主主机管理;instance管理 命令总结

xioaxu790 发表于 2014-8-31 17:15:08 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 21258
本帖最后由 howtodown 于 2014-9-1 23:58 编辑
问题导读
1、如何显示某个物理主机详细信息?
2、如何使用 instance管理的帮助命令?
3、如何列出 secgroup和启动实例?




帮助信息
  1. [root@station140 ~(keystone_admin)]# nova help | grep hyper  
  2.     hypervisor-list     List hypervisors.  
  3.     hypervisor-servers  List instances belonging to specific hypervisors.  
  4.     hypervisor-show     Display the details of the specified hypervisor.  
  5.     hypervisor-stats    Get hypervisor statistics over all compute nodes.  
  6.     hypervisor-uptime   Display the uptime of the specified hypervisor.
复制代码


查询物理服务器
  1. nova hypervisor-list  
  2. +----+----------------------+  
  3. | ID | Hypervisor hostname  |  
  4. +----+----------------------+  
  5. | 1  | station140.cloud.com |  
  6. +----+----------------------+
复制代码


显示某个物理主机详细信息方法
  1. nova hypervisor-show station140.cloud.com  
  2. +----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+  
  3. | Property             | Value                                                                                                                                                                                                                   |  
  4. +----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+  
  5. | hypervisor_hostname  | station140.cloud.com                                                                                                                                                                                                    |  
  6. | cpu_info             | {"vendor": "Intel", "model": "Westmere", "arch": "x86_64", "features": ["rdtscp", "hypervisor", "avx", "osxsave", "xsave", "vmx", "pclmuldq", "ss", "ds", "vme"], "topology": {"cores": 1, "threads": 1, "sockets": 2}} |  
  7. | free_disk_gb         | -5                                                                                                                                                                                                                      |  
  8. | hypervisor_version   | 12001                                                                                                                                                                                                                   |  
  9. | disk_available_least | -18                                                                                                                                                                                                                     |  
  10. | local_gb             | 15                                                                                                                                                                                                                      |  
  11. | free_ram_mb          | 5312                                                                                                                                                                                                                    |  
  12. | id                   | 1                                                                                                                                                                                                                       |  
  13. | vcpus_used           | 1                                                                                                                                                                                                                       |  
  14. | hypervisor_type      | QEMU                                                                                                                                                                                                                    |  
  15. | local_gb_used        | 20                                                                                                                                                                                                                      |  
  16. | memory_mb_used       | 2560                                                                                                                                                                                                                    |  
  17. | memory_mb            | 7872                                                                                                                                                                                                                    |  
  18. | current_workload     | 0                                                                                                                                                                                                                       |  
  19. | vcpus                | 2                                                                                                                                                                                                                       |  
  20. | running_vms          | 1                                                                                                                                                                                                                       |  
  21. | service_id           | 4                                                                                                                                                                                                                       |  
  22. | service_host         | station140.cloud.com                                                                                                                                                                                                    |  
  23. +----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
复制代码


显示某个主机当前使用的资源方法
  1. [root@station140 ~(keystone_admin)]# nova hypervisor-stats  
  2. +----------------------+-------+  
  3. | Property             | Value |  
  4. +----------------------+-------+  
  5. | count                | 1     |  
  6. | vcpus_used           | 0     |  
  7. | local_gb_used        | 0     |  
  8. | memory_mb            | 7872  |  
  9. | current_workload     | 0     |  
  10. | vcpus                | 2     |  
  11. | running_vms          | 0     |  
  12. | free_disk_gb         | 15    |  
  13. | disk_available_least | 7     |  
  14. | local_gb             | 15    |  
  15. | free_ram_mb          | 7360  |  
  16. | memory_mb_used       | 512   |  
  17. +----------------------+-------+  
复制代码


openstack 命令行管理: instance管理
相关帮助
  1. [root@station140 ~(keystone_admin)]# nova boot  
  2. usage: nova boot [--flavor <flavor>] [--image <image>]  
  3.                  [--image-with <key=value>] [--boot-volume <volume_id>]  
  4.                  [--snapshot <snapshot_id>] [--num-instances <number>]  
  5.                  [--meta <key=value>] [--file <dst-path=src-path>]  
  6.                  [--key-name <key-name>] [--user-data <user-data>]  
  7.                  [--availability-zone <availability-zone>]  
  8.                  [--security-groups <security-groups>]  
  9.                  [--block-device-mapping <dev-name=mapping>]  
  10.                  [--block-device key1=value1[,key2=value2...]]  
  11.                  [--swap <swap_size>]  
  12.                  [--ephemeral size=<size>[,format=<format>]]  
  13.                  [--hint <key=value>]  
  14.                  [--nic <net-id=net-uuid,v4-fixed-ip=ip-addr,port-id=port-uuid>]  
  15.                  [--config-drive <value>] [--poll]  
  16.                  <name>
复制代码


列出flavor-list
  1. [root@station140 ~(keystone_admin)]# nova flavor-list | grep -E 'ID|computer|-'  
  2. +----+--------------+-----------+------+-----------+------+-------+-------------+-----------+  
  3. | ID | Name         | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |  
  4. +----+--------------+-----------+------+-----------+------+-------+-------------+-----------+  
  5. | 6  | m1.vcomputer | 2048      | 20   | 0         |      | 1     | 1.0         | True      |  
  6. +----+--------------+-----------+------+-----------+------+-------+-------------+-----------+
复制代码


列出镜像命名
  1. [root@station140 ~(keystone_admin)]#  glance image-list | grep -v "+" | awk '{printf "%-35s %25s\n",  $2,$4}'  
  2. ID                                                       Name  
  3. 2aad80bf-6fbb-4348-bb20-2c07dbf4f687          centos5.8_x86_64  
  4. 2d6bb00d-002f-4675-ba84-73d90fdc1020                    cirros
复制代码


等价命令
  1. nova image-list | grep -v "+" | awk '{printf "%-35s %25s\n",  $2,$4}'  
复制代码


列出 keypair
  1. [root@station140 ~(keystone_admin)]# nova keypair-list  
  2. +----------+-------------------------------------------------+  
  3. | Name     | Fingerprint                                     |  
  4. +----------+-------------------------------------------------+  
  5. | terrykey | 94:b8:9c:2a:31:8c:2c:87:7f:f5:80:24:23:73:f8:e9 |  
  6. +----------+-------------------------------------------------+  
复制代码


列出 secgroup
  1. [root@station140 ~(keystone_admin)]# nova secgroup-list  
  2. +--------------------------------------+---------+--------------------+  
  3. | Id                                   | Name    | Description        |  
  4. +--------------------------------------+---------+--------------------+  
  5. | 91a191a6-b89e-4f87-99c0-0fb985985978 | default | default            |  
  6. | 6966a8e4-0980-40ad-a409-baac65b60287 | terry   | allow ping and ssh |  
  7. +--------------------------------------+---------+--------------------+  
复制代码


启动第一个实例 (只有一个网卡)
  1. [root@station140 ~(keystone_admin)]# nova boot --flavor m1.vcomputer --image centos5.8_x86_64 --key-name terrykey --security-groups terry --nic net-id=d0e3f988-d62f-4f95-ab21-b73f4dae326b terry_instance1  
  2. +--------------------------------------+--------------------------------------+  
  3. | Property                             | Value                                |  
  4. +--------------------------------------+--------------------------------------+  
  5. | OS-EXT-STS:task_state                | scheduling                           |  
  6. | image                                | centos5.8_x86_64                     |  
  7. | OS-EXT-STS:vm_state                  | building                             |  
  8. | OS-EXT-SRV-ATTR:instance_name        | instance-00000006                    |  
  9. | OS-SRV-USG:launched_at               | None                                 |  
  10. | flavor                               | m1.vcomputer                         |  
  11. | id                                   | 3760f47f-1b56-4429-a046-f77fb6d50d1a |  
  12. | security_groups                      | [{u'name': u'terry'}]                |  
  13. | user_id                              | 9b3904aef3f84d6b9432989f0e0e0194     |  
  14. | OS-DCF:diskConfig                    | MANUAL                               |  
  15. | accessIPv4                           |                                      |  
  16. | accessIPv6                           |                                      |  
  17. | progress                             | 0                                    |  
  18. | OS-EXT-STS:power_state               | 0                                    |  
  19. | OS-EXT-AZ:availability_zone          | nova                                 |  
  20. | config_drive                         |                                      |  
  21. | status                               | BUILD                                |  
  22. | updated                              | 2014-02-17T06:09:24Z                 |  
  23. | hostId                               |                                      |  
  24. | OS-EXT-SRV-ATTR:host                 | None                                 |  
  25. | OS-SRV-USG:terminated_at             | None                                 |  
  26. | key_name                             | terrykey                             |  
  27. | OS-EXT-SRV-ATTR:hypervisor_hostname  | None                                 |  
  28. | name                                 | terry_instance1                      |  
  29. | adminPass                            | eQMSKUvs7oem                         |  
  30. | tenant_id                            | e3a71a59840c4e88b8740b789c3afb9c     |  
  31. | created                              | 2014-02-17T06:09:24Z                 |  
  32. | os-extended-volumes:volumes_attached | []                                   |  
  33. | metadata                             | {}                                   |  
  34. +--------------------------------------+--------------------------------------+  
复制代码


下面显示为虚拟机创建中
  1. [root@station140 ~(keystone_admin)]# nova list  
  2. +--------------------------------------+-----------------+--------+------------+-------------+----------------+  
  3. | ID                                   | Name            | Status | Task State | Power State | Networks       |  
  4. +--------------------------------------+-----------------+--------+------------+-------------+----------------+  
  5. | 93d0c9c1-b38b-4fe3-9ae3-400f43276f60 | terry_instance1 | BUILD  | spawning   | NOSTATE     | net1=10.0.0.50 |  
  6. +--------------------------------------+-----------------+--------+------------+-------------+----------------+
复制代码


下面显示为正常运行中的 instance
  1. [root@station140 ~(network_admin)]# nova list  
  2. +--------------------------------------+-----------------+--------+------------+-------------+----------------+  
  3. | ID                                   | Name            | Status | Task State | Power State | Networks       |  
  4. +--------------------------------------+-----------------+--------+------------+-------------+----------------+  
  5. | 3760f47f-1b56-4429-a046-f77fb6d50d1a | terry_instance1 | ACTIVE | None       | Running     | net1=10.0.0.50 |  
  6. +--------------------------------------+-----------------+--------+------------+-------------+----------------+
复制代码


列出主机部分信息
  1. [root@station140 /(keystone_admin)]# nova list  --fields "networks,name,status" --name terry_instance1  
  2. +--------------------------------------+--------------------------------+-----------------+--------+  
  3. | ID                                   | Networks                       | Name            | Status |  
  4. +--------------------------------------+--------------------------------+-----------------+--------+  
  5. | f76bd659-da1d-482a-b74d-08b67b95c113 | net1=10.0.0.50, 192.168.48.142 | terry_instance1 | ACTIVE |  
  6. +--------------------------------------+--------------------------------+-----------------+--------+
复制代码

注: fields 需使用小写进行定义


上一篇:
openstack 命令行管理八:浮动 IP 管理;网络测试 命令总结
下一篇:
openstack 命令行管理十:日志管理、instance novnc 访问管理 命令总结


没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条