A new MariaDB VM is provisioned with a boot disk and a single 15 GB data disk. To ensure performance, you must separate database data files, transaction logs, and undo files onto their own disks. You add a new disk for each file type, point MariaDB to the appropriate disk for each type, and then delete the old disk to reclaim your storage.
Outcomes
Create disks with specific requirements.
Attach disks to existing VMs.
Detach disks from VMs.
Delete disks.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that the cluster API is reachable.
The command also creates the storage-multiple namespace and starts the mariadb-server VM in that namespace.
[student@workstation ~]$ lab start storage-multiple
Instructions
As the admin user, locate and then navigate to the OpenShift web console.
Confirm that the mariadb-server VM is running.
From a terminal, log in to your Red Hat OpenShift cluster as the admin user.
[student@workstation ~]$ oc login -u admin -p redhatocp \
https://api.ocp4.example.com:6443
Login Successful
...output omitted...Identify the URL for the OpenShift web console.
[student@workstation ~]$ oc whoami --show-console
https://console-openshift-console.apps.ocp4.example.comOpen a web browser and navigate to the web console URL: https://console-openshift-console.apps.ocp4.example.com
Select and log in as the admin user with redhatocp as the password.
Confirm that only the vda, vdb, and vdc disks are attached to the VM.
Navigate to → .
Select the storage-multiple project.
Confirm that the mariadb-server VM is running.
Click the VM name and navigate to the tab.
Log in as the root user with redhat as the password.
Run the lsblk command to list the block devices.
[root@mariadb-server ~]#lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTvda252:0 0 10G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 100M 0 part /boot/efi └─vda3 252:3 0 9.9G 0 part /vdb252:16 0 1M 0 diskvdc252:32 0 14.2G 0 disk
Navigate to the → tab.
Notice that the storage class for the dbroot disk is nfs-storage, which is using slow NFS shares as back-end storage.
The MariaDB server uses that dbroot disk to store the database files.
Confirm that the database service is working correctly and that you can access the sakila database.
[root@mariadb-server ~]#mysql -u devuser -p'developer' sakila...output omitted... MariaDB [sakila]>SHOW TABLES;+----------------------------+ | Tables_in_sakila | +----------------------------+ ...output omitted... +----------------------------+ 23 rows in set (0.001 sec) MariaDB [sakila]>quitBye
Log out of the VM console.
[root@mariadb-server ~]# logoutCreate and attach three 5 GiB disks to the mariadb-server VM.
Use the fast ocs-external-storagecluster-ceph-rbd-virtualization storage class in Block mode.
Preallocate the space for improving write performance.
Use the VirtIO interface to connect the disks to the VM.
Stop the mariadb-server VM to attach more disks.
From the OpenShift web console, select the mariadb-server VM and then click → .
Click to confirm the operation, if needed.
Navigate to the → tab.
Click to create and attach the dbdata disk.
Complete the form by using the following information and click to create and attach the disk to the VM.
Repeat this step for the dbredo and dbundo disks.
You configure that disk for the MariaDB Server data files in another step.
If the field is set to SCSI and VirtIO is not available, then click and start over. The web interface takes a few seconds to detect that the VM is stopped.
| Field | Value |
|---|---|
| Use this disk as a boot source | Unset |
| Name |
|
| Source | Blank (creates PVC) |
| Size | 5 GiB |
| Type | Disk |
| Interface | VirtIO |
| StorageClass |
ocs-external-storagecluster-ceph-rbd-virtualization
|
| Apply optimized StorageProfile settings | Checked |
| Access mode | Shared access (RWX) |
| Volume mode | Block |
| Enable preallocation | Checked |
Wait until OpenShift finishes the provisioning of the VM disks and the Pending changes admonition is not displayed.
![]() |
Click → to start the VM and wait until it is running.
Log in to the VM console and confirm that three new 5 GiB devices are available.
Navigate to the tab and then log in as the root user with redhat as the password.
Run the lsblk command to list the block devices.
Notice the three 5 GiB block devices.
[root@mariadb-server ~]#lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 10G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 100M 0 part /boot/efi └─vda3 252:3 0 9.9G 0 part / vdb 252:16 0 1M 0 disk vdc 252:32 0 14.2G 0 diskvdd 252:48 0 5G 0 disk![]()
vde 252:64 0 5G 0 disk![]()
vdf 252:80 0 5G 0 disk
The lab command prepared the /root/dbmove.sh script to format the three disks and then move the database files to these disks.
Run the script to migrate the MariaDB server data.
From the mariadb-server VM console, run the script:
[root@mariadb-server ~]# ~/dbmove.sh
...output omitted...Confirm that the database service is working correctly and that you can access the sakila database.
[root@mariadb-server ~]#mysql -u devuser -p'developer' sakila...output omitted... MariaDB [sakila]>SHOW TABLES;+----------------------------+ | Tables_in_sakila | +----------------------------+ ...output omitted... +----------------------------+ 23 rows in set (0.001 sec) MariaDB [sakila]>quitBye
Log out of the VM console.
[root@mariadb-server ~]# logoutDetach and then delete the dbroot disk.
The MariaDB server stored its data on that disk before you moved the data to the three new disks.
Click → to stop the VM, and wait for the machine to stop.
Navigate to the → tab.
Click the vertical ellipsis icon to the right of the dbroot disk and then click .
In the confirmation window, click to confirm.
Click → , and wait until the VM is running.
Log in to the VM console and confirm that the 15 GiB device is no longer shown.
Navigate to the tab and then log in as the root user with redhat as the password.
Run the lsblk command to list the block devices.
Notice that the deleted 15 GiB block device is no longer listed.
[root@mariadb-server ~]#lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 10G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 100M 0 part /boot/efi └─vda3 252:3 0 9.9G 0 part / vdb 252:16 0 1M 0 disk vdc 252:32 05G0 disk /mariadb/data vdd 252:48 05G0 disk /mariadb/redo vde 252:64 05G0 disk /mariadb/undo
Log out of the VM console.
[root@mariadb-server ~]# logout