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 10.3 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:

System Variable/Option

Description

bind_address

The 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.

log_bin

Enables binary logging and sets the name of the binlog file.

server_id

Unique numeric identifier for each Enterprise Server node.

MariaDB Enterprise Server 10.3 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.

System Variable

Description

binlog_commit_wait_count

Sets the number of transactions that the server commits as a group to the binary log.

binlog_commit_wait_usec

Sets the number of microseconds that the server waits for transactions to group commit before it commits the current group.

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 2.5 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.