手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

LVS+Keepalived+Squid+Nginx高可用负载均衡缓存配置

[日期:2012-06-10] 来源:Linux社区  作者:wgkgood [字体:大 中 小]

一、LVS+Keepalived安装

1、下载源码包 
cd /usr/src/  
wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz   
wget http://www.keepalived.org/software/keepalived-1.1.15.tar.gz 

2、建立软链接 
ln -s /usr/src/kernels/2.6.* /usr/src/linux 

3、安装ipvsadm、keepalived 
cd /usr/src/ && tar xzvf ipvsadm-1.24.tar.gz &&cd ipvsadm-1.24  
&& make && make install 
cd /usr/src/  &&  tar -xzvf keepalived-1.1.15.tar.gz  &&  
cd keepalived-1.1.15  && ./configure  &&  make  &&  make install 

4、配置keepalived 
cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/  
cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/  
mkdir -p /etc/keepalived  
cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/ 
cp /usr/local/sbin/keepalived /usr/sbin/ 

5、修改keepalived配置文件
vi /etc/keepalived/keepalived.conf,根据实际情况修改:

  1. ! Configuration File for keepalived  
  2.    
  3. global_defs {  
  4.    notification_email {  
  5.       wgkgood@163.com  
  6.    }  
  7.    notification_email_from wgkgood@163.com  
  8.    smtp_server 127.0.0.1  
  9.    smtp_connect_timeout 30  
  10.    router_id LVS_DEVEL  
  11. }  
  12.    
  13. # VIP1  
  14. vrrp_instance VI_1 {  
  15.     state MASTER //备份服务器改成BACKUP  
  16.     interface eth0  
  17.     lvs_sync_daemon_inteface eth0  
  18.     virtual_router_id 51  
  19.     priority 100 //备份服务器改成90  
  20.     advert_int 5  
  21.     authentication {  
  22.         auth_type PASS  
  23.         auth_pass 1111  
  24.     }  
  25.     virtual_ipaddress {  
  26.         192.9.117.145 //VIP地址  
  27.     }  
  28. }  
  29. virtual_server 192.9.117.145 80 {  
  30.     delay_loop 6  
  31.     lb_algo rr //lvs算法  
  32.     lb_kind DR  
  33.    persistence_timeout 60  
  34. protocol TCP  
  35.    
  36.     real_server 192.9.117.141 80 {  
  37.         weight 100  
  38.         TCP_CHECK {  
  39.         connect_timeout 10  
  40.         nb_get_retry 3  
  41.         delay_before_retry 3  
  42.         connect_port 80  
  43.         }  
  44.     }  
  45.  real_server 192.9.117.142 80 {  
  46.         weight 100  
  47.         TCP_CHECK {  
  48.         connect_timeout 10  
  49.         nb_get_retry 3  
  50.         delay_before_retry 3  
  51.         connect_port 80  
  52.         }  
  53.     }  
  54. }  

同理Lvs_backup也如上安装,并修改参数,Lvs+keepalived配置完毕后,启动keepalived, /etc/init.d/keepalived start 即可!然后在squid_1、squid_2分别执行realserver.sh脚本

linux
相关资讯       LVS  负载均衡  高可用 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款