dubbo教程高可用架構(gòu)篇第09節(jié)fastdfs集群的安裝_第1頁
dubbo教程高可用架構(gòu)篇第09節(jié)fastdfs集群的安裝_第2頁
dubbo教程高可用架構(gòu)篇第09節(jié)fastdfs集群的安裝_第3頁
dubbo教程高可用架構(gòu)篇第09節(jié)fastdfs集群的安裝_第4頁
dubbo教程高可用架構(gòu)篇第09節(jié)fastdfs集群的安裝_第5頁
免費(fèi)預(yù)覽已結(jié)束,剩余13頁可下載查看

下載本文檔

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

文檔簡(jiǎn)介

FastDFS 介紹(參考:FastDFS是一個(gè)開源的分布式文件系統(tǒng),它對(duì)文件進(jìn)行管理,功能包括:文件、文件同步、文件(文件上傳、文件)等,解決了大容量和負(fù)載均衡的問題。特別適合以文件為載體的服務(wù),如相冊(cè)、等等。上起負(fù)載均衡的作用。節(jié)點(diǎn)文件,完成文件管理的所有功能:、同步和提供存取接口,valuepair)方式表示,如:width=1024,其中的key為width,value為1024。文件metadata是文件屬性列表,可以包含多個(gè)鍵值對(duì)。FastDFS系統(tǒng)結(jié)構(gòu)如下圖所示:和節(jié)點(diǎn)都可以由一臺(tái)多臺(tái)服務(wù)器構(gòu)成。和節(jié)點(diǎn)中的服務(wù)器均可以隨時(shí)增加或下為了支持大容量,節(jié)點(diǎn)(服務(wù)器)采用了分卷(或分組)的組織方式。系統(tǒng)由一個(gè)或多個(gè)卷組成,卷與卷之間的文件是相互獨(dú)立的,所有卷的文件容量累加就是整個(gè)系統(tǒng)中的文件容量。一個(gè)卷可以由一臺(tái)或多臺(tái)服務(wù)器組成,一個(gè)卷下的服務(wù)器中的文件都是相同的,卷中的多臺(tái)服務(wù)器FastDFS客戶端發(fā)起對(duì)FastDFS的文件傳輸動(dòng)作,是通過連接到某一臺(tái)TrackerServer的指定端口來實(shí)現(xiàn)的,TrackerServer來決定選擇哪一臺(tái)StorageServerStorageServer的地址等信息返回給,然后再通過這些信息連接到這臺(tái)StorageServer,將要上傳的文件傳送到給StorageServer上。 FastDFS服務(wù)器 服務(wù)器 服務(wù)器1:35 服務(wù)器2:36 服務(wù)器3:37 服務(wù)器 環(huán)境:CentOS數(shù) 安裝包(隨壓縮包提供FastDFSvmon-mter.ip是從FastDFS和FastDHT中提取出來的公共C函數(shù)庫i-le.t..t.zjv.2.g 地址:: r(FastDFS+NginxTrar(FastDFS+Nginx e(FastDFS+NginxGroupStorage(FastDFS+NginxStorage(FastDFS+NginxStorage(FastDFS+Nginx2(Keepalived+Nginx1(Keepalived+NginxFastDFS集Group本的FastDFS文件系統(tǒng)集群的最終結(jié)構(gòu)Group #yuminstallmakecmakegccgcc-mon#cd#unzip #cd ##./make.sh 因?yàn)镕astDFS主程序設(shè)置的lib 是/usr/local/lib,所以需要?jiǎng)?chuàng)建軟.#ln-s mon.so mon.soln-s mon.so #ln-s/usr/lib64/libfdfs.so/usr/local/lib/libfdfs.so#ln-s/usr/lib64/libfdfs.so/usr/lib/libfdfs.so #cd#tar-zxvfFastDFS_v5.05.tar.gz#cdFastDFS #./make.sh#./make.sh #cd/usr/bin/#ls|grepfdfs和/etc/init.d/fdfs_tracker兩個(gè)中的/usr/local/bin修改成/usr/bin:#vi#vi/etc/init.d/fdfs_storaged注意:以上操作無論是配置tracker還是配置storage是必須的,而trackerstorage區(qū)別主要是在安裝完fastdfs之后的配置過程中。二、配置 Tracker.6..13、91811、FastDFS樣例配置文件,并重命名:#cd/etc/fdfs/cptracker.conf.sampletracker.conf2、編輯配置文件:#vi -1-1.html3、創(chuàng)建基礎(chǔ)數(shù)據(jù) #mkdir-p/fastdfs/tracker#vi/etc/sysconfig/iptables##FastDFSTracker-AINPUT-mstate--stateNEW-mtcp-ptcp--dport22122-j重啟#serviceiptables#/etc/init.d/fdfs_trackerd 下創(chuàng)建data、logs兩個(gè) 看tracker是否啟動(dòng)成功:tail-100f/#/etc/init.d/fdfs_trackerd#vi##FastDFS/etc/init.d/fdfs_trackerd三、配置FastDFS(191..35、126.16、37、19...38#cd/etc/fdfs/#cpstorage.conf.sample#vi #設(shè)置storage #路 #tracker服務(wù)器的IP地址和端口 #多個(gè)tracker直接添加多條配置 #設(shè)置http端-1-1.html)3、創(chuàng)建基礎(chǔ)數(shù)據(jù) #mkdir-p/fastdfs/storage#vi/etc/sysconfig/iptables##FastDFSStorage-AINPUT-mstate--stateNEW-mtcp-ptcp--dport23000-j重啟#serviceiptables#/etc/init.d/fdfs_storaged(初次成功啟動(dòng),會(huì)在/fastdfs/storage下創(chuàng)建數(shù)據(jù)data各節(jié)點(diǎn)啟動(dòng)動(dòng),使用tail-f/fastdfs/storage/logs/storaged.log命令節(jié)點(diǎn)日志,可以/usr/bin/fdfs_monitor #/etc/init.d/fdfs_storaged#vi##FastDFS/etc/init.d/fdfs_storaged四、文件上傳測(cè)試(19.611#cp/etc/fdfs/.conf.sample/etc/fdfs/.conf#vi/etc/fdfs/.conf#/usr/bin/fdfs_upload_file/etc/fdfs/.confID件六、在各節(jié)點(diǎn)12.8.15、121816、918117、9.18..3)上安 作FastDFS通過Tracker服務(wù)器,將文件放在Storage服務(wù)器,但是同組服務(wù)器之間需要進(jìn)入文件,有同步延遲的問題。假設(shè)Tracker服務(wù)器將文件上傳到了35,上傳成功后文件ID已經(jīng)返回給客戶端。此時(shí)FastDFS集群機(jī)制會(huì)將這個(gè)文件同步到同組36,在文件還沒有完成的情況下,客戶端如果用這個(gè)文件ID在36上取文件,就會(huì)出現(xiàn)文件無法的錯(cuò)誤。而fastdfs-nginx-module可以重定向文件連接到源服務(wù)器取文件,避免客戶端由于延遲導(dǎo)致的文件無法錯(cuò)誤。(解壓后的fastdfs-nginx-module在nginx安裝時(shí)使用)傳到/#cd#tar-zxvffastdfs-nginx-#vi/usr/local/src/fastdfs-nginx-CORE_INCS="$CORE_INCS/usr/local/include/fastdfs 修改為:CORE_INCS="$CORE_INCS/usr/include/fastdfs 本#yuminstallgccgcc-c++makeautomakeautoconflibtoolpcrepcre-develzlibzlib-developensslopenssl-devel#cd#tar-zxvfnginx-1.6.2.tar.gz#cdnginx-1.6.2#./configure--prefix=/usr/local/nginx--add-module=/usr/local/src/fastdfs-nginx-module/src#make&&makeinstall #cp/usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/#vi/etc/fdfs/mod_fastdfs.confurl_have_group_name=truegroup_count=2#cd/usr/local/src/FastDFS/conf#cphttp.confmime.types9、在/fastdfs/storage文件下創(chuàng)建軟連接,將其到實(shí)際存放數(shù)據(jù)的 ln-s/fastdfs/storage/data//fastdfs/storage/data/M0010、配置Nginx,簡(jiǎn)潔版nginx配置樣例:#vi/usr/local/nginx/conf/nginx.confuserroot;worker_processes1;events{worker_connections}http default_typeapplication/octet-stream; keepalive_timeout65;server{ server_namelocalhost;location~/group([0-9])/M00{} 500502503504/50x.html;location=/50x.html{ }}}因?yàn)閔ttp.server_port默認(rèn)為8888,如果想改成80,則要對(duì)應(yīng)修改過來。對(duì)應(yīng)的Nginx配置為:location~/group([0-{}11、中打開Nginx的8888端口#vi/etc/sysconfig/iptables##Nginx-AINPUT-mstate--stateNEW-mtcp-ptcp--dport8888-j重 :#serviceiptables12、啟動(dòng)#/usr/local/nginx/sbin/nginxngx_http_fastdfs_setpid=xxx設(shè)置Nginx開機(jī)啟動(dòng)#vi七、在節(jié)點(diǎn)12.8.11、1218.13)上安 #yuminstallgccgcc-c++makeautomakeautoconflibtoolpcrepcre-develzlibzlib-developensslopenssl-devel傳到#cd#tar-zxvfngx_cache_purge-5、編譯安裝Nginx(添加ngx_cache_purge模塊)#cd#tar-zxvfnginx-1.6.2.tar.gz#cdnginx-1.6.2#./configure--prefix=/usr/local/nginx--add-module=/usr/local/src/ngx_cache_purge-2.3#make&&makeinstall#vi/usr/local/nginx/conf/nginx.confuserroot;worker_processes#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo; eventsworker_connections1024;useepoll;}http default_typeapplication/octet-'$remote_addr-$remote_user[$time_local]"$request"#'$status$body_bytes_sent"$http_referer"#'"$http_user_agent"#access_loglogs/access.log #keepalive_timeoutkeepalive_timeout#gzipon;server_names_hash_bucket_size128;_header_buffer_size32k;large__header_buffers432k;_max_body_size300m;_redirect_set_headerHost_set_headerX-Real-IP_set_headerX-Forwarded-For _connect_timeout_send_timeout_read_timeout_buffer_size_buffers4_busy_buffers_size_cache_path/fastdfs/cache/nginx/ _cachelevels=1:2keys_zone=http-cache:200mmax_size=1ginactive=30d;_temp_path/fastdfs/cache/nginx/ #設(shè)置group1的服務(wù)器upstreamfdfs_group1server35:8888weight=1max_fails=2fail_timeout=30s;server36:8888weight=1max_fails=2}#設(shè)group2服upstreamfdfs_group2server37:8888weight=1max_fails=2fail_timeout=30s;server38:8888weight=1max_fails=2}server server_namelocalhost;#charsetkoi8-#access_loglogs/host.access.logmain;#設(shè)置group的負(fù)載均衡參數(shù)location/group1/M00_next_upstreamhttp_502http_504errortimeout_cachehttp-_cache_valid200304_passexpires}location/group2/M00_next_upstreamhttp_502http_504errortimeout_cachehttp-_cache_valid200304_passexpires}location~/purge(/.*){allow;allow/24;denyall;_cache_purgehttp-cache}#error_page #redirectservererrorpagestothestaticpage/50x.html 500502503504/50x.html;location=/50x.html{ }}} #mkdir-p #mkdir-p 7、系統(tǒng)打開對(duì)應(yīng)的端口vietc/sysconfig/iptables##Nginx-AINPUT-mstate--stateNEW-mtcp-ptcp--dport8000-jACCEPT#serviceiptablesrestart##/usr/local/nginx/sbin/nginx-sNginx機(jī)啟#vi前面直接通過Storage節(jié)點(diǎn)中的Nginx的文Tracker1中的NginxTracker2中的Nginx由上面的文件效果可以看到,每一個(gè)Tracker中的Nginx都單獨(dú)對(duì)后端的Storage組做了負(fù)載均衡,但整套FastDFS集群如果想對(duì)外提供統(tǒng)一的文 地址,還需要對(duì)兩個(gè)Tracker中的Nginx進(jìn)行HA集群八、使用Kelv+ix組成的高可用負(fù)載均衡集群做兩個(gè)Trackerix的負(fù)載均 r(FastDFS+NginxTrar(FastDFS+Nginx e(FastDFS+NginxGroupStorage(FastDFS+NginxStorage(FastDFS+NginxStorage(FastDFS+Nginx2(Keepalived+Nginx1(Keepalived+NginxFastDFS集GroupGroup(12Nginx行相同的配置)#vi/usr/local/nginx/conf/nginx.confuserroot;worker_processes1;#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo; eventsworker_connections}http default_typeapplication/octet-#log_formatmain'$remote_addr-$remote_user[$time_local]"$requ

溫馨提示

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

評(píng)論

0/150

提交評(píng)論