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

9-mmm High availability Cluster of mysql Series

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

Share

Shulou(Shulou.com)06/01 Report--

Introduction to mmm High availability Cluster:

High availability cluster introduction: active / standby mode, when the master cannot provide services, the standby host takes over to provide services.

This process is transparent to the client.

I. preliminary preparatory work

1. Prepare five linux servers: master (192.168.4.122) and master / standby (192.168.4.123)

From (192.168.4.126), from (192.168.4.127), manage host (192.168.4.128)

Four hosts are master and slave username: tongbu, password: 123456

2. Master and standby are made into mutual master-slave mode, and two slave servers are made into master-slave mode.

3. IP Planning, write-vip=192.168.4.100,read-vip=192.168.4.101/192.168.4.102

2. Install and configure Mysql-mmm

1. Installation: first install the dependency package: yum-y install perl-*

Cd mysql-mmm-2.2.1/

Make install / / enter the unzipped directory and install it directly

2. Configuration file description: cd / etc/mysql-mmm

Mmm_agent.conf / / data node host file (four mysql servers)

Mmm_common.conf / / Common profile (required for all five hosts)

Mmm_mon.conf / / manage hosts file (192.168.4.128)

Mmm_tools.conf / / Management tools

3. Modify the configuration file of the data node: mmm_agent.conf (modified by four mysql servers)

Include mmm_common.conf / / load file

This db1 / / the name defined in the cluster

Name planning: name according to role and ip address

Master122,master123,slave126,slave127

4. Modify the configuration of the management node (192.168.4.128) mmm_mon.conf

1 include mmm_common.conf

two

three

4 ip 192.168.4.128 / / monitor the IP address of this machine

5 pid_path / var/run/mmm_mond.pid

6 bin_path / usr/lib/mysql-mmm/

7 status_path / var/lib/misc/mmm_mond.status

8 ping_ips 192.168.4.122,192.168.4.123,192.168.4.126,192.168.4.127 / / monitored IP address

nine

ten

eleven

12 monitor_user monitor / / the user name of the monitoring database, which is used to monitor whether the four database services are normal

13 monitor_password 123456 / / the above user name needs to be authorized on that host

fourteen

5. Modify the common configuration file: mmm_common.conf (required for all five hosts)

Modify it on one host and send it to the other four hosts

Active_master_role writer

Cluster_interface eth0

Pid_path / var/run/mmm_agentd.pid

Bin_path / usr/lib/mysql-mmm/

Replication_user tongbu / / users used locally for master-slave synchronization

Replication_password 123456

The user name detected by the agent_user agent / / agent

Agent_password 123456

Ip 192.168.4.122

Mode master / / mode

Peer master123 / / identity peer host

Ip 192.168.4.123

Mode master

Peer master122

Ip 192.168.4.126

Mode slave

Ip 192.168.4.127

Mode slave

Hosts master122, master123

Ips 192.168.4.100 / / two active and standby virtual IP

Mode exclusive / / exclusive mode

Hosts slave126, slave127

Ips 192.168.4.101, 192.168.4.102

Mode balanced / / equilibrium mode

6. Add two authorized accounts on the 4.122 host: monitor and agent

Grant replication client on *. * to monitor@'%' identified by '123456'

Grant replication client,process,super on *. * to agent@'%' identified by '123456'

Start the data node service and manage the mmm_monitor service on the host of the node

1. Install startup dependency packages on five hosts: the following three rpm packages or tar packages

Resolve the dependency package that starts the agent service:

Algorithm-Diff-1.1902.tar.gz

Perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm

Proc-Daemon-0.03.tar.gz

2. Install the above three packages

Yum-y install gcc gcc-c++

Cd mysql-mmm/

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

Cd Algorithm-Diff-1.1902/

Perl Makefile.PL

Make

Make install

Cd..

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

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

Cd Proc-Daemon-0.03/

Perl Makefile.PL

Make

Make install

3. Install the software package to obtain VIP: Net-ARP-1.0.8.tgz (installed on four mysql services)

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

4. Start the agent service: start on five servers

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

Netstat-ntulp | grep 9989 / / check the port number to see whether the service is started

Cat / var/log/mysql-mmm/mmm_agentd.log / / Startup log

5. Start the mmm_monitor service on the host of the management node

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

Netstat-ntulp | grep 9988 / / check whether it starts or not

Ls / var/log/mysql-mmm/mmm_mond.log / / log file

6. On the management host, view the monitoring information: mmm_control show

Master122 (192.168.4.122) master/AWAITING_RECOVERY. Roles:

Master123 (192.168.4.123) master/AWAITING_RECOVERY. Roles:

Slave126 (192.168.4.126) slave/AWAITING_RECOVERY. Roles:

Slave127 (192.168.4.127) slave/AWAITING_RECOVERY. Roles:

7. Set online: all four mmm_control set_online stations need to be set up.

Mmm_control set_online master122

Mmm_control set_online master123

Mmm_control set_online slave126

Mmm_control set_online slave127

View: mmm_control show after setting up

Master122 (192.168.4.122) master/ONLINE. Roles: writer (192.168.4.100)

Master123 (192.168.4.123) master/ONLINE. Roles:

Slave126 (192.168.4.126) slave/ONLINE. Roles: reader (192.168.4.101)

Slave127 (192.168.4.127) slave/ONLINE. Roles: reader (192.168.4.102)

How to view IP:

Ip addr show | grep 192.168.4. / / you can see that two ip addresses have been obtained.

IV. Testing

1. To add a connected user who accesses the database on the data node, you only need to create an authorized account on 4.122

Grant all on *. * to admin@'%' identified by '123456'

2. Client test:

Mysql-h292.168.4.100-uadmin-p123456

After logging in, add, delete, change and check the database, and then in the four mysql

Verify that it is correct on the server

3. Manually shut down the main mysql server 4.122.

See if the client can access, add, delete, modify and check, etc.

4. 4.122 after moving your hands, you first need to set up online: mmm_control set_online master122

But VIP still corresponds to 4.123, so it won't switch over automatically.

We have to put 4.123:mmm_control set_offline master123 first.

Only in this way can 4.122 get VIP.

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