扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
在本页阅读全文(共3页)
二、多vrrp负载集群部署
参照"cdn缓存服务器集群部署"操作步骤,多vrrp_instance集群的部署也按真实服务器和负载均衡器2个环节来处理。
● 真实服务器上进行的操作
1、 编写负载均衡客户端配置脚本。本例中有3组真实服务器,每组服务器使用相同的lvs客户端配置脚本。配置脚本除了vip而外,其余的部分与本章其他部分所列的lvs客户端配置脚本完全相同。关于3个组vip地址使用情况,请看参表6-4,表6-5。
2、 检验lvs客户端配置脚本的正确性。
● 负载均衡器上的操作
1、 负载均衡器lvs_1
(1) 安装ipvsadm。方法如前文所叙。
(2) 安装keepalived。方法如前文所叙。
(3) 新增配置文件 /etc/keepalived/keepalived.conf。为了跟第二个lvs负载均衡器做比较,我在后面把2个配置文件放在一个表格里(表3),方便查看。
2、 负载均衡器lvs_2
(1)安装ipvsadm。方法如前文所叙。
(2)安装keepalived。方法如前文所叙。
(3)新增配置文件 /etc/keepalived/keepalived.conf。
负载均衡器lvs_1配置文件/etc/keepalived/keepalived.conf |
负载均衡器lvs_2配置文件/etc/keepalived/keepalived.conf |
#guration File for keepalived,writed by sery #global define global_defs { router_id lvs_1 } vrrp_sync_group VGM { group { VI_WEB } } vrrp_sync_group VGB { group { VI_CTCP } } vrrp_instance VI_WEB{ state MASTER interface eth0 lvs_sync_daemon_inteface eth0 virtual_router_id 51 priority 180 advert_int 5 authentication { auth_pass 1111 } virtual_ipaddress { 61.135.93.99 } } # setting port 80 forward virtual_server 61.135.93.99 80 { delay_loop 6 lb_algo wlc lb_kind DR persistence_timeout 10 protocol TCP real_server 61.135.99.80 80 { weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 61.135.93.81 80 { weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 61.135.93.82 80 { weight 90 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 61.135.93.83 80 { weight 90 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } } vrrp_instance VI_CTCP { state BACKUP interface eth0 lvs_sync_daemon_inteface eth0 virtual_router_id 52 priority 150 advert_int 5 authentication { auth_pass 2222 } virtual_ipaddress { 61.135.93.100 } } virtual_server 61.135.93.100 3000 { delay_loop 6 lb_algo wlc lb_kind DR persistence_timeout 50 protocol TCP real_server 61.135.93.84 3000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 3000 } } real_server 61.135.93.85 3000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 3000 } } real_server 61.135.93.86 3000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 3000 } } real_server 61.135.93.87 3000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 3000 } } } virtual_server 61.135.93.100 4000 { delay_loop 6 lb_algo wlc lb_kind DR persistence_timeout 50 protocol TCP real_server 61.135.93.88 4000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 4000 } } real_server 61.135.93.89 4000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 4000 } } real_server 61.135.93.90 4000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 4000 } } real_server 61.135.93.91 4000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 4000 } } } |
#guration File for keepalived,writed by sery #global define global_defs { router_id lvs_2 } vrrp_sync_group VGM { group { VI_CTCP } } vrrp_sync_group VGB { group { VI_WEB } } vrrp_instance VI_WEB{ state BACKUP interface eth0 lvs_sync_daemon_inteface eth0 virtual_router_id 51 priority 150 advert_int 5 authentication { auth_pass 1111 } virtual_ipaddress { 61.135.93.99 } } # setting port 80 forward virtual_server 61.135.93.99 80 { delay_loop 6 lb_algo wlc lb_kind DR persistence_timeout 10 protocol TCP real_server 61.135.99.80 80 { weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 61.135.93.81 80 { weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 61.135.93.82 80 { weight 90 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 61.135.93.83 80 { weight 90 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } } vrrp_instance VI_CTCP { state MASTER interface eth0 lvs_sync_daemon_inteface eth0 virtual_router_id 52 priority 180 advert_int 5 authentication { auth_pass 2222 } virtual_ipaddress { 61.135.93.100 } } virtual_server 61.135.93.100 3000 { delay_loop 6 lb_algo wlc lb_kind DR persistence_timeout 50 protocol TCP real_server 61.135.93.84 3000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 3000 } } real_server 61.135.93.85 3000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 3000 } } real_server 61.135.93.86 3000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 3000 } } real_server 61.135.93.87 3000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 3000 } } } virtual_server 61.135.93.100 4000 { delay_loop 6 lb_algo wlc lb_kind DR persistence_timeout 50 protocol TCP real_server 61.135.93.88 4000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 4000 } } real_server 61.135.93.89 4000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 4000 } } real_server 61.135.93.90 4000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 4000 } } real_server 61.135.93.91 4000{ weight 100 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 4000 } } } |
表3 lvs负载均衡器配置文件keepalived.conf
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者