MHA安装及等效性配置
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.
上一篇: Spire高效稳定的.NET组件
下一篇: Java 创建、填充PDF表单域
推荐阅读
-
linux下安装tomcat安装及配置教程(在linux中怎么安装tomcat)
-
详解Linux下JDK、Tomcat的安装及配置
-
gvim文本编辑器配置及相关插件安装图文教程
-
linux下安装tomcat安装及配置教程(在linux中怎么安装tomcat)
-
spark 安装教程(spark环境搭建及配置)
-
Eclipse中php插件安装及Xdebug配置的使用详解
-
SharePoint 2007图文开发教程(1) 简介,安装,配置及创建Web应用程序
-
Apache2.4.34 + php 7.28 + MySQL8.0.12 安装及配置
-
VUE 配置vue-devtools调试工具及安装方法
-
CentOS6.5环境安装nginx服务器及负载均衡配置操作详解