本文共 2462 字,大约阅读时间需要 8 分钟。
keepalived 是解决单故障节点的软件
1、 keepalived+LVS/DR2、 任意单故障节点 的 高可用作 分发器 的 高可用用 keepalived 作 LVS/DR 模式 分发器 的 高可用实验拓扑clientnode1主、node2备webA 、webB浮动资源有: 浮动ip、策略
IP 规划
client 192.168.4.254node1 192.168.4.50node2 192.168.4.55浮动ip(vip) 192.168.4.252webA 192.168.4.51webB 192.168.4.52配置步骤
#chkconfig iptables off #取消开机自起#service iptables stop #关闭防火墙#setenforce 0 #关闭selinux1 配置好网络环境 所有地址的IP
#vim /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0ONBOOT=yesBOOTPROTO=staticIPADDR=192.168.4.50NETMASK=255.255.255.0GATEWAY=192.168.4.10DNS1=202.106.0.20...#service network restart #systemctl restart NetworkManager2 配置webA、B 服务自定义Web页面
#yum install -y httpd#echo “192.168.4.51” > /var/www/html/index.html#echo “192.168.4.52” > /var/www/html/index.html#service httpd start ; chkconfig httpd on #rhel6#systemctl start httpd;systemctl enable httpd #rhel7配置webA、B的vip 和DR模式的网络配置
临时修改方法可写在/etc/rc.local文件里开机执行#ifconfig lo:1 192.168.4.252/32#echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore#echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce#echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore#echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce永久修改方法#vim /etc/sysctl.conf.. ..net.ipv4.conf.all.arp_ignore = 1net.ipv4.conf.lo.arp_ignore = 1net.ipv4.conf.lo.arp_announce = 2net.ipv4.conf.all.arp_announce = 2#sysctl -p
在node1、node2 分别安装 keepalived 软件包
#yum -y install keepalived ipvsadm 修改配置node1#vim /etc/keepalived/keepalived.conf! Configuration File for keepalivedglobal_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id LVS_DEVEL}vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 priority 150 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.4.252 }}virtual_server 192.168.4.252 80 { delay_loop 6 lb_algo rr #集群算法 lb_kind DR #DR模式 nat_mask 255.255.255.0#persistence_timeout 50 #坚持时间同一客户端50秒内访问分配同一服务器注释掉实现实时轮询 protocol TCP connect_timeout 3 nb_get_retry 3 delay_before_retry 3 real_server 192.168.4.51 80 { weight 1 } real_server 192.168.4.52 80 { weight 1 }}
node2:
#vim /etc/keepalived/keepalived.confstate MASTERpriority 150#systemctl start keepalived#ipvsadm -Ln
验证 254:
转载于:https://blog.51cto.com/45545613/2083341