Skip to content

Instantly share code, notes, and snippets.

@niczero
Created February 1, 2017 13:23
Show Gist options
  • Save niczero/3a0b5c4677a084e239613a46a76bd161 to your computer and use it in GitHub Desktop.
Save niczero/3a0b5c4677a084e239613a46a76bd161 to your computer and use it in GitHub Desktop.
Quiesce a MySQL database (eg for hot rsync)
perl -MMojo::Base=strict -MMojo::Util=spurt
-MMojar::Mysql::Connector=cnf,/home/me/.mysql/super_production-02.cnf
-E'my $d = Mojar::Mysql::Connector->new->connection;
$d->do(q{FLUSH LOGS});
my $unquiesce = $d->quiesce;
spurt $$ => q{/tmp/quiesced};
say q{Quiesced!};
while (-f q{/tmp/quiesced} and $d->ping) {
say join q{ | }, $d->selectrow_array(q{SHOW MASTER STATUS});
sleep 30
}
$unquiesce->()'
perl -MMojo::Base=strict \
-MMojar::Mysql::Connector=cnf,/home/me/.mysql/super_production-02.cnf \
-E'my $d = Mojar::Mysql::Connector->new->connection;
$d->global_var(innodb_max_dirty_pages_pct => 80);
say $d->global_var(q{innodb_max_dirty_pages_pct})'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment