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

Keepalived High availability

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Keepalived High availability

1.Keepalived Notification configuration

Sender configuration:

[root@s2 ~] # yum install mailx-y

[root@s2 ~] # vim / etc/mail.rc

Set from=398808313@qq.com

Set smtp=smtp.qq.com

Set smtp-auth-user=398808313@qq.com

Set smtp-auth-password=mfcjxxjezawgdgee

Set smtp-auth=login

Set ssl-verify=ignore

Set smtp-auth-password=mfcjxxjezawgdgee details:

(1) enter QQ Mail

Turn on this option, and then generate the value step by step.

Keepalived Notification script

[root@localhost keepalived] # cat / etc/keepalived/notify.sh

#! / bin/bash

Contact='2973707860@qq.com'

Notify () {

Mailsubject= "$(hostname) to be $1, vip transfer"

Mailbody= "$(date +'% F% T'): vrrp transition, $(hostname) changed to be $1"

Echo "$mailbody" | mail-s "$mailsubject" $contact

}

Case $1 in

Master)

Notify master

Backup)

Notify backup

Fault)

Notify fault

*)

Echo "Usage: $(basename $0) {master | backup | fault}"

Exit 1

Esac

Keepalived Notification configuration

Define a notification script:

Notify_master |:

The script that is triggered when the current node becomes the master

Notify_backup |:

Script triggered when the current node is converted to a standby node

Notify_fault |:

The script that is triggered when the current node changes to the "failed" state

Notify |:

Common format notification trigger mechanism, a script can complete the above three states of the transition when the notification

2. Keepalived+haproxy

When haproxy goes down, vip drifts to other backup hosts as well.

Highly available HAProxy (keepalived main profile)

Vrrp_script chk_haproxy {

Script "/ etc/keepalived/chk_haproxy.sh"

Interval 1

Weight-80

Fall 3

Rise 5

Timeout 2

}

Have a request

Track_script {

Chk_haproxy

}

[root@s1 ~] # yum install psmisc-y (killall package)

[root@s1 ~] # cat / etc/keepalived/chk_haproxy.sh

#! / bin/bash

/ usr/bin/killall-0 haproxy (check whether the program is alive)

[root@s1 ~] # chmod adepx / etc/keepalived/chk_haproxy.sh

3. Keepalived+nginx

It's similar to the haproxy above.

4.Keepalived case 1: implementing the LVS-DR pattern

Virtual_server 172.18.200.248 80 {

Delay_loop 6

Lb_algo wrr

Lb_kind DR

# persistence_timeout 120 # session duration

Protocol TCP

Sorry_server 172.18.200.105 80

Real_server 172.18.200.103 80 {

Weight 1

TCP_CHECK {

Connect_timeout 5

Nb_get_retry 3

Delay_before_retry 3

Connect_port 80

}

}

Real_server 172.18.200.104 80 {

Weight 1

TCP_CHECK {

Connect_timeout 5

Nb_get_retry 3

Delay_before_retry 3

Connect_port 80

}

}

}

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

Servers

Wechat

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

12
Report