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
Library Management Create a library create databa...
Table of contents question background Idea & ...
1. Packaging Vue project Enter the following name...
The main text page of TW used to have a width of 8...
During normal project development, if the MySQL v...
This article uses examples to illustrate the prin...
Code implementation: Copy code The code is as fol...
Since we are going to upload pictures, the first ...
Dark background style page design is very popular...
Table of contents Preface Six features of JSON.st...
Execute the command to install the plugin postcss...
This article shares MYSQL logs and backup and res...
Table of contents 1. Problem 2. Solution 1. Decla...
1. Check BIOS First check which startup mode your...
Google China has released a translation tool that ...