4 MySQL 5.7 High Availability

Source: Internet
Author: User

MySQL 5.7 Master-slave replication


Https://dev.mysql.com/doc/refman/5.7/en/replication-gtids-howto.html
GTID (globaltransaction ID) is the number of a committed transaction and is a globally unique number. Gtid is actually made up of Uuid+tid. Where the UUID is the unique identity of a MySQL instance. The TID represents the number of transactions that have been committed on the instance and is monotonically incremented as the transaction commits.

Set Gtid mode, in the my.cnf inside the Mysqld tab inside the settings, after Setup, restart the MySQL service to take effect:

[Mysqld]
Gtid_mode=on
Log-slave-updates=on
Enforce-gtid-consistency=on

Mysql> Change Master to
master_host= ' main Library IP ',
Master_port= The main library port,
Master_user= ' Repl ',
master_password= ' repl password ',
master_auto_position=1;
mysql> start slave;

PS: Where there are differences, previously non-gtid is used master_log_file= ' mysql-bin.000009 ', master_log_pos=154, and Gtid adopted master_auto_positon=1; From the binlog of the Sync Master Library.
View copy status from library, yes double Yes, and seconds_behind_master:0:
The slave to use the master with GTID based transactions as the replication data source, and to use gtid-based auto-p Ositioning rather than file-based positioning. Issue a change MASTER to statement on the slave, including the master_auto_position option in the statement to tell the SL Ave that the master ' s transactions is identified by Gtids.

View standby Information
1. Main library show Slave hosts;

    1. SELECT * from INFORMATION_SCHEMA. Processlist WHERE COMMAND = ' Binlog Dump ';
      View synchronization Status
      1.Show slave Status\g
    2. SELECT service_state from Performance_schema.replication_connection_status;

Build a Cascade Backup library

    1. You need to set up Log_slave_updates=1 to make the repository generate Binlog
    2. Back up the database and build a new database from backup
    3. Synchronizing the new database with the standby library
    4. Change the new database to synchronize with the main library
      Reset slave;
      Change Master to
      master_host= ' main Library IP ',
      Master_port= The main library port,
      Master_user= ' Repl ',
      master_password= ' repl password ',
      Master_auto_position=1;

    5. Su-mysql
      2. Login to the default (3306) Port instance
      Source. Profile
      mysql–uroot–p–h127.0.0.1–p3306
      3. Login to the 3307 port instance
      source. p3307
      mysql–uroot–p–h127.0.0.1–p3307

Knowledge Point collation:
1.. mysql_history file records the commands executed by the MySQL user, there is a security risk and requires soft connection processing. Lns-l/dev/null $HOME/.mysql_history
2, MySQL how to build semi-synchronous and asynchronous standby library.
3. Installation of MySQL environment. Note Modify the owner, VIP configuration of the/relay_log folder.

4 MySQL 5.7 High Availability

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.