[TOC]
百度百科:
FastDFS是一個(gè)開源的輕量級(jí)分布式文件系統(tǒng)蛀序,它對(duì)文件進(jìn)行管理群叶,功能包括:文件存儲(chǔ)、文件同步储耐、文件訪問(wèn)(文件上傳羊初、文件下載)等,解決了大容量存儲(chǔ)和負(fù)載均衡的問(wèn)題什湘。特別適合以文件為載體的在線服務(wù)长赞,如相冊(cè)網(wǎng)站、視頻網(wǎng)站等等闽撤。
FastDFS為互聯(lián)網(wǎng)量身定制得哆,充分考慮了冗余備份、負(fù)載均衡哟旗、線性擴(kuò)容等機(jī)制贩据,并注重高可用、高性能等指標(biāo)闸餐,使用FastDFS很容易搭建一套高性能的文件服務(wù)器集群提供文件上傳饱亮、下載等服務(wù)。
FastDFS項(xiàng)目地址:https://github.com/happyfish100
FastDFS架構(gòu)圖:
通過(guò)架構(gòu)圖可以很清晰的看出FastDFS由兩個(gè)核心模塊組成Tracker(跟蹤器)舍沙、Storage(存儲(chǔ)器)近上。
FastDFS安裝
第一步:克隆libfastcommon項(xiàng)目
編譯、安裝: ./make.sh &&./make.sh install
第二步:克隆fastdfs項(xiàng)目
編譯拂铡、安裝: ./make.sh &&./make.sh install
安裝完成后會(huì)在/etc/init.d下生成兩個(gè)可執(zhí)行腳本fdfs_storaged和fdfs_trackerd戈锻。
FastDFS配置
配置tracker服務(wù)
編輯配置文件
[root@hmhbt tracker]# cd /etc/fdfs/
[root@hmhbt fdfs]# cp tracker.conf.sample tracker.conf
[root@hmhbt fdfs]# vim tracker.conf
#啟用配置文件
disabled=false
#設(shè)置tracker的端口號(hào)
port=22122
#設(shè)置tracker的數(shù)據(jù)文件和日志目錄(需手動(dòng)創(chuàng)建)
base_path=/mnt/fastdfs/tracker
#設(shè)置http端口號(hào)
http.server_port=9090
創(chuàng)建base_path路徑
mkdir -p /mnt/fastdfs/tracker
防火墻打開22122端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT
啟動(dòng)tracker服務(wù)器
/etc/init.d/fdfs_trackerd start
配置storage服務(wù)
[root@hmhbt /]# cd /etc/fdfs
[root@hmhbt fdfs]# cp storage.conf.sample storage.conf
# 修改的內(nèi)容如下:
disabled=false # 啟用配置文件
port=23000 # storage服務(wù)端口
base_path=/mnt/fastdfs/storage # 數(shù)據(jù)和日志文件存儲(chǔ)根目錄
store_path0=/mnt/fastdfs/storage #第一個(gè)存儲(chǔ)目錄,第二個(gè)存儲(chǔ)目錄起名為:store_path1=xxx和媳,其它存儲(chǔ)目錄名依次類推...
store_path_count=1 # 存儲(chǔ)路徑個(gè)數(shù)格遭,需要和store_path個(gè)數(shù)匹配
tracker_server=192.168.1.200:22122 # tracker服務(wù)器IP和端口 可配置多個(gè)
tracker_server=192.168.1.200:22122
創(chuàng)建base_path
[root@hmhbt fdfs]# mkdir -p /mnt/fastdfs/storage
防火墻開啟23000端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 23000 -j ACCEPT
啟動(dòng)storage
[root@hmhbt fdfs]# /etc/init.d/fdfs_storaged start
文件上傳測(cè)試
修改Tracker服務(wù)器客戶端配置文件
[root@hmhbt fdfs]# cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
[root@hmhbt fdfs]# vim /etc/fdfs/client.conf
# 修改以下配置,其它保持默認(rèn)
base_path=/mnt/fastdfs/tracker
tracker_server=192.168.1.200:22122
[root@hmhbt bin]# cd /usr/bin
[root@hmhbt bin]# ./fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/EB5B05F395308337453689873914EB94.jpg
group1/M00/00/00/wKgByFkjAXeAFwc3AAGX2D-yq14580.jpg
返回文件ID號(hào):group1/M00/00/00/wKgByFkjAXeAFwc3AAGX2D-yq14580.jpg
FastDFS介紹(官方文檔):http://download.csdn.net/detail/xyang81/9656542
FastDFS配置文件詳解:http://download.csdn.net/detail/xyang81/9656557
以上屬于原創(chuàng)文章留瞳,轉(zhuǎn)載請(qǐng)注明作者@怪咖
QQ:208275451