Mmm realizes MySQL high availability

Source: Internet
Author: User
Tags install perl

A MySQL master-slave Build
Slightly

A setup hosts parsing
[[email protected] conf]# vi/etc/hosts (three servers same add the following)
192.168.31.2 M1
192.168.31.3 M2
192.168.31.4 slave1

Two sets the name of each server corresponding to the Hosts file respectively
Slightly

Three create the appropriate account
GRANT REPLICATION SLAVE, REPLICATION CLIENT on *. * to ' mmm_slave ' @ ' 192.168.31.% ' identified by ' 123456 '; (This user is added to both master and master replication m1,m2)
Flush privileges;

Four M1 M2 configured as main main mode
M1 configuration file
[Mysqld]
Innodb_file_per_table=1
Log-bin=/data/mysql/mysql-bin.log
Binlog_format = ROW
Server-id=1
Binlog-do-db=mmm_test
Replicate-do-db=mmm_test

M2 configuration file
[Mysqld]
Innodb_file_per_table=1
Log-bin=/data/mysql/mysql-bin.log
Binlog_format = ROW
server-id=2
Binlog-do-db=mmm_test
Replicate-do-db=mmm_test



Execute on the M2
Change Master to master_host= ' 192.168.31.2 ', master_user= ' mmm_slave ', master_password= ' 123456 ', master_log_file= ' mysql-bin.000017 ', master_log_pos=326;
Start slave;

Execute on M1 (main master model)
Change Master to master_host= ' 192.168.31.3 ', master_user= ' mmm_slave ', master_password= ' 123456 ', master_log_file= ' Mysql-bin.000001 ', master_log_pos=312;
Start slave;

Five configuration M1 and slave1 master-slave
SLAVE1 configuration file
[Mysqld]
Server-id =3
Innodb_file_per_table=1
Log-bin=/data/mysql/mysql-bin.log
Binlog_format = ROW
Replicate-do-db=mmm_test

Perform
Change Master to master_host= ' 192.168.31.2 ', master_user= ' mmm_slave ', master_password= ' 123456 ', master_log_file= ' mysql-bin.000017 ', master_log_pos=326;
Start slave;



Six installation mysql-mmm (three server execution results are the same)
[Email protected] software]# wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
[Email protected] software]# RPM-IVH epel-release-5-4.noarch.rpm
[Email protected] software]# yum-y install mysql-mmm*
[Email protected] software]# Rpm-qa | grep mysql-mmm
Mysql-mmm-2.2.1-2.el6.noarch
Mysql-mmm-agent-2.2.1-2.el6.noarch
Mysql-mmm-tools-2.2.1-2.el6.noarch
Mysql-mmm-monitor-2.2.1-2.el6.noarch

Seven on three nodes authorized

GRANT process,super,replication CLIENT on *. * to ' mmm_agent ' @ ' 192.168.31.% ' identified by ' 123456 '; (Agent account, is the MMM agent used to become read-only mode and synchronization master, etc.)
GRANT REPLICATION CLIENT on *. * to ' mmm_monitor ' @ ' 192.168.31.% ' identified by ' 123456 '; (Monitoring account, is the MMM monitoring server for the MySQL server to do health check)
Flush privileges;

Eight configuration MMM monitoring, proxy services
Modify mmm_common.conf on 13 servers (the same steps are performed on three servers)
[Email protected] conf]# cd/etc/mysql-mmm/
[email protected] mysql-mmm]# CP mmm_common.conf Mmm_common.conf.bak
[Email protected] mysql-mmm]# VI mmm_common.conf
Active_master_role writer

Cluster_interface Eth1 # Here's the case, my three servers are different here.
Pid_path/var/run/mysql-mmm/mmm_agentd.pid
bin_path/usr/libexec/mysql-mmm/
Replication_user Mmm_slave # Copy account created earlier
Replication_password 123456 # Copy the password of the account
Agent_user Mmm_agent # The proxy account created earlier
Agent_password 123456 # password for proxy account

IP 192.168.31.2
Mode Master
Peer M1

IP 192.168.31.3
Mode Master
Peer M2

IP 192.168.31.4
mode slave

<role writer>
Hosts M1, M2 # can serve as a writer's server
IPs 192.168.31.10 # Writer node Virtual IP, application write request will be connected directly to this IP
Mode Exclusive # Exclusive modes
</role>

<role reader>
Hosts M1,m2,slave1 # as a server for reader
IPs 192.168.31.20 # Reader node virtual IP, application read request will be connected directly to this IP
Mode Balanced # Balance mode
</role>

2 Modifying the mmm_agent.conf of M1
[Email protected] mysql-mmm]# VI mmm_agent.conf
Include mmm_common.conf

# the ' This ' variable refers to this server. Proper operation requires
# That's "This" server (db1 by default), as well as all other servers, has the
# proper IP addresses set in mmm_common.conf.
This M1

3 Modifying the mmm_agent.conf of M2
[Email protected] mysql-mmm]# VI mmm_agent.conf
Include mmm_common.conf

# the ' This ' variable refers to this server. Proper operation requires
# That's "This" server (db1 by default), as well as all other servers, has the
# proper IP addresses set in mmm_common.conf.
This M2

4 Modifying the mmm_agent.conf of slave1
[Email protected] mysql-mmm]# VI mmm_agent.conf
Include mmm_common.conf

# the ' This ' variable refers to this server. Proper operation requires
# That's "This" server (db1 by default), as well as all other servers, has the
# proper IP addresses set in mmm_common.conf.
This slave1

5 Modify the Mmm_mon.conf on Mon (This is M1 sharing a server)
[Email protected] mysql-mmm]# VI mmm_mon.conf
Include mmm_common.conf

<monitor>
IP IP 192.168.31.2
Pid_path/var/run/mysql-mmm/mmm_mond.pid
Bin_path/usr/libexec/mysql-mmm
Status_path/var/lib/mysql-mmm/mmm_mond.status
Ping_ips 192.168.31.2,192.168.31.3,192.168.31.4
Auto_set_online 10

# The Kill_host_bin does not exist by default, though the monitor would
# Throw a warning about it missing. See the section 5.10 "Kill Host
# functionality "in the PDF documentation.
#
# Kill_host_bin/usr/libexec/mysql-mmm/monitor/kill_host
#
</monitor>

Monitor_user Mmm_monitor
Monitor_password 123456

Debug 0




Nine start all related services
13 Servers Start Mysql-mmm-agent Service
[[email protected] mysql-mmm]#/etc/init.d/mysql-mmm-agent start
[[email protected] mysql-mmm]#/etc/init.d/mysql-mmm-agent start
[[email protected] mysql-mmm]#/etc/init.d/mysql-mmm-agent start

2 Start the Mysql-mon service on M1
[[email protected] mysql-mmm]#/etc/init.d/mysql-mmm-monitor start

3 Viewing the MMM status information on the Mysql-mon monitoring machine
[Email protected] mysql-mmm]# Mmm_control Show
The can ' t connect to monitor daemon appears
Then yum-y install perl-time-hires*
If you still see Can ' t connect to monitor daemon check the master and slave for problems

[[email protected] ~]# Mmm_control Show # The next few lines will appear
M1 (192.168.31.2) master/online. Roles:writer (192.168.31.10)
M2 (192.168.31.3) master/online. Roles:reader (192.168.31.20)
Slave1 (192.168.31.4) slave/online. Roles:

[[email protected] ~]# Mmm_control checks all # appears below
M1 Ping [last change:2015/09/24 00:39:19] OK
M1 MySQL [last change:2015/09/24 00:39:19] OK
M1 rep_threads [last change:2015/09/24 00:39:19] error:replication is broken
......
M2 Rep_backlog [last change:2015/09/24 00:39:19] Ok:backlog is null


Ten View cluster logs
[Email protected] ~]# tail-f/var/log/mysql-mmm/mmm_agentd.log
2015/09/23 18:38:11 FATAL Child exited with ExitCode 98, restarting after second sleep
2015/09/23 18:38:21 FATAL listener:can ' t create socket!
.......
2015/09/24 00:39:13 INFO added:writer (192.168.31.10)


[Email protected] ~]# tail-f/var/log/mysql-mmm/mmm_mond.log
2015/09/24 00:35:10 WARN Checker ' MySQL ' is dead!
......
2015/09/24 00:35:16 INFO Child exited normally (with ExitCode 0), shutting down

[Email protected] mysql-mmm]# tail-f/var/log/mysql-mmm/mmm_agentd.log
2015/09/23 02:53:38 INFO END
.......
2015/09/24 00:38:55 INFO Child exited normally (with ExitCode 0), shutting down
2015/09/24 00:38:55 INFO changing active master to ' M1 '

11 Testing
We use the M1 IP a can be found 192.168.31.10 on M1
Analog M1 Downtime
Using service MySQL Stop

In view of IP a The VIP was found on the M2.



















Mmm realizes MySQL high availability

Related Article

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.