码迷,mamicode.com
首页 > 其他好文 > 详细

centos6.7-keepalived-DNS-ntp一主一从服务器端配置

时间:2015-12-30 19:59:16      阅读:441      评论:0      收藏:0      [点我收藏+]

标签:keepalived   dns   ntp   

1.        yum -y install  kernel-devel make  gcc  openssl-devel  libnl*  popt*  popt-static

2.       wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz

3.       tar zxvf keepalived-1.2.7.tar.gz

4.       cd keepalived-1.2.7

5.       ./configure 

6.       执行完最后一条时,终端应该显示为下图这样,如果不是请不要继续,自己返回来看下有没有哪里执行有误;

技术分享1.2.7,gcc,-g -o2,yes,yes,yes,yes,yes,no,no

 

 

 

 

 

 

 

 

7.       make &make install

 

 

注册成系统服务

1.      cp /usr/local/etc/rc.d/init.d/keepalived   /etc/rc.d/init.d/

2.     cp /usr/local/etc/sysconfig/keepalived    /etc/sysconfig/

3.     mkdir /etc/keepalived

4.     cp /usr/local/etc/keepalived/keepalived.conf   /etc/keepalived/

5.     cp /usr/local/sbin/keepalived   /usr/sbin/

 

至此,可以使用  service keepalived stop start status 等启动停止查看

设置开机启动  chkconfig keepalived on

 

 

配置keepalived

vi /etc/keepalived/keepalived.conf

 

 

 

 

 

 

主节点:

1.  global_defs {  

2.      router_id NodeB  

3.  }  

4.  vrrp_instance VI_1 {  

5.      state MASTER    #设置为主服务器  

6.      interface eth0  #监测网络接口  

7.      virtual_router_id 51  #主、备必须一样  

8.      priority 90   #(主、备机取不同的优先级,主机值较大,备份机值较小,值越大优先级越高)  

9.      advert_int 1   #VRRP Multicast广播周期秒数  

10.    authentication {  

11.    auth_type PASS  #VRRP认证方式,主备必须一致  

12.    auth_pass 1111   #(密码)  

13.}  

14.virtual_ipaddress {  

15.    192.168.8.100/24  #VRRP HA虚拟地址  

16.}  

 

备节点:

1.  global_defs {  

2.      router_id NodeB  

3.  }  

4.  vrrp_instance VI_1 {  

5.      state BACKUP    #设置为备服务器  

6.      interface eth0  #监测网络接口  

7.      virtual_router_id 51  #主、备必须一样  

8.      priority 90   #(主、备机取不同的优先级,主机值较大,备份机值较小,值越大优先级越高)  

9.      advert_int 1   #VRRP Multicast广播周期秒数  

10.    authentication {  

11.    auth_type PASS  #VRRP认证方式,主备必须一致  

12.    auth_pass 1111   #(密码)  

13.}  

14.virtual_ipaddress {  

15.    192.168.8.100/24  #VRRP HA虚拟地址  

16.}  

至此可以实现VIP自动浮动,使用ip addr 验证

 

 

 

####以下配置在172.28.8.199上绑定DNS服务端口53

virtual_server172.28.8.199 53 {

   delay_loop 2

   lb_algo wrr

   lb_kind DR

   net_mask 255.255.255.255   #一定要加上这行,否则53端口在199 ip上监听不起来

   persistence_timeout 3

   protocol TCP

 

   real_server 172.28.8.197 53 {

       weight 3

       TCP_CHECK {

       connect_timeout 2

       nb_get_retry 3

       delay_before_retry 3

       connect_port 53

}

   }

   real_server 172.28.8.198 53 {

       weight 3

       TCP_CHECK {

       connect_timeout 2

       nb_get_retry 3

       delay_before_retry 3

       connect_port 53

       }

######udp 53

virtual_server172.28.8.199 53 {

   delay_loop 2

   lb_algo wrr

   lb_kind DR

   persistence_timeout 3

   protocol UDP

 

   real_server 172.28.8.197 53 {

       weight 3

       UDP_CHECK {

       connect_timeout 2

       nb_get_retry 3

       delay_before_retry 3

       connect_port 53

}

   }

   real_server 172.28.8.198 53 {

       weight 3

       UDP_CHECK {

       connect_timeout 2

       nb_get_retry 3

       delay_before_retry 3

       connect_port 53

       }

 

 

 

Keepalive在一个节点启动或重启后,一定要重启下named服务,要不然53端口要过很长时间才能在浮动IP上启来


centos6.7-keepalived-DNS-ntp一主一从服务器端配置

标签:keepalived   dns   ntp   

原文地址:http://406647516.blog.51cto.com/2249087/1730033

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!