亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

DR模式搭建LVSkeepalived-多web應用

發布時間:2020-08-19 00:23:32 來源:ITPUB博客 閱讀:173 作者:1006356403 欄目:建站服務器

服務器劃分

注:測試環境因此nginxApache都部署在同一臺real server

Masterbackupreal server服務器公用。

VIP

172.20.0.210

Master

172.20.0.22

Backup

172.20.0.25

Real_server

172.20.0.22

Real_server

172.20.0.25

Web :nginx

port:8220

Web :Apache

port:8221

Masterbackup部署

安裝ipvsadm

創建相應的目錄

[root@SALT1 ~]# mkdir software

[root@SALT1 ~]# cd software/

 

下載安裝包:

相應的命令為:

wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz

DR模式搭建LVSkeepalived-多web應用

查看內核參數

[root@SALT1 software]# uname -a

Linux SALT1 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux 

 

創建軟連接,不創建此鏈接,ipvsadm編譯安裝不過去。

[root@SALT1 software]# ln -s /usr/src/kernels/2.6.32-431.el6.x86_64/ /usr/src/linux

 

編譯安裝ipvsadm

[root@SALT1 software]# ls

ipvsadm-1.24.tar.gz

[root@SALT1 software]# tar -xvf ipvsadm-1.24.tar.gz  

ipvsadm-1.24/config_stream.c

ipvsadm-1.24/config_stream.h

…….

[root@SALT1 software]# cd ipvsadm-1.24

[root@SALT1 ipvsadm-1.24]# make && make install

make -C libipvs

make[1]: Entering directory `/root/software/ipvsadm-1.24/libipvs'

gcc -Wall -Wunused -Wstrict-prototypes -g -O2 -I/usr/src/linux/include  -DHAVE_NET_IP_VS_H

……..

 

加載LVS IP_VS模塊

[root@ccb log]# ipvsadm

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

[root@ccb log]# lsmod |grep ip_vs

ip_vs                 115643  0

libcrc32c               1246  1 ip_vs

ipv6                  321422  31 ip_vs

 

安裝keepalived

下載安裝包

相應的命令為:

[root@SALT1 software]# wget http://www.keepalived.org/software/keepalived-1.1.19.tar.gz

--2016-07-13 14:09:03--  http://www.keepalived.org/software/keepalived-1.1.19.tar.gz

Resolving www.keepalived.org... 37.59.63.157, 2001:41d0:8:7a9d::1

Connecting to www.keepalived.org|37.59.63.157|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 241437 (236K) [application/x-gzip]

Saving to: “keepalived-1.1.19.tar.gz”

 

100%[===================================================================================================================>] 241,437      190K/s   in 1.2s   

 

2016-07-13 14:09:06 (190 KB/s) - “keepalived-1.1.19.tar.gz” saved [241437/241437]

 

編譯安裝keepalived

 

[root@SALT1 software]# tar -xvf keepalived-1.1.19.tar.gz

keepalived-1.1.19/

keepalived-1.1.19/config.log

keepalived-1.1.19/configure

keepalived-1.1.19/README

keepalived-1.1.19/ChangeLog

keepalived-1.1.19/Makefile.in

……..

[root@SALT1 software]# cd keepalived-1.1.19

[root@SALT1 keepalived-1.1.19]# ./configure --prefix=/usr/local/keepalived

checking for gcc... gcc

……

[root@SALT1 keepalived-1.1.19]#

[root@SALT1 keepalived-1.1.19]# make

make -C lib || exit 1;

make[1]: Entering directory `/root/software/keepalived-1.1.19/lib'

gcc -g -O2 -I. -Wall -Wunused -Wstrict-prototypes  -c memory.c

gcc -g -O2 -I. -Wall -Wunused -Wstrict-prototypes  -c utils.c

……

Make complete

[root@SALT1 keepalived-1.1.19]# make install

make -C keepalived install

make[1]: Entering directory `/root/software/keepalived-1.1.19/keepalived'

install -d /usr/local/keepalived/sbin

……

創建相應的目錄

[root@ccb keepalived-1.1.19]# cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

[root@ccb keepalived-1.1.19]# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

[root@ccb keepalived-1.1.19]# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/

[root@ccb keepalived-1.1.19]# mkdir  /etc/keepalived/

[root@ccb keepalived-1.1.19]#cd

[root@ccb ~]# cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/


至此lvskeepalived安裝完成。


Keepalived配置

Master配置:

[root@localhost ~]# vi /etc/keepalived/keepalived.conf

#global define

global_defs {

router_id node-A

}

 

 

vrrp_sync_group test {

group {

  test

}

}

 

vrrp_instance test {

    state MASTER

    interface eth2

    lvs_sync_daemon_interface eth2

    virtual_router_id 50

    priority 180

    advert_int 3

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

      172.20.0.210

    }

}

virtual_server 172.20.0.210 8220 {

     delay_loop 3

     lb_algo rr

     lb_kind DR                   

     persistence_timeout 1

     protocol TCP

        

        

     real_server 172.20.0.22 8220 {

         weight 1            

         TCP_CHECK {

             connect_timeout 3

             nb_get_retry 3

             delay_before_retry 3

             connect_port 8220

         }

     }

     real_server 172.20.0.25 8220 {

         weight 1                

         TCP_CHECK {

             connect_timeout 3

             nb_get_retry 3

             delay_before_retry 3

             connect_port 8220

         }

     }

 

 }

 virtual_server 172.20.0.210 8221 {

     delay_loop 3

     lb_algo rr

     lb_kind DR                   

     persistence_timeout 1

     protocol TCP

     real_server 172.20.0.25 8221 {

         weight 1                 

         TCP_CHECK {

             connect_timeout 3

             nb_get_retry 3

             delay_before_retry 3

             connect_port 8221

         }

     }

real_server 172.20.0.22 8221 {

         weight 1

         TCP_CHECK {

             connect_timeout 3

             nb_get_retry 3

             delay_before_retry 3

             connect_port 8221

         }

     }

 }

Backup配置


[root@localhost ~]# vi /etc/keepalived/keepalived.conf

#global define

global_defs {

router_id node-B

}

 

 

vrrp_sync_group test {

group {

  test

}

}

 

vrrp_instance test {

    state BACKUP

    interface eth2

    lvs_sync_daemon_interface eth2

    virtual_router_id 50

    priority 150

    advert_int 3

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

      172.20.0.210

    }

}

virtual_server 172.20.0.210 8220 {

     delay_loop 3

     lb_algo rr

     lb_kind DR                    

     persistence_timeout 1

     protocol TCP

        

        

     real_server 172.20.0.22 8220 {

         weight 1            

         TCP_CHECK {

             connect_timeout 3

             nb_get_retry 3

             delay_before_retry 3

             connect_port 8220

         }

     }

     real_server 172.20.0.25 8220 {

         weight 1                

         TCP_CHECK {

             connect_timeout 3

             nb_get_retry 3

             delay_before_retry 3

             connect_port 8220

         }

     }

 

 }

 virtual_server 172.20.0.210 8221 {

     delay_loop 3

     lb_algo rr

     lb_kind DR                   

     persistence_timeout 1

     protocol TCP

     real_server 172.20.0.25 8221 {

         weight 1                 

         TCP_CHECK {

             connect_timeout 3

             nb_get_retry 3

             delay_before_retry 3

             connect_port 8221

         }

     }

real_server 172.20.0.22 8221 {

         weight 1

         TCP_CHECK {

             connect_timeout 3

             nb_get_retry 3

             delay_before_retry 3

             connect_port 8221

         }

     }

 }

 

Web應用配置:

確認啟動nginxapache

[root@localhost sbin]# lsof -i:8220

COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

nginx   22005   root    6u  IPv4  86789      0t0  TCP *:8220 (LISTEN)

nginx   22006 nobody    6u  IPv4  86789      0t0  TCP *:8220 (LISTEN)

[root@localhost sbin]# lsof -i:8221

COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

httpd   22012   root    4u  IPv6  86820      0t0  TCP *:8221 (LISTEN)

httpd   22015 apache    4u  IPv6  86820      0t0  TCP *:8221 (LISTEN)

httpd   22016 apache    4u  IPv6  86820      0t0  TCP *:8221 (LISTEN)

httpd   22017 apache    4u  IPv6  86820      0t0  TCP *:8221 (LISTEN)

httpd   22018 apache    4u  IPv6  86820      0t0  TCP *:8221 (LISTEN)

httpd   22019 apache    4u  IPv6  86820      0t0  TCP *:8221 (LISTEN)

httpd   22020 apache    4u  IPv6  86820      0t0  TCP *:8221 (LISTEN)

httpd   22021 apache    4u  IPv6  86820      0t0  TCP *:8221 (LISTEN)

httpd   22022 apache    4u  IPv6  86820      0t0  TCP *:8221 (LISTEN)

 

在兩臺real_server上分別創建lvsDR_node腳本:

 

[root@localhost ~]# vi /etc/init.d/lvsDR_node

#!/bin/bash

 

# descript : start real server DR

 

VIP=172.20.0.210

 

. /etc/rc.d/init.d/functions

 

case "$1" in

 

       start)

 

             echo "start LVS of RealServer DR"

 

             /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up  

 

             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 of RealServer DR"

 

             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

 

啟動keepalived:

分別啟動masterbackup服務器上面的keepalived:

[root@localhost ~]# /etc/init.d/keepalived start

Starting keepalived: [  OK  ]

[root@localhost ~]#

啟動real_server上面的lvsDR_node

[root@localhost ~]# /etc/init.d/lvsDR_node start

start LVS of RealServer DR

驗證:

查看啟動狀態:

Master


DR模式搭建LVSkeepalived-多web應用

backup

 

 DR模式搭建LVSkeepalived-多web應用

Web切換驗證

Apache驗證

DR模式搭建LVSkeepalived-多web應用

 

Nginx驗證:

DR模式搭建LVSkeepalived-多web應用

現在VIP是在master服務器(172.20.0.22)服務器上,為了確保web應用切換之后應用也能正常訪問,將master服務器上的nginxapache停掉。:

DR模式搭建LVSkeepalived-多web應用

可以看到22服務器上nginxApache都不能訪問了

Nginx:

DR模式搭建LVSkeepalived-多web應用

Apache:

DR模式搭建LVSkeepalived-多web應用

查看狀態:

DR模式搭建LVSkeepalived-多web應用

使用VIP訪問:


DR模式搭建LVSkeepalived-多web應用

DR模式搭建LVSkeepalived-多web應用

如上圖可以看到web應用切換之后web應用依然可以通過VIP正常訪問。

VIP切換驗證:

切換VIP

Master:

DR模式搭建LVSkeepalived-多web應用

Backup

DR模式搭建LVSkeepalived-多web應用

Nginx驗證:

DR模式搭建LVSkeepalived-多web應用

Apache驗證:

DR模式搭建LVSkeepalived-多web應用

注:當master上的keepalived再次啟動,VIP又會立刻切換到master上,而backup會自動切換為backup state

如圖:

DR模式搭建LVSkeepalived-多web應用
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

登封市| 铅山县| 四平市| 田林县| 宜黄县| 界首市| 大兴区| 天峻县| 化州市| 大新县| 阿城市| 墨竹工卡县| 贵州省| 安溪县| 巴塘县| 灵丘县| 会东县| 玛沁县| 玛曲县| 吉林省| 石首市| 浦北县| 潼南县| 云林县| 乌拉特前旗| 新郑市| 珲春市| 西畴县| 湘潭县| 荣昌县| 宁德市| 静乐县| 新巴尔虎左旗| 万载县| 武邑县| 石楼县| 台南市| 宜川县| 资溪县| 伊宁市| 如皋市|