Decrease device1 Size for MariaDB Xpand

Overview

The device1 file in MariaDB Xpand is used for all database data, undo logs, temporary tables, Binlogs, and Xpand system objects. Xpand ensures that the device1 file is the same size on all nodes of the cluster. Once the optimum size of the device1 file is derived, it rarely requires change.

To increase the size of the device1 file, see ALTER CLUSTER RESIZE DEVICES.

To reduce the size of the device1 file cluster-wide, follow these instructions.

The following procedure is meant to be completed on one Xpand node at a time. If you have space within your cluster, you may complete the cycle on more than one Xpand node at a time.

  1. Verify, set initial global:

    MariaDB Xpand's device_auto_resize_to_largest system variable controls how device1 files are consistently sized throughout your cluster. Ensure that this is initially set to false so it does not interfere with this process.

    Verify that the initial setting of device_auto_resize_to_largest is false

    SHOW GLOBAL VARIABLES LIKE 'device_auto_resize_to_largest';
    

    Set the global to FALSE, if necessary.

    Run this only if needed:

    SET GLOBAL device_auto_resize_to_largest = FALSE;
    
  2. Softfail an node or nodes, if your cluster has enough free space.

  3. Remove old device1 file:

    After the Xpand node(s) have been softfailed and removed from the cluster, run the following from a command line prompt. This will result in a group change.

    Note

    These commands will format the Xpand node to its default state and remove all the data.

    Run these commands on each Xpand node that was softfailed

    $ rm /data/clustrix/pnid
    $ systemctl stop clustrix
    $ systemctl start clustrix
    
  4. Re-add the Xpand node to the cluster:

    Use this syntax from the MariaDB client to create a default device1 file. This will result in a group change.

    Run this from an Xpand node other than the Xpand node(s) just softfailed:

    ALTER CLUSTER ADD '192.0.2.2';
    
  5. Resize device1:

    Resize the device1 file on each Xpand node added above by using the following control port command:

    Run this command on each Xpand node whose IP was added to the cluster

    $ nc localhost 2048
    $ device resize deviceid size
    

    For example, this sets the size for the first (and only) device of the system (device1), to 800 GiB on the Xpand node to which you are connected. Do this on each Xpand node added above.

    $ device resize 1 800g
    

    Note

    MariaDB recommends that you leave 50 - 100 GiB of free or work space available on each drive. This is site-specific and MariaDB Support can provide guidelines for your specific workload.

  6. Rebalance data:

    The Rebalancer will automatically distribute data to the reconfigured Xpand node(s). If your cluster has enough free space, you do not need to wait for this operation to finish before continuing. For additional information, see "Manage the Rebalancer for MariaDB Xpand".

  7. Repeat for all Xpand nodes:

    Repeat steps 2-6 until all Xpand nodes of the cluster have had their device1 file decreased.

  8. Set global for future use:

    Once the procedure is complete on all Xpand nodes and the device1 files have been reduced in size, set the global variable device_auto_resize_to_largest to TRUE. This ensures that all future Xpand nodes added to the cluster will have their device1 files sized the same.

    Note

    Do not set this global to TRUE until all Xpand nodes in the cluster have completed this process.

    Run this on one Xpand node after all device1 files have been decreased

    SET GLOBAL device_auto_resize_to_largest = 'TRUE';