Exchange 2016 负载均衡LVS+Keepalived

天下之事常成于困约,而败于奢靡。这篇文章主要讲述Exchange 2016 负载均衡LVS+Keepalived相关的知识,希望能为你提供帮助。
接上个博客,邮件系统中部署了3台邮件服务器。下面使用 LVS+Keepalived 实现owa负载均衡。 一、安装所需软件,如下所示:

[root@171 ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@171 ~]# yum install keepalived -y#yum安装keepalived [root@171 ~]# rpm -qa keepalived#查看keepalived版本 keepalived-1.3.5-19.el7.x86_64 [root@171 ~]# yum install ipvsadm -y#安装lvs [root@171 ~]# cat /etc/keepalived/keepalived.conf [root@171 ~]# systemctl restart keepalived#重启keepalived [root@171 ~]# systemctl enable keepalived#开机启动keepalived

二、配置 keepalived
[root@171 keepalived]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalivedglobal_defs notification_email acassen@firewall.loc failover@firewall.loc sysadmin@firewall.locnotification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id LVS_DEVEL vrrp_skip_check_adv_addr vrrp_strict vrrp_garp_interval 0 vrrp_gna_interval 0vrrp_instance VI_1 state MASTER interface ens33 virtual_router_id 51 priority 100 advert_int 1 authentication auth_type PASS auth_pass 1111virtual_ipaddress#设置VIP为192.168.3.170 192.168.3.170virtual_server 192.168.3.170 0 delay_loop 6 lb_algo rr lb_kind DR persistence_timeout 50 protocol TCPreal_server 192.168.3.232 0#设置集群中的服务器192.168.3.232 weight 1 TCP_CHECK connect_timeout 3 nb_get_retry 3 delay_before_retry 3real_server 192.168.3.233 0#设置集群中的服务器192.168.3.233 weight 1 TCP_CHECK connect_timeout 3 nb_get_retry 3 delay_before_retry 3real_server 192.168.3.234 0#设置集群中的服务器192.168.3.234 weight 1 TCP_CHECK connect_timeout 3 nb_get_retry 3 delay_before_retry 3

2.1 查看VIP已为 192.168.3.170,机器实际IP是171
Exchange 2016 负载均衡LVS+Keepalived

文章图片

三、修改 /etc/sysctrl.conf 文件
vi /etc/sysctrl.conf net.ipv4.ip_forward = 1#开启路由转发功能。往指定地方转发 net.ipv4.conf.all.send_redirects = 0#禁止转发重定向报文 net.ipv4.conf.ens33.send_redirects = 0#禁止ens33转发重定向报文,ens33是网卡名,根据实际需要填写 net.ipv4.conf.default.send_redirects = 0#禁止转发默认重定向报文

Exchange 2016 负载均衡LVS+Keepalived

文章图片

四、配置 ipvs
ipvsadm -C# -C clear the virtual server table清除ipvs所有的值 ipvsadm -A -t 192.168.3.170:443 -s rr#大写A,把到123:80的流量转出去 ipvsadm -a -t 192.168.3.170:443 -r 192.168.3.232:443 -g#找170:443,注抛给232:443。小g表示 DR模式,直连路由网关 ipvsadm -a -t 192.168.3.170:443 -r 192.168.3.233:443 -g#找170:443,注抛给233:443。小g表示 DR模式,直连路由网关 ipvsadm -a -t 192.168.3.170:443 -r 192.168.3.234:443 -g#找170:443,注抛给234:443。小g表示 DR模式,直连路由网关 ipvsadm-save > /etc/sysconfig/ipvsadm#永久保存systemctl enable ipvsadm#ipvs开机自启动ipvsadm -Lnc 查看ipvs访问过程ipvsadm -Ln 检查ipvs本机规则

五、Exchange 服务器配置环回网卡
【Exchange 2016 负载均衡LVS+Keepalived】5.1 打开设备管理器
Exchange 2016 负载均衡LVS+Keepalived

文章图片

5.2 添加过时硬件
Exchange 2016 负载均衡LVS+Keepalived

文章图片

5.3
Exchange 2016 负载均衡LVS+Keepalived

文章图片

5.4
Exchange 2016 负载均衡LVS+Keepalived

文章图片

5.5
Exchange 2016 负载均衡LVS+Keepalived

文章图片

5.6
Exchange 2016 负载均衡LVS+Keepalived

文章图片

5.7 设置环回网卡IP为192.168.3.170
netsh interface ipv4 set interface "本地连接" weakhostreceive=enabled netsh interface ipv4 set interface "本地连接" weakhostsend=enabled netsh interface ipv4 set interface "环回网卡" weakhostreceive=enabled netsh interface ipv4 set interface "环回网卡" weakhostsend=enabled

Exchange 2016 负载均衡LVS+Keepalived

文章图片

六 访问测试
测试方法:环境其中一台服务器 owa 验证方式改为:域\\用户名 方式
6.1 全部服务器为开机状态
Exchange 2016 负载均衡LVS+Keepalived

文章图片

6.2 一台 owa 验证方式为:域\\用户名的是开机状态,其它 Exchange 服务器关机。
Exchange 2016 负载均衡LVS+Keepalived

文章图片


    推荐阅读