您好,登錄后才能下訂單哦!
一、部署環(huán)境:(CentOS 6.9)
tracker server:10.10.1.105
storage server:10.10.1.106 10.10.1.107
client:10.10.1.105
二、FastDFS: 開源的輕量級分布式文件系統(tǒng);
三個(gè)角色:
tracker server :跟蹤服務(wù)器,調(diào)度,在內(nèi)存中記錄所有存儲組和存儲服務(wù)器的狀態(tài)信息; tracker.conf
storage server :存儲服務(wù)器,文件(data)和文件屬性(metadata),一組服務(wù)器; storage.conf
client :客戶端,業(yè)務(wù)請求發(fā)起方,通過專用接口基于TCP協(xié)議與tracker以及storage server進(jìn)行交互;client.conf
存儲:
group_name/M##/&&/&&/file_name
group_name :存儲組的組名;上傳完成后,需要客戶端自行保存;
M## :服務(wù)器配置的虛擬路徑,與磁盤選項(xiàng)store_path#對應(yīng);
兩級以兩位16進(jìn)制數(shù)字名字的目錄;
文件名:與原文件名并不相同;由storage server根據(jù)特定信息生成,文件名包含:源存儲服務(wù)器的IP地址、文件創(chuàng)建時(shí)間戳、文件大小、隨機(jī)數(shù)和文件擴(kuò)展名等;
三、安裝
1、安裝依賴包libfastcommon
2、安裝fastDFS
3、需要關(guān)閉iptables、selinux
安裝方式一:
# git clone https://github.com/happyfish200/fastdfs.git
# git clone https://github.com/happyfish200/libfastcommon.git
# git clone https://github.com/happyfish200/fastdfs-nginx-module.git
mv libfastcommon libfastcommon-1.0.36
tar zcf libfastcommon-1.0.36.tar.gz libfastcommon-1.0.36
mv fastdfs fastdfs-5.0.10
tar zcf fastdfs-5.0.10.tar.gz fastdfs-5.0.10
mkdir rpmbuild/{SOURCES,SPECS} -pv
cp /tools/libfastcommon-1.0.36.tar.gz rpmbuild/SOURCES/
cp /tools/fastdfs-5.0.10.tar.gz rpmbuild/SOURCES/
cp /tools/libfastcommon-1.0.36/libfastcommon.spec rpmbuild/SPECS/
cp /tools/fastdfs-5.0.10/fastdfs.spec rpmbuild/SPECS/
yum install rpm-build
rpmbuild -ba libfastcommon.spec
rpmbuild -ba fastdfs.spec
生成rpm包直接安裝即可
安裝方式二:
tar xzf libfastcommon_v1.23.tar.gz
cd libfastcommon
./make.sh
./make.sh install
tar xzf FastDFS_v5.08.tar.gz
cd FastDFS
./make.sh
./make.sh install
tracker和storage配置完成后測試上傳:
# fdfs_upload_file ./client.conf /usr/share/backgrounds/centos_2048x1536_logoonly.jpg
group1/M00/00/00/CgoBalkG2PmAThTWAAD_7aV8rDY985.jpg
四、安裝fastdfs-nginx-module模塊,通過http協(xié)議訪問文件
注:以下兩個(gè)文件需要復(fù)制到storage的目錄
cp fastdfs-5.0.10/conf/{http.conf,mime.types} /etc/fdfs/
安裝此模塊需要重新編譯nginx
1、./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_sub_module --add-module=/root/soft/fastdfs-nginx-module/src
2、nginx.conf 文件加入以下配置
location ~ /group[0-9]+/M00 {
root /home/fastdfs/data;
ngx_fastdfs_module;
}
3、ln -s /home/fastdfs/data /home/fastdfs/data/M00
4、配置mod_fastdfs.conf文件
cp /root/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
mod_fastdfs.conf重點(diǎn)配置項(xiàng):
tracker_server=10.10.1.105:22122
url_have_group_name = true ***開啟組名訪問
group_count = 1
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/home/fastdfs
5、重載nginx服務(wù)器
以組名訪問時(shí):
location ~ /group[0-9]+/M00 {
root /home/fastdfs/data;
ngx_fastdfs_module;
}
https://cache.yisu.com/upload/information/20200309/32/49826.jpg
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。