Galera (cluster)

Deploy Galera, a synchronous multi-master replication solution for relational databases such as MariaDB and MySQL that maintains data consistency across multiple servers.

📘

Cluster deployment

The app is deployed with three Linode instances to create a highly available MariaDB Galera cluster, each with the plan type and size you select.

Each of these Linode instances will appear on your invoice as separate items. To deploy MariaDB on a single instance, see the MySQL/MariaDB guide.

1. Deploy Galera cluster

 Estimated deployment time: 5–10 minutes

Follow the deployment instructions from the Get started section to configure the app, deploy it, and verify software installation.

For information on the app-specific configurations, see the Configuration options section.

Base distribution and plan

  • Supported distribution: Ubuntu 24.04 LTS
  • Recommended plan: Depends on the size of your MySQL database and the amount of traffic you expect.

Configuration options

Configure the required options to deploy your instance. For additional customization, add advanced options.

The table maps the Cloud Manager UI fields to their corresponding API/CLI keys (stackscript_data) required for automated deployments.

StackScript ID: 1088136

UI fieldAPI/CLI keyDescription
Required options
Cluster Namecluster_nameThe name you want to use for this cluster deployment.
Linode API tokentoken_passwordA valid Linode API token if you want to deploy additional Linode instances as part of this cluster.
Follow Manage personal access tokens to get the token on your account with Read/Write access to Linodes.
Add Account SSH Keys to All Nodesadd_ssh_keysWhen set to yes, any SSH Keys that are added to the root user account (in the SSH Keys section). They're also added to your limited user account on all deployed Linode instances. Possible values are: yes or no.
SSL InformationsslheaderSet to Yes by default. This requires providing details for a self-signed TLS/SSL certificate, like country, town, organization, and email address.
Country or regioncountry_nameApplies to a TLS/SSL certificate. The country or region for you or your organization. When using the API/CLI, specify it as a two-letter ISO country or region code.
State or province state_or_province_nameApplies to a TLS/SSL certificate. The state or province for you or your organization.
Localitylocality_nameApplies to a TLS/SSL certificate. The town or other locality for you or your organization.
Organizationorganization_nameApplies to a TLS/SSL certificate. The name of your organization.
Email addressemail_addressApplies to a TLS/SSL certificate. The email address you want to use for your certificate file. This email address may receive notifications about the state of your certificate, including when it's expired.
Advanced options
Disable root access over SSHdisable_rootApplies to a limited sudo user. To block the root user from logging in over SSH, select Yes. Defaults to No.
Note: When you disable the root user from logging in over SSH and don't provide a valid Account SSH Key assigned to the authorized_user, you can still switch to the root user. To do that, log in as root via the Lish console and run cat /home/$USERNAME/.credentials to view the generated password for the limited sudo user.
CA Common Nameca_common_nameApplies to a TLS/SSL certificate. The common name for the self-signed Certificate Authority (CA).
Common Namecommon_nameApplies to a TLS/SSL certificate. The common name used for the domain.
Galera cluster sizecluster_sizeThe number of Linode instances that are created as part of this cluster. The only possible value is 3.

Use API, CLI, or Terraform

In addition to deploying the app to a new Linode instance via Cloud Manager, you can also use the Linode API, CLI, or Terraform. When running the operation, you need to provide the StackScript ID, supported Linux distribution, and app-specific fields along with the standard Linode deployment configurations.

Note: Generate a personal access token to authenticate your API, CLI, or Terraform requests.

curl --location 'https://api.linode.com/v4/linode/instances' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'Authorization: Bearer abc123def456hij789klm' \
    --data-raw '{
        "region": "us-east",
        "type": "g6-standard-2",
        "image": "linode/ubuntu24.04",
        "label": "my-galera-cluster-one-click-app",
        "root_pass": "@C0mpl3x#P@ssw0rd",
        "stackscript_id": 1088136,
        "stackscript_data": {
            "cluster_name":"my-cluster",
            "token_password":"abc123def456hij789klm",
            "add_ssh_keys":"no",
            "country_name":"US",
            "state_or_province_name":"Massachusetts",
            "locality_name": "Cambridge",
            "organization_name":"Akamai Technologies",
            "email_address":"jsmith@example.com"
        }
    }'
linode-cli linodes create \
    --region us-east \
    --type g6-standard-2 \
    --label my-galera-cluster-one-click-app \
    --image linode/ubuntu24.04 \
    --root_pass @C0mpl3x#P@ssw0rd \
    --stackscript_id 1088136 \
    --stackscript_data '{"cluster_name":"my-cluster", "token_password":"abc123def456hij789klm", "add_ssh_keys": "no", "country_name":"US", "state_or_province_name":"Massachusetts", "locality_name":"Cambridge", "organization_name": "Akamai Technologies", "email_address":"jsmith@example.com"}'
resource "linode_instance" "my-linode" {
    region         = "us-east"
    type           = "g6-standard-2"
    label          = "my-galera-cluster-one-click-app"
    image          = "linode/ubuntu24.04"
    root_pass      = "@C0mpl3x#P@ssw0rd"
    stackscript_id = 1088136
    stackscript_data = {
        "cluster_name"           = "my-cluster"
        "token_password"         = "abc123def456hij789klm"
        "add_ssh_keys"           = "no"
        "country_name"           = "US"
        "state_or_province_name" = "Massachusetts"
        "locality_name"          = "Cambridge"
        "organization_name"      = "Akamai Technologies"
        "email_address"          = "jsmith@example.com"
    }
}

2. Access MySQL/MariaDB

The standard tool for interacting with MariaDB is the mysql client, which installs with the mysql-server package. The MariaDB client is used through a terminal.

Log in as root

  1. Log in to MySQL as the root user by running the sudo mysql -u root -p command.

  2. When prompted, enter the MySQL root password you set when launching the Quick Deploy App. Then, you'll see a welcome header and the MySQL prompt like this one, MariaDB [(none)]>.

  3. Generate a list of commands for the MySQL prompt by entering \h.

    List of all MySQL commands:
    Note that all text commands must be first on line and end with ';'
    ?         (\?) Synonym for `help'.
    clear     (\c) Clear command.
    connect   (\r) Reconnect to the server. Optional arguments are db and host.
    delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.
    edit      (\e) Edit command with $EDITOR.
    ego       (\G) Send command to mysql server, display result vertically.
    exit      (\q) Exit mysql. Same as quit.
    go        (\g) Send command to mysql server.
    help      (\h) Display this help.
    nopager   (\n) Disable pager, print to stdout.
    notee     (\t) Don't write into outfile.
    pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
    print     (\p) Print current command.
    prompt    (\R) Change your mysql prompt.
    quit      (\q) Quit mysql.
    rehash    (\#) Rebuild completion hash.
    source    (\.) Execute an SQL script file. Takes a filename as an argument.
    status    (\s) Get status information from the server.
    system    (\!) Execute a system shell command.
    tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
    use       (\u) Use another database. Takes database name as argument.
    charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
    warnings  (\W) Show warnings after every statement.
    nowarning (\w) Don't show warnings after every statement.
    
    For server side help, type 'help contents'
    
    MariaDB [(none)]>
  4. Grant access to the database you created when launching the Quick Deploy App for the MySQL user.

    In this example, the database is called webdata, the user webuser, and the password for the user is p@ssw0rd. Your password needs to be different from the root password for MySQL.

    GRANT ALL ON webdata.* TO 'webuser' IDENTIFIED BY 'p@ssw0rd';
  5. Enter the exit command to leave MySQL/MariaDB.

Create a sample table

  1. Log back in as the MySQL user by running the sudo mysql -u webuser -p command. In this example, the MySQL user is webuser.

  2. Create a sample table called customers.

    use webdata;
    create table customers (customer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name TEXT, last_name TEXT);

    This creates a table with:

    • A customer ID field of type INT for an integer (auto-incremented for new records, used as the primary key).
    • Two fields for storing the customer’s name. In this example, webdata is the database that you created when launching the Quick Deploy App.
  3. View the contents of the table you created.

    describe customers;
    +-------------+---------+------+-----+---------+----------------+
    | Field       | Type    | Null | Key | Default | Extra          |
    +-------------+---------+------+-----+---------+----------------+
    | customer_id | int(11) | NO   | PRI | NULL    | auto_increment |
    | first_name  | text    | YES  |     | NULL    |                |
    | last_name   | text    | YES  |     | NULL    |                |
    +-------------+---------+------+-----+---------+----------------+
  4. Enter the exit command to leave MySQL/MariaDB.

Additional resources

For more information about the installed packages, see their official documentation.

📘

Note that we can't vouch for the accuracy or timeliness of externally hosted resources.

For more information about MySQL/MariaDB, see our official documentation.


Did this page help you?