openstack基本命令
Posted 波神
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openstack基本命令相关的知识,希望对你有一定的参考价值。
1,查看nova服务列表
[[email protected] ~(keystone_admin)]# nova-manage service list Binary Host Zone Status State Updated_At nova-consoleauth cc.scgajzpt.chinacloud.com internal enabled :-) 2017-08-11 11:31:58 nova-scheduler cc.scgajzpt.chinacloud.com internal enabled :-) 2017-08-11 11:31:55 nova-conductor cc.scgajzpt.chinacloud.com internal enabled :-) 2017-08-11 11:31:57 nova-cert cc.scgajzpt.chinacloud.com internal enabled :-) 2017-08-11 11:31:52 nova-compute nc1.scgajzpt.chinacloud.com nova enabled :-) 2017-08-11 11:31:57 nova-compute nc2.scgajzpt.chinacloud.com nova enabled :-) 2017-08-11 11:31:56 nova-compute nc3.scgajzpt.chinacloud.com nova enabled :-) 2017-08-11 11:31:54 nova-compute nc4.scgajzpt.chinacloud.com nova enabled :-) 2017-08-11 11:32:00 nova-compute nc5.scgajzpt.chinacloud.com nova enabled :-) 2017-08-11 11:31:51 nova-compute nc6.scgajzpt.chinacloud.com nova enabled :-) 2017-08-11 11:31:52
2、查看镜像列表
[[email protected] ~(keystone_admin)]# glance image-list +--------------------------------------+-----------------------------------------+-------------+------------------+-------------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +--------------------------------------+-----------------------------------------+-------------+------------------+-------------+--------+ | 1a813c75-8a47-40c6-acf0-4a2fb889d1ff | CentOS-6.8 | qcow2 | bare | 346292224 | active | | c8505727-7dd4-4011-887a-acce1e78c1e7 | CentOS-7.2 | qcow2 | bare | 410693120 | active | | ec1981de-1b1a-463f-ada5-6672a0dd6299 | CentOS-7.2-DVD | qcow2 | bare | 2086412288 | active | | 27b9ee6d-fdb5-460c-b73d-3b5779e7fe4b | CentOS-7.2-DVD-5G | qcow2 | bare | 579990016 | active | | 68f98be3-4e39-4507-9d5b-3dfa6b6a9a41 | CentOS6.5 | qcow2 | bare | 1084293120 | active | | 94328370-0334-43bd-b7ee-0b474ec0d4ee | CentOS7 | qcow2 | bare | 912654336 | active | | 4c88a413-33b4-432b-88bb-ae3ef6e0892e | centos7_lvm_docker50g | qcow2 | bare | 3598450688 | active | | e5a0514e-2315-4d0c-9fe6-be3797acf3e0 | docker50g-0930 | qcow2 | bare | 3185115136 | active | | 5c58a54b-e9e0-40cf-bf1a-162894659005 | docker50g-0930-m | raw | bare | 53687091200 | active | | a2a5795f-62b2-4586-8cd9-fd906cd8eece | linux_legacy | vmdk | bare | 1024 | active | | 1835da74-b1da-439c-a3ba-e4cb235825c2 | Mir-APP | qcow2 | bare | 510263296 | active | | 9b8984ab-5bf9-46f0-aaa2-6e7590ebe73e | Mir-AutoDeploy | qcow2 | bare | 8117813248 | active | | efbd484f-3b2f-40c4-b6ba-46d33e2f342a | otheros_legacy | vmdk | bare | 1024 | active | | 59f61beb-8fea-4309-a42e-fe27a2b416f9 | redhat6.7-kvm-oracle11g | qcow2 | bare | 19319095296 | active | | 616d43de-1f08-4c3b-8294-42720c6047d6 | redhat6.7-kvm-tomcat7-15disk-qcow2 | qcow2 | bare | 2994012160 | active | | 71ce38f9-0c15-4c7d-9279-327145423939 | redhat6.7-kvm-weblogic12c | qcow2 | bare | 5416747008 | active | | 1057c8ee-4102-4bda-8a6c-2edc73c33c7c | redhat67-8disk | qcow2 | bare | 3056599040 | active | | b4e6dbbf-8558-4841-98ac-f5654b8082b0 | redhat67-kvm-mysql51-15disk-maste-slave | qcow2 | bare | 6644498432 | active | | f77abf41-8324-45cc-b18d-f57f54e46b35 | redhat67-kvm-nginx180-15disk | qcow2 | bare | 2976972800 | active | | 320b3483-385e-4e94-97ac-d188ba156662 | redhat67-ruby-8disk-20170811053409 | raw | bare | 8589934592 | active | | 689b381c-7d9c-48bf-be85-a35590e4f9a7 | windows_legacy | vmdk | bare | 1024 | active | | 654a402f-654f-4fcb-a7cf-b5d402d28932 | windows2008_r2_20G.qcow2 | qcow2 | bare | 7577468928 | active | | 3c0472b3-4664-4fac-906d-8c9a0733519c | WinSrv2008R2sp1 | qcow2 | bare | 3384541184 | active | +--------------------------------------+-----------------------------------------+-------------+------------------+-------------+--------+
3、上传一个镜像文件到openstack
如果是KVM的镜像要加这个属性: --property hypervisor_type="qemu" 如果是vmdk的镜像要加--property hypervisor_type="vmware" glance image-update 6b9b28ca-fb08-4285-b8ca-2e439d6c6eec --name windows2008_vmdk_iis Disk Format:vmdk、qcow2 hypervisor_type:vmware、qemu 2. glance image-create --disk-format qcow2 --container-format bare --file ./镜像文件名 --min-disk=20 -- property os-type=windows --name windows glance image-create --disk-format qcow2 --property hypervisor_type=qemu --container-format bare --file ./centos6Tomcat.qcow2 --min-disk=22 --property os-type=linux --name centos6_kvm_tomcat7test glance image-create --disk-format vmdk --property hypervisor_type=vmware --container-format bare --file ./centos6Tomcat.qcow2 --is-public=True --min-disk=20 --property os-type=linux --property vmware_disktype=thin --property vmware_adaptertype=lsiLogicsas --name centos6-vmdk-oracle11g 导入windows镜像;property vmware_disktype=preallocated否则会黑屏 glance image-create --disk-format vmdk --property hypervisor_type=vmware --property vmware_adaptertype=lsiLogicsas -- property vmware_disktype=preallocated --property vmware_ostype=winNetEnterprise64Guest --container-format bare --file ./windows2008server-flat.vmdk --is-public=True --min-disk=25 --property os-type=windows --name vmdk_windows2008_iis_new2 --property vmware_ostype=winNetEnterprise64Guest --property vmware_disktype=preallocated --property vmware_adaptertype=lsiLogicsas
下载一个镜像到本地
glance image-download --file /usr/cuitlab/redhat6.7-ruby-1.8.7-8disk.qcow2 320b3483-385e-4e94-97ac-d188ba156662
4、删除一个镜像
glance image-delete 镜像ID
5、查看虚拟机列表
[[email protected] ~(keystone_admin)]# nova list +--------------------------------------+--------------------------------------+--------+------------+-------------+-----------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+--------------------------------------+--------+------------+-------------+-----------------------+ | 15a52160-d5ca-498a-ac3c-52ef9c0b6d55 | 0aea3c09-ea6a-4f23-9e91-1dbe391bd24d | ACTIVE | - | Running | flat=172.16.80.119 | | 3325791d-9258-4097-8dd7-1aa962fd470c | 1ed4905b-a069-4f7a-a7b2-7646f207e817 | ACTIVE | - | Running | flat=172.16.80.142 | | 03048019-4a5f-40fa-a8f3-f06ee1eeeab1 | 22a6847a-de26-464c-8688-a96677f6957d | ACTIVE | - | Running | flat=172.16.80.134 | | 04674bb7-f841-42ca-8b4d-1da531240d93 | 3ab417ae-6220-4f73-9ed0-451cd59cae85 | ACTIVE | - | Running | flat=172.16.80.117 | | 3ac89719-c2a1-4bc6-add1-400009fa22c6 | 49271e30-415c-43bc-a034-5e69801d6cfc | ACTIVE | - | Running | flat=172.16.80.140 | | 35194efe-0bc5-4f8a-868a-81c6061ed9e1 | 6a0278b0-9b10-47ac-add4-5064b0ed71ab | ACTIVE | - | Running | flat=172.16.80.114 | | 824a709b-55cc-4f97-95cf-9f1b8f14ee6a | 7b26e406-f505-4b48-b4c3-9e0e5b480219 | ACTIVE | - | Running | flat=172.16.80.118 | | 977a7bbd-de0f-45e0-aef7-37cb9ed5d0b8 | Mir-Back | ACTIVE | - | Running | flat=172.16.80.97 | | c8f77d10-5148-4cd9-9a16-e9ff0cb48d7b | Mir-UI | ACTIVE | - | Running | flat=172.16.80.99 | | 3690ca9a-a662-4a0e-a341-62f5a7bdb50f | Whitehole | ACTIVE | - | Running | flat=172.16.80.98 | | 260ac822-4933-48df-958b-10b1a5263e69 | aee8bf0d-12d3-4e48-98c4-3e62a48291d6 | ACTIVE | - | Running | flat=172.16.80.121 | | 2aff9e8d-086d-4c97-8227-d8eef4f4cacf | b2e31a1e-6a3a-48eb-8050-1e2cc19d0ab3 | ACTIVE | - | Running | flat=172.16.80.138 | | 33b40a80-cd0d-47e0-bc9a-c2e46bb1eedd | b49352f1-247d-487d-8a33-0df700c5c8ec | ACTIVE | - | Running | flat=172.16.80.115 | | c3bf93df-981e-47f7-bb06-750f704d6554 | b9c88ced-da8a-4a0c-963d-9c6ef2aa6950 | ACTIVE | - | Running | flat=172.16.80.116 | | ee4a7ccd-5541-460b-b73c-a75f616d37b2 | c4352a92-2a9e-4b10-ad70-a75b9c438958 | ACTIVE | - | Running | flat=172.16.80.103 | | c06994be-8b39-45c0-bbc6-09acf8f57c48 | fd6df44b-b350-4553-ab5b-0e44e31cfec3 | ACTIVE | - | Running | flat=172.16.80.141 | | 86d44b67-0db3-4e92-a13b-93babcc37195 | jzpt_Jenkins | ACTIVE | - | Running | flat=172.16.80.81 | | 179c4462-bbf8-4e44-b393-ef1ea1268bde | jzpt_dkrepo | ACTIVE | - | Running | flat=172.16.80.94 |
6、查看某一个虚拟机的详情
[[email protected] ~(keystone_admin)]# nova show 15a52160-d5ca-498a-ac3c-52ef9c0b6d55 +--------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Property | Value | +--------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | nova | | OS-EXT-SRV-ATTR:host | nc4.scgajzpt.chinacloud.com | | OS-EXT-SRV-ATTR:hypervisor_hostname | nc4.scgajzpt.chinacloud.com | | OS-EXT-SRV-ATTR:instance_name | instance-00000a86 | | OS-EXT-STS:power_state | 1 | | OS-EXT-STS:task_state | - | | OS-EXT-STS:vm_state | active | | OS-SRV-USG:launched_at | 2017-05-18T09:06:38.000000 | | OS-SRV-USG:terminated_at | - | | accessIPv4 | | | accessIPv6 | | | config_drive | | | created | 2017-05-18T08:57:35Z | | flat network | 172.16.80.119 | | flavor | vcpus_1_ram_1024_disk_20_eph_0 (vcpus_1_ram_1024_disk_20_eph_0) | | hostId | 07d02f8dd88ba89819a9899ac6a6a9ef06910e40a2f4bd92eafa6bc7 | | id | 15a52160-d5ca-498a-ac3c-52ef9c0b6d55 | | image | redhat67-kvm-mysql51-15disk-maste-slave (b4e6dbbf-8558-4841-98ac-f5654b8082b0) | | key_name | FARM-319-3f234828 | | metadata | {"p2p_producer_endpoint": "http://172.16.101.40/messaging", "behaviors": "mysql2", "owner_email": "[email protected]", "hash": "dcbbbf54e7c365", "farmid": "319", "message_format": "json", "realrolename": "mysql-15disk", "region": "RegionOne", "httpproto": "http", "szr_key": "ibpDHXXfK2lxsj9l324uYC1tPS3SKH554u1+/f3f", "queryenv_url": "http://172.16.101.40/query-env", "platform": "openstack", "farm_roleid": "410", "role": "mysql2", "roleid": "25", "server_index": "1", "serverid": "0aea3c09-ea6a-4f23-9e91-1dbe391bd24d", "env_id": "1", "isvm": "1", "cloud_storage_path": "swift://"} | | name | 0aea3c09-ea6a-4f23-9e91-1dbe391bd24d | | os-extended-volumes:volumes_attached | [{"id": "e02f8070-e50d-4e52-9bf3-950b16bf3ced"}] | | progress | 0 | | security_groups | default, scalr.3f234828.ip-pool | | status | ACTIVE | | tenant_id | cbeb053466384fd4a3eaa4fced6e307a | | updated | 2017-05-18T09:04:01Z | | user_id | 5b6cace6194f4fc6b4c5bac8e9bcc258 | +--------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
7、获取虚拟机的网页访问地址
[[email protected] ~(keystone_admin)]# nova get-vnc-console 2aff9e8d-086d-4c97-8227-d8eef4f4cacf novnc +-------+------------------------------------------------------------------------------------+ | Type | Url | +-------+------------------------------------------------------------------------------------+ | novnc | http://172.16.80.100:6080/vnc_auto.html?token=a268b4d9-aa0b-45a5-92e2-98ebb954448c | +-------+------------------------------------------------------------------------------------+
8、删除一个虚拟机
nova delete f62f11a5-055d-426b-a159-70d11aafdc76 如果删除的时候出现一直deleting,先激活 nova reset-state f62f11a5-055d-426b-a159-70d11aafdc76 --active 再执行 nova delete f62f11a5-055d-426b-a159-70d11aafdc76
以上是关于openstack基本命令的主要内容,如果未能解决你的问题,请参考以下文章