Linux搭建FastFDFS檔案管理系統搭建,部署及上傳材料

來源:互聯網
上載者:User

標籤:rom   功能   erro   for   檔案名稱   1.0   自己的   刪除檔案   base   

昨天下午花了三四個小時在Linux centos 6 上搭建了一個Distributed File System。純粹是搭建來做自己的檔案備份。所以把一些自己在其中遇到的一些問題給總結出來,免得更多人走錯路。

 

 FastDFS 的一些介紹(英文來自官方github):

 

FDFS , 開源Distributed File System。主要的功能是:檔案儲存體,同步,存取(上傳和下載),它可以解決高容量和運載平衡的問題。FastDFS是符合了那些 圖片,視頻,照片分享的網站的需求。

FDFS 有分別有 tracker 和 storage 兩個角色。tracker 負責安排和平衡檔案的操作。storage 負責隱藏檔和其它對檔案的操作(檔案的儲存,同步,提供訪問檔案的介面)。通過key&value檔案的方式進行展現中繼資料。例如:width=1024,key為width 則 value為"1024" 

trackerd 可以是一個或者多個的伺服器。在 tracker 叢集或者 storaged 叢集中你可以隨時隨地可以添加或者移除叢集而絲毫不影響線上的網站。tracker 叢集變得越來越流行了。

storaged  組合檔案的容量或者群組去獲得高容量。storage 系統包含著一個或者多個在這些沒有任何聯絡的容量卷。整個storage 系統的容量相當於所有容量的總和。一個檔案卷可以包含一個或更多的儲存類型是相同的storaged 伺服器。

當整個storage 的容量爆了,你可以繼續添加更多的捲去擴大記憶體。所以,你需要更多的伺服器。...

卷名和檔案名稱是組成身份認證的兩個部分。

用戶端測試的代碼請參考目錄:client / test

 

 

FastDFS的搭建過程:

從搭建部署到測試成功需要 9 步:

 

#step 1. download libfastcommon source package from github and install it,

   the github address:

   https://github.com/happyfish100/libfastcommon.git

  下載libfastcommon 資源套件 

 

#step 2. download FastDFS source package and unpack it, 

tar xzf FastDFS_v5.x.tar.gz

#for example:

tar xzf FastDFS_v5.08.tar.gz

  下載FastDFS 的資源套件並解壓

 

#step 3. enter the FastDFS dir

cd FastDFS

   進入FastDFS解壓後的檔案夾

#step 4. execute:

./make.sh

   安裝

   

 

#step 5. make install

./make.sh install

   安裝

#step 6. edit/modify the config file of tracker and storage

   修改 tracker.conf 和 storage.conf 兩個設定檔 

 

#step 7. run server programs

#start the tracker server:

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

#in Linux, you can start fdfs_trackerd as a service:

/sbin/service fdfs_trackerd start

 

 

#start the storage server:

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

#in Linux, you can start fdfs_storaged as a service:

/sbin/service fdfs_storaged start

   其中storage 和 tracker 兩個服務

 

#step 8. run test program

#run the client test program:

/usr/bin/fdfs_test <client_conf_filename> <operation>

/usr/bin/fdfs_test1 <client_conf_filename> <operation>

#for example, upload a file:

/usr/bin/fdfs_test conf/client.conf upload /usr/include/stdlib.h

    測試 

  

#step 9. run monitor program

#run the monitor program:

/usr/bin/fdfs_monitor <client_conf_filename>

    通過moniter檢測項目運行情況

 

 

 

 

接下來我們進行正確的步驟:

 

所需軟體包的github地址:

FastDFS       : https://github.com/happyfish100/fastdfs.git  

libfastcommon : https://github.com/happyfish100/libfastcommon.git  

 

所需的的環境:

Linux centos 6.5或者以上

如果系統沒有gcc,那就命令列( yum install gcc )進行安裝

 

 

 

下載:

 

cd /opt && mkdir fastdfs && cd fastdfs                            #在opt目錄下建立檔案夾 fastdfs git clone https://github.com/happyfish100/fastdfs.git                  #下載FastDFSgit clone https://github.com/happyfish100/libfastcommon.git               #下載libfastcommoncd /opt/fastdfs/libfastcommon                                #進入目錄進行安裝./make.sh && ./make.sh install  cd /opt/fastdfs/fastdfs  ./make.sh && ./make.sh install  

 

 

設定檔:

所有的設定檔都在 /usr/bin/fdfs/ 下 :

client.conf.sample  storage.conf.sample  storage_ids.conf.sample  tracker.conf.sample

 

cd /etc/fdfsmv tracker.conf.sample  tracker.confmv storage.conf.sample storage.conf.sample
mv client.conf.sample client.conf.sample

 

 

 

修改設定檔的內容如下:

storage.conf

# the base path to store data and log filesbase_path=/mnt/xfsd/fastdfs/storage# store_path#, based 0, if store_path0 not exists, it‘s value is base_path# the paths must be existstore_path0=/mnt/xfsd/fastdfs/storage# tracker_server can ocur more than once, and tracker_server format is#  "host:port", host can be hostname or ip addresstracker_server=host:22122#standard log level as syslog, case insensitive, value list:### emerg for emergency### alert### crit for critical### error### warn for warning### notice### info### debuglog_level=debug# the port of the web server on this storage serverhttp.server_port=80

 

 

bash_path 是storage儲存的資料和日誌的地址

store_path0 和bash_path一樣,只不過這個是優先儲存的地址,如果不存在,預設是bash_path

tracker_server 是指tracker服務角色的 地址:連接埠。(如果tracker 和 storage 是同一個伺服器的話,那麼就填寫伺服器的ip和地址。)

log_level 是輸出日誌的層級設計

http.server_port 是http服務的接受連接埠

 

tracker.conf

# the tracker server portport=22122# the base path to store data and log filesbase_path=/mnt/xfsd/fastdfs/tracker/# HTTP port on this tracker serverhttp.server_port=80

 

 

修改後可以啟動服務了

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf  (start | restart | stop)/usr/bin/fdfs_storaged /etc/fdfs/storage.conf  (start | restart | stop)

 

檢查服務:

/usr/bin/fdfs_moniter /etc/fdfs/storaged.conf 

開啟連接埠(我用的是iptables,簡單便捷就可以配置了,可以去網上看下怎麼安裝iptables):

 

 

最後,進行測試:

fdfs_delete_file              # 刪除檔案       fdfs_upload_file               #上傳檔案fdfs_test                         # 測試檔案fdfs_download_file                    #下載檔案

 

拿fdfs_test來測試:

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /目標檔案路徑 

 

成功後會有以下資訊:

 

Linux搭建FastFDFS檔案管理系統搭建,部署及上傳材料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.