Bookmark this page

Guided Exercise: Attach and Access Disks on Virtual Machines

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

  1. As the admin user, locate and then navigate to the OpenShift web console. Confirm that the mariadb-server VM is running.

    1. 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...
    2. Identify the URL for the OpenShift web console.

      [student@workstation ~]$ oc whoami --show-console
      https://console-openshift-console.apps.ocp4.example.com
    3. Open a web browser and navigate to the web console URL: https://console-openshift-console.apps.ocp4.example.com

      Select htpasswd_provider and log in as the admin user with redhatocp as the password.

  2. Confirm that only the vda, vdb, and vdc disks are attached to the VM.

    1. Navigate to VirtualizationVirtualMachines. Select the storage-multiple project. Confirm that the mariadb-server VM is running.

    2. Click the VM name and navigate to the Console tab. Log in as the root user with redhat as the password. Run the lsblk command to list the block devices.

      [root@mariadb-server ~]# lsblk
      NAME   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 disk
    3. Navigate to the ConfigurationDisks 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.

    4. 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]> quit
      Bye
    5. Log out of the VM console.

      [root@mariadb-server ~]# logout
  3. Create 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.

    1. Stop the mariadb-server VM to attach more disks. From the OpenShift web console, select the mariadb-server VM and then click ActionsStop. Click Stop to confirm the operation, if needed.

    2. Navigate to the ConfigurationDisks tab. Click Add disk to create and attach the dbdata disk. Complete the form by using the following information and click Add 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.

      Note

      If the Interface field is set to SCSI and VirtIO is not available, then click Cancel 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
      • dbdata

      • dbredo

      • dbundo

      SourceBlank (creates PVC)
      Size5 GiB
      TypeDisk
      InterfaceVirtIO
      StorageClass ocs-external-storagecluster-ceph-rbd-​virtualization
      Apply optimized StorageProfile settings Checked
      Access modeShared access (RWX)
      Volume modeBlock
      Enable preallocation Checked
    3. Wait until OpenShift finishes the provisioning of the VM disks and the Pending changes admonition is not displayed.

    4. Click ActionsStart to start the VM and wait until it is running.

    5. Log in to the VM console and confirm that three new 5 GiB devices are available. Navigate to the Console 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 ~]# lsblk
      NAME   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 disk
      vdd    252:48   0    5G  0 disk	1
      vde    252:64   0    5G  0 disk	2
      vdf    252:80   0    5G  0 disk	3

      1

      The vdd device corresponds to the dbdata disk.

      2

      The vde device corresponds to the dbredo disk.

      3

      The vdf device corresponds to the dbundo disk.

  4. 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.

    1. From the mariadb-server VM console, run the script:

      [root@mariadb-server ~]# ~/dbmove.sh
      ...output omitted...
    2. 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]> quit
      Bye
    3. Log out of the VM console.

      [root@mariadb-server ~]# logout
  5. Detach 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.

    1. Click ActionsStop to stop the VM, and wait for the machine to stop.

    2. Navigate to the ConfigurationDisks tab. Click the vertical ellipsis icon to the right of the dbroot disk and then click Detach. In the confirmation window, click Detach to confirm.

    3. Click ActionsStart, and wait until the VM is running.

    4. Log in to the VM console and confirm that the 15 GiB device is no longer shown. Navigate to the Console 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 ~]# lsblk
      NAME   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    5G  0 disk /mariadb/data
      vdd    252:48   0    5G  0 disk /mariadb/redo
      vde    252:64   0    5G  0 disk /mariadb/undo
    5. Log out of the VM console.

      [root@mariadb-server ~]# logout

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish storage-multiple

Revision: do316-4.14-d8a6b80