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

Example Analysis of High availability of keepalived+vip+mysql dual computers

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

Share

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

This article mainly shows you the "keepalived+vip+mysql dual high availability example analysis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn the "keepalived+vip+mysql dual high availability example analysis" this article.

1. Environment mysql master-slave

Update

Yum update glib*

Configure third-party sources

Yum install-y epel-release

Install keepalived directly through yum

# check to see if there is an installation package

Yum list | grep keepalived

Installation

Yum install keepalived.x86_64

The various parameter definitions are shown in the following bolg

Http://blog.csdn.net/zhu_tianwei/article/details/43603135

Case study of real production environment

Master

Path / etc/keepalived/keepalived.conf

Judge the master and slave by the weight priority 0-250.

# master##

Global_defs {

Router_id HA_MySQL

}

Vrrp_instance VI_1 {

State BACKUP

Interface em1

Virtual_router_id 12

Priority 120

Advert_int 1

Nopreempt

Authentication {

Auth_type PASS

Auth_pass 1111

}

Virtual_ipaddress {

# vip

192.168.27.12

}

}

Virtual_server 192.168.27.12 3306 {

Delay_loop 2

Lb_algo wrr

Lb_kind DR

Persistence_timeout 60

Protocol TCP

Real_server 192.168.27.73 3306 {

Weight 3

Inhibit_on_failure

# check whether port 3306 of the real ip is down if down executes stop_keeplived.sh

Notify_down / usr/local/keepalived/sbin/stop_keeplived.sh

TCP_CHECK {

Connect_timeout 10

Nb_get_retry 3

Delay_before_retry 3

Connect_port 3306

}

}

}

# # slave##

Slave judges master and slave by weight priority 0-250.

Global_defs {

Router_id HA_MySQL

}

Vrrp_instance VI_1 {

State BACKUP

Interface em1

Virtual_router_id 12

Priority 100

Advert_int 1

# nopreempt

Authentication {

Auth_type PASS

Auth_pass 1111

}

Virtual_ipaddress {

# vip

192.168.27.12

}

}

Virtual_server 192.168.27.12 3306 {

Delay_loop 2

Lb_algo wrr

Lb_kind DR

Persistence_timeout 60

Protocol TCP

Real_server 192.168.27.72 3306 {

Weight 3

Notify_down / usr/local/keepalived/sbin/stop_keeplived.sh

TCP_CHECK {

Connect_timeout 10

Nb_get_retry 3

Delay_before_retry 3

Connect_port 3306

}

}

}

# stop_keeplived.sh#

/ usr/local/keepalived/sbin/stop_keeplived.sh

Content

#! / bin/bash

Echo "test" > text.txt

/ etc/init.d/keepalived stop

# errors encountered

Stop mysql 3306 port

Service mysqld stop

Normally, vip should drift, but there is no drift. Check the keepalived status.

Service keepalived status

Found ipvs: Protocol not available prompt message

This problem prevents vip from drifting

The reason is that the ip_vs module system does not automatically load by default.

View the ip_vs module

Lsmod | grep ip_vs needs to be loaded manually if there is no value

Modprobe ip_vs

Modprobe ip_vs_wrr

Lsmod | normal output of grep ip_vs

[root@hs-73 sbin] # lsmod | grep ip_vs

Ip_vs_wrr 12697 0

Ip_vs 140944 2 ip_vs_wrr

Nf_conntrack 105745 1 ip_vs

Libcrc32c 12644 2 xfs,ip_vs

Set boot load

/ etc/rc.local

Modprobe ip_vs

Modprobe ip_vs_wrr

Write to rc.local configuration file

Until this problem is solved.

Vip can drift normally.

Use the command ip a to view vip

-the machine corresponding to keepalived must open port 112, otherwise the two sides cannot communicate.

The above is all the contents of the article "sample Analysis of High availability on keepalived+vip+mysql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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