
There are two types of replication.
- Master-Master - Both databases are masters, meaning both can be used for reading and writing.
- Master-Slave - One database is the master, the other is the slave. Only the master can read and write, the slave can only read.
The show master status command can be used to display the status of the master. This assume you are able to log into your MariaDB or mySQL server or you have configured passwordless authentication and will be using the -e command line option.
~] mysql -e "show master status \G"
File: binary-log.000015
Position: 725
Binlog_Do_DB:
Binlog_Ignore_DB:
Notice in this example that the name of the binary log file is binary-log.000015. The name and location of the binary log files is defined using the log-bin directive in the main configuration file (e.g. /etc/my.cnf).
log-bin=/var/lib/mysql/binary-log
In this example, and by default, the binary log files are located in the /var/lib/mysql directory (on a Linux system).
~]# ll /var/lib/mysql
-rw-r----- 1 mysql mysql 70268749 Jul 24 20:47 binary-log.000014
-rw-r----- 1 mysql mysql 401992544 Jul 27 04:21 binary-log.000015
-rw-r----- 1 mysql mysql 66 Jul 24 20:47 binary-log.index
The reset master command will make it so that the master file returns to the file ending in 000001 and position will also restart at 0 and then increment like normal.
mysql -e "show master status \G"
The show master status command can be issued again, and the binary log file should end in 000001 and the position should be a relative low number (based on the volume of requests hitting your database) as compared to the original position value.
~] mysql -e "show master status \G"
File: binary-log.000001
Position: 14
Binlog_Do_DB:
Binlog_Ignore_DB:
Also, the binary log file in the /var/lib/mysql directory should also end in 000001.
~]# ll /var/lib/mysql
-rw-r----- 1 mysql mysql 401992544 Jul 27 04:21 binary-log.000001
-rw-r----- 1 mysql mysql 66 Jul 24 20:47 binary-log.index
Did you find this article helpful?
If so, consider buying me a coffee over at