Mariadb 10.3 uses mariabackup backup as the master
Mariabackup is a new branch of Mariadb based on xtrabackup, which has been installed with mariadb by default.
1. Master database creates master-slave account
Grant replication slave on *. * to 'repl'@'%' identified by "repl"
two。 The main library uses mariabackup to create full backups
Mkdir-p / data/mariabackupmariabackup-- backup-- target-dir=/data/mariabackup-S / var/lib/mysql/mysql.sock-uroot-p123456
3. Prepare to back up data
Mariabackup-prepare-target-dir=/data/mariabackup
4. Send backup data to the slave library
Note: the mysql service needs to be shut down from the library, and all data from the library will be deleted.
From database data location / var/lib/mysql
Cd / data/mariabackuprsync-av. Slave_hostip:/var/lib/mysql
5. Start the database service from the library
Note: before starting the slave library, you need to keep the configuration file of the INNODB of the slave library with the backup-my.cnf in the backup file, otherwise the database may not be started.
# This MySQL options file was generated by innobackupex.# The MySQL server[mysqld] innodb_checksum_algorithm=crc32innodb_data_file_path=ibdata1:12M:autoextendinnodb_log_files_in_group=2innodb_log_file_size=50331648innodb_page_size=16384innodb_undo_directory=./innodb_undo_tablespaces=0
Set file permissions
Chown-R mysql:mysql / var/lib/mysql/
Start the slave library
Systemctl start mysql
6. Set master and slave from the slave library
Check the xtrabackup_binlog_info of the backup file
Mysql-bin.000248 17358780 0-155-1993077
From the above, we know the BINLOG file set from the library and the starting copy location.
Change master to master_host='master_server', master_port=3306,master_user='repl',master_password='repl',MASTER_LOG_FILE='mysql-bin.000248', MASTER_LOG_POS=17358780
Note: it is in the backup file
Xtrabackup_binlog_info-the BINLOG and starting position of the database
Xtrabackup_binlog_pos_innodb-the BINLOG and starting position of the INNODB of the database
Xtrabackup_info-Information of database backup
Normally, if the server's database is INNODB's storage engine, the xtrabackup_binlog_info and xtrabackup_binlog_pos_innodb files are consistent
But if the server has other storage engines such as myisam, the starting position of xtrabackup_binlog_info is larger than xtrabackup_binlog_pos_innodb. So we chose the location stored in the xtrabackup_binlog_info