1. Introductionpython-mysql-replication is a MySQL replication protocol tool implemented in Python. We can use it to parse binlog to obtain insert, update, delete and other events in the log, and meet other business needs based on this. For example, when data changes, the cache is invalidated, and DML events are listened to to notify downstream business parties to take corresponding actions. Project information Second practice2.1 Installation and ConfigurationGet the source code git clone http://www.github.com/noplay/python-mysql-replication Install using pip Permissions: You can use the replication account directly or use other accounts, but the account must have SELECT, REPLICATION SLAVE, REPLICATION CLIENT permissions GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON . TO 'replicator'@'%' IDENTIFIED BY 'xxxxx'; The parameter settings related to database log are as follows: log_bin=on,binlog_format=row,binlog_row_image=FULL 2.2 Core Class Introduction The entry point of This instance provides a collection of various events for parsing binlog, and each event is also an object. The parameters required to initialize the BinLogStreamReader() instance are as follows: 2.3 How to use it?The simplest usage script name is pyreplica.py Open two windows, one for execution and the other for mysql to write or modify data The output is as follows: 2.3 ExtensionBased on the log event analysis provided by this tool, we can do a lot of things. The more famous tool binlog2sql uses this tool to parse binlog for data rollback. The result of executing the script is as follows In addition to parsing binlog, we can also use Summarize The above is the Python-based MySQL replication tool introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Two implementation solutions for vuex data persistence
>>: How to install theano and keras on ubuntu system
1. Why set maxPostSize? The tomcat container has ...
Preface This article mainly introduces the releva...
introduce This chapter mainly introduces the proc...
Table of contents Manual deployment 1. Create a s...
binlog is a binary log file that records all DML ...
This article shares the specific code for JavaScr...
Copy code The code is as follows: <html> &l...
Official documentation: JSON Functions Name Descr...
First: via text/HTML var txt1="<h1>Tex...
Table of contents 1. What is Proxy? 2. How to use...
Table of contents Preface Front-end structure Bac...
Table of contents Thoughts triggered by an online...
Table of contents 1.Vue.js features: 2.Observer.j...
Table of contents 1. What is redux? 2. The princi...
Table of contents 1. Insert statement 1.1 Insert ...