MySQL MHA部署笔记

一。环境

操作系统:Redhat 6.3

MySQL:MySQL 5.5

MHA:mha4mysql-manager-0.55,mha4mysql-node-0.54

二。安装

MHA Node:

$ yum install perl-DBD-MySQL
$ rpm -ivh mha4mysql-node-X.Y-0.noarch.rpm

MHA Manager:

  $ perl -MCPAN -e "install Config::Tiny"
 $ perl -MCPAN -e "install Log::Dispatch"
 $ perl -MCPAN -e "install Parallel::ForkManager"
 $ tar
-zxf mha4mysql-manager-X.Y.tar.gz
 $ perl
Makefile.PL
 $ make
 $ sudo make install

三。Running MHA Manager from daemontools

Currently MHA Manager process does not run as a daemon. If failover completed successfully or the master process was killed by accident, the manager stops working. To run as a daemon, daemontool. or any external daemon program can be used. Here is an example to run from daemontools.

1. Install daemontools

ForRedHat

1.下载daemontools

wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/utilities/RHEL_6/x86_64/daemontools-doc-0.76-2.2.x86_64.rpm

2. Create run file under /service/masterha(app_name)/run

manager_host# mkdir /service/masterha_app1

注:第一级目录必须是/service,不能使用其它名字,试着把/service改成/mha等,尝试多很多次都未果,现在还没有找到原因,有可能是daemontools默认约定;

  第二级目录根据实际情况重命名

  第三级文件的名字必须是run

 manager_host# cat /service/masterha_test1/run

#!/bin/sh

 exec masterha_manager --global_conf=/etc/mha/masterha_default.cnf --conf=/etc/mha/masterha_test1/conf/app.conf --wait_on_monitor_error=60 --wait_on_failover_error=60 >> /var/log/masterha/test1/app.log 2>&1

开启snc服务

manager_host# /usr/bin/svscanboot

注:如果不开启此服务,启动如下命令会报错“找不到文件”之类的。

manager_host# chmod 755 /service/masterha_test1/run

You can stop/restart monitoring by daemontool commands.
## stopping monitoring
 manager_host
# svc -d /service/masterha_test1

## starting monitoring

 manager_host# svc -u /service/masterha_test1

## 启动后将会看到supervise进程

 manager_host# ps -efwww|grep supervise

root     21528  1206  0 15:25 ?        00:00:00 supervise masterha_test1


 manager_host# ps -efwww|grep manager

root     21529 21528  0 15:25 ?        00:00:05 perl /usr/local/bin/masterha_manager --global_conf=/etc/mha/masterha_default.cnf --conf=/etc/mha/masterha_test1/conf/app.conf --wait_on_monitor_error=60 --wait_on_failover_error=60



参考:

https://code.google.com/p/mysql-master-ha/wiki/Installation

http://cr.yp.to/daemontools.html



本文出自 “MySQL一点一滴” 博客,请务必保留此出处http://iamadba.blog.51cto.com/1034125/1375826

MySQL MHA部署笔记,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。