For LVS distribution MySQL monitoring

Source: Internet
Author: User

Requirement: LVS performs read load on MySQL. If the master and slave nodes are not synchronized, the problem may occur, how can I remove the slave database from LVS when the master node is not synchronized? And if I remove the slave database when the LVS server loads one slave database, there is no way to check the database, so I write a script, and I think the logic is strong.

#! /Bin/bash
C = 'cat/opt/duoyongtu/10/mysql.txt'
For I in $ c
Do
A = 'mysql-uroot-h $ I-p12345678-P3306-e "show slave status \ G" | egrep '(Slave_IO_Running | Slave_ SQL _Running) '| awk' {print $ NF }''
For k in $
Do
If ["$ k "! = "Yes"]; then
F = 'ssh 192.168.0.146 "ip a | grep 192.168.1.5 | wc-l "'
If ["$ f"-eq 1]; then
B = 'ssh 192.168.0.146 "cat/opt/yanchao/xianzai.txt | wc-l "'
If ["$ B"-ge 2]; then
# Sh/www/shell/syslog_2.sh $ I-slave-stop 'hostname' 1 2 1 6
Ssh $ I "iptables-A INPUT-s 192.168.0.146-p tcp-m tcp -- dport 3306-j DROP"
Ssh $ I "iptables-A INPUT-s 192.168.0.147-p tcp-m tcp -- dport 3306-j DROP"
Echo bad
Else
Echo good
Fi
Else
B = 'ssh 192.168.0.147 "cat/opt/yanchao/xianzai.txt | wc-l "'
If ["$ B"-ge 2]; then
# Sh/www/shell/syslog_2.sh $ I-slave-stop 'hostname' 1 2 1 6
Ssh $ I "iptables-A INPUT-s 192.168.0.146-p tcp-m tcp -- dport 3306-j DROP"
Ssh $ I "iptables-A INPUT-s 192.168.0.147-p tcp-m tcp -- dport 3306-j DROP"
Echo bad
Else
Echo good
Fi
Fi
Else
D = 'ssh $ I "iptables-L-n | grep 192.168.0.146 | wc-l "'
If ["$ d"-ge 1]; then
For e in 192.168.0.146 192.168.0.147
Do
Ssh $ I "iptables-F"
Done
Fi
Fi
Done
Done

Implement MySQL high availability for WEB sites through LVS

LVS + Apache + PHP + MySQL read/write splitting

MySQL LVS Server Load balancer

Enterprise Web high availability cluster practice-LVS + Keepalived + MySQL HA

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.