Install Mysql MHA On Redhat6.3

官方介绍:MHA performs automating master failover and slave promotion with minimal downtime, usually within 10-30 seconds. MHA prevents replication consistency problems and saves on expenses of having to acquire additional servers. All this with zero performance degradation, no complexity (easy-to-install) and requiring no change to existing deployments.MHA also provides scheduled online master switching, safely changing the currently running master to a new master, within mere seconds (0.5-2 seconds) of downtime (blocking writes only).MHA provides the following functionality, and can be useful in many deployments in which high availability, data integrity and near non-stop master maintenance are required.1.Automated master monitoring and failover2.Interactive (manually initiated) Master Failover3.Non-interactive master failover4.Online switching master to a different host详细可参见官方文档:https://code.google.com/p/mysql-master-ha/wiki/Overview

体系结构:

安装环境:

Manager:OS:redhat 6.3NAME:zbdba1IP:192.168.56.160NODE1:Mysql_role:masterOS:redhat 6.3NAME:zbdba2IP:192.168.56.161NODE2:Mysql_role:slaveOS:redhat6.3NAME:zbdba3IP:192.168.56.1611、安装配置manager节点2、在node节点安装mysql3、配置mysql主从复制4、在node节点安装mha5、配置节点间互信6、开启MHA7、测试MHA

1、安装配置manager节点下载mha的manager和node包

wget ?plugin=attach&pcmd=open&file=mha4mysql-manager-0.56-0.el6.noarch.rpm&refer=matsunobuwget ?plugin=attach&pcmd=open&file=mha4mysql-node-0.56-0.el6.noarch.rpm&refer=matsunobu安装依赖包:

yum install perl-DBD-MySQLyum install perl-Config-Tinyyum install perl-Log-Dispatchyum install perl-Parallel-ForkManager

这里推荐使用repoforge源:wget 安装rpm -ivh mha4mysql-node-0.56-0.el6.noarch.rpmrpm -ivh mha4mysql-manager-0.56-0.el6.noarch.rpm

配置manager:

mkdir -p /etc/masterha/app1[root@zbdba1 masterha]# cat app1.cnf[server default] manager_workdir=/masterha/app1 manager_log=/masterha/app1/manager.log user=rootpassword=mysqlssh_user=rootrepl_user=rootrepl_password=mysqlping_interval=1shutdown_script=""#master_ip_failover_script="/usr/local/bin/master_ip_failover"master_ip_online_change_script=""report_script=""[server1]hostname=192.168.56.161master_binlog_dir="/var/lib/mysql"candidate_master=1[server2]hostname=192.168.56.162master_binlog_dir="/var/lib/mysql"candidate_master=1这两步就不详细说明了

4、在node节点安装mha两个node节点安装:rpm -ivh perl-DBD-MySQL-4.022-1.el6.rfx.x86_64.rpmmha4mysql-node-0.56-0.el6.noarch.rpm5、配置节点间互信

[root@zbdba1 ~]# ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa):/root/.ssh/id_rsa already exists.Overwrite (y/n)? yEnter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:f6:86:4a:38:7f:43:ec:d4:1f:d7:04:2e:48:5f:be:c9 root@zbdba1The key's randomart image is:+–[ RSA 2048]—-+|||. o ||. o + . ||. o o .||.S. o = ||. .+o. . E .|| o .+. o. o ||+ .+. . ||o. .|+—————–+[root@zbdba1 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.56.161root@192.168.56.161's password:Now try logging into the machine, with "ssh 'root@192.168.56.161'", and check in: .ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.[root@zbdba1 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.56.162root@192.168.56.162's password:Now try logging into the machine, with "ssh 'root@192.168.56.162'", and check in: .ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.[root@zbdba2 ~]# ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa):/root/.ssh/id_rsa already exists.Overwrite (y/n)? yEnter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:19:00:7f:cb:7d:5f:cd:48:3b:08:5a:7f:28:2e:9e:f8 root@zbdba2The key's randomart image is:+–[ RSA 2048]—-+| …||. .||. o o . ||o B o + +.||S o = = +||. o o o ||. . . ||o o||..E|+—————–+[root@zbdba2 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.56.162root@192.168.56.162's password:Now try logging into the machine, with "ssh 'root@192.168.56.162'", and check in: .ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.[root@zbdba3 ~]# ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa):Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:9f:2f:5f:0c:fb:dc:f7:f9:4d:b2:de:48:01:ae:51:d1 root@zbdba3The key's randomart image is:+–[ RSA 2048]—-+|.. ||.E ||o ||o . ||S . o . ||. + + . ||+ . = .||.. = B+||oo.*.X|+—————–+[root@zbdba3 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.56.161root@192.168.56.161's password:Now try logging into the machine, with "ssh 'root@192.168.56.161'", and check in: .ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.进行测试:[root@zbdba1 ~]# masterha_check_ssh –conf=/etc/masterha/app1.cnf Tue Feb 10 21:59:19 2015 – [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.Tue Feb 10 21:59:19 2015 – [info] Reading application default configuration from /etc/masterha/app1.cnf..Tue Feb 10 21:59:19 2015 – [info] Reading server configuration from /etc/masterha/app1.cnf..Tue Feb 10 21:59:19 2015 – [info] Starting SSH connection tests..Tue Feb 10 21:59:20 2015 – [debug]Tue Feb 10 21:59:19 2015 – [debug] Connecting via SSH from root@192.168.56.161(192.168.56.161:22) to root@192.168.56.162(192.168.56.162:22)..Tue Feb 10 21:59:19 2015 – [debug] ok.Tue Feb 10 21:59:20 2015 – [debug]Tue Feb 10 21:59:20 2015 – [debug] Connecting via SSH from root@192.168.56.162(192.168.56.162:22) to root@192.168.56.161(192.168.56.161:22)..Tue Feb 10 21:59:20 2015 – [debug] ok.Tue Feb 10 21:59:20 2015 – [info] All SSH connection tests passed successfully.6、开启MHA

开启之前进行复制测试:

成功是奋斗的结果,而奋斗是成功的必经之路。

Install Mysql MHA On Redhat6.3

相关文章:

你感兴趣的文章:

标签云: