MHA安装及等效性配置

php中文网
发布: 2016-06-07 16:13:13
原创
1365人浏览过

MHA由MHA节点(可以理解为子节点)及MHA管理节点2部分组成。因此对于MHA的安装,相应的也分为2个部分,即安装MHA节点,安装MHA管理节点。本文基于CentOS 5.9 64bit简要描述了MHA的安装,同时也描述了在配置MHA时需要完成的等效性配置。供大家参考。 1、MHA的组

mha由mha节点(可以理解为子节点)及mha管理节点2部分组成。因此对于mha的安装,相应的也分为2个部分,即安装mha节点,安装mha管理节点。本文基于centos 5.9 64bit简要描述了mha的安装,同时也描述了在配置mha时需要完成的等效性配置。供大家参考。

1、MHA的组成
MHA consists of MHA Manager and MHA Node packages. MHA Manager runs on a manager server, and MHA Node runs on each MySQL server. MHA Node programs do not run always, but are invoked from MHA manager programs when needed (at configuration check, failover, etc). Both MHA 【本文来自鸿网互联 (http://www.68idc.cn)】Manager and MHA Node are written in Perl.

2、安装MHA Node
MHA Node has scripts and dependent perl modules that do the following.
save_binary_logs: Saving and copying dead master's binary logs
apply_diff_relay_logs: Identifying differential relay log events and applying all necessary log events
purge_relay_logs: Purging relay log files
You need to install MHA Node to all MySQL servers (both master and slave). You also need to install MHA Node on a management server because MHA Manager modules internally depend on MHA Node modules. MHA Manager internally connects to managed MySQL servers via SSH and executes MHA Node scripts. MHA Node does not depend on any external Perl modules except DBD::mysql so you should be able to install easily.

###本次安装环境
# cat /etc/issue
CentOS release 5.9 (Final)
Kernel \r on an \m

###本次的演示环境
# more /etc/hosts
192.168.1.6 dbsrv1 #DB master
192.168.1.7 dbsrv2 #DB slave1
192.168.1.8 dbsrv3 #DB slave2
192.168.1.82 mysql-manager #DB manager node

###以下安装包,建议node和manger都安装
# yum install perl-DBD-MySQL
# yum install perl-Config-Tiny
# yum install perl-Log-Dispatch
# yum install perl-Parallel-ForkManager

###如果yum时相关相关包时,无法获取到,建议配置epel后再安装,需要注意对应的相关版本号。
# wget http://mirrors.ustc.edu.cn/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -Uvh epel-release-5-4.noarch.rpm

###以下安装包从网络上搜集整理,大家可根据情形自行决定是否安装
# yum -y install perl-Config-IniFiles ncftp perl-Params-Validate perl-CPAN perl-Test-Mock-LWP.noarch \
> perl-LWP-Authen-Negotiate.noarch perl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

# ls -hltr
total 172K
-rw-r--r-- 1 root root 112K Dec 5 15:46 mha4mysql-manager-0.56.tar.gz
-rw-r--r-- 1 root root 49K Dec 5 15:46 mha4mysql-node-0.56.tar.gz

# tar -xvf mha4mysql-node-0.56.tar.gz
# cd mha4mysql-node-0.56
# perl Makefile.PL
# make && make install

###验证安装后的几个文件
[root@dbsrv1 bin]# ls apply_diff_relay_logs save_binary_logs filter_mysqlbinlog purge_relay_logs
apply_diff_relay_logs filter_mysqlbinlog purge_relay_logs save_binary_logs

3、安装MHA Manager
MHA Manager has administrative command line programs such as masterha_manager, masterha_master_switch, etc, and dependent Perl modules. MHA Manager depends on the following Perl modules. You need to install them before installing MHA Manager. Do not forget to install MHA Node.
MHA Node package
DBD::mysql
Config::Tiny
Log::Dispatch
Parallel::ForkManager
Time::HiRes (included from Perl v5.7.3)

###以下部分为管理节点上的安装,注,管理节点也要安装MHA Node,此处省略
# tar -xvf mha4mysql-manager-0.56.tar.gz
# perl Makefile.PL
# make && make install

# ls /usr/bin/mast*
/usr/bin/masterha_check_repl /usr/bin/masterha_conf_host /usr/bin/masterha_master_switch
/usr/bin/masterha_check_ssh /usr/bin/masterha_manager /usr/bin/masterha_secondary_check
/usr/bin/masterha_check_status /usr/bin/masterha_master_monitor /usr/bin/masterha_stop

4、配置等效性
###为各节点配置hosts文件
# for i in 6 7 8;do scp /etc/hosts 192.168.1.$i:/etc/;done

[root@mysql-manager #]$ whoami
root
###配置等效性
[root@mysql-manager ~]# ssh-keygen
[root@mysql-manager ~]# ls -a ./.ssh/
. .. id_rsa id_rsa.pub
[root@mysql-manager ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.6
[root@mysql-manager ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.7
[root@mysql-manager ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.8

###使用上面的方法在其余的几个节点如法炮制后验证等效性
[root@dbsrv2 ~]# ssh dbsrv1 date;ssh dbsrv2 date;ssh dbsrv3 date; ssh mysql-manager date;

###在管理节点端使用MHA命令验证等效性
[root@mysql-manager ~]# masterha_check_ssh --conf=/etc/app1.cnf
Mon Feb 16 15:12:43 2015 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Feb 16 15:12:43 2015 - [info] Reading application default configuration from /etc/app1.cnf..
Mon Feb 16 15:12:43 2015 - [info] Reading server configuration from /etc/app1.cnf..
Mon Feb 16 15:12:43 2015 - [info] Starting SSH connection tests..
Mon Feb 16 15:12:45 2015 - [debug]
Mon Feb 16 15:12:43 2015 - [debug] Connecting via SSH from mysql@192.168.1.6(192.168.1.6:22) to mysql@192.168.1.7(192.168.1.7:22)..
Mon Feb 16 15:12:44 2015 - [debug] ok.
Mon Feb 16 15:12:44 2015 - [debug] Connecting via SSH from mysql@192.168.1.6(192.168.1.6:22) to mysql@192.168.1.8(192.168.1.8:22)..
Mon Feb 16 15:12:44 2015 - [debug] ok.
Mon Feb 16 15:12:45 2015 - [debug]
Mon Feb 16 15:12:44 2015 - [debug] Connecting via SSH from mysql@192.168.1.7(192.168.1.7:22) to mysql@192.168.1.6(192.168.1.6:22)..
Mon Feb 16 15:12:44 2015 - [debug] ok.
Mon Feb 16 15:12:44 2015 - [debug] Connecting via SSH from mysql@192.168.1.7(192.168.1.7:22) to mysql@192.168.1.8(192.168.1.8:22)..
Mon Feb 16 15:12:44 2015 - [debug] ok.
Mon Feb 16 15:12:45 2015 - [debug]
Mon Feb 16 15:12:44 2015 - [debug] Connecting via SSH from mysql@192.168.1.8(192.168.1.8:22) to mysql@192.168.1.6(192.168.1.6:22)..
Mon Feb 16 15:12:45 2015 - [debug] ok.
Mon Feb 16 15:12:45 2015 - [debug] Connecting via SSH from mysql@192.168.1.8(192.168.1.8:22) to mysql@192.168.1.7(192.168.1.7:22)..
Mon Feb 16 15:12:45 2015 - [debug] ok.
Mon Feb 16 15:12:45 2015 - [info] All SSH connection tests passed successfully.

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号