博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于lvs均衡负载socket服务的配置实现
阅读量:2438 次
发布时间:2019-05-10

本文共 4383 字,大约阅读时间需要 14 分钟。

 

lvs均衡的机制是基于IP层面的因此,所有的高层协议都是可以被均衡负载的。

 

其实其他配置都是差不多的,就是在monitor script上一定要注意加200%的注意。

 

我的一个socket服务,连上端口后,如果给/n,就会给出文本串结果。

 

于是

 

Sending Message 设置为空

Send 设置为"/n"

Expect 设置为"*"

 

这样服务就被monitor起来了。

 

调度协议也是很重要的,看不同的应用场景了,网友的blog做了总结

 

调度器通过"轮叫"调度算法将外部请求按顺序轮流分配到集群中的真实服务器上,它均等地对待每一台服务器,而不管服务器上实际的连接数和系统负载。

wrr 加权轮叫(Weighted Round Robin)

调度器通过"加权轮叫"调度算法根据真实服务器的不同处理能力来调度访问请求。这样可以保证处理能力强的服务器处理更多的访问流量。调度器可以自动问询真实服务器的负载情况,并动态地调整其权值。

lc 最少链接(Least Connections)

调度器通过"最少连接"调度算法动态地将网络请求调度到已建立的链接数最少的服务器上。如果集群系统的真实服务器具有相近的系统性能,采用"最小连接"调度算法可以较好地均衡负载。

wlc 加权最少链接(Weighted Least Connections)

在集群系统中的服务器性能差异较大的情况下,调度器采用"加权最少链接"调度算法优化负载均衡性能,具有较高权值的服务器将承受较大比例的活动连接负载。调度器可以自动问询真实服务器的负载情况,并动态地调整其权值。

lblc 基于局部性的最少链接(Locality-Based Least Connections)

"基于局部性的最少链接" 调度算法是针对目标IP地址的负载均衡,目前主要用于Cache集群系统。该算法根据请求的目标IP地址找出该目标IP地址最近使用的服务器,若该服务器是可用的且没有超载,将请求发送到该服务器;若服务器不存在,或者该服务器超载且有服务器处于一半的工作负载,则用"最少链接"的原则选出一个可用的服务器,将请求发送到该服务器。

lblcr 带复制的基于局部性最少链接(Locality-Based Least Connections with Replication)

" 带复制的基于局部性最少链接"调度算法也是针对目标IP地址的负载均衡,目前主要用于Cache集群系统。它与LBLC算法的不同之处是它要维护从一个目标IP地址到一组服务器的映射,而LBLC算法维护从一个目标IP地址到一台服务器的映射。该算法根据请求的目标IP地址找出该目标IP地址对应的服务器组,按"最小连接"原则从服务器组中选出一台服务器,若服务器没有超载,将请求发送到该服务器,若服务器超载;则按"最小连接"原则从这个集群中选出一台服务器,将该服务器加入到服务器组中,将请求发送到该服务器。同时,当该服务器组有一段时间没有被修改,将最忙的服务器从服务器组中删除,以降低复制的程度。

dh 目标地址散列(Destination Hashing)

"目标地址散列"调度算法根据请求的目标IP地址,作为散列键(Hash Key)从静态分配的散列表找出对应的服务器,若该服务器是可用的且未超载,将请求发送到该服务器,否则返回空。

sh 源地址散列(Source Hashing)

"源地址散列"调度算法根据请求的源IP地址,作为散列键(Hash Key)从静态分配的散列表找出对应的服务器,若该服务器是可用的且未超载,将请求发送到该服务器,否则返回空。

 

 

可以参考

 

这里边讲述5.2中如何配置Monitor Script,有兴趣的可以根据这个文档再仔细做做

 

EDIT MONITORING SCRIPTS Subsection

Click on the MONITORING SCRIPTS link at the top of the page. The EDIT MONITORING SCRIPTS subsection allows the administrator to specify a send/expect string sequence to verify that the service for the virtual server is functional on each real server. It is also the place where the administrator can specify customized scripts to check services requiring dynamically changing data.

 

 

The EDIT MONITORING SCRIPTS Subsection

Figure 4.9. The EDIT MONITORING SCRIPTS Subsection

Sending Program

For more advanced service verification, you can use this field to specify the path to a service-checking script. This functionality is especially helpful for services that require dynamically changing data, such as HTTPS or SSL.

To use this functionality, you must write a script that returns a textual response, set it to be executable, and type the path to it in the Sending Program field.

Tip

To ensure that each server in the real server pool is checked, use the special token %h after the path to the script in the Sending Program field. This token is replaced with each real server's IP address as the script is called by the nanny daemon.

The following is a sample script to use as a guide when composing an external service-checking script:

#!/bin/shTEST=`dig -t soa example.com @$1 | grep -c dns.example.comif [ $TEST != "1" ]; then	echo "OKelse	echo "FAIL"fi

Note

If an external program is entered in the Sending Program field, then the Send field is ignored.

Send

Enter a string for the nanny daemon to send to each real server in this field. By default the send field is completed for HTTP. You can alter this value depending on your needs. If you leave this field blank, the nanny daemon attempts to open the port and assume the service is running if it succeeds.

Only one send sequence is allowed in this field, and it can only contain printable, ASCII characters as well as the following escape characters:

  • /n for new line.

  • /r for carriage return.

  • /t for tab.

  • / to escape the next character which follows it.

Expect

Enter a the textual response the server should return if it is functioning properly. If you wrote your own sending program, enter the response you told it to send if it was successful.

Tip

To determine what to send for a given service, you can open a telnet connection to the port on a real server and see what is returned. For instance, FTP reports 220 upon connecting, so could enter quit in the Send field and 220 in the Expect field.

Warning

Remember to click the ACCEPT button after making any changes in this panel. To make sure you do not lose any changes when selecting a new panel.

Once you have configured virtual servers using the Piranha Configuration Tool, you must copy specific configuration files to the backup LVS router. See for details.

 

当然了,同步配置文件也是挺重要的,按照上一行的同步配置文件操作即可。

 

 

转载地址:http://jxgmb.baihongyu.com/

你可能感兴趣的文章
最简单FreeBSD网关方案(转)
查看>>
Windows 98 多用户的管理(转)
查看>>
更改Windows XP 的日期和时间(转)
查看>>
windows2000中的“秘密武器”(三)(转)
查看>>
Linux程序应用开发环境和工具经验谈(转)
查看>>
Linux办公一条龙之电子表格Calc(转)
查看>>
在NETBSD上配置ADSL+IPF+IPNAT(转)
查看>>
Windows 98 使用维护向导(转)
查看>>
用win2000收发传真(转)
查看>>
Linux办公一条龙之初识OpenOffice(转)
查看>>
Linux上安装GCC编译器过程(转)
查看>>
使用Windows XP 的任务计划(转)
查看>>
FreeBSD软盘操作(转)
查看>>
Linux分区工具的使用方法(转)
查看>>
深入理解硬盘的Linux分区(转)
查看>>
循序渐进教你LINUX之软件配置方法(转)
查看>>
NetBSD 指导手册(转)
查看>>
打造FreeBSD桌面系统(2)(转)
查看>>
为你的 Windows 98 加把锁(转)
查看>>
Windows 98 资源管理(转)
查看>>