FastFDS 檔案服務系統

2021-08-06 07:01:12 字數 3372 閱讀 3898

1.1什麼是fastfds

1.2fastfds架構

如圖:

1.3tracker集群

fastdfs 集群中的 tracker server 可以有多台,tracker server 之間是相互平等關係同時提供服務,tracker server 不存在單點故障。客戶端請求 tracker server 採用輪詢方式,如果請求的 tracker 無法提供服務則換另乙個 tracker。

1.4storager集群

storage 集群採用了分組儲存方式。storage 集群由乙個或多個組構成,集群儲存總容量為集群中所有組的儲存容量之和。乙個組由一台或多台儲存伺服器組成,組內的 storage server 之間是平等關係,不同組的 storage server 之間不會相互通訊,同組內的 storage server之間會相互連線進行檔案同步,從而保證同組內每個 storage 上的檔案完全一致的。乙個組的儲存容量為該組內儲存伺服器容量最小的那個,由此可見組內儲存伺服器的軟硬體配置最好是一致的。

採用分組儲存方式的好處是靈活、可控性較強。比如上傳檔案時,可以由客戶端直接指定上傳到的組也可以由 tracker 進行排程選擇。乙個分組的儲存伺服器訪問壓力較大時,可以在該組增加儲存伺服器來擴充服務能力(縱向擴容)。當系統容量不足時,可以增加組來擴充儲存容量(橫向擴容)。

1.5storage 狀態收集

1.6檔案上傳流程

客戶端上傳檔案後儲存伺服器將檔案 id 返回給客戶端,此檔案 id 用於以後訪問該檔案的索引資訊。檔案索引資訊包括:組名,虛擬磁碟路徑,資料兩級目錄,檔名。

組名:檔案上傳後所在的 storage 組名稱,在檔案上傳成功後有 storage 伺服器返回,需要客戶端自行儲存。

虛擬磁碟路徑:storage 配置的虛擬路徑,與磁碟選項 store_path*對應。如果配置了store_path0 則是 m00,如果配置了 store_path1 則是 m01,以此類推。

資料兩級目錄:storage 伺服器在每個虛擬磁碟路徑下建立的兩級目錄,用於儲存資料檔案。

檔名:與檔案上傳時不同。是由儲存伺服器根據特定資訊生成,檔名包含:源儲存伺服器、 ip 位址、檔案建立時間戳、檔案大小、隨機數和檔案拓展名等資訊

1.7linux上安裝fastdfs

1.8**測試–上傳

①環境準備,準備client.conf配置檔案,準備jar包

tracker_server=192.168.25.133:22122
②測試**

@test

public

void

uploadpic() throws exception

}

1.9fastfds工具類

package cn.e3.utils;

import org.csource.common.namevaluepair;

import org.csource.fastdfs.clientglobal;

import org.csource.fastdfs.storageclient1;

import org.csource.fastdfs.storageserver;

import org.csource.fastdfs.trackerclient;

import org.csource.fastdfs.trackerserver;

public

class

fastdfsclient

clientglobal.init(conf);

trackerclient = new trackerclient();

trackerserver = trackerclient.getconnection();

storageserver = null;

storageclient = new storageclient1(trackerserver, storageserver);

}/**

* 上傳檔案方法

* title: uploadfile

* description:

*@param filename 檔案全路徑

*@param extname 副檔名,不包含(.)

*@param metas 檔案擴充套件資訊

*@return

*@throws exception

*/public string uploadfile(string filename, string extname, namevaluepair metas) throws exception

public string uploadfile(string filename) throws exception

public string uploadfile(string filename, string extname) throws exception

/*** 上傳檔案方法

* title: uploadfile

* description:

*@param filecontent 檔案的內容,位元組陣列

*@param extname 副檔名

*@param metas 檔案擴充套件資訊

*@return

*@throws exception

*/public string uploadfile(byte filecontent, string extname, namevaluepair metas) throws exception

public string uploadfile(byte filecontent) throws exception

public string uploadfile(byte filecontent, string extname) throws exception

}

1.10工具類測試**

@test

public

void

uploadpicbyutils() throws exception

linux系統檔案服務

ftp是tcp ip協議組中應用層的協議之一 給使用者提供檔案共享服務,網際網路上的 資源和軟體資源。絕大部分都是通過ftp伺服器傳遞 控制埠 command 21 tcp 資料埠 data 20 tcp ftpserver 預設配置 安裝vsftp yum y install vsftpd 準備要...

Linux系統Samba檔案共享服務

一 samba伺服器的安裝 確認安裝以下軟體包 root test rpm qa grep samba samba common 3.0.10 1.4e.9 samba client 3.0.10 1.4e.9 system config samba 1.2.21 1 samba swat 3.0....

配置網路檔案系統NFS服務

這個也頭痛了好久,之前可以再開發板和linux之間相互ping通,然後linux那邊要啟動好nfs服務。我是再home nfs目錄下的,修改 etc 目錄下exports檔案為 home nfs sync,rw 然後進入 etc init.d 目錄下面有個 nfs kernel server 將它r...