Mojar::Mysql::Replication - Monitor and control the replication threads
use Mojar::Mysql::Replication; my $repl = Mojar::Mysql::Replication->new(connector => ...); say 'Lag: ', $repl->sql_lag;
A class for monitoring and managing replication threads.
First create a replication object (manager) that knows how to connect to the replicating database.
use Mojar::Mysql::Replication; use Mojar::Mysql::Connector ( cnf => '...', -connector => 1 ); my $repl = Mojar::Mysql::Replication->new( connector => $self->connector, log => $self->log );
Then you can monitor the status of its replication.
$connection_time = $repl->io_run_time; $lag = $repl->sql_lag; $required_binlog = $repl->status->{master_log_file};
And you can manage replication.
$repl->safety('max_safety')->stop; $repl->start_io->start_sql;
Replication is most often used for scaling out for performance, protection from potentially interfering readers, and data security. There are, however, very few tools to help monitor and manage replication, probably due to the fiddliness of the details. At one site this package helps manage 100+ MySQL servers.
Copyright (C) 2006--2014, Nic Sandfield.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
MySQL manual, Percona Toolkit.
To install Mojar::Mysql, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojar::Mysql
CPAN shell
perl -MCPAN -e shell install Mojar::Mysql
For more information on module installation, please visit the detailed CPAN module installation guide.