In this exercise, you will deploy an instance with persistent bootable storage, create a blank volume, attach the volume to the instance, detach it, and attach it to another instance. You will deploy a new instance from a volume snapshot. Also, you will delete the created volumes and volume snapshots.
Outcomes
You should be able to:
Deploy an instance with persistent storage.
Create a blank volume, and attach and detach it.
Create a volume snapshot, and deploy a new instance with it.
Delete the volume and volume snapshot.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that all resources required for the exercise are present.
[student@workstation ~]$ lab vmdisks-volumes start
Procedure 5.3. Instructions
This guided exercise is in two parts. In part 1 you use the CLI, and in part 2 you use the Dashboard.
As the developer1 user in the finance project, create a new instance with a persistent volume, and then verify the resources. Use the values in the following table:
| Setting | Instance |
|---|---|
| Instance name |
finance-server1
|
| Image |
rhel8
|
| Flavor |
default
|
| Network (private) |
finance-network3
|
| Disk Size | 10 |
On workstation, source the identity environment file for the developer1 user in the finance project.
[student@workstation ~]$ source ~/developer1-finance-rcUse the openstack server create command to create the finance-server1 instance using the information in the previous table. Add the --boot-from-volume option to create the instance with a persistent volume.
[student@workstation ~(developer1-finance)]$openstack server create \>--image rhel8 \>--flavor default \>--boot-from-volume 10 \>--nic net-id=finance-network3 \>--wait \>finance-server1+-----------------------------+--------------------------------------------------+ | Field | Value | +-----------------------------+--------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | nova | | OS-EXT-STS:power_state | Running | | OS-EXT-STS:task_state | None | | OS-EXT-STS:vm_state | active | | OS-SRV-USG:launched_at | 2020-06-22T00:24:52.000000 | | OS-SRV-USG:terminated_at | None | | accessIPv4 | | | accessIPv6 | | | addresses | finance-network3=192.168.3.205 | | adminPass | UmEXRdzRexm4 | | config_drive | | | created | 2020-06-22T00:24:15Z | | flavor | default (8ff1eecb-15b4-4f32-bb99-4dec999a78c7) | | hostId | a0de1ca783d5960886a0be1d0a8112c23618837b11244c94 | | | 17240de7 | | id | 758d7485-e2dc-4998-8a6d-adb9cda9fcd1 | | image | | | key_name | None | | name | finance-server1 | | progress | 0 | | project_id | 3fe4ec06f5654a4d906a640d7f1a0457 | | properties | | | security_groups | name='default' | | status | ACTIVE | | updated | 2020-06-22T00:24:52Z | | user_id | b3bf77638121e0abd2a5e89fa85f6649e76fd45d45a1470b | | | ce0adcce1a5c3570 | | volumes_attached | id='960ca587-357b-44d3-844f-b713b4be1059' | +-----------------------------+--------------------------------------------------+
Verify that a volume has been created and used for the finance-server1 instance. Notice the value of server_id in the output; it has the same value as the finance-server1 server ID.
[student@workstation ~(developer1-finance)]$openstack volume list -f json[ { "ID": "960ca587-357b-44d3-844f-b713b4be1059", "Name": "", "Status": "in-use", "Size": 10, "Attached to": [ { "id": "960ca587-357b-44d3-844f-b713b4be1059", "attachment_id": "a7d414c7-1ea5-4109-bec8-b9dcc505400d", "volume_id": "960ca587-357b-44d3-844f-b713b4be1059", "server_id": "758d7485-e2dc-4998-8a6d-adb9cda9fcd1", "host_name": null, "device": "/dev/vda", "attached_at": "2020-06-22T00:24:49.000000" } ] } ]
Create a 1 GB blank volume named finance-volume2, attach it to the finance-server1 server, and verify the resources.
Create a blank volume named finance-volume2. Configure the size of this volume to be 1 GB.
[student@workstation ~(developer1-finance)]$openstack volume create \>--size 1 finance-volume2+---------------------+----------------------------------------------------------+ | Field | Value | +---------------------+----------------------------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | consistencygroup_id | None | | created_at | 2020-06-22T00:52:48.000000 | | description | None | | encrypted | False | | id | dcd7baf1-d091-4c91-a305-8b547dee88e5 | | multiattach | False | | name | finance-volume2 | | properties | | | replication_status | None | | size | 1 | | snapshot_id | None | | source_volid | None | | status | creating | | type | tripleo | | updated_at | None | | user_id | b3bf77638121e0abd2a5e89fa85f6649e76fd45d45a1470bce0adcce | | | 1a5c3570 | +---------------------+----------------------------------------------------------+
Verify that the finance-volume2 volume has been correctly created. Verify that the value for the status field is available.
[student@workstation ~(developer1-finance)]$openstack volume show \>-c name -c status finance-volume2+--------+-----------------+ | Field | Value | +--------+-----------------+ | name | finance-volume2 | | status | available | +--------+-----------------+
Attach the finance-volume2 volume to the finance-server1 instance.
[student@workstation ~(developer1-finance)]$openstack server add volume \>finance-server1 finance-volume2
Verify that finance-volume2 has been correctly attached to the finance-server1 instance as the /dev/vdb device.
[student@workstation ~(developer1-finance)]$openstack volume list \>-c Name -c "Attached to"+-----------------+------------------------------------------+ | Name | Attached to | +-----------------+------------------------------------------+ |finance-volume2| Attached tofinance-server1 on /dev/vdb| | | Attached to finance-server1 on /dev/vda | +-----------------+------------------------------------------+
Modify the /etc/motd file to create a message of the day. Create an XFS file system on the finance-volume2 volume, create the /volume2 directory, mount it, and create a file on it.
Retrieve the console URL for the finance-server1 instance.
[student@workstation ~(developer1-finance)]$openstack console url show \>finance-server1+-------+------------------------------------------------------------------------+ | Field | Value | +-------+------------------------------------------------------------------------+ | type | novnc | | url | http://172.25.250.50:6080/vnc_auto.html?path=%3Ftoken%3Dd2ba4452-2337- | | | 4052-8cf2-182e63cd06f9 | +-------+------------------------------------------------------------------------+
Open Firefox and navigate to the console URL previously obtained.
Log in to finance-server1 using root as the user name and redhat as the password.
Add the following lines to the /etc/motd file.
[root@finance-server1 ~]#cat << EOF > /etc/motd> >WELCOME TO THE IMAGE FROM A SNAPSHOT> >EOF
Verify in the finance-server1 instance that the finance-volume2 volume is mapped to the /dev/vdb device.
[root@finance-server1 ~]#lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 253:0 0 10G 0 disk └─vda1 253:1 0 10G 0 part /vdb 253:16 0 1G 0 disk
Create a new partition in the /dev/vdb device.
[root@finance-server1 ~]#parted /dev/vdb \>mklabel msdos \>mkpart primary xfs 0% 100%Information: You may need to update /etc/fstab. [root@finance-server1 ~]#
Create an XFS file system on the /dev/vdb1 partition.
[root@finance-server1 ~]# mkfs.xfs /dev/vdb1
...output omitted...Create the /volume2 directory. Mount the /dev/vdb1 partition on the /volume2 directory. Verify that the /dev/vdb1 partition has been correctly mounted.
[root@finance-server1 ~]#mkdir /volume2[root@finance-server1 ~]#mount -t xfs /dev/vdb1 /volume2/[root@finance-server1 ~]#mount | grep /volume2/dev/vdb1 on /volume2 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
Create the /volume2/file file.
[root@finance-server1 ~]# echo "This is my file" > /volume2/fileVerify the /volume2/file file has been created.
[root@finance-server1 ~]# cat /volume2/file
This is my fileUnmount the /dev/vdb1 partition from the /volume2 directory.
[root@finance-server1 ~]# umount /volume2Detach the finance-volume2 volume from the finance-server1 instance, and verify it.
In the workstation terminal window, use the openstack server remove volume command to detach the volume from finance-server1.
[student@workstation ~(developer1-finance)]$openstack server remove volume \>finance-server1 finance-volume2
Verify that the finance-volume2 volume has been correctly detached. Verify that the status for the finance-volume2 volume is available.
[student@workstation ~(developer1-finance)]$openstack volume show \>-c name -c status finance-volume2+--------+-----------------+ | Field | Value | +--------+-----------------+ | name | finance-volume2 | | status |available| +--------+-----------------+
Create an image from a volume snapshot. Name it finance-server1-snapshot and verify the resources.
Use the openstack server image create command to create both the snapshot and an image.
[student@workstation ~(developer1-finance)]$openstack server image create \>--name finance-server1-snapshot \>--wait finance-server1+------------------+-------------------------------------------------------------+ | Field | Value | +------------------+-------------------------------------------------------------+ | checksum | d41d8cd98f00b204e9800998ecf8427e | | container_format | bare | | created_at | 2020-06-22T02:53:24Z | | disk_format | qcow2 | | file | /v2/images/205b421d-8497-45e9-8155-9c7165e0b115/file | | id | 205b421d-8497-45e9-8155-9c7165e0b115 | | min_disk | 10 | | min_ram | 2048 | |name|finance-server1-snapshot| ...output omitted... |status|active| | tags | | | updated_at | 2020-06-22T02:53:25Z | | virtual_size | None | | visibility | private | +------------------+-------------------------------------------------------------+
Verify that the finance-server1-snapshot snapshot has been created.
[student@workstation ~(developer1-finance)]$openstack volume snapshot list \>-c Name -c Status+---------------------------------------+-----------+ | Name | Status | +---------------------------------------+-----------+ | snapshot for finance-server1-snapshot | available | +---------------------------------------+-----------+
Create a new instance with the finance-server1-snapshot image, and then verify the resources. Use the values in the following table:
| Setting | Instance |
|---|---|
| Instance name |
finance-server2
|
| Image |
finance-server1-snapshot
|
| Flavor |
default
|
| Network (private) |
finance-network3
|
Use the openstack server create command to create the finance-server2 instance using the information in the previous table.
[student@workstation ~(developer1-finance)]$openstack server create \>--image finance-server1-snapshot \>--flavor default \>--nic net-id=finance-network3 \>--wait \>finance-server2+-----------------------------+--------------------------------------------------+ | Field | Value | +-----------------------------+--------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | nova | | OS-EXT-STS:power_state | Running | | OS-EXT-STS:task_state | None | | OS-EXT-STS:vm_state | active | | OS-SRV-USG:launched_at | 2020-06-22T03:26:36.000000 | | OS-SRV-USG:terminated_at | None | | accessIPv4 | | | accessIPv6 | | | addresses | finance-network3=192.168.3.167 | | adminPass | uvR2QtcT4ZuC | | config_drive | | | created | 2020-06-22T03:26:26Z | | flavor | default (8ff1eecb-15b4-4f32-bb99-4dec999a78c7) | | hostId | 270d29f8ba5e76c1fd80c56d592882a1138b5d12ad0f35a1 | | | 7eac7546 | | id |253ff506-7d33-4269-8d29-49d897c2602c| | image | finance-server1-snapshot | | | (205b421d-8497-45e9-8155-9c7165e0b115) | | key_name | None | | name | finance-server2 | | progress | 0 | | project_id | 3fe4ec06f5654a4d906a640d7f1a0457 | | properties | | | security_groups | name='default' | | status | ACTIVE | | updated | 2020-06-22T03:26:37Z | | user_id | b3bf77638121e0abd2a5e89fa85f6649e76fd45d45a1470b | | | ce0adcce1a5c3570 | | volumes_attached | id='4053e1de-62bb-470a-8fc3-b6bbdaaa2590' | +-----------------------------+--------------------------------------------------+
Verify that the finance-server2 instance uses /dev/vda for its persistent storage. Notice in the output the value of server_id; it is the same as the ID for finance-server2.
[student@workstation ~(developer1-finance)]$openstack volume list -f json[ { "ID": "4053e1de-62bb-470a-8fc3-b6bbdaaa2590", "Name": "", "Status": "in-use", "Size": 10, "Attached to": [ { "id": "4053e1de-62bb-470a-8fc3-b6bbdaaa2590", "attachment_id": "63c115a7-7d5b-48ab-8f4c-f1d545a1e209", "volume_id": "4053e1de-62bb-470a-8fc3-b6bbdaaa2590", "server_id": "253ff506-7d33-4269-8d29-49d897c2602c", "host_name": null, "device": "/dev/vda", "attached_at": "2020-06-22T03:26:33.000000" } ] }, ...output omitted... ]
Verify the message of the day in the /etc/motd file on the finance-server2 instance. Attach the finance-volume2 volume to the finance-server2 instance and verify the file on it.
Attach the finance-volume2 volume to the finance-server2 instance.
[student@workstation ~(developer1-finance)]$openstack server add volume \>finance-server2 finance-volume2
Verify that finance-volume2 has been correctly attached to the finance-server2 instance as the /dev/vdb device.
[student@workstation ~(developer1-finance)]$openstack volume list \>-c Name -c "Attached to"+-----------------+------------------------------------------+ | Name | Attached to | +-----------------+------------------------------------------+ | | Attached to finance-server2 on /dev/vda | |finance-volume2| Attached tofinance-server2 on /dev/vdb| | | Attached to finance-server1 on /dev/vda | +-----------------+------------------------------------------+
Retrieve the console URL for the finance-server2 instance.
[student@workstation ~(developer1-finance)]$openstack console url show \>finance-server2+-------+------------------------------------------------------------------------+ | Field | Value | +-------+------------------------------------------------------------------------+ | type | novnc | | url | http://172.25.250.50:6080/vnc_auto.html?path=%3Ftoken%3Db57c1498-5b5a- | | | 4093-9234-a5f30bb8cfd3 | +-------+------------------------------------------------------------------------+
Open Firefox and navigate to the console URL previously obtained.
Log in to finance-server2 using root as the user name and redhat as the password.
Notice the message after you have logged in.
finance-server2 login:rootPassword: Last login: Mon Jun 22 15:25:58 on tty1WELCOME TO THE IMAGE FROM A SNAPSHOT[root@finance-server2 ~]#
Verify in the finance-server2 instance that the finance-volume2 volume is mapped to the /dev/vdb device.
[root@finance-server2 ~]#lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 253:0 0 10G 0 disk └─vda1 253:1 0 10G 0 part / vdb 253:16 0 1G 0 disk└─vdb1 253:17 0 1023M 0 part
Mount the /dev/vdb1 partition on the /volume2 directory. The directory /volume2 must be created.
[root@finance-server1 ~]# mount -t xfs /dev/vdb1 /volume2/Display the contents of the /volume2/file file.
[root@finance-server2 ~]# cat /volume2/file
This is my fileDelete the finance-server2 instance with its volume, and finance-server1-snapshot snapshot.
In the terminal window on workstation, review the volumes and where they are mounted. Determine which volume ID is attached as /dev/vda/ in the finance-server2 instance.
[student@workstation ~(developer1-finance)]$openstack volume list \>-c ID -c "Attached to"+--------------------------------------+-----------------------------------------+ | ID | Attached to | +--------------------------------------+-----------------------------------------+ |83d6a764-c41c-4569-9fe7-03be4cccb0b6| Attached tofinance-server2on /dev/vda | | 4439d1b9-a428-41ad-8dad-cbebc3dfccf3 | Attached to finance-server2 on /dev/vdb | | 71cb3ed1-8ed2-494f-bca8-61fdf7b24daf | Attached to finance-server1 on /dev/vda | +--------------------------------------+-----------------------------------------+
Delete the finance-server2 instance.
[student@workstation ~(developer1-finance)]$openstack server delete \>finance-server2
Delete the finance-server2 volume.
[student@workstation ~(developer1-finance)]$openstack volume delete \>83d6a764-c41c-4569-9fe7-03be4cccb0b6
Verify that the finance-server2 volume has been deleted.
[student@workstation ~(developer1-finance)]$openstack volume list \>-c Name -c "Attached to"+-----------------+------------------------------------------+ | Name | Attached to | +-----------------+------------------------------------------+ | finance-volume2 | | | | Attached to finance-server1 on /dev/vda | +-----------------+------------------------------------------+
List the volume snapshot.
[student@workstation ~(developer1-finance)]$ openstack volume snapshot list
+-----------------------+-----------------------+-------------+-----------+------+
| ID | Name | Description | Status | Size |
+-----------------------+-----------------------+-------------+-----------+------+
| 53b88d27-2c10-4578-bf | snapshot for finance- | | available | 10 |
| ba-94f59bc04bb0 | server1-snapshot | | | |
+-----------------------+-----------------------+-------------+-----------+------+Delete the finance-server1-snapshot volume snapshot.
[student@workstation ~(developer1-finance)]$openstack volume snapshot delete \>53b88d27-2c10-4578-bfba-94f59bc04bb0
Use the Dashboard to perform the following steps.
In the Dashboard, as developer1, create an instance with a persistent volume.
Log in to the Dashboard at http://dashboard.overcloud.example.com as developer1, using Example as the domain and redhat as the password. Confirm that the selected project is finance.
Navigate to → → and then click .
On the tab, enter finance-server3 in the field.
On the tab, select from the → list. Set the to . Click to select rhel8 as the image.
On the tab, click to select default as the flavor.
On the tab, ensure that the finance-network3 network has been allocated.
Click to launch the finance-server3 instance.
Verify that a volume has been created and used for the finance-server3 instance.
Navigate to → → .
Create a 1 GB blank volume named finance-volume4 and attach it to the finance-server3 instance.
Navigate to → → and click .
Enter finance-volume4 in the field. Select 1 in the field. Click to create the volume.
Select in the menu for finance-volume4.
Select finance-server3 in the field, and then click .
Verify that the field sets the finance-volume4 mapping to /dev/vdb on finance-server3.
Detach the finance-volume4 volume from the finance-server3 instance.
Navigate to → → and then click in the menu for the finance-volume4 volume.
Click for finance-server3. Click again in the window to confirm.
Verify that the finance-volume4 volume status is Available.
Create an image from the finance-server3 volume snapshot.
Navigate to → → and then click for finance-server3.
Enter finance-server3-snapshot in the field. Click to create the volume snapshot.
Verify that the finance-server3-snapshot snapshot has been created.
Navigate to → → .
Create an instance with the finance-server3-snapshot volume snapshot.
Navigate to → → and then click .
On the tab, enter finance-server4 in the field.
On the tab, select from the list.
Set the to . Click to select finance-server3-snapshot as the volume snapshot.
On the tab, click to select default as the flavor.
On the tab, ensure that the finance-network3 network has been allocated.
Click to launch the finance-server4 instance.
In the column, verify that the status is Running.
Delete the finance-server4 instance and the finance-server3-snapshot snapshot.
Navigate to → → .
Delete finance-server4 instance by selecting from the actions menu.
Click again in the window to confirm.
Navigate to → → .
Delete the finance-server3-snapshot volume snapshot by selecting from the actions menu.
Click again in the window to confirm.
This concludes the guided exercise.