MARIADB 10.2.8 version Gtid master-slave environment building and switching

Source: Internet
Author: User

1. First build the master-slave

Main environment: 192.168.1.117

From the environment: 192.168.1.123

A. First install the mariadb in the form of a binary package (negligible)

B. Configuring variables for the environment

Pass Match

[Mysqld]

Binlog-format=row

Log-slave-updates=true

Master-info-repository=table

Relay-log-info-repository=table

Sync-master-info=1

slave-parallel-threads=2

Binlog-checksum=crc32

Master-verify-checksum=1

Slave-sql-verify-checksum=1

Binlog-rows-query-log-events=1

My master and slave servers are configured with Log-bin and Relay-log

Primary server

server_id = 100

log-bin=mysql-bin、

Relay_log=relay-bin

From the server

Server_id=101

Log-bin=mysql-bin

Relay_log=relay-bin

C. First use the main machine to authorize from the machine

Lord Operations

GRANT REPLICATION SLAVE, REPLICATION CLIENT on * * to ' SLAVE ' @ ' 192.168.1.123 ' identified by ' password '

Show Master Status View the Bin-log file from the server and the offset

Select Binlog_gtid_pos ("mysql-bin.000001", 1696); View Gtid number

D. Start synchronization

Set global gtid_slave_pos= ' 0-1001-58 ';

Change Master to

Master_host= ' 192.168.1.123 ',

Master_user= ' slave ',

master_password= ' Password ',

master_port=3306,

Master_use_gtid=slave_pos;

Start slave;

Here is the difference from the previous replication based on the binary log: you need to set the global Gtid_slave_pos value and use the Master_use_gtid statement

Check sync status, no error is normal

F. Master-slave data can be performed

See if the master-slave data is consistent

This does not take into account the fact that the volume of data is too large, if the volume of data is too large, or now the main library to do backup, and then lead to the from the library

2. Failover emulation

A. Killing the MySQL process simulation database hangs out

Ps-ef|grep MySQL

Kill-9 PID

B. Remove the slave from the server

Reset slave All;

C. Authorization to from the library

GRANT REPLICATION SLAVE, REPLICATION CLIENT on * * to ' SLAVE ' @ ' 192.168.1.117 ' identified by ' password '

D. Initiating replication on a new slave library

    • Copy from library with Gtid, syntax: Change MASTER to Master_use_gtid = {Slave_pos | current_pos | no}

    • Generally use Slave_pos, when A->b,a hangs, b when master, then a OK, want to do b slave case, use Current_pos, because B was formerly the main library, there is no slave_pos this value

The official website knows

Change Master to

Master_host= ' 192.168.1.117 ',

Master_user= ' slave ',

master_password= ' Password ',

master_port=3306,

Master_use_gtid=current_pos;

Start slave;

E. Viewing new information from a library

show slave status\g;

F. Test to see if the master-slave is consistent

MARIADB 10.2.8 version Gtid master-slave environment building and switching

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.