块设备存储¶
新建卷¶
加载 ``demo``证书,作为非管理员项目执行下面的步骤:
$ . demo-openrc
创建一个 1 GB 的卷:
$ openstack volume create --size 1 volume1 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | consistencygroup_id | None | | created_at | 2016-03-08T14:30:48.391027 | | description | None | | encrypted | False | | id | a1e8be72-a395-4a6f-8e07-856a57c39524 | | multiattach | False | | name | volume1 | | properties | | | replication_status | disabled | | size | 1 | | snapshot_id | None | | source_volid | None | | status | creating | | type | None | | updated_at | None | | user_id | 684286a9079845359882afc3aa5011fb | +---------------------+--------------------------------------+
过会,卷状态应该从``creating`` 变成``available``:
$ openstack volume list +--------------------------------------+--------------+-----------+------+-------------+ | ID | Display Name | Status | Size | Attached to | +--------------------------------------+--------------+-----------+------+-------------+ | a1e8be72-a395-4a6f-8e07-856a57c39524 | volume1 | available | 1 | | +--------------------------------------+--------------+-----------+------+-------------+
附加卷到一个实例上¶
附加卷到一个实例上:
$ openstack server add volume INSTANCE_NAME VOLUME_NAME
使用实例名称替换
INSTANCE_NAME
并使用你想要附加卷的名称替换``VOLUME_NAME ``。Example
附加
volume1 ``卷到 ``provider-instance
云主机:$ openstack server add volume provider-instance volume1
备注
这个命令执行后没有输出。
列出卷:
$ openstack volume list +--------------------------------------+--------------+--------+------+--------------------------------------------+ | ID | Display Name | Status | Size | Attached to | +--------------------------------------+--------------+--------+------+--------------------------------------------+ | a1e8be72-a395-4a6f-8e07-856a57c39524 | volume1 | in-use | 1 | Attached to provider-instance on /dev/vdb | +--------------------------------------+--------------+--------+------+--------------------------------------------+
使用SSH方式访问你的实力,并使用``fdisk`` 命令验证`/dev/vdb`块存储设备作为卷存在。
$ sudo fdisk -l Disk /dev/vda: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 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 Device Boot Start End Blocks Id System /dev/vda1 * 16065 2088449 1036192+ 83 Linux 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 Disk /dev/vdb doesn't contain a valid partition table
备注
你必须在设备上创建文件系统并挂载它,才能使用这个卷。
For more information about how to manage volumes, see the python-openstackclient documentation for Pike, the python-openstackclient documentation for Queens, or the python-openstackclient documentation for Rocky.
返回到:ref: launch-instance。