目前常見的web集群調(diào)度器分為軟件和硬件,軟件通常使用開源的LVS,Haproxy,Nginx,硬件一般使用比較多的是F5,也有很多人使用國內(nèi)的一些產(chǎn)品,如梭子魚,綠盟等
隆回ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!
LVS不支持正則處理,不能實現(xiàn)動靜分離
對于大型網(wǎng)站,LVS的實施配置復(fù)雜,維護成本相對較高
特別適用于負(fù)載特別大的web站點
運行在當(dāng)前的硬件上可支持?jǐn)?shù)以萬計的并發(fā)連接連接請求
RR:最簡單常用的,輪詢調(diào)度
LC:最小連接數(shù)算法,根據(jù)后端的節(jié)點連接數(shù)大小動態(tài)分配前端請求
SH:來源訪問調(diào)度算法,用于有session會話記錄在服務(wù)器端,可以基于來源ip,cookie做群集調(diào)度
Haporxy服務(wù)器 192.168.13.175
web1服務(wù)器 192.168.13.151
web2服務(wù)器 192.168.13.176
client測試機
[root@web1 ~]# yum install -y \ ##安裝環(huán)境需要組件包
> pcre-devel \ ##開發(fā)包
> zlib-devel \ ##壓縮包
> gcc \
> gcc-c++ \
> make
[root@web1 ~]# useradd -M -s /sbin/nologin nginx ##創(chuàng)建系統(tǒng)用戶
[root@web1 ~]# mkdir /abc ##創(chuàng)建掛載點
[root@web1 ~]# mount.cifs //192.168.100.3/LNMP-C7 /abc/ ##掛載
Password for root@//192.168.100.3/LNMP-C7:
[root@web1 ~]# cd /abc/
[root@web1 abc]# tar zxvf nginx-1.12.2.tar.gz -C /opt ##解壓
[root@web1 abc]# cd /opt/nginx-1.12.2/
[root@web1 nginx-1.12.2]# ./configure \ ##進行配置
> --prefix=/usr/local/nginx \
> --user=nginx \
> --group=nginx
[root@web1 nginx-1.12.2]# make && make install
[root@web1 nginx-1.12.2]# echo "this is kgv web" > /usr/local/nginx/html/test.html
##創(chuàng)建站點網(wǎng)頁內(nèi)容,web2上為this is accp web
[root@web1 nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ##便于系統(tǒng)識別
[root@web1 nginx-1.12.2]# nginx -t ##檢查語法
[root@web1 nginx-1.12.2]# nginx ##開啟服務(wù)
[root@web1 nginx-1.12.2]# systemctl stop firewalld.service ##關(guān)閉防火墻
[root@web1 nginx-1.12.2]# setenforce 0
[root@haproxy ~]# yum install -y \ ##安裝環(huán)境組件工具
> pcre-devel \
> bzip2-devel \
> gcc \
> gcc-c++ \
> make
[root@haproxy ~]# systemctl stop firewalld.service ##關(guān)閉防火墻
[root@haproxy ~]# setenforce 0
[root@haproxy ~]# mkdir /abc
[root@haproxy ~]# mount.cifs //192.168.100.3/LNMP-C7 /abc/ ##掛載
[root@haproxy ~]# cd /abc/
[root@haproxy abc]# tar zxvf haproxy-1.5.19.tar.gz -C /opt/ ##解壓
[root@haproxy abc]# cd /opt/haproxy-1.5.19/
[root@haproxy haproxy-1.5.19]# make TARGET=linux26 ##編譯
[root@haproxy haproxy-1.5.19]# make install ##安裝
[root@haproxy haproxy-1.5.19]# mkdir /etc/haproxy ##創(chuàng)建配置文件目錄
[root@haproxy haproxy-1.5.19]# cp examples/haproxy.cfg /etc/haproxy/ ##模板復(fù)制到配置目錄下
[root@haproxy haproxy-1.5.19]# cd /etc/haproxy/
[root@haproxy haproxy]# vim haproxy.cfg ##編輯配置文件
----------刪除所有l(wèi)isten項目,并添加------------------------------------
注釋以下語句
chroot /usr/share/haproxy
redispatch
添加
listen webcluster 0.0.0.0:80
option httpchk GET /test.html ##web網(wǎng)頁
balance roundrobin ##輪詢
server inst1 192.168.13.151:80 check inter 2000 fall 3 ##健康檢查請求三次
server inst2 192.168.13.176:80 check inter 2000 fall 3
[root@haproxy haproxy]# cp /opt/haproxy-1.5.19/examples/haproxy.init /etc/init.d/haproxy ##啟動文件
[root@haproxy haproxy]# chmod +x /etc/init.d/haproxy ##執(zhí)行權(quán)限
[root@haproxy haproxy]# chkconfig --add /etc/init.d/haproxy ##添加到service
[root@haproxy haproxy]# ln -s /usr/local/sbin/haproxy /usr/sbin/ ##便于系統(tǒng)識別
[root@haproxy haproxy]# service haproxy start ##開啟服務(wù)
Starting haproxy (via systemctl): [ 確定 ]
[root@haproxy haproxy]# netstat -ntap | grep haproxy ##查看端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 39884/haproxy
高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
文章名稱:Haproxy搭建web群集——(實踐?。?創(chuàng)新互聯(lián)
網(wǎng)站地址:http://aaarwkj.com/article22/ccpecc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、網(wǎng)站設(shè)計、云服務(wù)器、網(wǎng)站策劃、商城網(wǎng)站、全網(wǎng)營銷推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容