本帖最后由 howtodown 于 2014-9-1 23:58 编辑
问题导读
1、如何显示某个物理主机详细信息?
2、如何使用 instance管理的帮助命令?
3、如何列出 secgroup和启动实例?
帮助信息
- [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.
复制代码
查询物理服务器
- nova hypervisor-list
- +----+----------------------+
- | ID | Hypervisor hostname |
- +----+----------------------+
- | 1 | station140.cloud.com |
- +----+----------------------+
复制代码
显示某个物理主机详细信息方法
- nova hypervisor-show station140.cloud.com
- +----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | Property | Value |
- +----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | hypervisor_hostname | station140.cloud.com |
- | 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}} |
- | free_disk_gb | -5 |
- | hypervisor_version | 12001 |
- | disk_available_least | -18 |
- | local_gb | 15 |
- | free_ram_mb | 5312 |
- | id | 1 |
- | vcpus_used | 1 |
- | hypervisor_type | QEMU |
- | local_gb_used | 20 |
- | memory_mb_used | 2560 |
- | memory_mb | 7872 |
- | current_workload | 0 |
- | vcpus | 2 |
- | running_vms | 1 |
- | service_id | 4 |
- | service_host | station140.cloud.com |
- +----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
复制代码
显示某个主机当前使用的资源方法
- [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 |
- +----------------------+-------+
复制代码
openstack 命令行管理: instance管理
相关帮助
- [root@station140 ~(keystone_admin)]# nova boot
- usage: nova boot [--flavor <flavor>] [--image <image>]
- [--image-with <key=value>] [--boot-volume <volume_id>]
- [--snapshot <snapshot_id>] [--num-instances <number>]
- [--meta <key=value>] [--file <dst-path=src-path>]
- [--key-name <key-name>] [--user-data <user-data>]
- [--availability-zone <availability-zone>]
- [--security-groups <security-groups>]
- [--block-device-mapping <dev-name=mapping>]
- [--block-device key1=value1[,key2=value2...]]
- [--swap <swap_size>]
- [--ephemeral size=<size>[,format=<format>]]
- [--hint <key=value>]
- [--nic <net-id=net-uuid,v4-fixed-ip=ip-addr,port-id=port-uuid>]
- [--config-drive <value>] [--poll]
- <name>
复制代码
列出flavor-list
- [root@station140 ~(keystone_admin)]# nova flavor-list | grep -E 'ID|computer|-'
- +----+--------------+-----------+------+-----------+------+-------+-------------+-----------+
- | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
- +----+--------------+-----------+------+-----------+------+-------+-------------+-----------+
- | 6 | m1.vcomputer | 2048 | 20 | 0 | | 1 | 1.0 | True |
- +----+--------------+-----------+------+-----------+------+-------+-------------+-----------+
复制代码
列出镜像命名
- [root@station140 ~(keystone_admin)]# glance image-list | grep -v "+" | awk '{printf "%-35s %25s\n", $2,$4}'
- ID Name
- 2aad80bf-6fbb-4348-bb20-2c07dbf4f687 centos5.8_x86_64
- 2d6bb00d-002f-4675-ba84-73d90fdc1020 cirros
复制代码
等价命令
- nova image-list | grep -v "+" | awk '{printf "%-35s %25s\n", $2,$4}'
复制代码
列出 keypair
- [root@station140 ~(keystone_admin)]# nova keypair-list
- +----------+-------------------------------------------------+
- | Name | Fingerprint |
- +----------+-------------------------------------------------+
- | terrykey | 94:b8:9c:2a:31:8c:2c:87:7f:f5:80:24:23:73:f8:e9 |
- +----------+-------------------------------------------------+
复制代码
列出 secgroup
- [root@station140 ~(keystone_admin)]# nova secgroup-list
- +--------------------------------------+---------+--------------------+
- | Id | Name | Description |
- +--------------------------------------+---------+--------------------+
- | 91a191a6-b89e-4f87-99c0-0fb985985978 | default | default |
- | 6966a8e4-0980-40ad-a409-baac65b60287 | terry | allow ping and ssh |
- +--------------------------------------+---------+--------------------+
复制代码
启动第一个实例 (只有一个网卡)
- [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
- +--------------------------------------+--------------------------------------+
- | Property | Value |
- +--------------------------------------+--------------------------------------+
- | OS-EXT-STS:task_state | scheduling |
- | image | centos5.8_x86_64 |
- | OS-EXT-STS:vm_state | building |
- | OS-EXT-SRV-ATTR:instance_name | instance-00000006 |
- | OS-SRV-USG:launched_at | None |
- | flavor | m1.vcomputer |
- | id | 3760f47f-1b56-4429-a046-f77fb6d50d1a |
- | security_groups | [{u'name': u'terry'}] |
- | user_id | 9b3904aef3f84d6b9432989f0e0e0194 |
- | OS-DCF:diskConfig | MANUAL |
- | accessIPv4 | |
- | accessIPv6 | |
- | progress | 0 |
- | OS-EXT-STS:power_state | 0 |
- | OS-EXT-AZ:availability_zone | nova |
- | config_drive | |
- | status | BUILD |
- | updated | 2014-02-17T06:09:24Z |
- | hostId | |
- | OS-EXT-SRV-ATTR:host | None |
- | OS-SRV-USG:terminated_at | None |
- | key_name | terrykey |
- | OS-EXT-SRV-ATTR:hypervisor_hostname | None |
- | name | terry_instance1 |
- | adminPass | eQMSKUvs7oem |
- | tenant_id | e3a71a59840c4e88b8740b789c3afb9c |
- | created | 2014-02-17T06:09:24Z |
- | os-extended-volumes:volumes_attached | [] |
- | metadata | {} |
- +--------------------------------------+--------------------------------------+
复制代码
下面显示为虚拟机创建中
- [root@station140 ~(keystone_admin)]# nova list
- +--------------------------------------+-----------------+--------+------------+-------------+----------------+
- | ID | Name | Status | Task State | Power State | Networks |
- +--------------------------------------+-----------------+--------+------------+-------------+----------------+
- | 93d0c9c1-b38b-4fe3-9ae3-400f43276f60 | terry_instance1 | BUILD | spawning | NOSTATE | net1=10.0.0.50 |
- +--------------------------------------+-----------------+--------+------------+-------------+----------------+
复制代码
下面显示为正常运行中的 instance
- [root@station140 ~(network_admin)]# nova list
- +--------------------------------------+-----------------+--------+------------+-------------+----------------+
- | ID | Name | Status | Task State | Power State | Networks |
- +--------------------------------------+-----------------+--------+------------+-------------+----------------+
- | 3760f47f-1b56-4429-a046-f77fb6d50d1a | terry_instance1 | ACTIVE | None | Running | net1=10.0.0.50 |
- +--------------------------------------+-----------------+--------+------------+-------------+----------------+
复制代码
列出主机部分信息
- [root@station140 /(keystone_admin)]# nova list --fields "networks,name,status" --name terry_instance1
- +--------------------------------------+--------------------------------+-----------------+--------+
- | ID | Networks | Name | Status |
- +--------------------------------------+--------------------------------+-----------------+--------+
- | f76bd659-da1d-482a-b74d-08b67b95c113 | net1=10.0.0.50, 192.168.48.142 | terry_instance1 | ACTIVE |
- +--------------------------------------+--------------------------------+-----------------+--------+
复制代码
注: fields 需使用小写进行定义
上一篇:
openstack 命令行管理八:浮动 IP 管理;网络测试 命令总结
下一篇:
openstack 命令行管理十:日志管理、instance novnc 访问管理 命令总结
|