keepalived主备调度器的实现

1、实验原理:
在企业中,如果只有一台调度器,那么如果它出现问题,将造成不可估量的损失,所以企业会使用两台调度器,主调度器正常工作,如果出现问题那么辅调度器接替它继续工作,不会影响业务。
2、实验环境
主和备两台调度器要有所有主机的解析,包括自己

server1:主调度器 IP:172.25.1.101
server4:辅调度器 IP:172.25.1.103
server2:服务器 IP:172.25.1.102
server3:服务器 IP:172.25.1.103
测试机:172.25.1.1

3、配置
server1

	keepalived-2.0.17.tar.gz					自己下载压缩包
	tar -zxf keepalived-2.0.17.tar.gz 
	yum install gcc openssl-devel			安装源码编译所需要的环境
	cd keepalived-2.0.17
	./configure --prefix=/usr/local/keepalived --with-init=systemdls
	make && make install
	ln -s /usr/local/keepalived/etc/keepalived/ /etc/
	/etc/init.d/ldirectord stop
	chkconfig ldirectord off
	cat /usr/lib/systemd/system/keeplived.service
	vim /etc/keepalived/keepalived.conf
		global_defs {
		   notification_email {
			root@localhost
		   }
		   notification_email_from keepalived@localhost
		   smtp_server 127.0.0.1
		   smtp_connect_timeout 30
		   router_id LVS_DEVEL
		   vrrp_skip_check_adv_addr
		   #vrrp_strict
		   vrrp_garp_interval 0
		   vrrp_gna_interval 0
		}

		vrrp_instance VI_1 {
		    state MASTER
		    interface eth0
		    virtual_router_id 51
		    priority 100
		    advert_int 1
		    authentication {
			auth_type PASS
			auth_pass 1111
		    }
		    virtual_ipaddress {
		    	172.25.1.101    
		    }
		}

		virtual_server 172.25.1.101 80 {					#sserver1 ip地址
		    delay_loop 6
		    lb_algo rr
		    lb_kind DR
		    #persistence_timeout 50
		    protocol TCP

		    real_server 172.25.1.102 80 {
			TCP_CHECK {
			weight 1
			    connect_timeout 3
			    retry 3
			    delay_before_retry 3
			}
		    }
		    real_server 172.25.1.103 80 {
			TCP_CHECK {
			weight 1
			    connect_timeout 3
			    retry 3
			    delay_before_retry 3
			}
		    }
		}
	systemctl start keepalived.service

server4

	tar -zxf keepalived-2.0.17.tar.gz 
	yum install gcc openssl-devel
	cd keepalived-2.0.17
	./configure --prefix=/usr/local/keepalived --with-init=systemdls
	make && make install
	ln -s /usr/local/keepalived/etc/keepalived/ /etc/
	/etc/init.d/ldirectord stop
	chkconfig ldirectord off
	vim /etc/keepalived/keepalived.conf
		vim /etc/keepalived/keepalived.conf
		global_defs {
		   notification_email {
			root@localhost
		   }
		   notification_email_from keepalived@localhost
		   smtp_server 127.0.0.1
		   smtp_connect_timeout 30
		   router_id LVS_DEVEL
		   vrrp_skip_check_adv_addr
		   #vrrp_strict
		   vrrp_garp_interval 0
		   vrrp_gna_interval 0
		}

		vrrp_instance VI_1 {
		    state BACKUP				备用调度器
		    interface eth0
		    virtual_router_id 51
		    priority 50
		    advert_int 1
		    authentication {
			auth_type PASS
			auth_pass 1111
		    }
		    virtual_ipaddress {
		    	172.25.1.101    
		    }
		}

		virtual_server 172.25.1.104 80 {					#server4 IP地址
		    delay_loop 6
		    lb_algo rr
		    lb_kind DR
		    #persistence_timeout 50
		    protocol TCP

		    real_server 172.25.1.102 80 {
			TCP_CHECK {
			weight 1
			    connect_timeout 3
			    retry 3
			    delay_before_retry 3
			}
		    }
		    real_server 172.25.1.103 80 {
			TCP_CHECK {
			weight 1
			    connect_timeout 3
			    retry 3
			    delay_before_retry 3
			}
		    }
		}
	systemctl start keepalived.service

server2,server3

systemctl start httpd

4、测试:
关掉主调度器
curl 172.25.1.101

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值