成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

keepalived+haproxy搭建web群集

haproxy配置文件詳解參考:haproxy

成都創(chuàng)新互聯(lián)公司,為您提供成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、網(wǎng)站營銷推廣、網(wǎng)站開發(fā)設(shè)計(jì),對服務(wù)成都石牌坊等多個(gè)行業(yè)擁有豐富的網(wǎng)站建設(shè)及推廣經(jīng)驗(yàn)。成都創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)公司成立于2013年,提供專業(yè)網(wǎng)站制作報(bào)價(jià)服務(wù),我們深知市場的競爭激烈,認(rèn)真對待每位客戶,為客戶提供賞心悅目的作品。 與客戶共同發(fā)展進(jìn)步,是我們永遠(yuǎn)的責(zé)任!

環(huán)境如下:

keepalived+haproxy搭建web群集

一、準(zhǔn)備:

1、下載haproxy 軟件包,haproxy???提取碼: 9it6?

2、web 網(wǎng)站可以使用Apache、Nginx、搭建都可以,這里為了方便我就直接使用系統(tǒng)盤帶的httpd服務(wù)了。

web網(wǎng)站的搭建可參考:基于 Linux 安裝 web 服務(wù)及基本配置;基于 Centos 7 搭建Nginx;

3、配置防火墻放行流量

4、我這里使用的全部是centos 7系統(tǒng),注意,該環(huán)境不是生產(chǎn)環(huán)境,若是在生產(chǎn)環(huán)境中,肯定還有后端存儲來存放網(wǎng)頁文件,web服務(wù)器讀取存儲服務(wù)器上的網(wǎng)頁返回給客戶端。這樣才可保證網(wǎng)頁內(nèi)容的一致性。

二、開始搭建:

1、配置主服務(wù)器:

[root@haproxy1?/]#?yum?-y?install?pcre-devel?bzip2-devel?keepalived??????????#?安裝相關(guān)的依賴包和軟件包
[root@haproxy1?media]#?tar?zxf?haproxy-1.5.19.tar.gz?-C?/usr/src/
[root@haproxy1?media]#?cd?/usr/src/haproxy-1.5.19/
[root@haproxy1?haproxy-1.5.19]#?make?TARHET=linux26??&&??make??install?????????#?編譯安裝,TARGET表示64位操作系統(tǒng)
[root@haproxy1?haproxy-1.5.19]#?mkdir?/etc/haproxy????????????????????#?創(chuàng)建用來存放主配文件的目錄
[root@haproxy1?haproxy-1.5.19]#?cp?examples/haproxy.cfg?/etc/haproxy/?????????????#?將編譯包中的主配文件復(fù)制到配置文件目錄,注意啊:這個(gè)配置文件是在編譯包中,注意看路徑
[root@haproxy1?/]#?vim?/etc/haproxy/haproxy.cfg?
#?this?config?needs?haproxy-1.1.28?or?haproxy-1.2.1
global
????????log?/dev/log????local0?info
????????log?/dev/log????local0?notice
????????#log?loghost????local0?info
????????maxconn?4096
????????#chroot?/usr/share/haproxy????????????????#?將此行注釋掉
????????uid?99
????????gid?99
????????daemon
????????#debug
????????#quiet
defaults
????????log?????global
????????mode????http
????????option??httplog
????????option??dontlognull
????????retries?3
????????redispatch
????????maxconn?2000
????????contimeout??????5000
????????clitimeout??????50000
????????srvtimeout??????50000
listen??webcluster??0.0.0.0:80?????????????????????????????#?將端口號修改為80,webcluster為群集名稱,可修改
????????option??httpchk?GET??/index.html
????????balance?roundrobin????????????????????????????#?表示采用輪詢算法
????????server??web1?192.168.1.20:80?check?inter?2000?fall?3??????????????????#?兩個(gè)web節(jié)點(diǎn)
????????server??web2?192.168.1.30:80?check?inter?2000?fall?3
[root@haproxy1?/]#?cp?/usr/src/haproxy-1.5.19/examples/haproxy.init?/etc/init.d/haproxy?????????????#?復(fù)制服務(wù)控制腳本
[root@haproxy1?/]#?ln?-s?/usr/local/sbin/haproxy?/usr/sbin/haproxy??????????????????#?創(chuàng)建鏈接使命令使用更方便
[root@haproxy1?/]#?chmod?+x?/etc/init.d/haproxy??????????????????????#?添加執(zhí)行權(quán)限
[root@haproxy1?/]#?chkconfig?--add?/etc/init.d/haproxy????????????????#?添加為系統(tǒng)服務(wù)
[root@haproxy1?/]#?/etc/init.d/haproxy?start?????????????????#?啟動
Starting?haproxy?(via?systemctl):??????????????????????????[??OK??]
[root@haproxy1?/]#?vim?/etc/rsyslog.d/haproxy.conf??????????????#?配置日志文件,寫入如下內(nèi)容
if?($programname?==?'haproxy'?and?$syslogseverity-text?==?'info')?then?-/var/log/haproxy/haproxy-info.log
&?~?
if?($programname?==?'haproxy'?and?$syslogseverity-text?==?'notice')?then?-/var/log/haproxy/haproxy-notice.log
&?~?
[root@haproxy1?/]#?systemctl?restart?rsyslog.service?????????????????#?重啟日志服務(wù)

配置 keepalived :

[root@haproxy1?/]#?vim?/etc/keepalived/keepalived.conf?
!?Configuration?File?for?keepalived
global_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?LVS1??????????#?主從調(diào)度器名稱區(qū)分開
}
vrrp_instance?VI_1?{
????state?MASTER
????interface?ens33??????????????#?修改網(wǎng)卡名稱
????virtual_router_id?51
????priority?100
????advert_int?1
????authentication?{
????????auth_type?PASS
????????auth_pass?1111
????}
????virtual_ipaddress?{?
????????192.168.1.100??????????#?填寫漂移地址
????}
}
[root@haproxy1?/]#?systemctl?restart?keepalived?????????????#?重啟服務(wù)使配置生效

2、配置從服務(wù)器:

[root@haproxy2?/]#??yum?-y?install?pcre-devel?bzip2-devel??keepalived
[root@haproxy2?media]#?tar?zxf?haproxy-1.5.19.tar.gz?-C?/usr/src/
[root@haproxy2?media]#?cd?/usr/src/haproxy-1.5.19/
[root@haproxy2?haproxy-1.5.19]#?make?TARGET=linux26?&&?make?install
[root@haproxy2?haproxy-1.5.19]#?mkdir?/etc/haproxy
[root@haproxy2?haproxy-1.5.19]#?scp?root@192.168.1.10:/etc/haproxy/haproxy.cfg?/etc/haproxy/??????????#?圖個(gè)方便直接復(fù)制
root@192.168.1.10's?password:?
haproxy.cfg??????????????????????????????????????????100%??570?????0.6KB/s???00:00????
[root@haproxy2?/]#?cp?/usr/src/haproxy-1.5.19/examples/haproxy.init?/etc/init.d/haproxy???????????#?復(fù)制服務(wù)控制腳本
[root@haproxy2?/]#?ln?-s?/usr/local/sbin/haproxy?/usr/sbin/haproxy
[root@haproxy2?/]#?chmod?+x?/etc/init.d/haproxy?
[root@haproxy2?/]#?chkconfig?--add?/etc/init.d/haproxy?
[root@haproxy2?/]#?/etc/init.d/haproxy?start?
Starting?haproxy?(via?systemctl):??????????????????????????[??OK??]
[root@haproxy2?/]#?scp?root@192.168.1.10:/etc/rsyslog.d/haproxy.conf?/etc/rsyslog.d/
root@192.168.1.10's?password:?
haproxy.conf?????????????????????????????????????????100%??226?????0.2KB/s???00:00???
[root@haproxy2?/]#?systemctl?restart?rsyslog.service?????????????????#?重啟服務(wù)使配置生效
[root@haproxy2?haproxy-1.5.19]#?scp?root@192.168.1.10:/etc/keepalived/keepalived.conf?/etc/keepalived/
root@192.168.1.10's?password:?
keepalived.conf??????????????????????????????????????100%?3511?????3.4KB/s???00:00????
[root@haproxy2?/]#?vim?/etc/keepalived/keepalived.conf????????????#?修改主配置文件,修改如下幾個(gè)部分
.......................?省略部分
???router_id?LVS2???????????????#?主從調(diào)度器區(qū)分ID
}
vrrp_instance?VI_1?{
????state?BACKUP???????????????????????#?狀態(tài)修改為?BACKUP
????interface?ens33?????????????????
????virtual_router_id?51
????priority?90???????????????????????????#?優(yōu)先級調(diào)低
????advert_int?1
????authentication?{
????????auth_type?PASS
????????auth_pass?1111
????}
????virtual_ipaddress?{
????????192.168.1.100????????????????#?漂移地址
????}
}
[root@haproxy2?/]#?systemctl?restart?keepalived

兩個(gè)web節(jié)點(diǎn)配置(兩個(gè)配置相同):

[root@web2 /]# yum -y install httpd

[root@web2 /]# echo server2.com > /var/www/html/index.html? ? ? ? ? # 創(chuàng)建測試網(wǎng)頁

[root@web2 /]# systemctl start httpd?

[root@web2 /]# systemctl enable httpd

keepalived+haproxy搭建web群集

keepalived+haproxy搭建web群集

當(dāng)然,在實(shí)際生產(chǎn)環(huán)境中網(wǎng)頁是一樣的,這里我為了驗(yàn)證出效果,所以做了兩個(gè)不同的測試文件。

網(wǎng)頁題目:keepalived+haproxy搭建web群集
文章出自:http://jinyejixie.com/article14/ijjede.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、動態(tài)網(wǎng)站外貿(mào)建站、App開發(fā)、品牌網(wǎng)站設(shè)計(jì)、云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)
新营市| 理塘县| 常熟市| 班玛县| 沙坪坝区| 莲花县| 漳浦县| 资阳市| 车致| 尼木县| 双桥区| 双牌县| 临朐县| 惠来县| 沅江市| 怀集县| 铁力市| 洛南县| 呼玛县| 昭苏县| 黔西县| 康保县| 施甸县| 秦皇岛市| 韩城市| 大悟县| 泊头市| 阳西县| 县级市| 通榆县| 武川县| 松溪县| 磴口县| 建德市| 上高县| 咸阳市| 二连浩特市| 温泉县| 麟游县| 浦县| 滕州市|