set_state

来自「mysql+ha. 实现高可用性 http://code.google.com」· 代码 · 共 55 行

TXT
55
字号
#!/usr/bin/env perl# Use mandatory external modulesuse strict;use Cwd;use File::Basename;use Data::Dumper;use POSIX;use Config;use DBI;# Determine installation dir nameour $SELF_DIR = dirname(dirname(dirname(Cwd::abs_path(__FILE__))));# Include parts of the systemrequire $SELF_DIR . '/lib/config.pm';require $SELF_DIR . '/lib/log.pm';require $SELF_DIR . '/lib/roles.pm';# Read config fileour $config = ReadConfig("mmm_agent.conf");if (scalar(@ARGV) < 2) {    print "Usage: $0 <old_state> <new_state>\n\n";    exit(1);}my $old_state = $ARGV[0];my $new_state = $ARGV[1];my $res = SetState($old_state, $new_state);print "$res\n";exit(0);#-----------------------------------------------------------------sub SetState($$) {    my $old_state = shift;    my $new_state = shift;        if ($new_state eq 'ADMIN_OFFLINE') {        LogDebug("Turning off slave in this host");	    ExecuteBin("turn_off_slave");	    return "OK: state changed to ADMIN_OFFLINE";    }        if ($old_state eq 'ADMIN_OFFLINE') {        LogDebug("Turning on slave in this host");	    ExecuteBin("turn_on_slave");	    return "OK: state changed from ADMIN_OFFLINE";    }        return "OK: state changed!";}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?