next up previous contents
Next: 自訂虛擬機 Images Up: Nova Compute and Controller Previous: 測試 Instances 虛擬機   Contents

Instance 管理 cinder 空間

  1. 載入一般使用者 myuser 環境變數。
    [root@kvm4 ~]# source keystonerc_myuser 
    [root@kvm4 ~(keystone_myuser)]# 
    \item 產生一個 1G,type 為 lvm,名為 vol1 的空間。
    \\\begin{myverbatim}
    [root@kvm4 ~(keystone_myuser)]# cinder create --volume-type lvm --display-name vol1 1
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |     attachments     |                  []                  |
    |  availability_zone  |                 nova                 |
    |       bootable      |                false                 |
    |      created_at     |      2014-01-27T11:43:48.057284      |
    | display_description |                 None                 |
    |     display_name    |                 vol1                 |
    |          id         | b8e18b4a-5731-4f5e-9aa7-a9871368bc39 |
    |       metadata      |                  {}                  |
    |         size        |                  1                   |
    |     snapshot_id     |                 None                 |
    |     source_volid    |                 None                 |
    |        status       |               creating               |
    |     volume_type     |                 lvm                  |
    +---------------------+--------------------------------------+
    
  2. 列出 cinder,有一個名為 vol1 的 1G 空間可用,記下其 id。
    [root@kvm4 ~(keystone_myuser)]# cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | b8e18b4a-5731-4f5e-9aa7-a9871368bc39 | available |     vol1     |  1   |     lvm     |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    
  3. 列出虛擬機,有一台名為 minkvm 可用。
    [root@kvm4 ~(keystone_myuser)]# nova list
    +--------------------------------------+--------+--------+--------------------------------------+
    | ID                                   | Name   | Status | Networks                             |
    +--------------------------------------+--------+--------+--------------------------------------+
    | 97b5d1bd-9741-4098-b2a9-bd16d5373cb7 | minkvm | ACTIVE | private=192.168.32.2, 192.168.122.10 |
    +--------------------------------------+--------+--------+--------------------------------------+
    
  4. 附上 vol1 的空間給虛擬機 minkvm。
    [root@kvm4 ~(keystone_myuser)]# nova volume-attach minkvm b8e18b4a-5731-4f5e-9aa7-a9871368bc39 auto
    +----------+--------------------------------------+
    | Property | Value                                |
    +----------+--------------------------------------+
    | device   | /dev/vdb                             |
    | serverId | 97b5d1bd-9741-4098-b2a9-bd16d5373cb7 |
    | id       | b8e18b4a-5731-4f5e-9aa7-a9871368bc39 |
    | volumeId | b8e18b4a-5731-4f5e-9aa7-a9871368bc39 |
    +----------+--------------------------------------+
    
  5. 列出 cinder,可以看到 vol1 正在加入 instance minkvm 中。
    [root@kvm4 ~(keystone_myuser)]# cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | b8e18b4a-5731-4f5e-9aa7-a9871368bc39 | attaching |     vol1     |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    
  6. 過一段時間再次列出 cinder,可以看到 vol1 已加入 instance minkvm 中。
    [root@kvm4 ~(keystone_myuser)]# cinder list
    +--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
    |                  ID                  | Status | Display Name | Size | Volume Type | Bootable |             Attached to              |
    +--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
    | b8e18b4a-5731-4f5e-9aa7-a9871368bc39 | in-use |     vol1     |  1   |     lvm     |  false   | 97b5d1bd-9741-4098-b2a9-bd16d5373cb7 |
    +--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
    
  7. 登入 instance minkvm。
    [root@kvm4 ~(keystone_myuser)]# ssh -i /root/key1.pem root@192.168.122.10
    Last login: Mon Jan 27 07:51:38 2014 from 192.168.122.1
    [root@kvm3 ~]#
    
  8. 看到有一顆 1G 的硬碟 /dev/vdb 可用。
    [root@kvm3 ~]# fdisk -luc /dev/vdb
    
    Disk /dev/vdb: 1073 MB, 1073741824 bytes
    16 heads, 63 sectors/track, 2080 cylinders, total 2097152 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    



2015-12-29