mysql-binlog-explorer
MySQL binlogs are the foundation for replication, but them can be useful for tracking intense write operations on database when using binlog_format=ROW. With that we can see all the changes that are actually applied to the database. For example: a statement like delete from table where timestamp > ? could affect just 3 or 1 million rows. Besides that, sometimes we have tons of very fast statements, but when composed together in a transaction it can takes lots of time.
This application aims to aid in tracking which transactions are being too write intensves.
Usage (simplified)
pip install mysql-binlog-explorer
mysql-binlog-explorer ~/logs/mysql-bin-changelog.411078 --tenant-identifier company_id --schema-ddl schema/my_db.ddl
We have two not required parameters (but they are quite useful).
schema-ddlis a file with the DDL instructions to create the database. It'll be use used to show the column names in the statements.tenant-identifierthe name of a column which is used to store the tenant id (usually a column name that repeats across every table). This will aid in the generated charts.
Usage (the real deal)
- Enable binlog (configuration varies depending on environment)
- Enable row format for binlog:
binlog_format=ROW - This kind o change needs to restart the server so be careful
Given that you already have a local mysql installation with brew, doing the above steps would mean:
mysql.server start --log-bin=binlog --binlog-format=ROW
Now you need the actual logs. In a MySQL session do the following:
SHOW BINARY LOGS; -- get the name of the binary log that you want to check
Now download it:
mysqlbinlog -h <HOST> -u <USER> -p<PASSWORD> --read-from-remote-server --base64-output=decode-rows -vv <NAME_FROM_STATEMENT_ABOVE> > my-bin-log.txt
Don't forget the --base64-output=decode-rows -vv, it's mandatory for the parser to work!
Now just use it.
mysql-binlog-explorer my-bin-log.txt
Screenshot
When the tenant information is used, the app can plot a chart with transactions/changes distribution per tenant identifier.
Caveats
- Tested only with MySQL 5.6 binlogs, other versions may not work as expected.
- The result of the parsing is stored entirely in-memory, so it may crash for very large file sets.
Metadata
Release files for mysql-binlog-explorer 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mysql-binlog-explorer-0.2.4.tar.gz | 154.3 kB | Without provenance | Details for mysql-binlog-explorer-0.2.4.tar.gz |
Release files / mysql-binlog-explorer-0.2.4.tar.gz
| Download URL | mysql-binlog-explorer-0.2.4.tar.gz |
|---|---|
| Size | 154.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b699a32afcb24f7a83dc792f09cfe4589ec117957c732e6f25135db38b887ac3
|
|
BLAKE2b-256 checksum How to use checksums |
8a3aae93d2f264932be513fcf0abab785c908950c01504a30012bc74ce9a412e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.16
|
Security for mysql-binlog-explorer 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.