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

How to achieve High availability with keepalived and nginx

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces "how to achieve high availability with keepalived combined with nginx". In daily operation, I believe many people have doubts about how to achieve high availability with keepalived and nginx. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the question of "how to achieve high availability by combining keepalived with nginx". Next, please follow the editor to study!

1. Brief introduction

Keepalived is a highly available solution for lvs services based on vrrp protocol, which can be used to avoid a single point of failure. A lvs service will have two servers running keepalived, one primary server (master) and one backup server (backup), but the external performance is a virtual ip. The master server will send a specific message to the backup server. When the backup server does not receive this message, that is, when the master server goes down, the backup server will take over the virtual ip and continue to provide services, thus ensuring high availability. Keepalived is a perfect implementation of vrrp, so before introducing keepalived, let's introduce the principle of vrrp.

Brief introduction of 1.vrrp Protocol

In the real network environment, the two hosts that need to communicate do not have a direct physical connection in most cases. In such a case, how do you choose the route between them? There are usually two solutions to the problem of how a host chooses a next-hop route to the destination host:

Use dynamic routing protocols (rip, ospf, etc.) on the host

Configure static routes on the host

It is obvious that it is very impractical to configure dynamic routing on the host because of many issues such as administration, maintenance costs, and support. Configuring static routes has become very popular, but routers (or default gateway default gateway) often become a single point of failure. The purpose of vrrp is to solve the single point failure problem of static routing. Vrrp dynamically transfers the routing task to a vrrp router in the virtual router in lan through an election (election) protocol.

2.vrrp working mechanism

In a vrrp virtual router, there are multiple physical vrrp routers, but these physical machines can not work at the same time, but one called master is responsible for routing work, the other is backup,master is not immutable, vrrp allows each vrrp router to participate in the election, and the final winner is master. Master has some privileges, such as having the ip address of a virtual router, which our host uses as a static route. The privileged master is responsible for forwarding packets sent to the gateway address and responding to arp requests.

Vrrp implements the function of virtual router by running for a protocol, and all protocol messages are sent in the form of ip Multicast (multicast) packets (Multicast address 224.0.0.18). The virtual router consists of a vrid (range 0255) and a set of ip addresses, which are represented as a well-known mac address. Therefore, in a virtual router, no matter who is master, the external is the same mac and ip (called vip). The client host does not need to modify its routing configuration because of the change of master. For the client, the master-slave switch is transparent.

In a virtual router, only the vrrp router as master will always send vrrp advertisement messages (vrrpadvertisement message), and backup will not preempt master unless it has a higher priority (priority). When the master is not available (the backup does not receive the notification message), the one with the highest priority among the multiple backup will be preempted as master. This preemption is very fast (

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

Internet Technology

Wechat

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

12
Report