> For the complete documentation index, see [llms.txt](https://asus-isg-aidc.gitbook.io/guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://asus-isg-aidc.gitbook.io/guide/latest/cli/commandreference/database.md).

# Database Management

| Developer | Last modified |
| --------- | ------------- |
| AIDC Team | 2026/08/21    |

## Table of Contents

* [1. Overview](#overview)
* [2. Subcommands](#subcommands)
* [3. Verifying the Cluster](#verifying-the-cluster)
* [4. Supported Operating Systems](#supported-operating-systems)
* [5. Usage Examples](#usage-examples)
* [6. Related Commands](#related-commands)

***

## 1. Overview <a href="#overview" id="overview"></a>

{% hint style="warning" %}
**⚠️ Prerequisite: `aidc-cli init` required first**

This command depends on settings saved by [`aidc-cli init`](/guide/latest/cli/commandreference/init.md). Before running it, make sure you have completed:

* [`aidc-cli init inventory`](/guide/latest/cli/commandreference/init.md#inventory) — render the node inventory from `aidc.csv`
* SSH access to the nodes — [`aidc-cli deploy install`](/guide/latest/cli/commandreference/deploy.md) sets this up during OS deployment; for nodes that already have an OS, run [`aidc-cli deploy access-key`](/guide/latest/cli/commandreference/deploy.md) or fill the `password` column in `aidc.csv`
* [`aidc-cli init mariadb-set`](/guide/latest/cli/commandreference/init.md#service-configuration) — save the MariaDB configuration

For the full setup sequence, see the [Getting Started](/guide/latest/cli/gettingstarted.md) guide.
{% endhint %}

The `database` command manages database cluster deployments on target nodes.

```bash
aidc-cli database <subcommand> [flags]
```

***

## 2. Subcommands <a href="#subcommands" id="subcommands"></a>

### 2.1 `maria-galera` — MariaDB Galera Cluster

Deploys a MariaDB Galera multi-master cluster for high-availability database services (commonly used as the Slurm accounting database backend).

```bash
aidc-cli database maria-galera
```

This will:

1. Install MariaDB server on designated nodes
2. Configure Galera replication
3. Bootstrap the cluster and join nodes
4. Set up users and privileges

{% hint style="info" %}
Configure MariaDB parameters first with `aidc-cli init mariadb-set` before deploying. Ensure that the "mariaDB-galera group" in the inventory has been set. Inventory CSV files must be set up correctly.
{% endhint %}

***

## 3. Verifying the Cluster <a href="#verifying-the-cluster" id="verifying-the-cluster"></a>

After deployment, verify the MariaDB Galera cluster:

```bash
# Enter the SQL environment
mysql -u root -p

# Check cluster status
SHOW STATUS LIKE 'wsrep_cluster_status';

# Check cluster sync status
SHOW STATUS LIKE 'wsrep_local_state_comment';

# Check cluster node count
SHOW STATUS LIKE 'wsrep_cluster_size';
```

***

## 4. Supported Operating Systems <a href="#supported-operating-systems" id="supported-operating-systems"></a>

{% hint style="info" %}
See the **Supported Platforms Matrix** for the authoritative, up-to-date list of operating systems validated for this service.
{% endhint %}

{% hint style="info" %}
MariaDB Galera supports both multi-server and single-server installations; however, a single-server installation is not considered a Galera DB cluster.
{% endhint %}

***

## 5. Usage Examples <a href="#usage-examples" id="usage-examples"></a>

```bash
# Configure and deploy MariaDB Galera
aidc-cli init mariadb-set
aidc-cli database maria-galera

# Deploy on specific nodes
aidc-cli database maria-galera -l db01,db02,db03
```

***

## Related Commands <a href="#related-commands" id="related-commands"></a>

| Command                | Purpose                                    |
| ---------------------- | ------------------------------------------ |
| `init mariadb-get/set` | View/set MariaDB configuration             |
| `slurm setup-cluster`  | Deploy Slurm (uses MariaDB for accounting) |
