您的位置:网站首页 > 行业资讯 > 行业动态 > 正文

DNS部署(四)之lvs+keepalived+bind架构高可用负载均衡DNS系统

  2016-01-21 10:31  中国润滑油信息网
DNS部署(四)之lvs+keepalived+bind架构高可用负载均衡DNS系统

1、收集拓扑

650) this.width=650;" src="/html/uploads/allimg/160121/1031063F2-0.jpg" title="DNS.png" alt="wKioL1Yu2YCAcj8xAAO5DxTDLEQ607.jpg" />

2、情况描述

系统描述

IP地址

感化

LB-master

192.168.1.105

主备负载均衡器(同时做web和DNS调整)

LB-backup

192.168.1.106

DNS-master

192.168.1.107

VIP:192.168.1.30(LVS DNS节点互为主辅同步)

DNS-backup

192.168.1.108

Web节点组

192.168.1.201-203

VIP:192.168.1.40(LVS web节点)

3、设置设置设备摆设摆设LVS调整器keepalived的设置设置设备摆设摆设文件

keepalived设置设置设备摆设摆设双vrrp instance,分手为:WEB实例和DNS实例

3.1 主LVS上keepalived的设置设置设备摆设摆设文件内容:

[root@lvs-M ~]#cat /etc/keepalived/keepalived.conf

! ConfigurationFile for keepalived

global_defs {

notification_email {

}

smtp_server 192.168.200.1

smtp_connect_timeout 30

router_id lvs_105

}

vrrp_instance VI_WEB {

state MASTER

interface eth0

virtual_router_id 51

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.1.40/24

}

}

#############LVSWEB################

virtual_server 192.168.1.40 80 {

delay_loop 6

lb_algo rr

lb_kind DR

nat_mask 255.255.255.0

#persistence_timeout 50

protocol TCP

real_server 192.168.1.201 80 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 192.168.1.202 80 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 192.168.1.203 80 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

}

#############DNSInstance start###############

vrrp_instance VI_DNS {

state BACKUP

interface eth0

virtual_router_id 52

priority 90

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.1.30/24

}

}

###########LVSDNS#######################

virtual_server 192.168.1.30 53 {

delay_loop 6

lb_algo rr

lb_kind DR

nat_mask 255.255.255.0

# persistence_timeout 50

protocol UDP

real_server 192.168.1.107 53 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 53

}

}

real_server 192.168.1.108 53 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 53

}

}

}

3.2 备LVS上keepalived的设置设置设备摆设摆设文件内容:

[root@lvs-S ~]#cat /etc/keepalived/keepalived.conf

! ConfigurationFile for keepalived

global_defs {

notification_email {

}

smtp_server 192.168.200.1

smtp_connect_timeout 30

router_id lvs_106

}

vrrp_instance VI_WEB {

state BACKUP

interface eth0

virtual_router_id 51

priority 90

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.1.40/24

}

}

#############LVSWEB################

virtual_server 192.168.1.40 80 {

delay_loop 6

lb_algo rr

lb_kind DR

nat_mask 255.255.255.0

#persistence_timeout 50

protocol TCP

real_server 192.168.1.201 80 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 192.168.1.202 80 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 192.168.1.203 80 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

}

#############DNS Instancestart###############

vrrp_instance VI_DNS {

state MASTER

interface eth0

virtual_router_id 52

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.1.30/24

}

}

###########LVSDNS#######################

virtual_server 192.168.1.30 53 {

delay_loop 6

lb_algo rr

lb_kind DR

nat_mask 255.255.255.0

# persistence_timeout 50

protocol UDP

real_server 192.168.1.107 53 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 53

}

}

real_server 192.168.1.108 53 {

weight 100

TCP_CHECK {

connect_timeout 8

nb_get_retry 3

delay_before_retry 3

connect_port 53

}

}

}

4、设置设置设备摆设摆设LVS节点办事器脚本(WEB节点与DNS节点都要设置设置设备摆设摆设)

4.1 DNS节点的设置设置设备摆设摆设内容(主备DNS都有设置设置设备摆设摆设):

[root@dns-M ~]# cat /etc/init.d/dns_rs.ctl

#!/bin/bash

. /etc/init.d/functions

VIP=192.168.1.30

case "$1" in

start)

echo "start LVS of Realserver DR mode"

/sbin/ifconfig lo:0 ${VIP} netmask 255.255.255.255 up

route add -host ${VIP} dev lo

echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore

echo "2" >/proc/sys/ne博彩网站t/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 ${VIP} netmask 255.255.255.255 down

route del -host ${VIP} dev lo

echo "stop LVS of Realserver DR mode"

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.1.1 对上面的脚本付与权限

[root@dns-S init.d]# chmod +x dns_rs.ctl

4.2 WEB节点的设置设置设备摆设摆设内容(web的所有节点都有设置设置设备摆设摆设)

[root@web1 ~]# cat /etc/init.d/web_rs.ctl

#!/bin/bash

. /etc/init.d/functions

VIP=192.168.1.40

case "$1" in

start)

echo "start LVS of Realserver DR mode"

/sbin/ifconfig lo:0 ${VIP} netmask 255.255.255.255 up

route add -host ${VIP} dev lo

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 ${VIP} netmask 255.255.255.255 down

route del -host ${VIP} dev lo

echo "stop LVS of Realserver DR mode"

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.2.1 对上面的脚本付与权限

[root@web1 init.d]# chmod +x web_rs.ctl

5、主DNS办事器的区域设置设置设备摆设摆设文件改动如下:

[root@dns-M ~]# cat /var/named/chroot/var/named/pp.org.zone

$TTL86400

@IN SOAdns.pp.org.root.pp.org. (

203; serial (d. adams)

3H; refresh

15M; retry

1W; expiry

1D); minimum

IN NSdns.pp.org.

DNS部署(四)之lvs+keepalived+bind架构高可用负载均衡DNS系统IN MX10mail.pp.org.

dns.pp.org.IN A192.168.1.107

wwwINA192.168.1.40

5.1 改动之后重启DNS办事

[root@dns-M ~]# rndc reload

server reload successful

6、综合测试

测试之前要启动相关办事(keepalived、lvs节点脚本、节点Apache、节点DNS办事器等)

A:首先启动一台负载均衡调整器的keepalived办事

[root@lvs-M ~]# /etc/init.d/keepalived start

Starting keepalived:[OK]

[root@lvs-M ~]# ip addr

1: lo:mtu16436 qdisc noqueue

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0:

mtu 1500 qdisc pfifo_fast qlen 1000

link/ether 00:0c:29:81:a8:b3 brd ff:ff:ff:ff:ff:ff

inet 192.168.1.105/24 brd 192.168.1.255 scope global eth0

inet 192.168.1.40/24 scopeglobal secondary eth0

inet 192.168.1.30/24 scopeglobal secondary eth0

inet6 fe80::20c:29ff:fe81:a8b3/64 scope link

valid_lft forever preferred_lft forever

3: sit0:mtu 1480 qdisc noop

link/sit 0.0.0.0 brd 0.0.0.0

查看调整规则:

[root@lvs-M ~]# ipvsadm -L -n

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

-> RemoteAddress:PortForward Weight ActiveConn InActConn

UDP 192.168.1.30:53 rr

-> 192.168.1.108:53Route10000

-> 192.168.1.107:53Route10000

TCP 192.168.1.40:80 rr

-> 192.168.1.203:80Route10000

-> 192.168.1.202:80Route10000

-> 192.168.1.201:80Route10000

B.停掉落和启用一台DNS办事,察看调整器

[root@dns-S slaves]# /etc/init.d/named stop

Stoppingnamed:[OK]

查看的日志内容:

Oct 26 23:38:10 localhostKeepalived_healthcheckers: TCP connection to [192.168.1.108:53] failed !!!

Oct 26 23:38:10 localhost Keepalived_healthcheckers:Removing service [192.168.1.108:53] from VS [192.168.1.30:53]

察看lvs调整规则中少了192.168.1.108机械

[root@lvs-M ~]# ipvsadm -L -n

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

-> RemoteAddress:PortForward Weight ActiveConn InActConn

UDP 192.168.1.30:53 rr

-> 192.168.1.107:53Route10000

TCP 192.168.1.40:80 rr

-> 192.168.1.203:80Route10000

-> 192.168.1.202:80Route10000

-> 192.168.1.201:80Route10000

再次启动回来,查看日志会发明又把对应的IP地址加入了进来!

C.启动第二台负载均衡调整器的keepalived办事

[root@lvs-S ~]# /etc/init.d/keepalived start

Starting keepalived:[OK]

此时DNS的VIP会分配到第二台负载均衡调整器上

[root@lvs-S ~]# ip addr

1: lo:mtu16436 qdisc noqueue

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope hoTO88.COMst lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0:

mtu 1500 qdisc pfifo_fast qlen 1000

link/ether 00:0c:29:b5:be:19 brd ff:ff:ff:ff:ff:ff

inet 192.168.1.106/24 brd 192.168.1.255 scope global eth0

inet 192.168.1.30/24 scope global secondary eth0

inet6 fe80::20c:29ff:feb5:be19/64 scope link

valid_lft forever preferred_lft forever

3: sit0:mtu 1480 qdisc noop

link/sit 0.0.0.0brd 0.0.0.0

WEB的VIP仍旧在第一台负载均衡调整器上!!

[root@lvs-M ~]#ip addr

1: lo: mtu 16436 qdisc noqueue

link/loopback 00:00:00:00:00:00 brd00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0:

mtu 1500 qdisc pfifo_fast qlen 1000

link/ether 00:0c:29:81:a8:b3 brdff:ff:ff:ff:ff:ff

inet 192.168.1.105/24 brd 192.168.1.255scope global eth0

inet 192.168.1.40/24 scope global secondaryeth0

inet6 fe80::20c:29ff:fe81:a8b3/64 scopelink

valid_lft forever preferred_lft forever

3: sit0: mtu 1480 qdisc noop

link/sit 0.0.0.0 brd 0.0.0.0

察看调整规则:

[root@lvs-S ~]#ipvsadm -L -n

IP VirtualServer version 1.2.1 (size=4096)

ProtLocalAddress:Port Scheduler Flags

-> RemoteAddress:PortForward Weight ActiveConn InActConn

UDP192.168.1.30:53 rr

-> 192.168.1.108:53Route

-> 192.168.1.107:53Route

TCP192.168.1.40:80 rr

-> 192.168.1.203:80Route10000

-> 192.168.1.202:80Route10000

-> 192.168.1.201:80Route10000

[root@lvs-M ~]#ipvsadm -L -n

IP VirtualServer version 1.2.1 (size=4096)

ProtLocalAddress:Port Scheduler Flags

-> RemoteAddress:PortForward Weight ActiveConn InActConn

UDP192.168.1.30:53 rr

-> 192.168.1.108:53Route10000

-> 192.168.1.107:53Route10000

TCP192.168.1.40:80 rr

-> 192.168.1.203:80Route

-> 192.168.1.202:80Route

-> 192.168.1.201:80Route

综上:主备调整器的keepalived办事都在事情!

注:bind9功能强大年夜,这里只是评论争论了最简单的设置设置设备摆设摆设!

本文出自 “一点点” 博客,谢绝转载!

  本文系中国润滑油信息网(www.sinolub.com)原创作品,若需转载务必以超链接的形式注明出处,转载时严禁任何有悖原文的文字修改;本网有权对所有侵权行为进行责任追究。

分享到: QQ空间 新浪微博 人人网 开心网 腾讯微博 更多

相关新闻

友情提醒

本信息真实性未经中国润滑油信息网证实,仅供您参考。未经许可,请勿转载。已经本网授权使用的,应在授权范围内使用,并注明“来源:中国润滑油信息网”。

本网部分文章转载自其它媒体,转载目的在于传递更多行业信息,并不代表本网赞同其观点和对其真实性负责。在本网论坛上发表言论者,文责自负,本网有权在网站内转载或引用,论坛的言论不代表本网观点。本网所提供的信息,如需使用,请与原作者联系,版权归原作者所有。如果涉及版权需要同本网联系的,请在15日内进行。

官方微博

热点招商

奥吉星润滑油全国招商

奥吉星润滑油(天泰集团化工控股有限公司 股票代码:GTS)是由天泰控股的专业润滑油生产企业。 全国招商热线:400-0635-789

Gulf海湾石油面向全国招商

海湾石油(中国)有限公司是Gulf Oil International 在国内的唯一子公司。 现诚招经销商。 招商热线:0535-2161171

埃尼润滑油面向全国招商

埃尼是一家综合性能源企业,业务遍及83个国家,拥有84,000名员工,从事石油和天然气勘探、生产、运输、转化和营销活动,业务涉及化工、油田服务、建筑和工程领域。

关于我们|本网动态|广告服务|联系方式|免责声明|版权信息|法律顾问
CopyRight©2015-2016 Sinolub.Com All Rights Reserved 九鼎公司 版权所有
《中华人民共和国增值电信业务经营许可证》编号:粤B2-20050302
服务热线:0754-88650988 在线服务QQ:619128006 润滑油商机信息群:③:50693127 ④:65958932