turn_on_slave
来自「mysql+ha. 实现高可用性 http://code.google.com」· 代码 · 共 52 行
TXT
52 行
#!/usr/bin/env perl# Use mandatory external modulesuse strict;use Cwd;use File::Basename;use Data::Dumper;use POSIX;use Config;use Time::HiRes;use DBI;# Determine installation dir nameour $SELF_DIR = dirname(dirname(Cwd::abs_path(__FILE__)));# Include parts of the systemrequire $SELF_DIR . '/lib/config.pm';# Read config file and statusour $config = ReadConfig("mmm_agent.conf");print TurnOnSlave();exit(0);#-----------------------------------------------------------------sub TurnOnSlave() { my $this = $config->{this}; # get self connection info my $host = $config->{host}->{$this}->{ip}; my $port = $config->{host}->{$this}->{port}; my $user = $config->{host}->{$this}->{user}; my $pass = $config->{host}->{$this}->{password}; # connect to server my $dsn = "DBI:mysql:host=$host;port=$port"; my $dbh = DBI->connect($dsn, $user, $pass, { PrintError => 0 }); return "ERROR: Can't connect to MySQL (host = $host:$port, user = $user)!" unless ($dbh); # Check server (simple) my $sth = $dbh->prepare("SLAVE START"); my $res = $sth->execute; return "ERROR: SQL Query Error: " . $dbh->errstr unless($res); $sth->finish; $dbh->disconnect(); $dbh = undef; return "OK";}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?