Skip to the content.

Làm việc với Cinder

1. Tạo, xóa, liệt kê, show volume

lamth@Precision:~$ openstack volume create --size 10 lamth-volume-test
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | nova                                 |
| bootable            | false                                |
| consistencygroup_id | None                                 |
| created_at          | 2020-07-15T07:01:08.000000           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | 7e84d45d-d9c8-4786-8374-d4001ec43574 |
| migration_status    | None                                 |
| multiattach         | False                                |
| name                | lamth-volume-test                    |
| properties          |                                      |
| replication_status  | None                                 |
| size                | 10                                   |
| snapshot_id         | None                                 |
| source_volid        | None                                 |
| status              | creating                             |
| type                | __DEFAULT__                          |
| updated_at          | None                                 |
| user_id             | c49ed0d3dfb144dfb41bf1fa9b619f73     |
+---------------------+--------------------------------------+

- Tạo một volume từ volume khác

```bash
lamth@Precision:~$ openstack volume list
+--------------------------------------+-------------------+-----------+------+------------------------------+
| ID                                   | Name              | Status    | Size | Attached to                  |
+--------------------------------------+-------------------+-----------+------+------------------------------+
| 8cbab483-b293-4212-b8a6-baa37f38924a | testvolumeimage   | available |   10 |                              |
| 7e84d45d-d9c8-4786-8374-d4001ec43574 | lamth-volume-test | available |   10 |                              |
| 37cde03d-a679-41dc-912c-23a5fcececbd |                   | in-use    |    9 | Attached to u18 on /dev/vda  |
+--------------------------------------+-------------------+-----------+------+------------------------------+
lamth@Precision:~$ openstack volume create --size 10 --source testvolumeimage testvolumevolume
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | nova                                 |
| bootable            | true                                 |
| consistencygroup_id | None                                 |
| created_at          | 2020-07-15T07:13:15.000000           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | 7a122366-5f79-4879-8bd9-88cda983bb99 |
| migration_status    | None                                 |
| multiattach         | False                                |
| name                | testvolumevolume                     |
| properties          |                                      |
| replication_status  | None                                 |
| size                | 10                                   |
| snapshot_id         | None                                 |
| source_volid        | 8cbab483-b293-4212-b8a6-baa37f38924a |
| status              | creating                             |
| type                | __DEFAULT__                          |
| updated_at          | None                                 |
| user_id             | c49ed0d3dfb144dfb41bf1fa9b619f73     |
+---------------------+--------------------------------------+
openstack volume delete <tên hoặc ID volume>
openstack volume list

2. Snapshot volume

[root@controller ~]# openstack volume snapshot create --volume dup_testimage snap_test
+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| created_at  | 2018-12-19T08:26:31.246334           |
| description | None                                 |
| id          | 039383eb-a7c2-4b6d-9121-eb6fdea0b19d |
| name        | snap_test                            |
| properties  |                                      |
| size        | 20                                   |
| status      | creating                             |
| updated_at  | None                                 |
| volume_id   | 1f502752-3764-4604-8b9d-fcc595dc9cfa |
+-------------+--------------------------------------+

 openstack volume snapshot delete <tên snapshot>

3. Attach và detach volume cho máy ảo

  openstack server add volume < VM> <tên volume> --device </dev/...>
  openstack server remove volume <VM> <tên volume>