クレデンシャルを読み込み、CLI コマンドへのアクセス権を取得します。

[root@controller ~]# . openrc/demo-openrc 
[root@controller ~]#

1GB のボリュームを作成します。

[root@controller ~]# cinder create --display-name mariadb-data 1
+------------------------------+--------------------------------------+
| Property                     | Value                                |
+------------------------------+--------------------------------------+
| attachments                  | []                                   |
| availability_zone            | nova                                 |
| bootable                     | false                                |
| consistencygroup_id          | None                                 |
| created_at                   | 2018-11-22T16:09:12.000000           |
| description                  | None                                 |
| encrypted                    | False                                |
| id                           | c211c310-29f7-4437-8d51-2bf5874c8f01 |
| metadata                     | {}                                   |
| multiattach                  | False                                |
| name                         | mariadb-data                         |
| os-vol-tenant-attr:tenant_id | b9644b0689c4469baa45f9acb009d860     |
| replication_status           | None                                 |
| size                         | 1                                    |
| snapshot_id                  | None                                 |
| source_volid                 | None                                 |
| status                       | creating                             |
| updated_at                   | None                                 |
| user_id                      | 64b377d70bc4457faa169912b02a24d1     |
| volume_type                  | None                                 |
+------------------------------+--------------------------------------+
[root@controller ~]# 

ボリュームのリストを表示します。作成したボリュームがリスト上に表示されます。

[root@controller ~]# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+
| ID                                   | Status    | Name         | Size | Volume Type | Bootable | Attached to                          |
+--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+
| 68aec228-ffff-4489-940f-8629bdf92c56 | in-use    |              | 10   | -           | true     | 7cf67e4e-0114-4cd4-b770-edfd5e213427 |
| 7418d28b-9348-4c29-9505-50fe50781701 | in-use    |              | 10   | -           | true     | 637ecf9c-64e3-41ea-85bd-242d84ddbcda |
| 841a81d5-7ba8-4f86-a0de-ad577ebf4bd0 | available | volume01     | 1    | -           | false    |                                      |
| 887d3b0e-7c1b-4c22-9711-6c6bfa028595 | available |              | 10   | -           | true     |                                      |
| b68ce6fd-e6c2-4b32-85fa-32849b913e25 | in-use    |              | 10   | -           | true     | 9636f060-409a-46c3-915b-aa6d50c5c629 |
| c211c310-29f7-4437-8d51-2bf5874c8f01 | available | mariadb-data | 1    | -           | false    |                                      |
| cc630181-2fd2-4f86-b171-5af099097dc6 | in-use    |              | 10   | -           | true     | a8daec69-2490-4ada-8c16-235f13e5c201 |
| f50234c8-422e-470b-ad02-c851bcfa4d35 | in-use    |              | 10   | -           | true     | 03c1fcaf-54b1-4591-9c4e-5f813bbba9f0 |
+--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+
[root@controller ~]# 

作成したボリュームをインスタンスに接続します。ここでは、spider_1 といったインスタンスに ボリュームIDが c211c310-29f7-4437-8d51-2bf5874c8f01 の mariadb-data ボリュームを接続しています。

[root@controller ~]# nova volume-attach spider_1 c211c310-29f7-4437-8d51-2bf5874c8f01
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| id       | c211c310-29f7-4437-8d51-2bf5874c8f01 |
| serverId | a8daec69-2490-4ada-8c16-235f13e5c201 |
| volumeId | c211c310-29f7-4437-8d51-2bf5874c8f01 |
+----------+--------------------------------------+
[root@controller ~]# 

spider_1 インスタンスでディスクのパーティション情報を確認します。 新たに、ディスク( /dev/vdb )が追加されていることを確認できます。

[root@spider-1 ~]# fdisk -l

Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos
Disk identifier: 0x000a2561

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     2099199     1048576   83  Linux
/dev/vda2         2099200    20971519     9436160   8e  Linux LVM

Disk /dev/mapper/centos-root: 8585 MB, 8585740288 bytes, 16769024 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 /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 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 /dev/vdb: 1073 MB, 1073741824 bytes, 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

[root@spider-1 ~]#