亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 4828 | 回復: 1
打印 上一主題 下一主題

Debian 7 (wheezy)上配置LVS + keepalived [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2014-06-28 11:29 |只看該作者 |倒序瀏覽

最近測試LVS+Keepalived, 正好才這里找些資料,就把自己的配置過程也分享下。

直接從 http://ox0spy.github.io/debian/2 ... epalived-on-debian/ 負責過來的,CU上格式不太好。

準備機器
LVS_MASTER - 172.16.8.129
LVS_BACKUP - 172.16.8.130
WEB_APP_SERVER_1 - 172.16.8.131
WEB_APP_SERVER_2 - 172.16.8.132
注:

virtual server: 172.16.8.252 (非真實機器, 只需要在web app server上配下這個IP)
所有機器都安裝的Debian 7.5 (wheezy)
安裝軟件
LVS_MASTER上安裝配置LVS和keepalived
$ ssh LVS_MASTER
$ sudo apt-get install ipvsadm keepalived
配置LVS
$ cat /etc/default/ipvsadm
# ipvsadm

# if you want to start ipvsadm on boot set this to true
AUTO="false"

# daemon method (none|master|backup)
DAEMON="master"

# use interface (eth0,eth1...)
IFACE="eth0"

# syncid to use
SYNCID="1"
配置keepalived
$ cat /etc/keepalived/keepalived.conf
global_defs {
   router_id LVS_MASTER   #BACKUP上修改為LVS_BACKUP
}

vrrp_instance VI_1 {
    state MASTER          #BACKUP上修改為BACKUP
    interface eth0
    virtual_router_id 51  #與備機的id必須一致
    priority 100          #BACKUP上修改為80
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.16.8.252     #virtual server
    }
}

virtual_server 172.16.8.252 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    #lb_kind NAT
    #persistence_timeout 5
    protocol TCP

    real_server 172.16.8.131 80 {
        weight 3
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }

    real_server 172.16.8.132 80 {
        weight 3
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}
LVS_BACKUP上安裝配置LVS和keepalived
$ ssh LVS_BACKUP
$ sudo apt-get install ipvsadm keepalived
配置LVS
$ cat /etc/default/ipvsadm
# ipvsadm

# if you want to start ipvsadm on boot set this to true
AUTO="false"

# daemon method (none|master|backup)
DAEMON="backup"

# use interface (eth0,eth1...)
IFACE="eth0"

# syncid to use
SYNCID="1"
配置keepalived
$ cat /etc/keepalived/keepalived.conf
global_defs {
   router_id LVS_BACKUP #BACKUP上修改為LVS_BACKUP
}

vrrp_instance VI_1 {
    state BACKUP          #BACKUP上修改為BACKUP
    interface eth0
    virtual_router_id 51  #與備機的id必須一致
    priority 80           #BACKUP上修改為80
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.16.8.252     #virtual server
    }
}

virtual_server 172.16.8.252 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    #lb_kind NAT
    #persistence_timeout 5
    protocol TCP

    real_server 172.16.8.131 80 {
        weight 3
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }

    real_server 172.16.8.132 80 {
        weight 3
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}
配置WEB_APP_SERVER_1
安裝nginx
$ ssh WEB_APP_SERVER_1
$ sudo apt-get install nginx
$ sudo bash -c 'echo "Web App Server 1" > /usr/share/nginx/www/index.html'
配置IP
$ sudo ifconfig eth0:0 172.16.8.252 netmask 255.255.255.255 up
修改配置文件 (上面的配置重啟后需要重新輸入命令)

$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
auto eth0
auto eth0:0

iface lo inet loopback

# The primary network interface
allow-hotplug eth0
#iface eth0 inet dhcp
iface eth0 inet static
        address 172.16.8.131
        netmask 255.255.255.0
        gateway 172.16.8.2

iface eth0:0 inet static
        address 172.16.8.252
        netmask 255.255.255.255
        gateway 172.16.8.2
配置WEB_APP_SERVER_2
安裝nginx
$ ssh WEB_APP_SERVER_2
$ sudo apt-get install nginx
$ sudo bash -c 'echo "Web App Server 2" > /usr/share/nginx/www/index.html'
配置IP
$ sudo ifconfig eth0:0 172.16.8.252 netmask 255.255.255.255 up
修改配置文件 (上面的配置重啟后需要重新輸入命令)

$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
auto eth0
auto eth0:0

iface lo inet loopback

# The primary network interface
allow-hotplug eth0
#iface eth0 inet dhcp
iface eth0 inet static
        address 172.16.8.132
        netmask 255.255.255.0
        gateway 172.16.8.2

iface eth0:0 inet static
        address 172.16.8.252
        netmask 255.255.255.255
        gateway 172.16.8.2
啟動LVS, keepalived
$ ssh LVS_MASTER
$ sudo service ipvsadm restart
$ sudo service keepalived restart
$ ssh LVS_BACKUP
$ sudo service ipvsadm restart
$ sudo service keepalived restart
測試
查看服務(wù)器狀態(tài)
$ while true; do curl 172.16.8.252; curl 172.16.8.252; sleep 1; done
Web App Server 1
Web App Server 2
Web App Server 1
Web App Server 2
...
$ ssh LVS_MASTER
$ sudo ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddressort Scheduler Flags
  -> RemoteAddressort           Forward Weight ActiveConn InActConn
TCP  172.16.8.252:80 rr
  -> 172.16.8.131:80              Route   3      0          29
  -> 172.16.8.132:80              Route   3      0          30
將WEB_APP_SERVER_1的nginx進程結(jié)束,查看效果
$ ssh WEB_APP_SERVER_1
$ sudo service nginx stop
$ while true; do curl 172.16.8.252; curl 172.16.8.252; sleep 1; done
curl: (7) couldn't connect to host
Web App Server 2
curl: (7) couldn't connect to host
Web App Server 2
curl: (7) couldn't connect to host
Web App Server 2
Web App Server 2
Web App Server 2
Web App Server 2
...
$ sudo ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddressort Scheduler Flags
  -> RemoteAddressort           Forward Weight ActiveConn InActConn
TCP  172.16.8.252:80 rr
  -> 172.16.8.132:80              Route   3      0          114
$ ssh WEB_APP_SERVER_1
$ sudo service nginx stop
$ while true; do curl 172.16.8.252; curl 172.16.8.252; sleep 1; done
Web App Server 1
Web App Server 2
Web App Server 1
Web App Server 2
...
將LVS_MASTER關(guān)閉,查看請求web app server的結(jié)果
$ ssh LVS_MASTER
$ sudo shutdown -h now
$ while true; do curl 172.16.8.252; curl 172.16.8.252; sleep 1; done
Web App Server 1
Web App Server 2
Web App Server 1
Web App Server 2
...

求職 : Linux運維
論壇徽章:
19
CU大牛徽章
日期:2013-03-13 15:15:0815-16賽季CBA聯(lián)賽之山東
日期:2016-10-31 10:40:10綜合交流區(qū)版塊每日發(fā)帖之星
日期:2016-07-06 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-02-08 06:20:00數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2016-01-15 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-01-15 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-01-10 06:20:00黃金圣斗士
日期:2015-11-24 10:45:10IT運維版塊每日發(fā)帖之星
日期:2015-09-01 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-08-13 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-07-30 09:40:012015年亞洲杯之巴勒斯坦
日期:2015-05-05 10:19:03
2 [報告]
發(fā)表于 2014-07-06 19:19 |只看該作者
好貼一定要頂。。!
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP