更新時(shí)間:2021-12-17 13:15:30 來(lái)源:動(dòng)力節(jié)點(diǎn) 瀏覽2331次
構(gòu)建一個(gè)高可用的Nginx集群。
1.基于nat結(jié)構(gòu)實(shí)現(xiàn);
2.實(shí)現(xiàn)高可用;
實(shí)驗(yàn)拓?fù)鋱D形:
1.按圖配置各個(gè)網(wǎng)卡地址;
2.設(shè)置Nginx主機(jī)(下面帶#的部分為從所需要的配置,其他則一樣)
Yum install httpd nginx
Vim /etc/httpd/conf/httpd.conf
Listen 80 àListen
8080
Vim /etc/nginx/nginx.conf
http{
upstream websrvs {
server 172.18.24.3:80;
server 172.18.24.5:80;
server 127.0.0.1:8080 backup;
}
}
vim /etc/nginx/conf.d/default.conf
location / {
proxy_pass http://websrvs;
}
vim /etc/keepalived/keepalived.conf
global_defs {
notification_email {
root@localhost
}
notification_email_from keeplived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id tes1t
vrrp_mcast_group4 224.0.100.24
}
vrrp_script ‘ngxstatus’ {
script “killall -0 nginx && exit 0 || exit 1”
interval 1
weight -5
}
vrrp_instance myr1 {
state MASTER
#BACKUP
interface eth0
#ens38
virtual_router_id 67
priority 100 #98
advert_int 1
authentication {
auth_type PASS
auth_pass UIpYPPDI
}
track_script {
ngxstatus
}
virtual_ipaddress {
172.18.24.13/16 dev eth0
#ens38
}
notify_master “/etc/keepalived/notify.sh master”
notify_backup “/etc/keepalived/notify.sh backup”
notify_fault “/etc/keepalived/notify.sh fault”
}
Systemctl start httpd
Systemctl start nginx
Systemctl start keepalived
3.配置RS主機(jī)
Yum install httpd
Vim /var/www/html/index.html
4.檢測(cè):curl http://172.18.24.13
檢測(cè)結(jié)果:實(shí)現(xiàn)高可用Nginx集群。
如果您想了解更相關(guān)知識(shí),不妨來(lái)關(guān)注一下動(dòng)力節(jié)點(diǎn)的Java在線學(xué)習(xí),里面的課程內(nèi)容全面細(xì)致,從入門(mén)到精通,很適合沒(méi)有基礎(chǔ)的小伙伴學(xué)習(xí),相信對(duì)大家會(huì)有所幫助的。
0基礎(chǔ) 0學(xué)費(fèi) 15天面授
有基礎(chǔ) 直達(dá)就業(yè)
業(yè)余時(shí)間 高薪轉(zhuǎn)行
工作1~3年,加薪神器
工作3~5年,晉升架構(gòu)
提交申請(qǐng)后,顧問(wèn)老師會(huì)電話與您溝通安排學(xué)習(xí)