您好,登錄后才能下訂單哦!
環(huán)境
硬件平臺(tái):國(guó)產(chǎn) arm64 3399cpu海之舟服務(wù)器
操作系統(tǒng):海之舟服務(wù)器操作系統(tǒng)1.0A
用戶訪問(wèn)192.168.125地址時(shí),haproxy分配至二臺(tái)服務(wù)器,192.168.1.7,192.168.1.8。實(shí)現(xiàn)負(fù)載分擔(dān)。
root@bigdataA:/home/zs# apt-get install haproxy //安裝軟件
root@bigdataA:/home/zs# nano /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
#main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main
bind *:80 //偵測(cè)端口80
default_backend webserver
#---------------------------------------------------------------------
#static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend webserver
balance roundrobin //輪詢方式
server web1 192.168.1.7:80 check //默認(rèn)每2000ms檢查一次服務(wù)器,192.168.1.7是否正常.
server web2 192.168.1.8:80 check
root@bigdataA:/home/zs# /etc/init.d/haproxy stop //重啟服務(wù)器,使配置生效
[ ok ] Stopping haproxy (via systemctl): haproxy.service.
root@bigdataA:/home/zs# /etc/init.d/haproxy start
[ ok ] Starting haproxy (via systemctl): haproxy.service.
root@bigdataA:/home/zs# netstat -an |more //查看端口是否啟用
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN //顯示80端口啟用
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 64 192.168.1.125:22 192.168.1.6:1524 ESTABLISHED
tcp6 0 0 :::8080 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 127.0.0.1:8005 :::* LISTEN
tcp6 0 0 :::8009 :::* LISTEN
Active UNIX domain sockets (servers and established)
root@bigdataA:/home/zs#
在客戶端瀏覽器中輸入地址http://192.168.1.125,即可訪問(wèn)到輪詢的網(wǎng)頁(yè).
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。