Skip to content

Latest commit

 

History

History
178 lines (152 loc) · 7.93 KB

04.Work-with-Cinder-using-CLI.md

File metadata and controls

178 lines (152 loc) · 7.93 KB

Làm việc với Cinder

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

  • Tạo một volume no-source
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 volume từ image
lamth@Precision:~$ openstack image list
+--------------------------------------+----------------------------+--------+
| ID                                   | Name                       | Status |
+--------------------------------------+----------------------------+--------+
| bdf401b4-fdef-4d64-9365-a7e770776ba1 | CentOS7-64bit-2019         | active |
| 50d4b4ed-5322-4291-867e-a049704a210c | Centos7.9-final            | active |
| 122d18e5-6027-425c-a82f-d6c56e528206 | Cirros                     | active |
| a4b63b26-e1bc-452d-8f6f-e75822d1f750 | U16-ipv6-enable            | active |
| 7566b922-9508-423b-ab8f-953ff2bec0cb | U18-ipv6-enable            | active |
| 965b11cc-fa17-48b1-bc74-04ed8854b713 | Windows-2012-r2-64bit-2020 | active |
+--------------------------------------+----------------------------+--------+
lamth@Precision:~$ openstack volume create --size 10 --image Centos7.9-final testvolumeimage
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | nova                                 |
| bootable            | false                                |
| consistencygroup_id | None                                 |
| created_at          | 2020-07-15T07:11:05.000000           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | 8cbab483-b293-4212-b8a6-baa37f38924a |
| migration_status    | None                                 |
| multiattach         | False                                |
| name                | testvolumeimage                      |
| 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
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     |
+---------------------+--------------------------------------+
  • Xóa volume
openstack volume delete <tên hoặc ID volume>
  • Liệt kê các volume
openstack volume list
  • show volume
openstack volume show <tên hoặc ID volume>

2. Snapshot volume

  • Tạo snapshot
[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 |
+-------------+--------------------------------------+
  • List ra danh sách các snapshot của volume
openstack volume snapshot list
  • Xóa snapshot
 openstack volume snapshot delete <tên snapshot>

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

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