收藏 分销(赏)

DNS服务器LVS方式负载均衡部署与测试.docx

上传人:s4****5z 文档编号:8795493 上传时间:2025-03-02 格式:DOCX 页数:14 大小:225.42KB 下载积分:10 金币
下载 相关 举报
DNS服务器LVS方式负载均衡部署与测试.docx_第1页
第1页 / 共14页
DNS服务器LVS方式负载均衡部署与测试.docx_第2页
第2页 / 共14页


点击查看更多>>
资源描述
DNS服务器LVS方式负载均衡部署与测试 测试环境: 本测试方案采用LVS(DR)+Keepalived部署高可用的DNS服务集群。 主机IP划分: Master-LB:192.168.100.70 Backup-LB:192.168.100.30 RS1:192.168.100.40 RS2:192.168.100.60 Clinet:192.168.100.200 拓扑图: 1、配置Maste-LB服务器: 1、 安装ipvsadm; yum install ipvsadm* -y 2、 安装keepalived yum install keepalived -y 3、 配置配置keepalived #cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { 460249547@ } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_1 } vrrp_instance VI_1 { state MASTER interface eth1 virtual_router_id 50 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.100.100 } } virtual_server 192.168.100.100 53 { delay_loop 1 lb_algo rr lb_kind DR nat_mask 255.255.255.255 !persistence_timeout 50 protocol UDP real_server 192.168.100.40 53 { weight 1 MISC_CHECK { misc_path "/usr/bin/dig -b 192.168.100.70 a www.test.org @192.168.100.40 +time=1 +tries=5 +fail >/dev/null" misc_timeout 6 } } real_server 192.168.100.60 53 { weight 1 MISC_CHECK { misc_path "/usr/bin/dig -b 192.168.100.70 a www.test.org @192.168.100.60 +time=1 +tries=5 +fail >/dev/null" misc_timeout 6 } } } vrrp_instance VI_2 { state MASTER interface eth1 virtual_router_id 52 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.100.100 } } virtual_server 192.168.100.100 53 { delay_loop 1 lb_algo rr lb_kind DR nat_mask 255.255.255.255 !persistence_timeout 50 protocol TCP real_server 192.168.100.40 53 { weight 1 TCP_CHECK { connect_timeout 5 nb_get_retry 3 connect_port 53 } } real_server 192.168.100.60 53 { weight 1 TCP_CHECK { connect_timeout 5 nb_get_retry 3 connect_port 53 } } } 4、 启动keepalived的服务 service keepalived restart 5、 查看配置是否生效 # ipvsadm –Ln [root@localhost ~]# ipvsadm -Ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 192.168.100.100:53 rr -> 192.168.100.40:53 Route 1 0 0 -> 192.168.100.60:53 Route 1 0 0 UDP 192.168.100.100:53 rr -> 192.168.100.40:53 Route 1 0 0 -> 192.168.100.60:53 Route 1 0 0 2、配置Backup-LB服务器: 1、 安装ipvsadm; yum install ipvsadm* -y 2、 安装keepalived yum install keepalived -y 3、 配置配置keepalived #cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { 460249547@ } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_2 } vrrp_instance VI_1 { state BACKUP interface eth1 virtual_router_id 50 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.100.100 } } virtual_server 192.168.100.100 53 { delay_loop 1 lb_algo rr lb_kind DR nat_mask 255.255.255.255 !persistence_timeout 50 protocol UDP real_server 192.168.100.40 53 { weight 1 MISC_CHECK { misc_path "/usr/bin/dig -b 192.168.100.70 a www.test.org @192.168.100.40 +time=1 +tries=5 +fail >/dev/null" misc_timeout 6 } } real_server 192.168.100.60 53 { weight 1 MISC_CHECK { misc_path "/usr/bin/dig -b 192.168.100.70 a www.test.org @192.168.100.60 +time=1 +tries=5 +fail >/dev/null" misc_timeout 6 } } } vrrp_instance VI_2 { state BACKUP interface eth1 virtual_router_id 52 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.100.100 } } virtual_server 192.168.100.100 53 { delay_loop 1 lb_algo rr lb_kind DR nat_mask 255.255.255.255 !persistence_timeout 50 protocol TCP real_server 192.168.100.40 53 { weight 1 TCP_CHECK { connect_timeout 5 nb_get_retry 3 connect_port 53 } } real_server 192.168.100.60 53 { weight 1 TCP_CHECK { connect_timeout 5 nb_get_retry 3 connect_port 53 } } } 4、 启动keepalived的服务 service keepalived restart 5、 查看配置是否生效 # ipvsadm –Ln [root@localhost ~]# ipvsadm -Ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 192.168.100.100:53 rr -> 192.168.100.40:53 Route 1 0 0 -> 192.168.100.60:53 Route 1 0 0 UDP 192.168.100.100:53 rr -> 192.168.100.40:53 Route 1 0 0 -> 192.168.100.60:53 Route 1 0 0 3、配置DNS-RS1与DNS-RS2: 1、 配置安装并配置DNS服务,并确保DNS服务能正常工作; 2、 在每一台REALSERVER上执行如下脚本 #!/bin/bash #description : Start Real Server VIP=192.168.100.100 . /etc/rc.d/init.d/functions case "$1" in start) echo " Start LVS of Real Server" /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce ;; stop) /sbin/ifconfig lo:0 down echo "close LVS Director server" echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce ;; *) echo "Usage: $0 {start|stop}" exit 1 esac 4、测试结果: [root@localhost ~]# ipvsadm -Ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 192.168.100.100:53 rr -> 192.168.100.40:53 Route 1 0 34 -> 192.168.100.60:53 Route 1 0 35 UDP 192.168.100.100:53 rr -> 192.168.100.40:53 Route 1 0 6 -> 192.168.100.60:53 Route 1 0 6 故障转移: Aug 13 22:55:52 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) Transition to MASTER STATE Aug 13 22:55:52 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) Transition to MASTER STATE Aug 13 22:55:53 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) Entering MASTER STATE Aug 13 22:55:53 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) setting protocol VIPs. Aug 13 22:55:53 centos6 Keepalived_healthcheckers[52500]: Netlink reflector reports IP 192.168.100.100 added Aug 13 22:55:53 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) Sending gratuitous ARPs on eth1 for 192.168.100.100 Aug 13 22:55:53 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) Entering MASTER STATE Aug 13 22:55:53 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) setting protocol VIPs. Aug 13 22:55:53 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.100.100 Aug 13 22:55:56 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) Received higher prio advert Aug 13 22:55:56 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) Entering BACKUP STATE Aug 13 22:55:56 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) removing protocol VIPs. Aug 13 22:55:56 centos6 Keepalived_healthcheckers[52500]: Netlink reflector reports IP 192.168.100.100 removed Aug 13 22:55:56 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) Received higher prio advert Aug 13 22:55:56 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) Entering BACKUP STATE Aug 13 22:55:56 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) removing protocol VIPs. Aug 13 22:55:56 centos6 Keepalived_vrrp[52501]: Netlink: error: Cannot assign requested address, type=(21), seq=1407932349, pid=0 Aug 13 22:56:00 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) Transition to MASTER STATE Aug 13 22:56:00 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) Transition to MASTER STATE Aug 13 22:56:01 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) Entering MASTER STATE Aug 13 22:56:01 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) setting protocol VIPs. Aug 13 22:56:01 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) Sending gratuitous ARPs on eth1 for 192.168.100.100 Aug 13 22:56:01 centos6 Keepalived_healthcheckers[52500]: Netlink reflector reports IP 192.168.100.100 added Aug 13 22:56:01 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) Entering MASTER STATE Aug 13 22:56:01 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) setting protocol VIPs. Aug 13 22:56:01 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.100.100 Aug 13 22:56:06 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_2) Sending gratuitous ARPs on eth1 for 192.168.100.100 Aug 13 22:56:06 centos6 Keepalived_vrrp[52501]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.10
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服