This is a read-only copy of the MariaDB Knowledgebase generated on 2025-05-01. For the latest, interactive version please visit https://mariadb.com/kb/.

Step 2: Start and Configure MariaDB Enterprise Server on Primary Server

Overview

This page details step 2 of the 7-step procedure "Deploy Primary/Replica Topology".

This step starts and configures a MariaDB Enterprise Server to operate as a primary server in MariaDB Replication.

Interactive commands are detailed. Alternatively, the described operations can be performed using automation.

Stop the Enterprise Server Service

The installation process might have started the Enterprise Server service. The service should be stopped prior to making configuration changes.

Stop the MariaDB Enterprise Server service:

$ sudo systemctl stop mariadb

Configure Enterprise Server

Enterprise Server nodes require that you set the following system variables and options:

ConnectorMariaDB Connector/R2DBC
bind_addressThe network socket Enterprise Server listens on for incoming TCP/IP client connections. On Debian or Ubuntu, this system variable must be set to override the 127.0.0.1 default configuration.
binlog_formatSet this to STATEMENT for HTAP.
server_idSets the numeric Server ID for this MariaDB Enterprise Server. The value set on this option must be unique to each node.
log_binSet this option to the file you want to use for the Binary Log. Setting this option enables binary logging.

MariaDB Enterprise Server also supports group commit.

Group Commit

Group commit can help performance by reducing I/O.

If you would like to configure parallel replication on replica servers, then you must also configure group commit on the primary server.

ConnectorMariaDB Connector/R2DBC
binlog_commit_wait_countThe network socket Enterprise Server listens on for incoming TCP/IP client connections. On Debian or Ubuntu, this system variable must be set to override the 127.0.0.1 default configuration.
binlog_commit_wait_usecSet this to STATEMENT for HTAP.

Example Configuration

On each Enterprise Server node, edit a configuration file and set these system variables and options:

[mariadb]
bind_address = 0.0.0.0
log_bin      = mariadb-bin.log
server_id    = 1

Set the server_id option to a value that is unique for each Enterprise Server node.

Start Primary Server

Start MariaDB Enterprise Server. If the Enterprise Server process is already running, restart it to apply the changes from the configuration file.

$ systemctl start mariadb

For additional information, see "Start and Stop Services".

Create User Accounts

The Primary/Replica topology requires several user accounts. Each user account should be created on the primary server, so that it is replicated to the replica servers.

Create the Replication User

Primary/Replica uses MariaDB Replication to replicate writes between the primary and replica servers. As MaxScale can promote a replica server to become a new primary in the event of node failure, all nodes must have a replication user.

The action is performed on the primary server.

Create the replication user and grant it the required privileges:

1. Use the CREATE USER statement to create replication user.

CREATE USER 'repl'@'192.0.2.%' IDENTIFIED BY 'repl_passwd';

Replace the referenced IP address with the relevant address for your environment.

Ensure that the user account can connect to the primary server from each replica.

2. Grant the user account the required privileges with the GRANT statement.

The following privileges are required:

GRANT REPLICATION SLAVE,
   REPLICATION CLIENT
ON *.* TO repl@'%';

Use this username and password for the MASTER_USER and MASTER_PASSWORD in the CHANGE MASTER TO statement when configuring replica servers in Step 3.

Create MaxScale User

Primary/Replica uses MariaDB MaxScale 25.01 to load balance between the nodes. MaxScale requires a database user to connect to the primary server when routing queries and to promote replicas in the event that the primary server fails.

This action is performed on the primary server.

1. Use the CREATE USER statement to create the MaxScale user:

CREATE USER 'mxs'@'192.0.2.%'
IDENTIFIED BY 'mxs_passwd';

Replace the referenced IP address with the relevant address for your environment.

Ensure that the user account can connect from the IP address of the MaxScale instance.

2. Use the GRANT statement to grant the privileges required by the router:

GRANT SHOW DATABASES ON *.* TO 'mxs'@'192.0.2.%';

GRANT SELECT ON mysql.columns_priv TO 'mxs'@'192.0.2.%';

GRANT SELECT ON mysql.db TO 'mxs'@'192.0.2.%';

GRANT SELECT ON mysql.procs_priv TO 'mxs'@'192.0.2.%';

GRANT SELECT ON mysql.proxies_priv TO 'mxs'@'192.0.2.%';

GRANT SELECT ON mysql.roles_mapping TO 'mxs'@'192.0.2.%';

GRANT SELECT ON mysql.tables_priv TO 'mxs'@'192.0.2.%';

GRANT SELECT ON mysql.user TO 'mxs'@'192.0.2.%';

3. Use the GRANT statement to grant privileges required by the MariaDB Monitor.

The following privileges are required:

GRANT SUPER,
   REPLICATION CLIENT,
   RELOAD,
   PROCESS,
   SHOW DATABASES,
   EVENT
ON *.* TO 'mxs'@'192.0.2.%';

Next Step

Navigation in the procedure "Deploy Primary/Replica Topology":

This page was step 2 of 7.

Next: Step 3: Start and Configure MariaDB Enterprise Server on Replica Servers

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.