本文共 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)
lblcr 带复制的基于局部性最少链接(Locality-Based Least Connections with Replication)
dh 目标地址散列(Destination Hashing)
sh 源地址散列(Source Hashing)
可以参考
这里边讲述5.2中如何配置Monitor Script,有兴趣的可以根据这个文档再仔细做做
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
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.
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
If an external program is entered in the Sending Program field, then the Send field is ignored.
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.
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.
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.
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/