首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > 云计算 >

Openstack范例相关操作

2013-01-05 
Openstack实例相关操作对于OpenStack的具体安装,可以查看“五岳之巅”的博客 http://blog.chinaunix.net/uid

Openstack实例相关操作

对于OpenStack的具体安装,可以查看“五岳之巅”的博客 http://blog.chinaunix.net/uid/22414998/frmd/154248.html 讲解较为详细。

以下内容是如何在linux命令行下进行nova-compute实例的相关操作,这些操作均可以通过OpenStack的Horizon服务在web界面上完成,本文只是作者笔记,供参考用。

 

客户端系统环境:

ubuntu-desktop-12.04

python-novaclient glance-client swift kvm

export SERVICE_TOKEN=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL="http://192.168.111.128:5000/v2.0/"
export SERVICE_ENDPOINT=http://192.168.111.128:35357/v2.0

以上是客户端主机系统的基本要求,本文中由于Nova是安装在192.168.111.128上面的,所以读者应根据实际情况设置。

 

在拥有以上的环境后,可以通过命令操作来查看、创建、管理实例。 

查看Image的信息:

root@client:~# nova image-list
+--------------------------------------+--------------+--------+--------+
|                  ID                  |     Name     | Status | Server |
+--------------------------------------+--------------+--------+--------+
| 50a278f9-54e2-485c-9592-f0e485689df0 | ubuntu-12.04 | ACTIVE |        |
+--------------------------------------+--------------+--------+--------+

root@client:~# nova image-list
+--------------------------------------+--------------+--------+--------+
|                  ID                  |     Name     | Status | Server |
+--------------------------------------+--------------+--------+--------+
| 50a278f9-54e2-485c-9592-f0e485689df0 | ubuntu-12.04 | ACTIVE |        |
+--------------------------------------+--------------+--------+--------+

查看可用的kvm实例化配置信息:
root@client:~# nova flavor-list
+----+--------------+-----------+------+-----------+------+-------+-------------+
| ID |     Name     | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor |
+----+--------------+-----------+------+-----------+------+-------+-------------+
| 1  | m1.tiny      | 512       | 0    | 0         |      | 1     | 1.0         |
| 2  | m1.small     | 2048      | 10   | 20        |      | 1     | 1.0         |
| 3  | m1.medium    | 4096      | 10   | 40        |      | 2     | 1.0         |
| 4  | m1.large     | 8192      | 10   | 80        |      | 4     | 1.0         |
| 5  | m1.xlarge    | 16384     | 10   | 160       |      | 8     | 1.0         |
| 6  | svr_2-512-10 | 512       | 10   | 20        |      | 2     | 1.0         |
+----+--------------+-----------+------+-----------+------+-------+-------------+

 

启动一个实例:

root@client:~# nova boot --flavor=1 --image=50a278f9-54e2-485c-9592-f0e485689df0 testserver
+-------------------------------------+--------------------------------------+
|               Property              |                Value                 |
+-------------------------------------+--------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                               |
| OS-EXT-SRV-ATTR:host                | None                                 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None                                 |
| OS-EXT-SRV-ATTR:instance_name       | instance-00000004                    |
| OS-EXT-STS:power_state              | 0                                    |
| OS-EXT-STS:task_state               | scheduling                           |
| OS-EXT-STS:vm_state                 | building                             |
| accessIPv4                          |                                      |
| accessIPv6                          |                                      |
| adminPass                           | sJcaPJYp22Fc                         |
| config_drive                        |                                      |
| created                             | 2012-12-22T06:36:02Z                 |
| flavor                              | m1.tiny                              |
| hostId                              |                                      |
| id                                  | 6b92ce5a-5499-4b42-a346-13b78e28d3e8 |
| image                               | ubuntu-12.04                         |
| key_name                            |                                      |
| metadata                            | {}                                   |
| name                                | testserver                           |
| progress                            | 0                                    |
| status                              | BUILD                                |
| tenant_id                           | dac9bcbdf94d4764b1fc919b126727ca     |
| updated                             | 2012-12-22T06:36:02Z                 |
| user_id                             | bb1468f01a8548cf8160836ca6a82679     |
+-------------------------------------+--------------------------------------+

该实例使用flavor中ID为1的资源配置,镜像使用ID为50a278f9-54e2-485c-9592-f0e485689df0 的镜像,实例的显示名称为testserver

启动完该实例后,直观的从web上看:

Openstack范例相关操作

 

命令行查看实例情况:

root@client:~# nova list
+--------------------------------------+------------+--------+----------+
|                  ID                  |    Name    | Status | Networks |
+--------------------------------------+------------+--------+----------+
| 6b92ce5a-5499-4b42-a346-13b78e28d3e8 | testserver | ACTIVE |          |
+--------------------------------------+------------+--------+----------+

 

 查看实例的详细信息:

root@client:~# nova show 6b92ce5a-5499-4b42-a346-13b78e28d3e8
+-------------------------------------+----------------------+
|               Property              |                          Value                           |
+-------------------------------------+----------------------+
| OS-DCF:diskConfig                   | MANUAL                                                   |
| OS-EXT-SRV-ATTR:host                | svr1                                                     |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None                                                     |
| OS-EXT-SRV-ATTR:instance_name       | instance-00000004                                        |
| OS-EXT-STS:power_state              | 1                                                        |
| OS-EXT-STS:task_state               | None                                                     |
| OS-EXT-STS:vm_state                 | active                                                   |
| accessIPv4                          |                                                          |
| accessIPv6                          |                                                          |
| config_drive                        |                                                          |
| created                             | 2012-12-22T06:36:02Z                                     |
| flavor                              | m1.tiny                                                  |
| hostId                              | 0cb64f5bbe94b0a71f29d17025afe844d0fd047f8dae71d0142ebae1 |
| id                                  | 6b92ce5a-5499-4b42-a346-13b78e28d3e8                     |
| image                               | ubuntu-12.04                                             |
| key_name                            |                                                          |
| metadata                            | {}                                                       |
| name                                | testserver                                               |
| progress                            | 0                                                        |
| status                              | ACTIVE                                                   |
| tenant_id                           | dac9bcbdf94d4764b1fc919b126727ca                         |
| updated                             | 2012-12-22T06:36:05Z                                     |
| user_id                             | bb1468f01a8548cf8160836ca6a82679                         |
+-------------------------------------+----------------------+

热点排行