In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to build MHA+MySQL". In daily operation, I believe many people have doubts about how to build MHA+MySQL. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to build MHA+MySQL". Next, please follow the editor to study!
One master and two slaves, the manager node is vm3
Master:10.0.0.2 vm1 node
Slave1: 10.0.0.3 vm2 node
Slave2: 10.0.0.4 vm3 manager
OS verision: CentOS release 6.5
1. Download the MHA installation package from https://code.google.com/p/mysql-master-ha/wiki/Downloads?tm=2
Mha4mysql-node-0.56-0.el6.noarch.rpm
Mha4mysql-manager-0.56-0.el6.noarch.rpm
Node needs to install the mha4mysql-node-0.56-0.el6.noarch.rpm package
Manager nodes need to install mha4mysql-manager-0.56-0.el6.noarch.rpm and mha4mysql-node-0.56-0.el6.noarch.rpm
Or download the source package from https://github.com/yoshinorim
2 configure all nodes with EPEL yum sources.
Rpm-ivh http://mirrors.opencas.cn/epel/6/i386/epel-release-6-8.noarch.rpm
Yum clean all; yum makecache
3 install mha4mysql-node-0.56-0.el6.noarch.rpm for all nodes
Yum-y install perl-DBD-MySQL ncftp
Rpm-ivh mha4mysql-node-0.56-0.el6.noarch.rpm
4 install mha4mysql-manager-0.56-0.el6.noarch.rpm for the manager node
Yum-y install perl-Config-Tiny perl-Params-Validate perl-Log-Dispatch perl-Parallel-ForkManager
Rpm-ivh mha4mysql-manager-0.56-0.el6.noarch.rpm
(5) configure ssh public key trust between nodes to realize key-free login. (manager to node, node to node)
Vm1:
Ssh-keygen-t rsa
Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.0.0.3
Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.0.0.4
Vm2:
Ssh-keygen-t rsa
Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.0.0.2
Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.0.0.4
Vm3:
Ssh-keygen-t rsa
Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.0.0.2
Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.0.0.3
Ssh from each node to log in to other nodes. (must be done, yes confirmation is required for the first time)
6. Create MHA monitoring users on each mysql node
Grant all privileges on *. * to 'mha_monitor'@'10.0.0.%' identified by' 123456'
Mysql > select user,host from user
+-+ +
| | user | host |
+-+ +
| | mha_monitor | 10.0.0.% | |
| | repl | 10.0.0.% | |
7 configure the mha conf file
Mkdir / etc/masterha
Mkdir-p / masterha/app1
The configuration file app1.cnf is as follows
Cat / etc/masterha/app1.cnf
[server default]
Manager_workdir=/masterha/app1
Manager_log=/masterha/app1/manager.log
Ssh_user=root # # OS ssh login user
User=mha_monitor # # users who log in to mysql master and slave on mha
Password=123456 # # user password of the master and slave of mha login mysql
Repl_user=repl # # Master-Slave replication user
Repl_password=p4ssw0rd # # Master-Slave copy user's password
Ping_interval=1
Shutdown_script= ""
# master_ip_failover_script= "/ usr/local/bin/master_ip_failover"
Master_ip_online_change_script= ""
Report_script= ""
[server1]
Hostname=10.0.0.2
Master_binlog_dir= "/ data/mysql3306"
Port=3306
Candidate_master=1
[server2]
Hostname=10.0.0.3
Master_binlog_dir= "/ data/mysql3306"
Port=3306
Candidate_master=1
[server3]
Hostname=10.0.0.4
Master_binlog_dir= "/ data/mysql3306"
Port=3306
No_master=1
8 start
Nohup masterha_manager-- conf=/etc/masterha/app1.cnf > / tmp/mha_manager.log
< /dev/null 2>& 1 &
After shutdown drops master, it can be switched smoothly.
However, masterha_check_ssh will report an error, but it does not affect the functionality:
[root@vm3] # masterha_check_ssh-- conf=/etc/masterha/app1.cnf
Wed Apr 6 15:56:05 2016-[warning] Global configuration file / etc/masterha_default.cnf not found. Skipping.
Wed Apr 6 15:56:05 2016-[info] Reading application default configuration from / etc/masterha/app1.cnf..
Wed Apr 6 15:56:05 2016-[info] Reading server configuration from / etc/masterha/app1.cnf..
Wed Apr 6 15:56:05 2016-[info] Starting SSH connection tests..
Wed Apr 6 15:56:05 2016-[debug]
Wed Apr 6 15:56:05 2016-[debug] Connecting via SSH from root@vm1 (10.0.0.2) to root@vm2 (10.0.0.3).
Wed Apr 6 15:56:05 2016-[debug] ok.
Wed Apr 6 15:56:05 2016-[debug] Connecting via SSH from root@vm1 (10.0.0.2 Connecting via SSH from root@vm1 22) to root@10.0.0.4 (10.0.0.4 Connecting via SSH from root@vm1 22).
Wed Apr 6 15:56:05 2016-[debug] ok.
Wed Apr 6 15:56:06 2016-[debug]
Wed Apr 6 15:56:05 2016-[debug] Connecting via SSH from root@vm2 (10.0.0.3) to root@vm1 (10.0.0.2).
Wed Apr 6 15:56:06 2016-[debug] ok.
Wed Apr 6 15:56:06 2016-[debug] Connecting via SSH from root@vm2 (10.0.0.3) to root@10.0.0.4 (10.0.0.4).
Wed Apr 6 15:56:06 2016-[debug] ok.
Wed Apr 6 15:56:06 2016-[error] [/ usr/share/perl5/vendor_perl/MHA/SSHCheck.pm, ln63]
Wed Apr 6 15:56:06 2016-[debug] Connecting via SSH from root@10.0.0.4 (10.0.0.4) to root@vm1 (10.0.0.2).
Warning: Permanently added '10.0.0.4' (RSA) to the list of known hosts.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
Wed Apr 6 15:56:06 2016-[error] [/ usr/share/perl5/vendor_perl/MHA/SSHCheck.pm, ln111] SSH connection from root@10.0.0.4 (10.0.0.4 ln111 22) to root@vm1 (10.0.0.2 usr/share/perl5/vendor_perl/MHA/SSHCheck.pm 22) failed!
SSH Configuration Check Failed!
At / usr/bin/masterha_check_ssh line 44 middle
9 finally, shutdown drops master to simulate failover:
-Failover Report-
App1: MySQL Master failover vm1 (10.0.0.2VR 3306) to vm2 (10.0.0.3V 3306) succeeded
Master vm1 (10.0.0.2 3306) is down!
Check MHA Manager logs at vm3:/masterha/app1/manager.log for details.
Started automated (non-interactive) failover.
Selected vm2 (10.0.0.3 3306) as a new master.
Vm2 (10.0.0.3): OK: Applying all logs succeeded.
10.0.0.4 (10.0.0.4): OK: Slave started, replicating from vm2 (10.0.0.3)
Vm2 (10.0.0.3 3306): Resetting slave info succeeded.
Master-slave switch succeeded.
# #
# #
With regard to the problem of masterha_check_ssh reporting errors, posts with similar problems found on MHA's official website have been explained as follows:
# 3 dba.abde...@gmail.com As mentioned here in the tutorial:
Https://code.google.com/p/mysql-master-ha/wiki/Tutorial
You shouldn't add an entry for the manager host. If you have 4 hosts, 1,2,3 and 4 (manager), you should add host entries for the first 3 ones only (1,2 & 3) then it should work without any problems.
His structure is as follows:
Master:10.10.105.9
Slave1:10.10.105.10
Slave2:10.10.105.11
Slave3+mha_manage:10.10.105.12
It's similar to my structure.
At this point, the study on "how to build MHA+MySQL" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.