HaProxy (一) Haproxy概述以及实现负载均衡和页面监控

本文介绍了HaProxy作为开源的反向代理和负载均衡器的基本概念,包括其在高可用环境中的应用、配置的三个部分,以及如何通过配置实现反向代理和页面监控。在实际操作中,通过示例展示了安装、配置和测试HaProxy的过程,以及通过监控页面检查服务器集群的运行状态。
摘要由CSDN通过智能技术生成

1.HaProxy概述

Haproxy是一个特别适合于高可用环境的TCP/HTTP开源的反向代理和负载均衡软件。在七层负载均衡方面功能很强大(支持cookie track, header rewrite等),支持双机热备,支持虚拟主机,支持健康检查,同时还提供直观的监控页面,可以清晰的监控服务器集群的运行状况。

2.Haproxy的配置

Haproxy的配置主要分三个部分:

  1. 命令行参数,这个时最优先的。
  2. global(全局)段。设置进程级参数。
  3. 代理配置段,通常位于default,listen,backend这样的形式内。

配置文件的语法是有关键字后跟可选的一个或多个参数(参数之间有空格)构成。如果字符串之间包含空格,要用 \ 转义。

3.Haproxy实现反向代理负载均衡和页面监控

haproxy反向代理服务端:172.25.60.1

RS1 :172.25.60.2

RS2:172.25.60.3

客户端:

个典型的Haproxy_exporter的监控metric例子 包含指标 haproxy_backend_bytes_in_total haproxy_backend_bytes_out_total haproxy_backend_client_aborts_total haproxy_backend_compressor_bytes_bypassed_total haproxy_backend_compressor_bytes_in_total haproxy_backend_compressor_bytes_out_total haproxy_backend_connection_errors_total haproxy_backend_current_queue haproxy_backend_current_server haproxy_backend_current_session_rate haproxy_backend_current_sessions haproxy_backend_http_connect_time_average_seconds haproxy_backend_http_queue_time_average_seconds haproxy_backend_http_response_time_average_seconds haproxy_backend_http_responses_compressed_total haproxy_backend_http_responses_total haproxy_backend_http_total_time_average_seconds haproxy_backend_response_errors_total haproxy_backend_retry_warnings_total haproxy_backend_server_aborts_total haproxy_backend_server_selected_total haproxy_backend_sessions_total haproxy_backend_up haproxy_backend_weight haproxy_exporter_build_info haproxy_exporter_csv_parse_failures haproxy_exporter_total_scrapes haproxy_frontend_bytes_in_total haproxy_frontend_bytes_out_total haproxy_frontend_compressor_bytes_bypassed_total haproxy_frontend_compressor_bytes_in_total haproxy_frontend_compressor_bytes_out_total haproxy_frontend_connections_total haproxy_frontend_current_session_rate haproxy_frontend_current_sessions haproxy_frontend_http_requests_total haproxy_frontend_http_responses_compressed_total haproxy_frontend_http_responses_total haproxy_frontend_limit_session_rate haproxy_frontend_limit_sessions haproxy_frontend_max_session_rate haproxy_frontend_max_sessions haproxy_frontend_request_errors_total haproxy_frontend_requests_denied_total haproxy_frontend_sessions_total haproxy_server_bytes_in_total haproxy_server_bytes_out_total haproxy_server_check_duration_seconds haproxy_server_check_failures_total haproxy_server_client_aborts_total haproxy_server_connection_errors_total haproxy_server_current_queue haproxy_server_current_session_rate haproxy_server_current_sessions haproxy_server_downtime_seconds_total haproxy_server_http_responses_total haproxy_server_max_queue haproxy_server_max_session_rate haproxy_server_max_sessions haproxy_server_redispatch_warnings_total haproxy_server_response_errors_total haproxy_server_retry_warnings_total haproxy_server_server_aborts_total haproxy_server_server_selected_total haproxy_server_sessions_total haproxy_server_up haproxy_server_weight haproxy_up process_cpu_seconds_total process_max_fds process_open_fds process_resident_memory_bytes process_start_time_seconds process_virtual_memory_bytes promhttp_metric_handler_requests_in_flight promhttp_metric_handler_requests_total
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值