Connect to MariaDB Xpand

Users and applications that need to connect to MariaDB Xpand to execute queries typically connect through MariaDB MaxScale. Depending on the topology, MaxScale then routes the query directly to an Xpand node or to a MariaDB Enterprise Server (ES), which sends Xpand-relevant queries through to the Xpand node.

This documentation applies to both Xpand topologies. This page details the benefits MaxScale provides MariaDB Xpand and describe show to test application connections and load balancing.

MaxScale as a Database Proxy

Both Xpand topologies rely on MariaDB MaxScale as a database proxy. MaxScale is an advanced database proxy that allows applications and clients to connect as they would to a single database while abstracting the complexity of the underlying database infrastructure.

Applications and clients should generally connect to MaxScale in both Xpand topologies. Applications gain many benefits by connecting to MaxScale:

  • MaxScale automatically load balances connections among the ES nodes (in an Xpand Storage Engine topology) and the Xpand nodes (in an Xpand Performance topology).

  • If a node fails, MaxScale automatically knows to stop using it.

  • If a node is undergoing maintenance, MaxScale can be instructed to temporarily stop using it.

  • MaxScale can perform additional audit logging.

  • MaxScale can provide additional security and traffic controls.

There are additional benefits in an Xpand Performance Topology:

  • MaxScale monitors the health and performance of Xpand nodes using Xpand Monitor (xpandmon).

  • If a new Xpand node is added, Xpand Monitor automatically detects the change, and MaxScale automatically starts using the node in load balancing.

There are additional benefits in an Xpand Storage Engine Topology:

  • MaxScale monitors the health and performance of ES nodes using MariaDB Monitor (mariadbmon).

  • If MariaDB Replication is configured between the ES nodes, MariaDB Monitor can perform auto-failover if the primary server fails.

Client Support

Both Xpand topologies are compatible with the MariaDB standard clients.

Test Application Connections

To test application connections, choose your topology.

Xpand Performance Topology

When using the Xpand Performance topology, perform the following procedure to test application connectivity.

This action is performed on a client connected to the MaxScale node.

To connect to MaxScale with MariaDB Client:

  1. Use the MariaDB Client to connect to the listener port on the MaxScale node:

    $ mariadb --host=192.0.2.10 \
       --port=3307 \
       --user=xpand_app_user \
       --password
    

    The listener port (Configure a Listener) should be specified by the --port option. When the listener uses TCP port 3306, you do not need to specify the port to the client.

    The user account (Create Application Database User) should be specified by the --user option.

    MaxScale's Read/Write Split Router (Configure Read/Write Split Router) will route the connection to one of the Xpand nodes (Configure Server Objects).

  2. Use the client connection to query the Xpand node's hostname:

    SELECT hostname
    FROM system.nodes
    WHERE nodeid IN(
       SELECT nodeid
       FROM system.sessions
       WHERE session_id=@@session_id
    );
    

    The output will show the hostname of one of the Xpand nodes.

Xpand Storage Engine Topology

When using the Xpand Storage Engine topology, perform the following procedure to test application connectivity.

This action is performed on a client connected to the MaxScale node.

To connect to MaxScale with MariaDB Client:

  1. Use the MariaDB Client to connect to the listener port on the MaxScale node:

    $ mariadb --host=192.0.2.10 \
       --port=3307 \
       --user=xpand_app_user \
       --password
    

    The listener port should be specified by the --port option. When the listener uses TCP port 3306, you do not need to specify the port to the client.

    The user account should be specified by the --user option.

    MaxScale's Read/Write Split Router will route the connection to one of the ES nodes.

  2. Use the client connection to query the ES node's hostname:

    SHOW GLOBAL VARIABLES
       LIKE 'hostname';
    

    The output will show the hostname of one of the ES nodes.

Test Connection Load Balancing

To test connection load balancing, choose your topology.

Xpand Performance Topology

When using the Xpand Performance topology, perform the following procedure to test connection load balancing.

This action is performed on a client connected to the MaxScale node.

  1. Open multiple terminals on the client.

  2. In each terminal, use the MariaDB Client to connect to the listener port on the MaxScale node:

    $ mariadb --host=192.0.2.10 \
       --port=3307 \
       --user=xpand_app_user \
       --password
    

    The listener port (Configure a Listener) should be specified by the --port option. When the listener uses TCP port 3306, you do not need to specify the port to the client.

    The user account (Create Application Database User) should be specified by the --user option.

    MaxScale's Read/Write Split Router (Configure Read/Write Split Router) will route the connection to one of the Xpand nodes (Configure Server Objects).

  3. In each terminal, use the client connection to query the Xpand node's hostname:

    SELECT hostname
    FROM system.nodes
    WHERE nodeid IN(
       SELECT nodeid
       FROM system.sessions
       WHERE session_id=@@session_id
    );
    

    The output will show the hostname of one of the Xpand nodes.

  4. Confirm that MaxScale is load balancing connections by checking that different terminals output different hostnames.

Xpand Storage Engine Topology

When using the Xpand Storage Engine topology, perform the following procedure to test connection load balancing.

This action is performed on a client connected to the MaxScale node.

  1. Open multiple terminals on the client.

  2. In each terminal, use the MariaDB Client to connect to the listener port on the MaxScale node:

    $ mariadb --host=192.0.2.10 \
       --port=3307 \
       --user=xpand_app_user \
       --password
    

    The listener port should be specified by the --port option. When the listener uses TCP port 3306, you do not need to specify the port to the client.

    The user account should be specified by the --user option.

    MaxScale's Read/Write Split Router will route the connection to one of the ES nodes.

  3. In each terminal, use the client connection to query the ES node's hostname:

    SHOW GLOBAL VARIABLES
       LIKE 'hostname';
    

    The output will show the hostname of one of the ES nodes.

  4. Confirm that MaxScale is load balancing connections by checking that different terminals output different hostnames.