搜尋
首頁後端開發php教程FastDFS+Nginx輕量級分散式檔案系統安裝使用

一 簡介

FastDFS是一個開源的輕量分散式檔案系統,它對檔案進行同步)等,解決了大容量儲存和負載平衡的問題。特別適合以文件為載體的線上服務,如相簿網站、影片網站等等。

FastDFS服務端有兩個角色:追蹤器(tracker)和儲存節點(storage)。追蹤器主要做調度工作,在存取上起負載平衡的作用。

二 安裝

1, 本次安裝採用三台centos5.105050 月 Nginx(注意這台不安裝fastsfd-niginx 外掛

)

192.168.80.101  storage nginx

192.168.80.102次這裡的安裝作業系統

2, 準備編譯環境 

yum -y install gcc gcc+ gcc-c++ openssl  

nginx  useradd fastdfs -M -s /sbin/nologin sbin/nologin為了方便測試 請關閉防火牆 service iptables stop

3, 下載源碼敲 cd /usr/local/src/ 進入目錄下,執行如下指令,下載wget http:/ /jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Server%20Source%20Code/FastDFS%20Server%20with%20PHP%20Extension%20Source%20Code%20V5.01/FastDFS_v501. 下載 nginx 1.7.0

wget 

http://nginx.org/download/nginx-1.7.0.tar.gz

🜎

wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.g 4, 安裝FastDFS (三台機器都要安裝)

tar xf FastDFS_v5.01.tar.gz make.sh install  

5, 解壓fastDFS-nginx-module

[root@local ~]卷xf fastdfs-nginx -module_v1.16.tar.gz

6, 安裝Nginx

192.168。 host ~]# cd /usr/local /src/

[root@localhost src]# tar xf nginx-1.7.0

.tar.gz7.0

.tar.gz

.

[root@localhost nginx-

1.7.0]# ./configure --user=nginx

 --group=group🜎nginx

[root@localhost nginx-

1.7.0

]# make

[root@localhost nginx-c 192.168.80.101,102 stroage nginx的安裝

[root@localhost ~]# cd /usr/local/src/

[root@localhost src]# tarxf 

[root@localhost src]# cd nginx-

1.7.0

[root@localhost nginx-

1.7.0 --group =nginx --prefix=/usr/local/nginx

--add-module=../fastdfs-nginx-module/src需要載入此模組

[root@localhost nginx-1.7.0]# make[root@localhost make[root@localhost.

  三 配置

192.168.80.100 tracker的設定

1,建立tracker資料以及日誌存放目錄

/root@localaft 2,修改

FastDFS

tracker.conf設定 檔案[root@localhost ~]# vim /etc/fdfs/tracker.conf

/c

max_c /span>work_threads=8

store_lookup=0

store_path=0

run_by_group=fastdfs

run_by_user=fastdfs

rotate_error_log=true設定的解析請參考我的以一篇文章 

tracker

設定檔解析

3,修改 vim /usr/local/nginx/conf/nginx.conf

user 

nginx

 nginx/3

worker_processes 3;

pid /usr/local/nginx/logs/nginx.pid;

worker_rlimit_nosfile events {use epoll; // epoll

Linux

內核為處理大批量檔案描述子

而作了改良的poll

檔案描述;

} http {

include mime.types;

default_type application/octet [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"'; upstream server_g1 {server 192.168.

80.101

:80;

server 192.168.

80

.

102

:80;

}

:80;

}

server {

_listen

server {🜎

location /g1 {

proxy_redirect off; proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr) proxy_pass http://server_g1;

}

  }}

4,將tracker

. cp /usr/local/ src/FastDFS/init.d/fdfs_trackerd /etc/init.d/

[root@localhost ~]# chkconfig --add fdfs_trackerd🠎

設定

storage (分別在192.168.80.101,102

上進行設定)

1, root資料存放目錄-p /data/fastdfs /storage

/data

 

2,修改FastDFS

storage.conf.

group_name=g1

base_path=/data/fastdfs

##工作執行緒數,通常設定為 

CPU 

_path_count=1 store_path0=/data/fastdfs/storage

##tracker_server 的地址

tracker_server=192.168.

80.100

:22122

##運行 FastDFS 

的用戶組

run_by_group =fastdfs

##運行 

FastDFS 的使用者

run_by_user=fastdfs_

 

3,把nginx模組的設定檔拷貝到 /etc/fdfs中,進行修改

[root@local ~ /src/mod_fastdfs.conf /etc/fdfs/

[root@localhost ~]# vim /etc/fdfs/mod_fastdfs.conf

.>

80.100

:22122

group_name=g1

url_have_group_name = true

store_path_count = true

store_path_count_count.

 

4,修改

nginx

設定檔

[root@localhost ~]# vim /usr/local/nginx/conf/nginx.confuser 

worker_processes 8;

pid /usr/local/nginx/logs/nginx.pid;worker_rlimit_nofile 1024 use epoll;

worker_connections 

1024

;

}http {

include mime.types; main '$remote_addr - $remote_user [$time_local] " $request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" inx/logs/access.log main;server {

listen 80;

server_name localhost0

server_name localhost0/root dfs/storage/data;

ngx_fastdfs_module;

}

  

}

}}

[root@localhost ~]# cp /usr/local/src /FastDFS/init.d/fdfs_storaged /etc/init.d/

[root@localhost ~]# config --add fdfs_storaged)

[ root@localhost ~]# service fdfs_storaged start

service管理並設定開機啟動

//建立軟體data /data/fastdfs/storage/data/M00

 

四 測試

1,在

192.168.80.

[root@localhost ~]# service fdfs_trackerd start

[root@localhost ~]# /usr/local/nginx/sbin/nginx2,在上面啟動.和

nginx

[root@localhost ~]# service fdfs_storaged start

[root@localhostŜ~]# /usr/local/ tracker上進行

[root@localhost ~]# vim /etc/fdfs/client.conf

base_path=/data/fastdfs

base_path=/data/fastdfs

:

4,查看叢集詳細

[root@localhost ~]# fdfs_monitor /etc/fdfs/client.conf

 _g5,測量upload_file /etc/fdfs/ client.conf aa.jpg

 

g1/M00/AC/2F/wKgKDVMppoGAMCFNAAIFvJcyojY165.jpg

http://192.168.80.101 /g1/M00/AC/2F/wKgKDVMppoGAMCFNAAIFvJcyojY165.jpghttp://192.168.

80.102🟎 65.jpg

以上就介紹了FastDFS+Nginx輕量級分散式檔案系統安裝使用,包含了方面的內容,希望對PHP教學有興趣的朋友有所幫助。

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
PHP與Python:了解差異PHP與Python:了解差異Apr 11, 2025 am 12:15 AM

PHP和Python各有優勢,選擇應基於項目需求。 1.PHP適合web開發,語法簡單,執行效率高。 2.Python適用於數據科學和機器學習,語法簡潔,庫豐富。

php:死亡還是簡單地適應?php:死亡還是簡單地適應?Apr 11, 2025 am 12:13 AM

PHP不是在消亡,而是在不斷適應和進化。 1)PHP從1994年起經歷多次版本迭代,適應新技術趨勢。 2)目前廣泛應用於電子商務、內容管理系統等領域。 3)PHP8引入JIT編譯器等功能,提升性能和現代化。 4)使用OPcache和遵循PSR-12標準可優化性能和代碼質量。

PHP的未來:改編和創新PHP的未來:改編和創新Apr 11, 2025 am 12:01 AM

PHP的未來將通過適應新技術趨勢和引入創新特性來實現:1)適應云計算、容器化和微服務架構,支持Docker和Kubernetes;2)引入JIT編譯器和枚舉類型,提升性能和數據處理效率;3)持續優化性能和推廣最佳實踐。

您什麼時候使用特質與PHP中的抽像類或接口?您什麼時候使用特質與PHP中的抽像類或接口?Apr 10, 2025 am 09:39 AM

在PHP中,trait適用於需要方法復用但不適合使用繼承的情況。 1)trait允許在類中復用方法,避免多重繼承複雜性。 2)使用trait時需注意方法衝突,可通過insteadof和as關鍵字解決。 3)應避免過度使用trait,保持其單一職責,以優化性能和提高代碼可維護性。

什麼是依賴性注入容器(DIC),為什麼在PHP中使用一個?什麼是依賴性注入容器(DIC),為什麼在PHP中使用一個?Apr 10, 2025 am 09:38 AM

依賴注入容器(DIC)是一種管理和提供對象依賴關係的工具,用於PHP項目中。 DIC的主要好處包括:1.解耦,使組件獨立,代碼易維護和測試;2.靈活性,易替換或修改依賴關係;3.可測試性,方便注入mock對象進行單元測試。

與常規PHP陣列相比,解釋SPL SplfixedArray及其性能特徵。與常規PHP陣列相比,解釋SPL SplfixedArray及其性能特徵。Apr 10, 2025 am 09:37 AM

SplFixedArray在PHP中是一種固定大小的數組,適用於需要高性能和低內存使用量的場景。 1)它在創建時需指定大小,避免動態調整帶來的開銷。 2)基於C語言數組,直接操作內存,訪問速度快。 3)適合大規模數據處理和內存敏感環境,但需謹慎使用,因其大小固定。

PHP如何安全地上載文件?PHP如何安全地上載文件?Apr 10, 2025 am 09:37 AM

PHP通過$\_FILES變量處理文件上傳,確保安全性的方法包括:1.檢查上傳錯誤,2.驗證文件類型和大小,3.防止文件覆蓋,4.移動文件到永久存儲位置。

什麼是無效的合併操作員(??)和無效分配運算符(?? =)?什麼是無效的合併操作員(??)和無效分配運算符(?? =)?Apr 10, 2025 am 09:33 AM

JavaScript中處理空值可以使用NullCoalescingOperator(??)和NullCoalescingAssignmentOperator(??=)。 1.??返回第一個非null或非undefined的操作數。 2.??=將變量賦值為右操作數的值,但前提是該變量為null或undefined。這些操作符簡化了代碼邏輯,提高了可讀性和性能。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
3 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。