欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

使用IPVS和Ldirectord实现高效稳定的IPVS服务

最编程 2024-08-10 20:38:23
...
1、 cp 样例配置文件
[root@node1 ~] # cd /usr/share/doc/heartbeat-ldirectord-2.1.4/
[root@node1 heartbeat-ldirectord-2.1.4] # cp ldirectord.cf /etc/ha.d
[root@node1 heartbeat-ldirectord-2.1.4] # cd /etc/ha.d
 
2、配置文件
##全局配置
# Global Directives 
##健康状态检测超时时间间隔                            
checktimeout=3 
##每一秒检查一次                            
checkinterval=1
#fallback=127.0.0.1:80
##自动装载配置文件
autoreload= yes
##日志文件
logfile= "/var/log/ldirectord.log"
##日志文件级别
#logfile="local0"
##邮件通知警告信息
#emailalert="admin@x.y.z"
##邮件通知间隔1小时
#emailalertfreq=3600
##邮件通知所有的状态信息
#emailalertstatus=all
##是否工作于静默模式
quiescent= yes
 
##虚拟服务配置
# Sample for an http virtual service
##VIP            
virtual=192.168.0.17:80
##RS gate为dr类型
                 real=192.168.0.20:80 gate
         #real=192.168.6.3:80 gate
         #real=192.168.6.6:80 gate
##backserver
         fallback=127.0.0.1:80 gate
##健康状态检查基于http协议
         service=http
##请求的页面
         request= ".health.html"
##检查request=“”页面中的字符串是否一致
         receive= ""
##对多个虚拟主机进行检查
         virtualhost=some.domain.com.au
##调度类型为rr
         scheduler=rr
##持久连接时长
         #persistent=600
##掩码
         #netmask=255.255.255.255
##基于tcp的检查,集群服务类型
         protocol=tcp
##检查类型为交互式检查
##checktype:connect是传输层检查,ping是网络层检查,negotlate是应用层检查
##当checktype=negotlate时,ldirectord将基于指定的协议与各RS建立连接,完成应用层检查
         checktype=negotia
##检查端口为80
         checkport=80
##请求的页面
         request= "index.html"
##请求的字符串检查
         #receive="Test Page"
##对虚拟主机检查
         #virtualhost=
         
         
3、准备web服务,node1作为back server提供sorry server服务
[root@node1 ha.d] # vim /var/www/html/index.html
This is sorry server(node1)
[root@node1 ha.d] # service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.0.15  for  ServerName
                                                            [  OK  ]
[root@node1 ha.d] # curl 192.168.0.15
This is sorry server(node1)
 
4、将配置文件 cp 给node2
[root@node1 ha.d] # scp ldirectord.cf node2:/etc/ha.d/

推荐阅读