MySQL high availability architecture-MMM Configuration

Source: Internet
Author: User
Experiment System: CentOS6.6 _ x86_64 prerequisites: Firewall and selinux both disable the experiment Description: There are five hosts in this experiment, and IP Address Allocation is shown in topology Experiment Software: mariadb-

Experiment System: CentOS 6.6 _ x86_64 prerequisites: Firewall and selinux both disable the experiment Description: There are five hosts in this experiment. IP Address Allocation is shown in the topology Experiment Software: mariadb-

Experimental System: CentOS 6.6 _ x86_64

Prerequisites: Firewall and selinux are both disabled.

Tutorial Description: This experiment has five hosts, with IP addresses allocated as topology.

Experimental software: mariadb-10.0.20 mysql-mmm-2.2.1 mysql-mmm-monitor-2.2.1 mysql-mmm-agent-2.2.1

:

Or:

------------------------------------------ Split line ------------------------------------------

FTP address: ftp://ftp1.linuxidc.com

Username: ftp1.linuxidc.com

Password:

Detailed description of MySQL-MMM configuration in LinuxIDC.com/MySQL high-availability architecture on June 1

For the download method, see

------------------------------------------ Split line ------------------------------------------

Tutorial topology:

Use MySQL-MMM for MySQL cluster deployment

Vip address not visible in MySQL MMM Architecture

Test the MMM high-availability architecture of MySQL

MySQL-MMM for MySQL High Availability

MySQL-MMM switching demonstration

Mysql proxy and MySQL-MMM achieve high availability of read/write splitting

Restore the MySQL-MMM Master from the REPLICATION_FAIL status

Use MySQL-MMM in CentOS to achieve high MySQL availability

I. Preparations

1. Modify the host names according to the following table:

2. Modify the hosts file and add the following content:

Vim/etc/hosts
------------------------------------------->
192.168.19.21 mon
192.168.19.66 db1
192.168.19.74 db2
192.168.19.76 db3
192.168.19.79 db4

3. Plan the virtual ip address. The list is as follows:

Ii. install and configure mariadb

1. Install On db1-4:

Tar xf mariadb-10.0.20-linux-x86_64.tar.gz-C/usr/local/
Cd/usr/local/
Ln-sv mariadb-10.0.20-linux-x86_64 mysql
Useradd-r mysql
Mkdir-pv/mydata/data
Chown-R mysql. mysql/mydata/data/
Cd mysql/
Chown-R root. mysql.
Scripts/mysql_install_db -- user = mysql -- datadir =/mydata/data/
Cp support-files/my-large.cnf/etc/my. cnf
Cp support-files/mysql. server/etc/init. d/mysqld
Chkconfig -- add mysqld
Chkconfig mysqld on

2. Edit the configuration file db1:

Vim/etc/my. cnf
--------------------------------------------->
[Mysqld]
Server-id = 1
Datadir =/mydata/data
Log-bin =/mydata/data/mysql1-bin
Binlog_format = ROW
Relay_log =/mydata/data/relay-log
Auto-increment = 2
Auto-increment-offset = 1
Sync_binlog = 1
Sync_master_info = 1
Sync_relay_log = 1
Sync_relay_log_info = 1
Max_binlog_size = 100 M
Log_slave_updates = 1
<---------------------------------------------
Service mysqld start

Db2:

Vim/etc/my. cnf
--------------------------------------------->
[Mysqld]
Server-id = 2
Datadir =/mydata/data
Log-bin =/mydata/data/mysql2-bin
Binlog_format = ROW
Relay_log =/mydata/data/relay-log
Auto-increment = 2
Auto-increment-offset = 2
Sync_binlog = 1
Sync_master_info = 1
Sync_relay_log = 1
Sync_relay_log_info = 1
Max_binlog_size = 100 M
Log_slave_updates = 1
<---------------------------------------------
Service mysqld start

Db3:

Vim/etc/my. cnf
--------------------------------------------->
[Mysqld]
Server-id = 3
Datadir =/mydata/data
Log-bin =/mydata/data/mysql3-bin
Binlog_format = ROW
Relay_log =/mydata/data/relay-log
Sync_binlog = 1
Sync_master_info = 1
Sync_relay_log = 1
Sync_relay_log_info = 1
Max_binlog_size = 100 M
Log_slave_updates = 1
<---------------------------------------------
Service mysqld start

Db4:

Vim/etc/my. cnf
--------------------------------------------->
[Mysqld]
Server-id = 4
Datadir =/mydata/data
Log-bin =/mydata/data/mysql4-bin
Binlog_format = ROW
Relay_log =/mydata/data/relay-log
Sync_binlog = 1
Sync_master_info = 1
Sync_relay_log = 1
Sync_relay_log_info = 1
Max_binlog_size = 100 M
Log_slave_updates = 1
<---------------------------------------------
Service mysqld start

Here we need to create three users, as shown in the following table:

/Usr/local/mysql/bin/mysql
------------------------------------------------->
Grant replication client on *. * TO 'mmm _ monitor' @ '2017. 192.% 'identified by '20160301 ';
Grant super, replication client, process on *. * TO 'mmm _ agent' @ '192. 192.% 'identified by '123 ';
Grant replication slave on *. * TO 'replicase' @ '192. 192.% 'identified by '123'

4. view the binary log location:

Flush tables with read lock; // apply the LOCK
Show master status;
+ ------------------- + ---------- + -------------- + ------------------ +
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+ ------------------- + ---------- + -------------- + ------------------ +
| Mysql1-bin.000004 | 936 |
+ ------------------- + ---------- + -------------- + ------------------ +

5. Do not close the mysql process connection to avoid lock failure. We will create another ssh connection to the db1 server for database backup:

/Usr/local/mysql/bin/mysqldump -- all-databases>/tmp/database-backup. SQL

6. Return to the mysql process and unlock it:

Unlock tables;

7. Copy the database-backup. SQL file to another db node:

Scp/tmp/database-backup. SQL db2:/tmp/
Scp/tmp/database-backup. SQL db3:/tmp/
Scp/tmp/database-backup. SQL db4:/tmp/

8. db2-4 hosts import SQL files and refresh permissions:

/Usr/local/mysql/bin/mysql </tmp/database-backup. SQL
/Usr/local/mysql/bin/mysql
------------------------------------------------->
Flush privileges;

3. Set Replication

1. operate on the db2-4, set db1 to the master of the db2-4:

Change master to MASTER_HOST = '192. 168.19.66 ', MASTER_USER = 'replicase', MASTER_PASSWORD = '000000', MASTER_LOG_FILE = 'mysql1-bin.000004', MASTER_LOG_POS = 192;
Start slave;

2. view the status:

Show slave status \ G

3. view the location of the db2 master log:

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.