gtid_binlog_pos variable contains two values

Posted on

Question :

I am trying to setup a master-slave replication with galera-cluster (choose 1 node as the primary master) and a standalone mariadb server (slave).

I have successfully setup the replication and data is in sync.

However, when I check the gtid_binlog_pos from the slave node, it is showing 0-1-2 (primary master’s binlog pos) and 99-2-2 (slave itself’s binlog pos).

Is this normal and what does it mean?

MariaDB [testdb]> show variables like 'gtid%';
+-------------------------+--------------+
| Variable_name           | Value        |
+-------------------------+--------------+
| gtid_binlog_pos         | 0-1-2,99-2-2 |
| gtid_binlog_state       | 0-1-2,99-2-2 |
| gtid_cleanup_batch_size | 64           |
| gtid_current_pos        | 0-1-2,99-2-2 |
| gtid_domain_id          | 99           |
| gtid_ignore_duplicates  | OFF          |
| gtid_pos_auto_engines   |              |
| gtid_seq_no             | 0            |
| gtid_slave_pos          | 0-1-2        |
| gtid_strict_mode        | OFF          |
+-------------------------+--------------+

And here is my configuration files:
primary master /etc/my.cnf.d/replication.cnf:

[mysqld]
# Galera node as master
wsrep_gtid_mode      = on
wsrep_gtid_domain_id = 0

server-id          = 01
log_slave_updates  = on
relay-log-index    = /var/log/mysql/gmariadb01-relay-bin.index
relay-log          = /var/log/mysql/gmariadb01-relay-bin
gtid_domain_id     = 1
log-bin            = /var/log/mysql/gmariadb01-bin
log-bin-index      = /var/log/mysql/gmariadb01-bin.index
binlog_format      = ROW
log_error          = /var/log/mysql/mariadb.err

replicate-do-db    = testdb

slave /etc/my.cnf.d/replication.cnf:

[mysqld]
#Replication slave to Galera Cluster
server-id          = 02
log_slave_updates  = on
relay-log-index    = /var/log/mysql/gmariadb03-relay-bin.index
relay-log          = /var/log/mysql/gmariadb03-relay-bin
gtid_domain_id     = 99
log-bin            = /var/log/mysql/gmariadb03-bin
log-bin-index      = /var/log/mysql/gmariadb03-bin.index
binlog_format      = ROW
log_error          = /var/log/mysql/mariadb.err

replicate-do-db    = testdb

Answer :

Yes, this looks correct for your configuration.

From the MariaDB GTID documentation:

A global transaction ID, or GTID for short, consists of three numbers
separated with dashes ‘-‘. For example:

0-1-10

  • The first number 0 is the domain ID, which is specific for global transaction ID (more on this below). It is a 32-bit unsigned integer.
  • The second number is the server ID, the same as is also used in old-style replication. It is a 32-bit unsigned integer.
  • The third number is the sequence number. This is a 64-bit unsigned integer that is monotonically increasing for each new event group
    logged into the binlog.

The server ID is set to the server ID of the server where the event
group is first logged into the binlog. The sequence number is
increased on a server for every event group logged. Since server IDs
must be unique for every server, this makes the (server_id,
sequence_number) pair, and hence the whole GTID, globally unique.

Leave a Reply

Your email address will not be published.