In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Semi-synchronous replication of mysql:
Asynchronous replication of mysql: mysql uses asynchronous synchronization by default. Master returns the result to the client after executing the transaction submitted by the client, indicating that the operation of the client has taken effect. At the same time, the binlog of the operation is notified to slave through dumper. Normally, slave will write the binlog locally and write the data synchronized with the master database through the sql statement. Master is not responsible for writing to the slave database.
The replication process of master and slave is completed by three threads, including two threads (sql statement and I / O thread on the slave side) and one I / O thread on the master side.
Synchronous replication of mysql: this is a paranoia. The client submits data to the master database, and the master database writes data to the master database only after the slave database writes the data locally and returns a receipt to the master database. The master library returns a message to the client, indicating that the task has been accepted successfully.
Mysql semi-synchronous: the dumper thread of master notifies salve and adds an ack,mysql5.7 support to wait for ack before the transaction is committed, and when the slave is not returned to master ack, it will be automatically degraded to asynchronous replication.
Semi-synchronization uses rpl_semi_sync_master_wait_point parameters to control the way in which master transactions are committed before semi-synchronization.
The semi-synchronous parameter after_sync,master in mysql passes each transaction write binlog to slave to refresh to disk relay log,master to wait for slave feedback to receive the ack after committing the transaction and returning a successful commit to the client.
Semi-synchronous deployment:
Semi-synchronous is based on asynchronous replication based on mysql, so you need to build an environment first. Build the environment and refer to my blog: http://12237658.blog.51cto.com/12227658/1907018
Test:
Master: master
Install the semi-synchronous plug-in:
Mysql > INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so'
Query OK, 0 rows affected (0.08 sec)
Check to see if the plug-in is installed successfully:
Mysql > show plugins; will eventually discover:
| | ngram | ACTIVE | FTPARSER | NULL | GPL | |
| | rpl_semi_sync_master | ACTIVE | REPLICATION | semisync_master.so | GPL | |
+-+
It shows success.
From: slave
Install the plug-in:
Mysql > INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so'
Query OK, 0 rows affected (0.11 sec)
Use: show plugins; or:
Mysql > SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE'% semi%'
If you find out
| | rpl_semi_sync_slave | ACTIVE | REPLICATION | semisync_slave.so | GPL | |
+-
That is, success.
Start semi-synchronization:
Master: master
Mysql > SET GLOBAL rpl_semi_sync_master_enabled = 1
Query OK, 0 rows affected (0.00 sec)
Mysql > show status like 'Rpl_semi_sync_master_status'
+-+ +
| | Variable_name | Value |
+-+ +
| | Rpl_semi_sync_master_status | ON |
+-+ +
1 row in set (0.00 sec)
From: slave
Mysql > SET GLOBAL rpl_semi_sync_slave_enabled = 1
Query OK, 0 rows affected (0.00 sec)
Mysql > show status like 'Rpl_semi_sync_slave_status'
+-+ +
| | Variable_name | Value |
+-+ +
| | Rpl_semi_sync_slave_status | ON |
+-+ +
1 row in set (0.00 sec)
Finally, restart the Ithumb O thread:
Mysql > STOP SLAVE IO_THREAD
Mysql > START SLAVE IO_THREAD
Test:
If you create a database without shutting down slave, the master and slave libraries will soon write
Lord:
Mysql > show status like 'Rpl_semi_sync_master_status'
+-+ +
| | Variable_name | Value |
+-+ +
| | Rpl_semi_sync_master_status | ON |
+-+ +
1 row in set (0.00 sec)
Mysql > create database ginkgo
Query OK, 1 row affected (0.05sec)
From:
Mysql > show status like 'Rpl_semi_sync_slave_status'
+-+ +
| | Variable_name | Value |
+-+ +
| | Rpl_semi_sync_slave_status | ON |
+-+ +
1 row in set (0.00 sec)
Mysql > show databases
+-+
| | Database |
+-+
| | information_schema |
| | ginkgo |
| | mysql |
| | performance_schema |
| | sys |
+-+
5 rows in set (0.00 sec)
Shut down the slave on the:
Mysql > drop database ginkgo
Query OK, 0 rows affected (10.06 sec)
Mysql > show status like 'Rpl_semi_sync_master_status'
+-+ +
| | Variable_name | Value |
+-+ +
| | Rpl_semi_sync_master_status | OFF |
+-+ +
1 row in set (0.00 sec)
Slave does not respond to ack for a long time and is forced to turn it into asynchronous, which takes a long time, mainly because of waiting time.
There must be no data change from the top.
* * Note: when writing a database, you must make sure in the configuration file that you allow that library to synchronize, and do not build a database randomly.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.