Master-slave replication for mysql and master-slave replication for mysql
Perform the following steps for master-slave replication:
Assume that the two master-slave mysql servers are deployed on the same machine on different ports
SQL thread reads the event from the relay log, replays the event, and updates the slave data so that it is consistent with the data in the master. As long as the thread is consistent with the I/O thread, the relay log is usually located in the OS cache, so the overhead of the relay log is very small.In addition, there is also a working thread in the master: Like other MySQL connections, opening a connection in the master will also enable the master t
Tagged: Server server multithreading MySQL styleGtid,global Transaction Identifiers, the global transaction identifier consists of a unique identifier for the server's UUID and transaction ID number. After MySQL 5.6, the transaction header records the server UUID, which is very simple to track.Uuiduniversally unique Identifier, globally unique identifier. A is master,b, C is slave, and when a goes down, B
> data.sql
If the data volume is large, Xtrabackup should be used to export the database, which is not described here.Some may ask, why not directly use binary logs for initialization?
If the master database has been running for a long period of time, it is not suitable to use slave database to copy data based on binary logs. It is time-consuming and performance-consuming to directly use binary logs to initialize slave database. In more cases, the configuration item of the binary log of the mas
server_id parameter must be unique;
10. On the slave server, use the -- skip-slave-start option to start the slave database. This will not immediately start the replication process from the database service, so that we can further configure the slave Database Service;
11. Set the slave database server to specify the u
Tags: mysql database replication primary master replication Master-slave replication semi-synchronous replication--------------MySQL to implement the database master-slave replication A
synchronized. Data synchronization we can easily complete with MySQL internal configuration, mainly with master-slave replication and primary master replication.2. Construction of basic Environment:2.1 Environmental Descriptionip:192.168.92.143ip:192.168.92.156CentOS 7.4.1708MySQL 5.7.222.2 Setting hostname, static interpretation:/etc/hosts2.3 SSH Password-free
Asynchronous replication: MySQL natively supports one-way, asynchronous replication. Asynchronous replication means there is a delay in copying data from one machine to another-most importantly this means that the data cannot be copied/applied to the slave at the same time when the application's transaction commit has
Tags: mysql replicationMySQL replication principle/library-based multi-threaded replication principle/BLGC-based multi-threaded replication principleSingle thread master-slave replication:From the library to the main library to request Binlog, and binlog into their own relaylog, from the library redo Binlog inside the
configuration (not including the same configuration as S1): server_id=120
loose-group_replication_local_address="192.168.100.23:20003" S4 configuration (not including the same configuration as S1): server_id=130
loose-group_replication_local_address="192.168.100.24:20004" S5 configuration (not including the same configuration as S1): server_id=140
loose-group_replication_local_address="192.168.100.25:20005" After the configuration is complete, launch the Mysqld instance. systemctl
reads the log information after the specified location of the log according to the requested information and returns the IO process to the slave. In addition to the information contained in the log, the returned information includes the name of the Bin-log file returned to the master side and the location of the Bin-log;3), after the slave IO process receives the information, the received log content is added to the end of the Relay-log file on the slave side, and the file name and location of
+ ---------- + -------------- + usage + | mysql-bin.000001 | 107 | usage | + usage + ---------- + -------------- + ------------------ + file and position will be used in the slave database to install 1) install mysql 2) Change the mysql configuration file my. cnf server-id = 2 # add, note that here is the underlined replay-log =/var/log/
. The slave server needs to configure the security function on mysql5.6, which means the information is usually contained on the master server. Information or logs should be in a table. Let's get started with configuration.
Here is an example!
First, you need to download the mysql test version. Click this link to download.
We need a sandbox environment for the slave server and two master servers. I will not explain in detail how to configure server_id
also know that two-way replication does not actually improve performance, and each server needs to make the same number of updates as if you had only one server. The only difference is that a bit of lock contention can be reduced because updates from another server are in sequence in slave. Even so, this benefit can be offset by network delays. 6. How to use replication to improve the performance of your s
server through scp or docker volume and import it to the slave database.
mysql -u root -p
6. Start the replication Link
Existing master@172.20.0.2 and slave@172.20.0.3, and data has been synchronized to slave database slave via mysqldump. Now configure replication link on slave server slave
MariaDB [(none)]> CHANGE M
enough.5. Start the slave process.
1. mysql> start slave;6. view the mysql log. Generally, it is in the/var/log/directory. If the startup is successful, you should see a log similar to the following.091104 8:42:02 [Note] Slave I/O thread: connected to master 'root @ X. X: 3306 ?,
operations while the slave server is only responsible for read operations.
Ii. Master-slave Replication
1. data redundancy, remote disaster recovery, and backup
2. Data read/write Separation
3. Load Balancing of database services
4. High Availability and Failover
5. Upgrade MySQL
Iii. considerations During master-slave Replication
1. Do not mix shi with differen
Practice Process:
Install 3 MySQL (S1,S2,S3) on a single server
Configure S1, start Group Replication
Configure S2, add to Group
Configure S3, add to Group
Test
The content is long, may not be convenient to actually operate, I also made a PDF version , you can download view, send Message 'gr' will automatically replyDetailed configur
/MY.CNF (the configuration file in Windows is Mysql.ini)Log-bin=mysql-bin Open Binary LogNote: The binary log must be turned on because the synchronization of the data is essentially the other MySQL database server executes the binary log of this data change again on this computer.192.168.95.11 Primary database server192.168.95.12 from the database serverBack to top 3.3,
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.