Nginx 高可用+負(fù)載均衡部署文檔V1.0.2_第1頁
Nginx 高可用+負(fù)載均衡部署文檔V1.0.2_第2頁
Nginx 高可用+負(fù)載均衡部署文檔V1.0.2_第3頁
Nginx 高可用+負(fù)載均衡部署文檔V1.0.2_第4頁
Nginx 高可用+負(fù)載均衡部署文檔V1.0.2_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

Nginx高可用+負(fù)載均衡部署指南軟件版本說明軟件版本Nginxnginx/1.6.0KeepalivedKeepalivedv1.2.15基礎(chǔ)軟件安裝Nginx安裝版本jdk-7u67-linux-x64.rpm,安裝步驟略安裝后檢驗(yàn)Nginx版本是否正確。[root@localhost~]#/usr/local/nginx/sbin/nginx–vnginxversion:nginx/1.6.0Keepalived安裝openssl安裝openssl必須安裝,否則安裝keepalived時(shí)無法編譯,keepalived依賴opensslopenssl安裝tarzxvfopenssl-1.0.1g.tar.gz./config--prefix=/usr/local/openssl./config-tmakedependmakemaketestmakeinstallln-s/usr/local/openssl/usr/local/sslopenssl配置vi/etc/ld.so.conf#在/etc/ld.so.conf文件的最后面,添加如下內(nèi)容:/usr/local/openssl/lib

vi/etc/profileexportOPENSSL=/usr/local/openssl/binexportPATH=$PATH:$OPENSSL

source/etc/profileyuminstallopenssl-devel-y

#如無法yum下載安裝,請修改yum配置文件

測試:ldd/usr/local/openssl/bin/openssl

linux-vdso.so.1=>

(0x00007fff996b9000)

libdl.so.2=>/lib64/libdl.so.2(0x00000030efc00000)

libc.so.6=>/lib64/libc.so.6(0x00000030f0000000)

/lib64/ld-linux-x86-64.so.2(0x00000030ef800000)whichopenssl

/usr/bin/opensslopensslversion

OpenSSL1.0.0-fips29Mar2010keepalived安裝本文在4、3兩臺機(jī)器進(jìn)行keepalived安裝安裝tarzxvfkeepalived-1.2.13.tar.gzcdkeepalived-1.2.13./configure--prefix=/usr/local/keepalivedmakemakeinstallcp/usr/local/keepalived/sbin/keepalived/usr/sbin/cp/usr/local/keepalived/etc/sysconfig/keepalived/etc/sysconfig/cp/usr/local/keepalived/etc/rc.d/init.d/keepalived/etc/init.d/mkdir/etc/keepalivedcp/usr/local/keepalived/etc/keepalived/keepalived.conf/etc/keepalivedkeepalived配置建檢查Nginx是否存活的腳本#新建Nginx檢查vim/usr/local/nginx/check.sh內(nèi)容如下:#!/bin/bash#ThisscriptisusedbykeepalivedforcheckingnginxrunningstatusCHECK_TIME=2check(){curl-m2/status>/dev/null2>&1return$?}while[$CHECK_TIME-ne0]dolet"CHECK_TIME-=1"checkNGINX_OK=$?if[$NGINX_OK-eq0];thenexit0fiif[$NGINX_OK-ne1]&&[$CHECK_TIME-eq0]thenexit1fidonekeepalived.conf:vim/usr/local/keepalived/etc/keepalived/keepalived.confMaster:Master!ConfigurationFileforkeepalivedvrrp_scriptcheck_run{

script“/usr/local/nginx/check.sh"

interval2

weight2}vrrp_instanceVI_1{

stateMASTER

#3上改為Master

interfaceeth0

#對外提供服務(wù)的網(wǎng)絡(luò)接口

virtual_router_id51

#VRRP組名,兩個(gè)節(jié)點(diǎn)的設(shè)置必須一樣,以指明各個(gè)節(jié)點(diǎn)屬于同一VRRP組

priority150

#數(shù)值愈大,優(yōu)先級越高

advert_int1

#同步通知間隔

authentication{

#包含驗(yàn)證類型和驗(yàn)證密碼。類型主要有PASS、AH兩種,通常使用的類型為PASS,據(jù)說AH使用時(shí)有問題

auth_typePASS

auth_pass1111

}

track_script{

check_run

#調(diào)用腳本check.sh檢查haproxy是否存活

}

virtual_ipaddress{

#vip地址

03deveth0scopegloba

}}slave:slave!ConfigurationFileforkeepalivedvrrp_scriptchech_run{

script“/usr/local/nginx/check.sh"

interval2

weight2}vrrp_instanceVI_1{

stateBACKUP

#

interfaceeth0

#對外提供服務(wù)的網(wǎng)絡(luò)接口

virtual_router_id51

#VRRP組名,兩個(gè)節(jié)點(diǎn)的設(shè)置必須一樣,以指明各個(gè)節(jié)點(diǎn)屬于同一VRRP組

priority120

#數(shù)值愈大,優(yōu)先級越高,

advert_int1

#同步通知間隔

authentication{

#包含驗(yàn)證類型和驗(yàn)證密碼。類型主要有PASS、AH兩種,通常使用的類型為PASS,據(jù)說AH使用時(shí)有問題

auth_typePASS

auth_pass1111

}

track_script{

check_run

#調(diào)用腳本check.sh檢查haproxy是否存活

}

virtual_ipaddress{

#vip地址

03deveth1scopegloba

}

}Nginx配置文件新建upstreams.confupstreamuc_cluster{ip_hash;serverapp01:7060;#主機(jī)名+端口serverapp01:7061;}upstreampos_cluster{ip_hash;serverapp01:7060;#主機(jī)名+端口serverapp01:7061;}upstreammps_cluster{ip_hash;serverapp01:7060;serverapp01:7061;serverapp02:7060;}upstreamgms_cluster{ip_hash;serverapp01:7060;serverapp01:7061;serverapp02:7060;}...新建server.confserver{listen80;server_name; default_type'text/html'; charsetutf-8;#charsetkoi8-r;#access_loglogs/host.access.logmain; location~.*.*${ #index/portal; proxy_passhttp://uc_cluster; rewrite"^/+$"/portalbreak; } location^~/pos/{ proxy_passhttp://pos_cluster; } location^~/mps/{ proxy_passhttp://mps_cluster; } location^~/gms/{ proxy_passhttp://gms_cluster; } location^~/fas/{ proxy_passhttp://fas_cluster; } location^~/mdm/{ proxy_passhttp://mdm_cluster; } location^~/pms/{ proxy_passhttp://pms_cluster; proxy_connect_timeout600s; proxy_send_timeout300s; } location^~/crm/{ proxy_passhttp://crm_cluster; }#error_page404/404.html;#redirectservererrorpagestothestaticpage/50x.html#error_page500502503504/50x.html;location=/50x.html{roothtml;}}新建proxy.conf文件#!nginx(-)#proxy.confproxy_redirectoff;proxy_set_headerHost$host;proxy_set_headerX-Real-IP$remote_addr;#???ip#proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;#??úμ??ipclient_max_body_size10m;client_body_buffer_size128k;proxy_connect_timeout90;proxy_send_timeout90;proxy_read_timeout90;proxy_buffer_size4k;proxy_buffers432k;proxy_busy_buffers_size64k;proxy_temp_file_write_size64k;修改Nginx文件#usernobody;worker_processes4;error_loglogs/error.log;error_loglogs/error.lognotice;error_loglogs/error.loginfo;pidlogs/nginx.pid;events{useepoll;worker_connections1024;}http{includeupstreams.conf;includemime.types;default_typeapplication/octet-stream;includeproxy.conf;log_formatmain'$remote_addr-$remote_user[$

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論