中文字幕第五页-中文字幕第页-中文字幕韩国-中文字幕最新-国产尤物二区三区在线观看-国产尤物福利视频一区二区

haproxy+keepalived實現網站高可靠-創新互聯

10年積累的做網站、網站建設經驗,可以快速應對客戶對網站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網絡服務。我雖然不認識你,你也不認識我。但先網站制作后付款的網站建設流程,更有五指山免費網站建設讓你可以放心的選擇與我們合作。

haproxy 1的配置文件,包括 keepalived 和 haproxy 的配置,分別如下:

 【haproxy 1的keepalived 配置文件】  /etc/keepalived/keepalived.conf

global_defs {
router_id NodeB
}
vrrp_instance VI_1 {
state BACKUP #設置為主服務器
interface ens33 #監測網絡接口
virtual_router_id 51 #主、備必須一樣
priority 90 #(主、備機取不同的優先級,主機值較大,備份機值較小,值越大優先級越高)
advert_int 1 #VRRP Multicast廣播周期秒數
authentication {
auth_type PASS #VRRP認證方式,主備必須一致
auth_pass 1111 #(密碼)
}
virtual_ipaddress {
192.168.248.200
}

 【haproxy 1的haproxy.conf 配置文件】  /etc/haproxy/haproxy.cfg

#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2

chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon

# turn on stats unix socket
stats socket /var/lib/haproxy/stats

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------

frontend web *:80
frontend web1 192.168.248.200:80
# bind 192.168.248.200:80
mode http
use_backend app

#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
balance roundrobin
server static 127.0.0.1:4331 check

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
balance roundrobin
server app1 192.168.248.144:80 check
server app2 192.168.248.146:80 check

【haproxy 2的keepalived 配置文件】

global_defs {
router_id NodeB
}
vrrp_instance VI_1 {
state BACKUP #設置為主服務器
interface ens33 #監測網絡接口
virtual_router_id 51 #主、備必須一樣
priority 90 #(主、備機取不同的優先級,主機值較大,備份機值較小,值越大優先級越高)
advert_int 1 #VRRP Multicast廣播周期秒數
authentication {
auth_type PASS #VRRP認證方式,主備必須一致
auth_pass 1111 #(密碼)
}
virtual_ipaddress {
192.168.248.200
}

【haproxy 2的haproxy.cfg】 /etc/haproxy/haproxy.cfg

#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2

chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon

# turn on stats unix socket
stats socket /var/lib/haproxy/stats

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------

frontend web *:80
frontend web1 192.168.248.200:80
# bind 192.168.248.200:80
mode http
use_backend app

#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
balance roundrobin
server static 127.0.0.1:4331 check

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
balance roundrobin
server app1 192.168.248.144:80 check
server app2 192.168.248.146:80 check

【web 服務器1 的http index文件內容】

[root@localhost zhou]# yum install -y httpd

[root@localhost zhou]# echo "Hello I am nginx-backend 1. " > /var/www/html/index.html
[root@localhost zhou]# service httpd start
Redirecting to /bin/systemctl start httpd.service
[root@localhost zhou]# firewall-cmd --permanent --add-port=80/tcp
success
[root@localhost zhou]# firewall-cmd --reload
success
[root@localhost zhou]#

【web 服務器2 的http index文件內容】

[root@localhost zhou]# yum install -y httpd

[root@localhost zhou]# echo "Hello I am nginx-backend 2. " > /var/www/html/index.html
[root@localhost zhou]# service httpd start
Redirecting to /bin/systemctl start httpd.service
[root@localhost zhou]# firewall-cmd --permanent --add-port=80/tcp
success
[root@localhost zhou]# firewall-cmd --reload
success
[root@localhost zhou]#

 【haproxy 1的服務啟動】 haproxy 2與之相同。

keepalived -f /etc/keepalived/keepalived.conf

haproxy  -f  /etc/haproxy/haproxy.cfg

firewall-cmd --permenant --add-port=80/tcp

firewall-cmd --reload

【驗證結果】

如果關閉掉一個haproxy ,則不影響系統的正常工作,web網站還是可以正常訪問,并且是輪詢的結果。

標題名稱:haproxy+keepalived實現網站高可靠-創新互聯
網頁地址:http://m.2m8n56k.cn/article30/dgsepo.html

成都網站建設公司_創新互聯,為您提供小程序開發、網站策劃、用戶體驗、面包屑導航動態網站、企業網站制作

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

外貿網站制作
主站蜘蛛池模板: 国产成人综合怡春院精品 | 成人毛片免费观看视频大全 | 久久久久久国产精品免费免费 | 亚洲国产精品看片在线观看 | 成年视频国产免费观看 | 亚洲精品国产福利片 | 精品国产一区二区三区久久 | 看a网站 | 精品国产成人在线 | 国产婷婷一区二区三区 | 波多野结衣3女同在线观看 波多野结衣aⅴ在线 | 午夜久久影院 | 一本色道久久综合亚洲精品高清 | 日本一区二区不卡视频 | 久久精品国产只有精品6 | 国产成人精品午夜免费 | 天干天干天啪啪夜爽爽色 | 国产精品一区在线播放 | 精品亚洲一区二区 | 中文在线亚洲 | chinese多姿势videos | 中文字幕在线一区二区在线 | 女人张开腿等男人桶免费视频 | 国产精品久久免费 | 看片日韩 | 亚洲国产精品看片在线观看 | 步兵社区 | 男人免费看片 | 久久久久久久性高清毛片 | 一级片免费视频 | 一级做a爰 | 偷拍精品视频一区二区三区 | 91国内精品久久久久免费影院 | 亚洲 欧美 日韩中文字幕一区二区 | 亚洲精品国产综合一线久久 | 亚洲一级毛片欧美一级说乱 | 自拍网在线| 亚洲高清毛片 | 久久精品成人一区二区三区 | 99视频免费播放 | 一级做a爰片久久毛片唾 |