首页 > 代码库 > ipvsadm与keepalived整合
ipvsadm与keepalived整合
1.准备两台虚拟服务器(DR),分别安装ipvsadm和keepalived
yum -y install ipvsadm yum -y install keepalived
2.配置keepalived.conf
#修改IP为192.168.2.137的DR vi /etc/keepalived/keepalived.conf #修改内容如下 ! Configuration File for keepalived global_defs { notification_email { root@localhost } notification_email_from lvs@localhost smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id 51 priority 50 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.150/24 dev eth0 label eth0:1 } } virtual_server 192.168.2.150 8080 { delay_loop 6 lb_algo wlc lb_kind DR nat_mask 255.255.255.0 persistence_timeout 50 protocol TCP real_server 192.168.2.137 8080 { weight 1 HTTP_GET { url { path / status_code 200 } connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } real_server 192.168.2.138 8080 { weight 1 HTTP_GET { url { path / status_code 200 } connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } } #修改IP为192.168.2.138的DR vi /etc/keepalived/keepalived.conf #修改内容如下 ! Configuration File for keepalived global_defs { notification_email { root@localhost } notification_email_from lvs@localhost smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 priority 110 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.150/24 dev eth0 label eth0:1 } } virtual_server 192.168.2.150 8080 { delay_loop 6 lb_algo wlc lb_kind DR nat_mask 255.255.255.0 persistence_timeout 50 protocol TCP real_server 192.168.2.137 8080 { weight 1 HTTP_GET { url { path / status_code 200 } connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } real_server 192.168.2.138 8080 { weight 1 HTTP_GET { url { path / status_code 200 } connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } }
3.准备两台RealServer(RS)
IP为: 192.168.2.137 192.168.2.138
4.分别为RealServer安装httpd服务
yum -y install httpd
5.启动httpd
service httpd start
6.启动keepalived
service keepalived start #可以查看一个是主,一个是从 ifconfig
7.请求192.168.2.150:8080可以看到访问结果
本文出自 “素颜” 博客,请务必保留此出处http://suyanzhu.blog.51cto.com/8050189/1945285
ipvsadm与keepalived整合
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。