当前位置:网站首页>14. Haproxy+kept load balancing and high availability
14. Haproxy+kept load balancing and high availability
2022-07-29 04:15:00 【Machoul】
haproxy+keepalived Load balancing and high availability
summary

- Multiple rabbitmq Services form clusters , from haproxy To do load balancing ,haproxy A port will be exposed , The client can use the haproxy Of the server ip+ Port to carry out alignment rabbitmq Use .
- But if it's a haproxy Words , When haproxy There is a single point of failure , So the whole rabbitmq There will be unavailable scenarios , So be right haproxy Make up your mind , Main operations to achieve high availability
- adopt keepalived Realization haproxy The master-slave relationship of , When one of them haproxy There is a failure and downtime , another haproxy We can continue to support the operation of our services , So as to achieve a highly available effect
haproxy Load balancing
Preparation conditions
- Three have been clustered rabbitmq The server
- 172.16.140.130:5672
- 172.16.140.131:5672
- 172.16.140.132:5672
- install haproxy Server for 172.16.140.130:5672
- Three have been clustered rabbitmq The server
install haproxy
yum install -y haproxycreate profile
mkdir -p /usr/local/config/haproxy cd /usr/local/config/haproxy vim haproxy.cfgAdd configuration content
global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon defaults log global mode tcp option tcplog option dontlognull retries 3 option redispatch maxconn 2000 timeout connect 5s timeout client 120s timeout server 120s listen rabbitmq_cluster bind 0.0.0.0:5671 mode tcp balance roundrobin server rabbitmq_node1 172.16.140.130:5672 check inter 5000 rise 2 fall 2 server rabbitmq_node2 172.16.140.131:5672 check inter 5000 rise 2 fall 2 server rabbitmq_node3 172.16.140.132:5672 check inter 5000 rise 2 fall 2 listen monitor bind 0.0.0.0:8100 mode http option httplog stats enable stats uri /stats stats refresh 5sstart-up haproxy
haproxy -f /usr/local/config/haproxy/haproxy.cfgConnect in code rabbitmq The address to be filled in is haproxy Address , The port number is
rabbitmq_clusterAddress configured inCan pass monitor in 8100 To view the current service status
keepalived High availability
In the use of the haproxy after , We have achieved the goal of load balancing , But if it's just a haproxy Words , So when haproxy Downtime , So the whole rabbitmq Will be unavailable , So we need to use keepalived To realize the active and standby mode
preparation
- Three have been clustered rabbitmq The server
- 172.16.140.130:5672
- 172.16.140.131:5672
- 172.16.140.132:5672
- Two installations haproxy Server for
- 172.16.140.130:5672
- 172.16.140.131:5672
- Three have been clustered rabbitmq The server
Expected results : For two haproxy Provide active and standby mode
install keepalived
yum install -y keepalivedAfter installation , stay
/etc/keepalived/There are documents inkeepalived.conffile , Backup the original , Create a new profile .Configuration profile
global_defs { # Global configuration router_id lb01 # Identification -> name } vrrp_instance VI_HAPROXY { state MASTER # Identify character status interface ens160 # Network card binding interface virtual_router_id 51 # Virtual routing id priority 150 # priority advert_int 1 # Monitoring intervals authentication { # authentication auth_type PASS # authentication auth_pass 1111 # The authentication code } virtual_ipaddress { 172.16.140.167 # Virtual VIP Address } }start-up keepalived
systemctl start keepalived systemctl enable keepalivedThe above steps also need to be operated on the standby machine , The difference is the configuration file
global_defs { router_id lb02 } vrrp_instance VI_1 { state BACKUP interface ens160 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 172.16.140.167 } }see keepalived journal
tail -f /var/log/messages -n 200
边栏推荐
- Pointer of pointer???...
- 15.federation
- [paper translation] vectornet: encoding HD maps and agent dynamics from vectorized representation
- [kvm] create virtual machine from kickstart file
- Const read only variable constant
- View partition table format
- The return value of the function is the attention of the pointer, the local variables inside the static limit sub function, and how the pointer to the array represents the array elements
- Blood cases caused by < meta charset=UTF-8> -- Analysis of common character codes
- 不会就坚持70天吧 数组中第k大的数
- The function "postgis_version" cannot be found when installing PostGIS
猜你喜欢

Why are there so many unknowns when opengauss starts?

不会就坚持66天吧 权重生成随机数

RMAN do not mark expired backups

不会就坚持61天吧 最短的单词编码

你真的会写Restful API吗?

MySQL gets the maximum value record by field grouping

When array is used as a function parameter, it is better to use the array size as a function parameter

Is the array name a pointer

Some problems about pointers

Machine vision Series 1: Visual Studio 2019 dynamic link library DLL establishment
随机推荐
10.回退消息
The difference between dynamic, VaR and object in fluent
LCA 板子
Rhel8 patch package production
从淘宝,天猫,1688,微店,京东,苏宁,淘特等其他平台一键复制商品到拼多多平台(批量上传宝贝详情接口教程)
不会就坚持67天吧 平方根
不会就坚持65天吧 只出现一次的数字
一个公司的面试笔记
Target detection learning process
A little understanding of pointer, secondary pointer, wild pointer, pointer as function return value
Beginner: array & String
What the hell is this error? It doesn't affect the execution result, but it always reports errors when executing SQL... Connecting maxcomputer uses
Code or script to speed up the video playback of video websites
如何查询版本的提交号
GBase 8a特殊场景下屏蔽 ODBC 负载均衡方式?
Class starts! See how smardaten decomposes complex business scenarios
数据集成这个地方的过滤条件该咋写,用的啥语法?sql语法处理bizdate可以不
[kvm] create virtual machine from kickstart file
Model tuning, training model trick
Asp.net MVC中文件夹中的控制器如何跳转到根目录的控制器中?