首页 / 邮件 / mysql高可用之MHA--邮件报警
mysql高可用之MHA--邮件报警
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mysql高可用之MHA--邮件报警,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3545字,纯文字阅读大概需要6分钟。
内容图文
![mysql高可用之MHA--邮件报警](/upload/InfoBanner/zyjiaocheng/494/1d926c13c2b24e3abf51b40cb8b635fc.jpg)
- [root@rd-mysql-test4 mha]# cat /usr/local/bin/send_report
- #!/usr/bin/perl
- # Copyright (C) 2011 DeNA Co.,Ltd.
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc.,
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ## Note: This is a sample script and is not complete. Modify the script based on your environment.
- use strict;
- use warnings FATAL => ‘all‘;
- use Mail::Sender;
- use Getopt::Long;
- #new_master_host and new_slave_hosts are set only when recovering master succeeded
- my ( $dead_master_host, $new_master_host, $new_slave_hosts, $subject, $body );
- my $smtp=‘smtp.163.com‘;
- my $mail_from=‘from@163.com‘;
- my $mail_user=‘from@163.com‘;
- my $mail_pass=‘password‘;
- #my $mail_to=[‘to1@qq.com‘,‘to2@qq.com‘];
- my $mail_to=‘to@qq.com‘;
- GetOptions(
- ‘orig_master_host=s‘ => \$dead_master_host,
- ‘new_master_host=s‘ => \$new_master_host,
- ‘new_slave_hosts=s‘ => \$new_slave_hosts,
- ‘subject=s‘ => \$subject,
- ‘body=s‘ => \$body,
- );
- # Do whatever you want here
- mailToContacts($smtp,$mail_from,$mail_user,$mail_pass,$mail_to,$subject,$body);
- sub mailToContacts {
- my ($smtp, $mail_from, $mail_user, $mail_pass, $mail_to, $subject, $msg ) = @_;
- open my $DEBUG, ">/var/log/masterha/app1/mail.log"
- or die "Can‘t open the debug file:$!\n";
- my $sender = new Mail::Sender {
- ctype => ‘text/plain;charset=utf-8‘,
- encoding => ‘utf-8‘,
- smtp => $smtp,
- from => $mail_from,
- auth => ‘LOGIN‘,
- TLS_allowed => ‘0‘,
- authid => $mail_user,
- authpwd => $mail_pass,
- to => $mail_to,
- subject => $subject,
- debug => $DEBUG
- };
- $sender->MailMsg(
- {
- msg => $msg,
- debug => $DEBUG
- }
- ) or print $Mail::Sender::Error;
- return 1;
- }
- exit 0;
- [server default]
- manager_log=/var/log/masterha/app1/manager.log
- manager_workdir=/var/log/masterha/app1
- master_binlog_dir=/data/mysql
- master_ip_failover_script=/usr/local/bin/master_ip_failover
- master_ip_online_change_script=/usr/local/bin/master_ip_online_change
- password=123456
- ping_interval=1
- remote_workdir=/tmp
- repl_password=123456
- repl_user=rep
- report_script=/usr/local/bin/send_report
- ssh_port=22
- ssh_user=root
- user=mha
- [server1]
- hostname=10.10.10.56
- port=3306
- [server2]
- hostname=10.10.10.57
- port=3306
- [server3] <li style="border-width: medium medium mediu 本文系统来源:http://www.cnblogs.com/John-2011/p/7818712.html
内容总结
以上是互联网集市为您收集整理的mysql高可用之MHA--邮件报警全部内容,希望文章能够帮你解决mysql高可用之MHA--邮件报警所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。