Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the MMM cluster deployment in MySQL

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

How the MMM cluster deployment in MySQL is, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

MySQL-MMM cluster deployment

MMM (Master-Master replication managerfor Mysql,Mysql Master Master replication Manager) is a flexible scripting program based on perl implementation for monitoring and failover of mysql replication and managing the configuration of mysql Master-Master replication (only one node is writable at a time).

Mmm_mond: monitor the process, be responsible for all monitoring work, determine and handle all node role activities. This script needs to be run on the supervisor.

Mmm_agentd: an agent process that runs on each mysql server, performs monitoring probe work and performs simple remote service settings. This script needs to be run on the supervised machine.

Mmm_control: a simple script that provides commands for managing mmm_mond processes.

Experimental topology diagram

Experimental environment preparation

The IP hostnames of the five virtual machines are:

192.168.4.10 Hostname: mysql10

192.168.4.11 Hostname: mysql11

192.168.4.12 Hostname: mysql12

192.168.4.13 Hostname: mysql13

192.168.4.120 Hostname: client120

Turn off the firewall and SELinux restrictions for each virtual machine to facilitate the experiment

10-13 install the mysql database service

First, configure the master-slave synchronization structure

1.1 configure main main structure 10 / 11

Common configuration

On virtual machine 10: user authorization to start binlog log restart database service administrator login specified master library information

Mysql > grant replication slave on *. * to slaveuser@ "%" identified by '123456'

[root@mysql10 ~] # vim / etc/my.cnf

[mysqld]

Server_id=10

Log-bin=master10

Binlog_format= "mixed"

[root@mysql10 ~] # systemctl restart mysqld

Mysql > show master status

| | master10.000001 | 154 | |

Mysql > change master to master_host= "192.168.4.11", master_user= "slaveuser", master_password= "123456", master_log_file= "master11.000001", master_log_pos=154

Mysql > start slave

Mysql > show slave status\ G

Relay_Master_Log_File: master13.000001

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

On virtual machine 11: user authorization to enable binlog logging and allow cascade replication to restart the database service administrator to log in to the specified master library information

Mysql > grant replication slave on *. * to slaveuser@ "%" identified by '123456'

[root@mysql11 mysql] # vim / etc/my.cnf

[mysqld]

Server_id=11

Log-bin=master11

Binlog_format= "mixed"

Log_slave_updates

[root@mysql11 mysql] # systemctl stop mysqld

[root@mysql11 mysql] # systemctl start mysqld

Mysql > show master status

| | master11.000001 | 154 | |

Mysql > change master to master_host= "192.168.4.10", master_user= "slaveuser", master_password= "123456", master_log_file= "master10.000001", master_log_pos=154

Mysql > start slave

Mysql > show slave status\ G

Relay_Master_Log_File: master10.000001

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Configure one master and multi-slave structure (configure the slave library of 11 respectively for 12 ~ (st) 13)

On virtual machine 12

[root@mysql12 ~] # vim / etc/my.cnf

[mysqld]

Server_id=12

[root@mysql12 ~] # systemctl stop mysqld

[root@mysql12 ~] # systemctl start mysqld

Mysql > change master to master_host= "192.168.4.11", master_user= "slaveuser", master_password= "123456", master_log_file= "master11.000001", master_log_pos=154

Mysql > start slave

Mysql > show slave status\ G

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

On virtual machine 13

[root@mysql13 ~] # vim / etc/my.cnf

[mysqld]

Server_id=13

[root@mysql13 ~] # systemctl stop mysqld

[root@mysql13 ~] # systemctl start mysqld

Mysql > change master to master_host= "192.168.4.11", master_user= "slaveuser", master_password= "123456", master_log_file= "master11.000001", master_log_pos=154

Mysql > start slave

Mysql > show slave status\ G

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

On virtual machine 10:

Adding an access user on 10 hosts allows guser to have the same authorized user on the other 3 hosts

Mysql > create database gamedb

Mysql > grant all on gamedb.* to guser@ "" identified by "123456"

The new data generated by the client 245 connecting to the 10 server using the authorized user guser is also available on the other three hosts.

[root@room1pc32 Desktop] # mysql-h292.168.4.10-uguser-p123456

MySQL [(none)] > create table gamedb.a (id int)

MySQL [(none)] > insert into gamedb.a values

MySQL [(none)] > insert into gamedb.a values

MySQL [(none)] > insert into gamedb.a values

Second, configure mysql-mmm

Mysql-mmm introduction:

Monitoring service: runs on the management node to monitor the data node

Agent service: runs on the data node to provide the system to the monitoring host

1) install mysql-mmm software on all hosts (10-13120)

Yum-y install perl-*

Tar-zxvf mysql-mmm.zip

Unzip mysql-mmm.zip

Cd mysql-mmm/

Tar-zxvf mysql-mmm-2.2.1.tar.gz

Cd mysql-mmm-2.2.1/

Make install

Ls / etc/mysql-mmm/

Mmm_agent.conf mmm_common.conf mmm_mon.conf mmm_tools.conf

2) modify the configuration file

a. Modify data Node Agent Service profile (10 11 12 13)

[root@mysql10 ~] # vim / etc/mysql-mmm/mmm_agent.conf

Include mmm_common.conf

This db10# Custom name

[root@mysql11 ~] # vim / etc/mysql-mmm/mmm_agent.conf

Include mmm_common.conf

This db11

[root@mysql12 ~] # vim / etc/mysql-mmm/mmm_agent.conf

Include mmm_common.conf

This db12

[root@mysql13 ~] # vim / etc/mysql-mmm/mmm_agent.conf

Include mmm_common.conf

This db13

b. Modify the configuration file of the management node monitoring service (120)

[root@client120 ~] # vim / etc/mysql-mmm/mmm_mon.conf

Include mmm_common.conf

Ip 192.168.4.120

Pid_path / var/run/mmm_mond.pid

Bin_path / usr/lib/mysql-mmm/

Status_path / var/lib/misc/mmm_mond.status

Ping_ips 192.168.4.10, 192.168.4.11, 192.168.4.12, 192.168.4.13

Monitor_user monitor# Monitoring user name

Monitor_password 12345 monitors user passwords

Debug 00 does not display debug information 1 displays debug information

c. Modify public files (10, 11, 12, 13, 120)

Vim / etc/mysql-mmm/mmm_common.conf

10 replication_user slaveuser# proxy user

11 replication_password 123456

twelve

13 agent_user agent# database

14 agent_password 123456

17 # modify four servers

18 ip 192.168.4.10

19 mode master

20 peer db11

twenty-one

twenty-two

twenty-three

24 ip 192.168.4.11

25 mode master

26 peer db10

twenty-seven

twenty-eight

twenty-nine

30 ip 192.168.4.12

31 mode slave

thirty-two

thirty-three

thirty-four

35 ip 192.168.4.13

36 mode slave

thirty-seven

thirty-nine

40 hosts db10, db11

41 ips 192.168.4.100

42 mode exclusive

forty-three

forty-four

forty-five

46 hosts db12, db13

47 ips 192.168.4.102, 192.168.4.105

48 mode balanced

forty-nine

d. Add the corresponding authorized user on the data node according to the settings of the profile

Monitor

Agent

3) Authorization on virtual machine 10

Mysql > grant replication client on *. * to monitor@ "%" identified by "123456"

Mysql > grant replication client,process,super on *. * to agent@ "%" identified by "123456"

4) the other three tests

Mysql > select user,host from mysql.user where user in ('agent','monitor')

Third, start the service

a. Start the data node host agent service (10-13): install the service to run the dependent package installation to obtain the vip address package startup service

Cd / root/mysql-mmm/

Tar-zxf Algorithm-Diff-1.1902.tar.gz

Cd Algorithm-Diff-1.1902/

Perl Makefile.PL

Make

Make install

Cd / root/mysql-mmm/

Tar-zxf Proc-Daemon-0.03.tar.gz

Cd Proc-Daemon-0.03/

Perl Makefile.PL

Make

Make install

Cd / root/mysql-mmm/

Rpm-ivh-nodeps perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm

/ etc/init.d/mysql-mmm-agent start

/ etc/init.d/mysql-mmm-agent status

Netstat-pantu | grep mmm

Netstat-pantu | grep: 9989

Tcp 00 192.168.4.11 9989 0.0.0.0 * LISTEN 10059/mmm_agentd

Yum-y install gcc gcc-c++

Cd / root/mysql-mmm/

Gunzip Net-ARP-1.0.8.tgz

Tar-xf Net-ARP-1.0.8.tar

Cd Net-ARP-1.0.8/

Perl Makefile.PL

Make

Make install

b. Start the management node host monitoring service (120): install the service run the software package to start the service

Cd / root/mysql-mmm/

Tar-zxf Algorithm-Diff-1.1902.tar.gz

Cd Algorithm-Diff-1.1902/

Perl Makefile.PL

Make

Make install

Cd / root/mysql-mmm/

Tar-zxf Proc-Daemon-0.03.tar.gz

Cd Proc-Daemon-0.03/

Perl Makefile.PL

Make

Make install

Cd / root/mysql-mmm/

Rpm-ivh-nodeps perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm

/ etc/init.d/mysql-mmm-monitor start

/ etc/init.d/mysql-mmm-monitor status

Netstat-pantu | grep mmm_mond

Netstat-pantu | grep 9988

Tcp 00 192.168.4.120 9988 0.0.0.0 * LISTEN 30047/mmm_mond

Fourth, verify the configuration of mysql-mmm

A check that the database service on the database node is running

Whether IO thread and SQ thread are OK

[root@mysql12] # mysql-uroot-p123456-e "show slave status\ G;" | grep-I yes

Mysql: [Warning] Using a password on the command line interface can be insecure.

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

b. View the local login management interface of the monitoring server and view the database service status

[root@client120 ~] # mmm_control show

Defined (@ array) is deprecated at / usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined ())

Db10 (192.168.4.10) master/AWAITING_RECOVERY. Roles:

Db11 (192.168.4.11) master/AWAITING_RECOVERY. Roles:

Db12 (192.168.4.12) slave/AWAITING_RECOVERY. Roles:

Db13 (192.168.4.13) slave/AWAITING_RECOVERY. Roles:

[root@client120 ~] # mmm_control set_online db10

[root@client120 ~] # mmm_control set_online db11

[root@client120 ~] # mmm_control set_online db12

[root@client120 ~] # mmm_control set_online db13

[root@client120 ~] # mmm_control show

Defined (@ array) is deprecated at / usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined ())

Db10 (192.168.4.10) master/ONLINE. Roles: writer (192.168.4.100)

Db11 (192.168.4.11) master/ONLINE. Roles:

Db12 (192.168.4.12) slave/ONLINE. Roles: reader (192.168.4.105)

Db13 (192.168.4.13) slave/ONLINE. Roles: reader (192.168.4.102)

c. Check locally whether the vip address has been obtained in the data reception year.

[root@client120] # ping-c 2 192.168.4.100

PING 192.168.4.100 (192.168.4.100) 56 (84) bytes of data.

64 bytes from 192.168.4.100: icmp_seq=1 ttl=64 time=0.367 ms

64 bytes from 192.168.4.100: icmp_seq=2 ttl=64 time=0.383 ms

[root@mysql10 Net-ARP-1.0.8] # ip addr show | grep 192.168.4.

Inet 192.168.4.10/24 brd 192.168.4.255 scope global eth0

Inet 192.168.4.100/32 scope global eth0

[root@mysql12 ~] # ip addr show | grep 192.168.4.

Inet 192.168.4.12/24 brd 192.168.4.255 scope global eth0

Inet 192.168.4.105/32 scope global eth0

[root@mysql13 ~] # ip addr show | grep 192.168.4.

Inet 192.168.4.13/24 brd 192.168.4.255 scope global eth0

Inet 192.168.4.102/32 scope global eth0

d. Client connects to VIP to access database service

[root@room1pc32 Desktop] # mysql-h292.168.4.100-uguser-p123456

MySQL [(none)] > select @ @ hostname

+-+

| | @ @ hostname |

+-+

| | mysql10 |

+-+

Analog virtual machine 10 hangs up

[root@mysql10 ~] # systemctl stop mysqld

[root@client120 ~] # mmm_control show

Defined (@ array) is deprecated at / usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined ())

Db10 (192.168.4.10) master/HARD_OFFLINE. Roles:

Db11 (192.168.4.11) master/ONLINE. Roles: writer (192.168.4.100)

Db12 (192.168.4.12) slave/ONLINE. Roles: reader (192.168.4.105)

Db13 (192.168.4.13) slave/ONLINE. Roles: reader (192.168.4.102)

[root@mysql13 ~] # ip addr show | grep 192.168.4

Inet 192.168.4.11/24 brd 192.168.4.255 scope global eth0

Inet 192.168.4.100/32 scope global eth0

MySQL [(none)] > select @ @ hostname

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id: 1900

Current database: * * NONE * *

+-+

| | @ @ hostname |

+-+

| | mysql11 |

+-+

1 row in set (0.00 sec)

Simulated virtual machine 10 fault fixed

[root@mysql10 ~] # systemctl start mysqld

[root@client120 ~] # mmm_control show

Defined (@ array) is deprecated at / usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined ())

Db10 (192.168.4.10) master/AWAITING_RECOVERY. Roles

Db11 (192.168.4.11) master/ONLINE. Roles: writer (192.168.4.100):

Db12 (192.168.4.12) slave/ONLINE. Roles: reader (192.168.4.105)

Db13 (192.168.4.13) slave/ONLINE. Roles: reader (192.168.4.102)

[root@client120 ~] # mmm_control set_online db10

[root@client120 ~] # mmm_control show

Defined (@ array) is deprecated at / usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined ())

Db10 (192.168.4.10) master/ONLINE. Roles:

Db11 (192.168.4.11) master/ONLINE. Roles: writer (192.168.4.100)

Db12 (192.168.4.12) slave/ONLINE. Roles: reader (192.168.4.105)

Db13 (192.168.4.13) slave/ONLINE. Roles: reader (192.168.4.102)

10 will not immediately occupy the VIP address. 10 will regain the VIP address when 11 fails.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report