FastDFS安裝使用實戰二(配置篇)

1、FastDFS簡介html

FastDFS是一個我的開發的、輕量級的、開源的分佈式文件系統,純C語言編寫,其功能包括:文件存儲、文件同步、文件訪問(文件上傳、文件下載)等,解決了大容量存儲和負載均衡的問題,具備穩定、高效、易用的優勢。linux

更多詳見:FastDFS主頁:http://code.google.com/p/fastdfs/服務器

做者爲版主的討論區:http://linux.chinaunix.net/bbs/forum-75-1.html  app

2、安裝環境負載均衡

一、操做系統:Ubuntu 9.10 32bitdom

二、部署結構:1個tracker、1個storage(1組),PC單機(即tracker、storage均在同一臺電腦上) 分佈式

3、安裝過程工具

官方安裝文檔:http://code.google.com/p/fastdfs/wiki/Setup  測試

一、獲取安裝包:從項目主頁(http://code.google.com/p/fastdfs/downloads/list )下載部署包 FastDFS_v1.29.tar.gz (FastDFS Server with PHP client extension source code V1.29, 2010-6-30最新發布版本)。google

二、解壓安裝包,而後切換到解壓後的 FastDFS 主目錄執行安裝,即依次執行:

Cmd代碼

  1. tar xzf FastDFS_v1.29.tar.gz   

  2. cd FastDFS   

  3. ./make.sh   

  4. ./make.sh install  

注意:

1)若是沒法執行,則須要先安裝gcc,Ubuntu系統可經過:sudo apt-get install gcc 安裝。
2)Ubuntu系統上安裝時須要將 make.sh 最後一段if去掉(從 if [ "$uname" = "Linux" ]; then 開始到倒數第2行),不然 ./make.sh install 時會報錯。
3)執行./make.sh install時可能須要 root 權限。
 
 

3a、配置tracker

1)在FastDFS主目錄的 conf 目錄下有配置文件樣例 tracker.conf,打開該文件,找到下列片斷,紅色部分根據實際狀況進行修改:

# the base path to store data and log files
base_path=/home/yuqing/fastdfs
  

2)啓動tracker服務:
命令格式:/usr/local/bin/fdfs_trackerd <tracker_conf_filename>

實例:/usr/local/bin/fdfs_trackerd /FastDFS/conf/tracker.conf

3b、配置storage

1)在FastDFS主目錄的 conf 目錄下有配置文件樣例 storage.conf,打開該文件,找到下列片斷,紅色部分根據實際狀況進行修改:

# the base path to store data and log files
base_path=/home/yuqing/fastdfs
  

# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/home/yuqing/fastdfs
 
#store_path1=/home/yuqing/fastdfs2
  

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=192.168.209.121:22122
  

2)啓動storage服務:
命令格式:/usr/local/bin/fdfs_storaged <storage_conf_filename>

實例:/usr/local/bin/fdfs_storaged /FastDFS/conf/storage.conf

第1次啓動將會在所設置的存儲路徑下建立256個子文件夾,須要一些時間。 

3)運行監控程序:
命令格式:/usr/local/bin/fdfs_monitor <storage_conf_filename>

實例:/usr/local/bin/fdfs_monitor /FastDFS/conf/storage.conf  

控制檯將會顯示存儲服務器的一些信息,相似以下:

Txt代碼

  1. base_path=/FastDFS/logs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0  

  2. server_count=1, server_index=0  

  3.   

  4. tracker server is 127.0.0.1:22122  

  5.   

  6. group count: 1  

  7.   

  8. Group 1:   

  9. group name = group1   

  10. free space = 42 GB   

  11. storage server count = 1  

  12. active server count = 1  

  13. storage_port = 23000  

  14. storage_http_port = 8888  

  15. store path count = 1  

  16. subdir count per path= 256  

  17. current write server index = 0  

  18.   

  19.     Host 1:   

  20.         ip_addr = 127.0.0.1 (localhost)  ACTIVE   

  21.         http domain =    

  22.         version = 1.29  

  23.         up time = 2010-07-20 16:52:44  

  24.         total storage = 49GB   

  25.         free storage = 42GB   

  26.         upload priority = 10  

  27.         store_path_count = 1  

  28.         subdir_count_per_path = 256  

  29.         storage_port = 23000  

  30.         storage_http_port = 8888  

  31.         current_write_path = 0  

  32.         source ip_addr =    

  33.         total_upload_count = 2  

  34.         success_upload_count = 2  

  35.         total_set_meta_count = 0  

  36.         success_set_meta_count = 0  

  37.         total_delete_count = 0  

  38.         success_delete_count = 0  

  39.         total_download_count = 0  

  40.         success_download_count = 0  

  41.         total_get_meta_count = 0  

  42.         success_get_meta_count = 0  

  43.         total_create_link_count = 0  

  44.         success_create_link_count = 0  

  45.         total_delete_link_count = 0  

  46.         success_delete_link_count = 0  

  47.         last_heart_beat_time = 2010-07-20 17:23:31  

  48.         last_source_update = 2010-07-20 17:16:43  

  49.         last_sync_update = 1970-01-01 08:00:00  

  50.         last_synced_timestamp= 1970-01-01 08:00:00  

四、測試安裝是否成功,上傳一個文件:

1)在 storage 服務器上 ,經過提供的命令行工具進行上傳:

命令格式:/usr/local/bin/fdfs_test <storage_conf_filename> <operation>

實例:/usr/local/bin/fdfs_test /FastDFS/conf/storage.conf   upload /home/x.zip 

控制檯將會一些信息,相似以下:

Txt代碼

  1. This is FastDFS client test program v1.29  

  2.   

  3. Copyright (C) 2008, Happy Fish / YuQing   

  4.   

  5. FastDFS may be copied only under the terms of the GNU General   

  6. Public License V3, which may be found in the FastDFS source kit.   

  7. Please visit the FastDFS Home Page http://www.csource.org/    

  8. for more detail.   

  9.   

  10. base_path=/FastDFS/logs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0  

  11. group_name=group1, ip_addr=127.0.0.1, port=23000  

  12. storage_upload_by_filename   

  13. group_name=group1, remote_filename=M00/00/00/fwAAAUxFaXsAAAAAACkHPTYooKs470.zip   

  14. source ip address: 127.0.0.1  

  15. file timestamp=2010-07-20 17:16:43  

  16. file size=2688829  

  17. file url: http://127.0.0.1/group1/M00/00/00/fwAAAUxFaXsAAAAAACkHPTYooKs470.zip   

  18. storage_upload_slave_by_filename   

  19. group_name=group1, remote_filename=M00/00/00/fwAAAUxFaXsAAAAAACkHPTYooKs470_big.zip   

  20. source ip address: 127.0.0.1  

  21. file timestamp=2010-07-20 17:16:43  

  22. file size=2688829  

  23. file url: http://127.0.0.1/group1/M00/00/00/fwAAAUxFaXsAAAAAACkHPTYooKs470_big.zip  

至此,基本的安裝已經成功。 

說明: 
1)在 tracker 和 storage 服務器是相互獨立的狀況下,在完成安裝步驟的1-2後,第3步根據是 tracker 或 storage 而分別執行對應的 3a 或 3b 步驟便可。

2)storage 服務器是以心跳的方式主動向 tracker 服務器彙報本身的信息的,因此啓動 tracker 和 storage 的順序是任意的。

相關文章
相關標籤/搜索