Mysql master-slave replication principle and Configuration1 copy Overview
The built-in replication function of Mysql is the basis for building large and high-performance applications. This distribution mechanism replicates data from a Mysql host to another Server Load balanc
: Executed_Gtid_Set: Auto_Position: 0 1 row in set (0.00 sec)-- Test, OK!-- Master-> slave: Same as master-slave
V. configuration parameters
Server-id
The ID value uniquely identifies the master and slave servers in the replication cluster, so they must be different. Master_id must be a positive integer between 1 and 232-1, and slave_id must be a positive integer between 2 and 232-1.
Log-bin Indicates that
='repluser',master_password='redhat',master_log_file='mysql-bin.000003',master_log_pos=356;
Mysql> show slave status/G to check the working status of the slave server. You can see Slave_IO_Running: No and Slave_ SQL _Running: No or no. enable these two items.
mysql>startslave;
mysql>setglobalread_only=1;
Copy directory of MySQL database backup: 1. mySQL replication Overview 2. advantages and ideas of MySQL replication 3. master server settings in the Data Replication environment 4. slave server setting for Data
Mysql backup and AB replication are available in two ways: Synchronous replication (msylq-cluster) asynchronous replication (mysql-ms master-slave backup is also called dual-machine Hot Backup) I. Mysql full backup (
archive.When flush TABLES with read lock is in effect (that is, the MySQL client program does not exit), read the current binary log name and offset value on the primary server:MySQL > SHOW MASTER STATUS;+---------------+----------+--------------+------------------+| File | Position | binlog_do_db | binlog_ignore_db |+---------------+----------+--------------+------------------+| mysql-bin.003 | 73 |
Test parameters:Sysbench--test=/root/sysbench0.5/sysbench/tests/db/insert.lua--mysql-table-engine=innodb--oltp-table-size= 1000000--max-requests=0--max-time=300--num-threads=16--oltp-tables-count=10--report-interval=10--mysql-host= 10.8.8.100--mysql-port=3312--
First, MySQL master (called Master) from (called slave) Copy principle:
(1). master records data changes to the binary log (binary log), which is the Log-bin specified file (These records are called binary log events binary log event)(2). Slave copy Master's binary log events to its relay logs (relay log)(3). Slave redo the event in the relay log, changing the data that reflects it (the data repeats itself)
Attached schematic diagram:
Second, the
MySQL database master-slave replication bitsCN. the master-slave replication of comMySQL 5.5 Database is studied based on the data on the Internet. The data on the Internet is already very detailed, but I still encountered many problems in practice, the following is a summary based on the information on the Internet and the problems I encountered. System environm
database and grant permissions Using replication slave, for example:
mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave001'@'192.168.0.99' IDENTIFIED BY '123456';mysql> FLUSH PRIVILEGES; (2) modify the configuration file my. cnf of the primary database, enable BINLOG, and set the value of server-id. After modification,
following scenarios:Class MYSQL_BIN_LOG: public TC_LOG{...Public:/* Committed transactions timestamp */Logical_clock max_committed_transaction;/* "Prepared" transactions timestamp */Logical_clock transaction_counter;...We can see that two Logical_clock variables are defined in the MYSQL_BIN_LOG class:Max_c ommitted_transaction: record the logical_clock when the last group was submitted, representing the last_committed in the above mysqlbinlogTransaction_counter: records the logcial_cl
= Test3binlog-ignore-db = MySQLBinlog-ignore-db = Information_schemaSlave-skip-errors=allLog-slave-updatesSymbolic-links=0Skip-name-resolve
The new additions to the B-way my.cnf configuration file are as follows:
################# #replication config#######################Log-bin = Mysql-binAuto-increment-increment = 2Auto-increment-offset = 2Replicate-do-db = Test1Replicate-do
Mysql database master-slave replication deployment notes, mysql master-slave
Principles of master-slave database replication:The master-slave replication of a database is to copy data from the master database to the slave database. The entire replication between the master a
Label:MySQL is an open-source relational database system. Replication (Replication) is a process that replicates data from one MySQL database server (master server master) to another server (from server slave).Configuring the primary server (master)1, edit the database configuration file my.cnf, generally in the/etc/directory.
#vi/etc/my.cnf
Add t
MySQL replication (2) bitsCN.com
As we can see from previous articles that binary logs play an important role in replication, this article focuses on the core component behind Mysql replication: the true nature of binary logs.Binary log structure
In terms of concept, binary
In the previous article "mud: learning the principles of mysql database master-slave synchronous replication", we introduced the basic principles of mysql master-slave replication. In this article, we will test the master-slave synchronous
that the host name of the synchronization Master is A (IP: 192.168.0.1), the Slave host name is B (IP: 192.168.0.2), and the two basedir directories of MySQL are/usr/local/mysql, datadir is both:/var/lib/mysql.
II. set synchronization server
1. set synchronization Master
Modify the my. cnf file in
# Replication Master
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.