Mysql high availability solution-MHA

Source: Internet
Author: User
Tags time 0 install perl
Environment Planning: Host Name and IP address management node tong3192.168.1.249 master node tong2192.168.1.248 master node tong1 & nb ..

Environment Planning: Host Name and IP address management node tong3192.168.1.249 master node tong2192.168.1.248 master node tong1 & nb ..

Environment Planning:

Node description host name IP Address

Management node tong3 192.168.1.249

Master node tong2 192.168.1.248

Master node tong1 192.168.1.247


1. Network and host name Configuration

Set the IP address of each host and the/etc/hosts file to parse each other

[Root @ tong1 ~] # Cat/etc/hosts
192.168.1.247 tong1
192.168.1.248 tong2
192.168.1.249 tong3
[Root @ tong1 ~] # Ping tong1-c1 -- the network must be pinged
PING tong1 (192.168.1.247) 56 (84) bytes of data.
64 bytes from localhost (192.168.1.247): icmp_seq = 1 ttl = 64 time = 0.021 MS

--- Tong1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0 ms
Rtt min/avg/max/mdev = 0.021/0.021/0.021/0.000 MS
[Root @ tong1 ~] # Ping tong2-c1
PING tong2 (192.168.1.248) 56 (84) bytes of data.
64 bytes from tong2 (192.168.1.248): icmp_seq = 1 ttl = 64 time = 0.109 MS

--- Tong2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0 ms
Rtt min/avg/max/mdev = 0.109/0.109/0.109/0.000 MS
[Root @ tong1 ~] # Ping tong3-c1
PING tong3 (192.168.1.249) 56 (84) bytes of data.
64 bytes from tong3 (192.168.1.249): icmp_seq = 1 ttl = 64 time = 0.124 MS

--- Tong3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0 ms
Rtt min/avg/max/mdev = 0.124/0.124/0.124/0.000 MS
[Root @ tong1 ~] #


2. Install mha management software mha manager

Tong3 management node:

[Root @ tong3 ~] # Yum install perl-DBD-MySQL cpan -- install the perl Tool

[Root @ tong3 ~] # Tar xvf mha4mysql-manager-0.53.tar.gz-C/usr/local/

[Root @ tong3 ~] # Cd/usr/local/mha4mysql-manager-0.53/

[Root @ tong3 mha4mysql-manager-0.53] # perl Makefile. PL

[Root @ tong3 mha4mysql-manager-0.53] # echo $?
0
[Root @ tong3 mha4mysql-manager-0.53] # make & make install

[Root @ tong3 mha4mysql-manager-0.53] # echo $?
0
[Root @ tong3 mha4mysql-manager-0.53] #


3. Install mha node on each data node

[Root @ tong2 ~] # Tar xvf mha4mysql-node-0.53.tar.gz
[Root @ tong2 ~] # Cd mha4mysql-node-0.53
[Root @ tong2 mha4mysql-node-0.53] # yum install perl-DBD-mysql cpan-y

[Root @ tong2 mha4mysql-node-0.53] # perl Makefile. PL
[Root @ tong2 mha4mysql-node-0.53] # make & make install

[Root @ tong2 mha4mysql-node-0.53] # echo $?
0
[Root @ tong2 mha4mysql-node-0.53] #


4. ssh mutual trust between nodes

[Root @ tong3 ~] # Ssh-keygen-t dsa

[Root @ tong3 ~] # Cd. ssh

[Root @ tong3. ssh] # cat id_dsa.pub> authorized_keys

[Root @ tong3. ssh] # scp 192.168.1.247:/root/. ssh/id_dsa.pub 247

[Root @ tong3. ssh] # scp 192.168.1.248:/root/. ssh/id_dsa.pub 248

[Root @ tong3. ssh] # cat 248 247> authorized_keys
[Root @ tong3. ssh] # scp authorized_keys 192.168.1.248:/root/. ssh/
Authorized_keys 100% 1800 1.8KB/s
[Root @ tong3. ssh] # scp authorized_keys 192.168.1.247:/root/. ssh/
Root@192.168.1.247's password:
Authorized_keys 100% 1800 1.8KB/s
[Root @ tong3. ssh] # ssh tong1 date
Tue Apr 28 8 12:57:02 CST 2015
[Root @ tong3. ssh] # ssh tong2 date
Tue Apr 28 8 12:59:57 CST 2015
[Root @ tong3. ssh] # ssh tong3 date
Tue Apr 28 8 12:57:25 CST 2015
[Root @ tong3. ssh] #


5. Edit the configuration file on the Management Node

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.