MySQL master-slave replication understanding

  • MySQL replication of master-slave
    1), what is copied from the master MySQL
    MySQL from the master copy means data can be copied from a MySQL database server to one or more master nodes from the node MySQL database. MySQL default asynchronous replication, so do not have access node from the master server to update their own data, update data can be performed on a remote connection, you can copy all database master database or specific database from the node.
    2), MySQL master-slave replication of
    a data Hot Standby
    as standby database, the primary database when the server fails, switch to continue working from the database, to avoid data loss.
    Second, separate read and write
    support for the MySQL database server to support more concurrent. Data read and write operations may be distributed among different servers. The operating report is particularly important, as some statements SQL statement is very slow, it will lead to lock table, affecting front desk. Using the main use of the copy, front master, responsible for writing a report using slave, is responsible for reading, the report will not have a reception lock SQL table, to ensure the normal operation of the front desk.
    Third, the schema extensions
    with the growing volume of business, I / O access frequency is too high, stand-alone might not be met. At this time, do more storage library, such as a multi-master-slave mode, in order to reduce disk I / O access, to improve I / O performance of a single machine.
  • MySQL master-slave replication principle
    basic data is replicated MySQL binary log file (binary log file). A MySQL database Once the binary logging is enabled, as a master node, database, all operations will be to "events" recorded in the binary log, other databases as slave via an I / O thread with the primary server to maintain communications and surveillance changes in the master binary log file, such as the discovery master binary log file is changed, it will copy the changes to their relay log in, then a slave SQL thread will related to "events" to perform its own database, in order to achieve the consistency of the database and primary database, we realized the master-slave replication.
    MySQL master-slave replication understanding
    Summarized as follows:
    1), Master operating statements recorded in the binlog log, and then grant permissions (user authorized to create the master slave remote connections, open binlog binary logging; usually for data security reasons, slave also open binlog function).
    2), slave open two threads: IO thread and the SQL thread. IO thread is responsible for reading the contents of master binlog to the relay log relay log in; SQL thread is responsible for reading out the binlog contents from the relay log log, and updates to the slave database, so we can guarantee slave data and master data consistent with the .
    . 3), from the master copy Mysql Mysql service requires at least two, of course Mysql service may be distributed over different servers, can also start a plurality of service on a MySQL server.
    4), Mysql from the master copy version Mysql best ensure that the same master and slave servers.
  • MySQL master-slave form
    common form of master-slave:
    one Lord, one from
    MySQL master-slave replication understanding
    a main two from a master multi-slave
    MySQL master-slave replication understanding
    replication cascade
    MySQL master-slave replication understanding
  • MySQL master-slave replication
    for configuration of MySQL master-slave replication needs:
    the primary server:
    open the binary log
    configure a unique server-id
    obtained master binary log file name and location
    to create a user account for the slave and master communication
    from the server:
    Configuration the only server-id
    using the master assigned user account read master binary log
    enabled slave service

Guess you like

Origin blog.51cto.com/10874766/2468557