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

Nginx+keepalived (partial configuration)

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

Share

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

Nginx-S should also be configured with the same Nginx proxy service configuration as Nginx-M.

Keepalived service configuration for Nginx-M and Nginx-S:

Profile template:

! Configuration File for keepalived

Global_defs {

Notification_email {

Ops@wangshibo.cn

Tech@wangshibo.cn

}

Notification_email_from ops@wangshibo.cn

Smtp_server 127.0.0.1

Smtp_connect_timeout 30

Router_id master-node

}

Vrrp_script chk_http_port {

Script "/ opt/chk_nginx.sh"

Interval 2

Weight-5

Fall 2

Rise 1

}

Vrrp_instance VI_1 {

State MASTER

Interface eth0

Mcast_src_ip 192.168.115.173

Virtual_router_id 51

Priority 101

Advert_int 1

Authentication {

Auth_type PASS

Auth_pass 1111

}

Virtual_ipaddress {

192.168.115.100

}

Track_script {

Chk_http_port

}

}

This monitoring script Nginx-S server also needs:

Script template:

#! / bin/bash

Counter=$ (ps-C nginx-- no-heading | wc-l)

If ["${counter}" = "0"]; then

Service nginx restart

Sleep 2

Counter=$ (ps-C nginx-- no-heading | wc-l)

If ["${counter}" = "0"]; then

Service keepalived stop

Fi

Fi

Only Apache service needs to be set up on the WEB server, and no other network settings are needed.

Turn on the keepalived and Nginx services on the Nginx-M and Nginx-S servers, then execute the monitoring script under / opt/, and then stop any of the Nginx proxy servers to verify whether one of the Nginx proxy servers is down. The other continues to work.

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