Mysql, MariaDB new master-slave cluster configuration Gtid

Source: Internet
Author: User

The previous article thanks to "Mysql, MariaDB traditional master-slave cluster Configuration", the technology has been very mature. Starting from Mysql5.6 and MariaDB10.0, with the new master-slave scheme Gtid, but the two systems to this version of the branch, the implementation has been different, configuration methods are different, the following are described separately.


MariaDB:

I use the version is still 10.1 version, the current version is not stable version, but does not affect the test. Deploy a deployment of two DB instances first, see http://bangbangba.blog.51cto.com/3180873/1701857

Until the replication user is created.

We're here because of the newly created database, so first reset the state of the main library,

Reset Master,

At this point, you can find that the old bin-log have been deleted and only a newly created log file is left.

Then execute the following statement, noting that the line behind Master_use_gtid=current_pos is different from the traditional pattern.

mariadb [mysql]> change master to master_host= ' localhost ',  master_port=10001,  master_user= ' rep ',  master_password= ' 123456 ', master_use_gtid=current_pos; query ok, 0 rows affected  (0.36 sec) mariadb [mysql]> start  Slave query ok, 0 rows affected  (0.18 sec) mariadb [mysql]> show  slave status \g;*************************** 1. row ***************************                Slave_IO_State:  waiting for master to send event                   Master_Host: localhost                   Master_User:  rep                  master_port: 10001                 Connect_Retry: 60               master_log_file: mysql-bin.000001           Read_Master_Log_Pos: 313                Relay_Log_File:  lyw-hp-relay-bin.000002                 relay_log_pos: 601        relay_master_log_file:  mysql-bin.000001             slave_io_ Running: yes            slave_sql_running:  yes         ...                     using_gtid: current_pos

The latter is more than the traditional master-slave mode of a line of content Using_gtid:current_pos, indicating the use of a new master-slave method.

Once set up, it is also necessary to test whether changes to the main library affect the contents of the library.



Mysql:

Mysql5.6 version began to support the Gtid replication method, which is configured in a different way than mariadb, you need to first modify the configuration file in the relevant configuration. What's NEW:

[Mysqld]gtid-mode = Onlog-slave-updates = trueenforce-gtid-consistency= true

Then start the two databases. You also need to configure the appropriate synchronization users.

Then, in the following command from the library, note that the last line Master_auto_position=1 is different from the mariadb.

mysql> change master to  master_host= ' localhost ',   master_port=20001,   master_user= ' rep ',   master_password= ' 123456 ', master_auto_position=1;mysql>  start slave;mysql> show slave status \g;*************************** 1.  row ***************************                Slave_IO_State: Waiting for master to send event                   master_ host: localhost                   Master_User: rep                   Master_Port: 20001                 connect_retry: 60               Master_Log_File: mysql-bin.000004           Read_Master_Log_Pos: 850                Relay_Log_File: lyw-hp-relay-bin.000002                 Relay_Log_Pos: 1060         Relay_Master_Log_File: mysql-bin.000004              Slave_IO_Running: Yes             Slave_SQL_Running: Yes             ......           Retrieved_Gtid_Set:  a34819a9-700f-11e5-a841-34238703623c:1-3            executed_gtid_set:  A34819a9-700f-11e5-a841-34238703623c:1-3

It can be seen that the last two lines with Gtid related state, Retrieved_gtid_set,executed_gtid_set, the use of Gtid this new synchronization mode.


The above master-slave configuration is the most basic configuration, online use is not enough, after the main hung, and will not automatically switch, please follow the article.

This article is from the "Bar Bar" blog, please be sure to keep this source http://bangbangba.blog.51cto.com/3180873/1701898

Mysql, MariaDB new master-slave cluster configuration Gtid

Related Article

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.