remove_snapshot

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

TXT
60
字号
#!/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(dirname(Cwd::abs_path(__FILE__))));# Include parts of the systemrequire $SELF_DIR . '/lib/config.pm';require $SELF_DIR . '/lib/log.pm';# Read config file and statusour $config = ReadConfig("mmm_lvm.conf");my $res = RemoveLvmSnapshot();print "$res\n";exit(0);#-----------------------------------------------------------------sub RemoveLvmSnapshot() {    my $this = $config->{this};    my $host = $config->{host}->{$this};    if (!$host) {        return "ERROR: Invalid 'this' value: '$this'!";    }    return RemoveSnapshot();}#-----------------------------------------------------------------sub RemoveSnapshot() {    my $this = $config->{this};    my $host = $config->{host}->{$this};    # Unmount snapshot    my $res = system("umount", $host->{lvm_mount_dir});    if ($res) {        return "ERROR: Can't umount snapshot: $!";    }    my @command = ($config->{bin_lvremove}, '-f', "/dev/" . $host->{lvm_volume_group} . "/mmm_snapshot");    my $lvm_res = system(@command);    print "LVM res = '$lvm_res'\n";        if ($lvm_res) {        return  "ERROR: Can't remove snapshot: $!";    }        return "OK: Snapshot removed!";}

⌨️ 快捷键说明

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