mysql_cdc
MySQL/MariaDB binlog replication client for Rust
Limitations
Please note the lib currently has the following limitations:
- Supports only standard auth plugins
mysql_native_password
andcaching_sha2_password
. - Currently, the library doesn't support SSL encryption.
- Doesn't handle split packets (16MB and more).
Binlog event stream replication
Real-time replication client works the following way.
use BinlogClient;
use BinlogOptions;
use Error;
use GtidList;
use GtidSet;
use ReplicaOptions;
use SslMode;
A typical transaction has the following structure.
GtidEvent
if gtid mode is enabled.- One or many
TableMapEvent
events.- One or many
WriteRowsEvent
events. - One or many
UpdateRowsEvent
events. - One or many
DeleteRowsEvent
events.
- One or many
XidEvent
indicating commit of the transaction.
It's best practice to use GTID replication with the from_gtid
method. Using the approach you can correctly perform replication failover.
Note that in GTID mode from_gtid
has the following behavior:
from_gtid(@@gtid_purged)
acts likefrom_start()
from_gtid(@@gtid_executed)
acts likefrom_end()
Reading binlog files offline
In some cases you will need to read binlog files offline from the file system.
This can be done using BinlogReader
class.
use ;
use File;
const PATH: &str = "mysql-bin.000001";