FastDFS部署總結

 

1、 安裝tracker_serverhtml

1、安裝libeventnginx

卸載原有的linevent web

yum -y remove libeventapache

wget http://down1.chinaunix.net/distfiles/libevent-1.4.12-stable.tar.gz服務器

tar xvf libevent1.4.12-stable.tar.gzapp

cd libevent負載均衡

./configure -prefix=/usrless

makedom

make installtcp

2安裝tracker_server

wget http://fastdfs.googlecode.com/files/FastDFS_v3.11.tar.gz

tar xvzf FastDFS_v3.05.tar.gz

cd FastDFS

./make.sh

./make.sh install

nginx添加fastdfs模塊,因此不須要fastdfs支持 http 因此我就不須要去掉 #WITH_HTTPD=1 前的註釋了,直接編譯./make.sh

vi /etc/fdfs/tracker.conf

修改/etc/fdfs/tracker.conf,主要修改如下兩處,若有其餘調整,可參考文檔自行調整,默認的配置也能夠工做。

# the base path to store data and log files

base_path=/home/tracker ====> 放置data和log的目錄

#func:上傳文件的選組方式。

#valu:0、1或2。

# 0:表示輪詢

# 1:表示指定組

# 2:表示存儲負載均衡(選擇剩餘空間最大的組)

store_lookup=0(默認配置爲2)通常配置0測試爲0

3、啓動tracker服務

mkdir -p /home/tracker

啓動tracker服務

[root@tracker]# /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf

確認8080,22122端口已經監聽

[root@tracker]# netstat -nl|grep -E '8080|22122'

tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN

tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN

V4.02辦法默認開機啓動

啓動時報錯:

p_w_picpath

處理方式:

緣由是系統debug的路徑中沒有咱們實際的動態庫的路徑

ln -s /usr/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2

中止tracker服務

[root@tracker]# /usr/local/bin/stop.sh /etc/fdfs/tracker.conf

進入/home/tracker /logs/tracker.log查看tracker的日誌是否正常啓動

2、 安裝storage_server

一、安裝FastDFS

wget http://fastdfs.googlecode.com/files/FastDFS_v3.11.tar.gz

wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.10.tar.gz

wget http://nginx.org/download/nginx-1.0.11.tar.gz

wget http://down1.chinaunix.net/distfiles/libevent-1.4.12-stable.tar.gz

 

卸載原有的linevent

tar xvf libevent1.4.12-stable.tar.gz(未安裝時安裝)

cd libevent1.4.12-stable

./configure -prefix=/usr

Make

Make install

 

tar xvzf FastDFS_v3.05.tar.gz

cd FastDFS

./make.sh

./make.sh install

二、安裝Nginx

groupadd www 創建用戶組

useradd -g www www 創建用戶www屬於www用戶組的

 

tar xvzf nginx-1.0.11.tar.gz

tar xvzf fastdfs-nginx-module_v1.10.tar.gz

cd nginx-1.0.11

./configure --prefix=/usr/local/nginx --add-module=/root/fastdfs-nginx-module/src

./configure --user=www --group=www --add-module=../fastdfs-nginx-module/src

--prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

make

make install

三、配置storage_server

vi /etc/fdfs/storage.conf

修改/etc/fdfs/storage.conf,主要修改如下幾處,若有其餘調整,可參考文檔自行調整,默認的配置也能夠工做。

# the name of the group this storage server belongs to

group_name=group1 ====> 此臺storage server所屬的服務器組名

# the base path to store data and log files

base_path=/home/storage ====> 放置data和log的目錄

# store_path#, based 0, if store_path0 not exists, it's value is base_path

# the paths must be exist

store_path0=/home/storage ====> 放置文件的目錄

# tracker_server can ocur more than once, and tracker_server format is

# "host:port", host can be hostname or ip address

tracker_server=172.16.23.176:22122 ====> tracker server的ip和端口,此處能夠寫多個tracker server,每行一個

#HTTP settings

http.disabled=true ====> 關閉內置的web server

# the port of the web server on this storage server

http.server_port=80 ====> web server的端口改爲80

擴展模塊配置

cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

vi /etc/fdfs/mod_fastdfs.conf

# the base path to store log files

base_path=/home/storage ====> 放置log的目錄

# FastDFS tracker_server can ocur more than once, and tracker_server format is

# "host:port", host can be hostname or ip address

tracker_server=172.16.23.176:22122 ====> tracker server的ip和端口,此處能夠寫多個tracker server,每行一個

# the group name of storage server

group_name=group1 ====> 此臺storage server所屬的服務器組名

# if uri including group name

# default value is false

url_have_group_name =true ====> 在URL中包含group名稱

# store_path#, based 0, if store_path0 not exists, it's value is base_path

# the paths must be exist

store_path0=/home/storage ====> 放置文件的目錄

# if need find content type from file extension name

# should set to false because it done by apache

http. need_find_content_type=true====> nginx下須要將http.conf中的參數http. need_find_content_type設置爲true,apache設置爲false(文檔建議,我的測試中未設置)

啓動storage_server

mkdir -p /home/storage

mkdir -p /home/storage/data

在nginx的server配置段中增長M00的location聲明

[root@storage]# vi /usr/local/nginx/conf/nginx.conf

location /group1/M00 {

root /home/storage/data;

ngx_fastdfs_module;

}

設置其它組:

location /group2/M00 {

root /home/storage/data;

ngx_fastdfs_module;

}

不建議作組間跳轉或者proxy,建議每一個group採用一個子域名,即經過子域名來區分group。如:g1.xxx.com, g2.xxx.com等等。

建立M00目錄的軟鏈接(可忽略不配)

[root@storage]# ln -s /home/storage/data /home/storage/data/M00

啓動storage服務

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

啓動nginx

[root@tracker]# /usr/local/nginx/sbin/nginx

確認80, 23000端口已經監聽

[root@storage]# netstat -nl|grep -E '80|23000'

tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN

重啓storage服務:

/usr/local/bin/restart.sh /etc/fdfs/storage.conf

中止storage服務:

/usr/local/bin/stop.sh /etc/fdfs/storage.conf

開機啓動服務:

vi /etc/rc.local

/usr/local/nginx/sbin/nginx

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

三、查看組中運行多個storage_server

進入tracker_server /home/tracker/data

cat storage_servers_new.dat

p_w_picpath

p_w_picpath

4、測試上傳文件tracker_server端操做)

FastDFS有自帶的客戶端程序,通過配置後,可進行文件上傳。

vi /etc/fdfs/client.conf文件。

Base_path=/tmp

修改tracker_server, 能夠不是惟一

Tracker_server 172.16.23.176:22122

開啓http支持

##include http.conf –>#include http.conf

[root@localhost ~]# vi b.txt

/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload b.txt

測試上傳(經常使用客戶上傳)

/usr/local/bin/fdfs_upload_file /etc/fdfs/client.conf b.txt

p_w_picpath

瀏覽

http://172.16.23.176:8080/group1/M00/00/00/rBAXr1AJGF_3rC-ZAAAAEc45MdM850_big.txt

跳轉至如下地址

http://172.16.23.173/group1/M00/00/00/rBAXr1AJGF_3rC-ZAAAAEc45MdM850_big.txt

http://172.16.23.175/group1/M00/00/00/rBAXr1AJGF_3rC-ZAAAAEc45MdM850_big.txt

查看存儲內文件:

cd /home/storage/data/M00/M00/00/00

storang1內容

Storang2內容

cd /home/storage/data/M00/M00/00/00

3、文件操做

1、查看文件信息tracker_server端操做)

fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/rBAXr1AIMnnK94hVAAAAFPmPj8E816.txt

2、下載文件tracker_server端操做)

/usr/local/bin/fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/rBAXr1AIMnnK94hVAAAAFPmPj8E816.txt

下載後文件名更改成demofile.txt

3、文件刪除(tracker_server端操做)

/usr/local/bin/fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/rBAXr1AIMnnK94hVAAAAFPmPj8E816.txt

4、 服務器信息

一、存儲服務器信息查看tracker_server端操做)

/usr/local/bin/fdfs_monitor /etc/fdfs/client.conf -h 172.16.23.176 list

/usr/local/bin/fdfs_monitor /etc/fdfs/client.conf

二、 存儲服務器踢出集羣tracker_server端操做)

/usr/local/bin/fdfs_monitor /etc/fdfs/client.conf -h 172.16.23.176 delete group1 172.16.23.173

注意:若是被刪除的storage server的狀態是ACTIVE,也就是該storage server還在線上服務的狀況下,是沒法刪除掉的。

三、 存儲服務器狀態

storage server有7個狀態,以下:

# FDFS_STORAGE_STATUS_INIT :初始化,還沒有獲得同步已有數據的源服務器

# FDFS_STORAGE_STATUS_WAIT_SYNC :等待同步,已獲得同步已有數據的源服務器

# FDFS_STORAGE_STATUS_SYNCING :同步中

# FDFS_STORAGE_STATUS_DELETED :已刪除,該服務器從本組中摘除(注:本狀態的功能還沒有實現)

# FDFS_STORAGE_STATUS_OFFLINE :離線

# FDFS_STORAGE_STATUS_ONLINE :在線,尚不能提供服務

# FDFS_STORAGE_STATUS_ACTIVE :在線,能夠提供服務

5、 擴展

一、擴展到多臺tracker和storage的配置方法

二、按照步驟一配置所需數量的tracker,只須要ip地址不重複就能夠。

三、按照步驟二配置所需數量的storage,注意Group_name項,若是是同一組,那麼group_name相同,端口號也相同,若是group_name不一樣,那麼端口號也不一樣。

四、在storage的配置文件中修改tracker_server的地址和端口,能夠指定多個,將新增的tracker也加進去就能夠了。

原始文件名和FastDFS上的文件名對應關係都是保存在DB, 源文件只有client知道.

6、 內部測試

 

一、測試上傳文件的選組方式。

 

#func:上傳文件的選組方式。
#valu:0、1或2。
# 0:表示輪詢
# 1:表示指定組
# 2:表示存儲負載均衡(選擇剩餘空間最大的組)
store_lookup=2

測試環境創建group1(172.16.23.17三、172.16.23.175)、group2(172.16.23.172);172.16.23.172掛在10G磁盤空間,默認store_lookup=2,當兩個組同時活動時客戶端測試上傳文件默認到組group2(172.16.23.172)。

二、測試group2組宕機下線

group2(172.16.23.172)服務器關機,文件上傳時上傳group2報錯,大約30秒後文件上傳測試從新如今group1上傳成功。選擇對storage 服務器下線處理。

/usr/local/bin/fdfs_monitor /etc/fdfs/client.conf -h 172.16.23.176 delete group1 172.16.23.173

 

三、 測試組group1中storang server宕機

Group 中172.16.23.173宕機,測試上傳至172.16.23.175讀取成功。

 

7、 Http下載方式

1tracker跳轉方式:經過Tracker server跳轉:Tracker server上需使用內置web server,Storage server可使用內置web server或使用外部web server,推薦使用外部web server如apache或nginx。

2非tracker跳轉方式使用擴展模塊方式:Storage server直接提供文件下載:tracker server上不須要任何web server,在每臺storage server上部署web server,直接對外提供HTTP服務目前已提供apache和nginx擴展模塊推薦使用擴展模塊方式

FastDFS擴展模塊要點:

?使用擴展模塊來解決文件同步延遲問題

?在每臺storage server上部署web server,直接對外提供HTTP服務

?tracker server上不須要部署web server,開啓http服務。

?若是請求文件在當前storage上不存在,經過文件ID反解出源storage,直接請求源storage

?目前已提供apache和nginx擴展模塊 FastDFS擴展模塊不依賴於FastDFS server,能夠獨立存在!

模塊工做機制:
?對請求URL中的文件名進行反解,獲得文件建立時間、文件大小和源storage server IP地址
? 若是文件在本地存在,直接返回文件內容;不然轉3
? 文件在本地不存在的狀況處理:
1)若是 (當前時間 - 文件建立時間) > 文件同步延遲閥值(如一天) 或者 源storage server IP地址在本機IP中(即當前文件上傳到的源storage server爲本機),則返回404 NOT FOUND
2)若是配置爲redirect模式,直接重定向到源storage server IP對應的URL;不然爲proxy模式,調用FastDFS client API從源storage server IP獲取該文件並返回給客戶端

? nginx的fdfs擴展模塊後,就使用nginx的負載均衡,向tracker server獲取兩個參數而已,這兩個參數是:
storage_sync_file_max_delay:文件同步的最大延遲,缺省爲1天
storage_sync_file_max_time:同步單個文件須要的最大時間,缺省爲5分鐘。

3.推薦的FastDFS部署方案

?文件上傳和刪除等操做:使用FastDFS client API,目前提供了C、PHP extension和Java的client API

?文件下載採用HTTP方式:使用nginx或者apache擴展模塊,不推薦使用FastDFS內置的web server

?不要作RAID,直接掛載單盤,每一個硬盤做爲一個mount point

Tracker server的性能很是高,一個較大的集羣(好比上百個group)中有3臺就足夠了。

8、FastDFS注意事項

1. 除了在storage.conf裏的tracker_server增長tracker的ip和端口,其餘地方要注意什麼?

tracker server ip和端口,確定是要正確設置的。支持多tracker server,每行設置一個tracker。另外,base_path也要正確設置。其他參數,一般採用缺省配置便可。

2. 每臺tracker和storage的啓動有沒有前後關係?

正常狀況下,應該先啓動tracker。FastDFS不會有這樣的要求,你要啓動storage也是沒有任何問題的。

3. fastDFS產生的記錄清空,再從新搭建一次,應該刪除哪些文件?

中止storage server和tracker server,刪除base_path下的data子目錄便可。注意:storage 的data目錄下保存了上傳文件,刪除時請慎重。

4. 這些Track Server的內容是對等的,仍是分組,每一個Track Server負責一部分Storage Server?

對等的。

Client是綁定一個Track Server,仍是能夠綁定多個或所有

在一個集羣中,應該綁定所有。

Storage Server也是一樣的問題,是綁定一個Track Server,仍是能夠多個或者所有?

在一個集羣中,應該綁定所有。

5. FastDFS存儲服務器的硬盤掛載

FastDFS存儲服務器的硬盤能夠作RAID,好比RAID5等等,這樣系統中的mount point只有一個。也能夠單個硬盤直接mount使用,這樣系統中的mount point就是多個(多個硬盤的狀況下)。RAID5並不能充分發揮各個磁盤的最大吞吐量,出於磁盤IO效率考慮,建議採用第二種作法,這樣磁盤總體IO吞吐量最理想的狀況下,爲各個硬盤IO吞吐量之和。
採用多個mount point的狀況下,若是有一塊硬盤損壞,能夠有兩種修復方法:
1. 更換掉壞掉的硬盤,在服務中止的狀況下,手工複製已有服務器上該路徑的文件到該mount point,而後啓動FastDFS服務程序fdfs_storaged;
2. 更換一臺一樣配置的新服務器,或者更換掉壞的硬盤後,重作系統,而後啓動FastDFS服務fdfs_storaged便可。

只要${base_path}這個路徑所在硬盤沒有壞,也就是系統數據文件(如${base_path}/data/sync/*)都在的狀況下,文件自動同步是沒有任何問題的。

6. 組內新增長一臺storage server A時,由系統自動完成已有數據同步,處理邏輯

tracker server的配置文件中沒有出現storage server,而storage server的配置文件中會列舉出全部的tracker server。這就決定了storage server和tracker server之間的鏈接由storage server主動發起,storage server爲每一個tracker server啓動一個線程進行鏈接和通信,這部分的通訊協議請參閱《FastDFS HOWTO -- Protocol》中的「2. storage server to tracker server command」。
tracker server會在內存中保存storage分組及各個組下的storage server,並將鏈接過本身的storage server及其分組保存到文件中,以便下次重啓服務時能直接從本地磁盤中得到storage相關信息。storage server會在內存中記錄本組的全部服務器,並將服務器信息記錄到文件中。tracker server和storage server之間相互同步storage server列表:
<1>. 若是一個組內增長了新的storage server或者storage server的狀態發生了改變,tracker server都會將storage server列表同步給該組內的全部storage server。以新增storage server爲例,由於新加入的storage server主動鏈接tracker server,tracker server發現有新的storage server加入,就會將該組內全部的storage server返回給新加入的storage server,並從新將該組的storage server列表返回給該組內的其餘storage server;
<2>. 若是新增長一臺tracker server,storage server鏈接該tracker server,發現該tracker server返回的本組storage server列表比本機記錄的要少,就會將該tracker server上沒有的storage server同步給該tracker server。
同一組內的storage server之間是對等的,文件上傳、刪除等操做能夠在任意一臺storage server上進行。文件同步只在同組內的storage server之間進行,採用push方式,即源服務器同步給目標服務器。以文件上傳爲例,假設一個組內有3臺storage server A、B和C,文件F上傳到服務器B,由B將文件F同步到其他的兩臺服務器A和C。咱們不妨把文件F上傳到服務器B的操做爲源頭操做,在服務器B上的F文件爲源頭數據;文件F被同步到服務器A和C的操做爲備份操做,在A和C上的F文件爲備份數據。同步規則總結以下:
<1>. 只在本組內的storage server之間進行同步;
<2>. 源頭數據才須要同步,備份數據不須要再次同步,不然就構成環路了;
<3>. 上述第二條規則有個例外,就是新增長一臺storage server時,由已有的一臺storage server將已有的全部數據(包括源頭數據和備份數據)同步給該新增服務器。
storage server有7個狀態,以下:
# FDFS_STORAGE_STATUS_INIT :初始化,還沒有獲得同步已有數據的源服務器
# FDFS_STORAGE_STATUS_WAIT_SYNC :等待同步,已獲得同步已有數據的源服務器
# FDFS_STORAGE_STATUS_SYNCING :同步中
# FDFS_STORAGE_STATUS_DELETED :已刪除,該服務器從本組中摘除(注:本狀態的功能還沒有實現)
# FDFS_STORAGE_STATUS_OFFLINE :離線
# FDFS_STORAGE_STATUS_ONLINE :在線,尚不能提供服務
# FDFS_STORAGE_STATUS_ACTIVE :在線,能夠提供服務
當storage server的狀態爲FDFS_STORAGE_STATUS_ONLINE時,當該storage server向tracker server發起一次heart beat時,tracker server將其狀態更改成FDFS_STORAGE_STATUS_ACTIVE。
組內新增長一臺storage server A時,由系統自動完成已有數據同步,處理邏輯以下:
<1>. storage server A鏈接tracker server,tracker server將storage server A的狀態設置爲FDFS_STORAGE_STATUS_INIT。storage server A詢問追加同步的源服務器和追加同步截至時間點,若是該組內只有storage server A或該組內已成功上傳的文件數爲0,則沒有數據須要同步,storage server A就能夠提供在線服務,此時tracker將其狀態設置爲FDFS_STORAGE_STATUS_ONLINE,不然tracker server將其狀態設置爲FDFS_STORAGE_STATUS_WAIT_SYNC,進入第二步的處理;
<2>. 假設tracker server分配向storage server A同步已有數據的源storage server爲B。同組的storage server和tracker server通信得知新增了storage server A,將啓動同步線程,並向tracker server詢問向storage server A追加同步的源服務器和截至時間點。storage server B將把截至時間點以前的全部數據同步給storage server A;而其他的storage server從截至時間點以後進行正常同步,只把源頭數據同步給storage server A。到了截至時間點以後,storage server B對storage server A的同步將由追加同步切換爲正常同步,只同步源頭數據;
<3>. storage server B向storage server A同步完全部數據,暫時沒有數據要同步時,storage server B請求tracker server將storage server A的狀態設置爲FDFS_STORAGE_STATUS_ONLINE;
<4>. 當storage server A向tracker server發起heart beat時,tracker server將其狀態更改成FDFS_STORAGE_STATUS_ACTIVE。

9. Storage 2: ip_addr = 172.16.23.173 RECOVERY 問題

 

單盤故障恢復中。。。緣由:採用多store path,更換group形成應避免。

10.Tracker和storage或storage之間時間要一致

 

11.上傳後原文件名和上傳後生成新的文件名的對應關係

上傳前爲test.txt,上傳後生成rBAXrVAfNqSRJqy3AAAABWFXmN8243_big.tx

要實現文件Id映射,可使用my-fastdfs-client, 須要保存原始文件名的話須要由應用端來保存這個映射關係。

12.兩個磁盤都給FastDFS使用,在nginx配置兩個location

location /group1/M00/ {
alias /fastdfs1/data/;
}
location /group1/M01/ {
alias /fastdfs2/data/;
}

13.Fdfs升級

重新編譯安裝Fdfs和Nginx+Nginx擴展模塊,配置文件無需更改

8、 應用場景

p_w_picpath

Nginx配置:

upstream webservergroup1 {

server 172.16.23.172:80;

server 172.16.23.173:80;

}

upstream webservergroup2 {

server 172.16.23.171:80;

server 172.16.23.175:80;

}

location /group1/M00 {

proxy_next_upstream http_502 http_504 error timeout invalid_header;

proxy_set_header Host $host;

proxy_set_header X-Forwarded-For $remote_addr;

proxy_set_header X-Real-IP $remote_addr;

proxy_pass http://webservergroup1;

access_log off;

}

location /group2/M00 {

proxy_next_upstream http_502 http_504 error timeout invalid_header;

proxy_set_header Host $host;

proxy_set_header X-Forwarded-For $remote_addr;

proxy_set_header X-Real-IP $remote_addr;

proxy_pass http://webservergroup2;

access_log off;

}

========================測試環境配置=======================

Tracker server 176配置:

# is this config file disabled

# false for enabled

# true for disabled

disabled=false

# bind an address of this host

# empty for bind all addresses of this host

bind_addr=

# the tracker server port

port=22122

# connect timeout in seconds

# default value is 30s

connect_timeout=30

# network timeout in seconds

# default value is 30s

network_timeout=60

# the base path to store data and log files

base_path=/home/tracker

# max concurrent connections this server supported

max_connections=256

# work thread count, should <= max_connections

# default value is 4

# since V2.00

work_threads=4

# the method of selecting group to upload files

# 0: round robin

# 1: specify group

# 2: load balance, select the max free space group to upload file

store_lookup=0

# which group to upload file

# when store_lookup set to 1, must set store_group to the group name

store_group=group2

# which storage server to upload file

# 0: round robin (default)

# 1: the first server order by ip address

# 2: the first server order by priority (the minimal)

store_server=0

# which path(means disk or mount point) of the storage server to upload file

# 0: round robin

# 2: load balance, select the max free space path to upload file

store_path=0

# which storage server to download file

# 0: round robin (default)

# 1: the source storage server which the current file uploaded to

download_server=0

# reserved storage space for system or other applications.

# if the free(available) space of any stoarge server in

# a group <= reserved_storage_space,

# no file can be uploaded to this group.

# bytes unit can be one of follows:

### G or g for gigabyte(GB)

### M or m for megabyte(MB)

### K or k for kilobyte(KB)

### no unit for byte(B)

### XX.XX% as ratio such as reserved_storage_space = 10%

reserved_storage_space = 10%

#standard log level as syslog, case insensitive, value list:

### emerg for emergency

### alert

### crit for critical

### error

### warn for warning

### notice

### info

### debug

log_level=info

#unix group name to run this program,

#not set (empty) means run by the group of current user

run_by_group=

#unix username to run this program,

#not set (empty) means run by current user

run_by_user=

# allow_hosts can ocur more than once, host can be hostname or ip address,

# "*" means match all ip addresses, can use range like this: 10.0.1.[1-15,20] or

# host[01-08,20-25].domain.com, for example:

# allow_hosts=10.0.1.[1-15,20]

# allow_hosts=host[01-08,20-25].domain.com

allow_hosts=*

# sync log buff to disk every interval seconds

# default value is 10 seconds

sync_log_buff_interval = 10

# check storage server alive interval seconds

check_active_interval = 120

# thread stack size, should >= 64KB

# default value is 64KB

thread_stack_size = 64KB

# auto adjust when the ip address of the storage server changed

# default value is true

storage_ip_changed_auto_adjust = true

# storage sync file max delay seconds

# default value is 86400 seconds (one day)

# since V2.00

storage_sync_file_max_delay = 86400

# the max time of storage sync a file

# default value is 300 seconds

# since V2.00

storage_sync_file_max_time = 300

# if use a trunk file to store several small files

# default value is false

# since V3.00

use_trunk_file = false

# the min slot size, should <= 4KB

# default value is 256 bytes

# since V3.00

slot_min_size = 256

# the max slot size, should > slot_min_size

# store the upload file to trunk file when it's size <= this value

# default value is 16MB

# since V3.00

slot_max_size = 16MB

# the trunk file size, should >= 4MB

# default value is 64MB

# since V3.00

trunk_file_size = 64MB

# if create trunk file advancely

# default value is false

# since V3.06

trunk_create_file_advance = false

# the time base to create trunk file

# the time format: HH:MM

# default value is 02:00

# since V3.06

trunk_create_file_time_base = 02:00

# the interval of create trunk file, unit: second

# default value is 38400 (one day)

# since V3.06

trunk_create_file_interval = 86400

# the threshold to create trunk file

# when the free trunk file size less than the threshold, will create

# the trunk files

# default value is 0

# since V3.06

trunk_create_file_space_threshold = 20G

# if check trunk space occupying when loading trunk free spaces

# the occupied spaces will be ignored

# default value is false

# since V3.09

# NOTICE: set this parameter to true will slow the loading of trunk spaces

# when startup. you should set this parameter to true when neccessary.

trunk_init_check_occupying = false

# if ignore storage_trunk.dat, reload from trunk binlog

# default value is false

# since V3.10

# set to true once for version upgrade when your version less than V3.10

trunk_init_reload_from_binlog = false

# if use storage ID instead of IP address

# default value is false

# since V4.00

use_storage_id = false

# specify storage ids filename, can use relative or absolute path

# since V4.00

storage_ids_filename = storage_ids.conf

# if store slave file use symbol link

# default value is false

# since V4.01

store_slave_file_use_link = false

# if rotate the error log every day

# default value is false

# since V4.02

rotate_error_log = false

# rotate error log time base, time format: Hour:Minute

# Hour from 0 to 23, Minute from 0 to 59

# default value is 00:00

# since V4.02

error_log_rotate_time=00:00

# rotate error log when the log file exceeds this size

# 0 means never rotates log file by log file size

# default value is 0

# since V4.02

rotate_error_log_size = 0

# HTTP settings

http.disabled=false

# HTTP port on this tracker server

http.server_port=8080

# check storage HTTP server alive interval seconds

# <= 0 for never check

# default value is 30

http.check_alive_interval=30

# check storage HTTP server alive type, values are:

# tcp : connect to the storge server with HTTP port only,

# do not request and get response

# http: storage check alive url must return http status 200

# default value is tcp

http.check_alive_type=tcp

# check storage HTTP server alive uri/url

# NOTE: storage embed HTTP server support uri: /status.html

http.check_alive_uri=/status.html

# if need find content type from file extension name

http.need_find_content_type=true

#use "#include" directive to include http other settings

##include http.conf

Storage server172配置:

# is this config file disabled

# false for enabled

# true for disabled

disabled=false

# the name of the group this storage server belongs to

group_name=group1

# bind an address of this host

# empty for bind all addresses of this host

bind_addr=

# if bind an address of this host when connect to other servers

# (this storage server as a client)

# true for binding the address configed by above parameter: "bind_addr"

# false for binding any address of this host

client_bind=true

# the storage server port

port=23000

# connect timeout in seconds

# default value is 30s

connect_timeout=30

# network timeout in seconds

# default value is 30s

network_timeout=60

# heart beat interval in seconds

heart_beat_interval=30

# disk usage report interval in seconds

stat_report_interval=60

# the base path to store data and log files

base_path=/home/storage

# max concurrent connections the server supported

# default value is 256

# more max_connections means more memory will be used

max_connections=256

# the buff size to recv / send data

# this parameter must more than 8KB

# default value is 64KB

# since V2.00

buff_size = 256KB

# work thread count, should <= max_connections

# work thread deal network io

# default value is 4

# since V2.00

work_threads=4

# if disk read / write separated

## false for mixed read and write

## true for separated read and write

# default value is true

# since V2.00

disk_rw_separated = true

# disk reader thread count per store base path

# for mixed read / write, this parameter can be 0

# default value is 1

# since V2.00

disk_reader_threads = 1

# disk writer thread count per store base path

# for mixed read / write, this parameter can be 0

# default value is 1

# since V2.00

disk_writer_threads = 1

# when no entry to sync, try read binlog again after X milliseconds

# must > 0, default value is 200ms

sync_wait_msec=50

# after sync a file, usleep milliseconds

# 0 for sync successively (never call usleep)

sync_interval=0

# storage sync start time of a day, time format: Hour:Minute

# Hour from 0 to 23, Minute from 0 to 59

sync_start_time=00:00

# storage sync end time of a day, time format: Hour:Minute

# Hour from 0 to 23, Minute from 0 to 59

sync_end_time=23:59

# write to the mark file after sync N files

# default value is 500

write_mark_file_freq=500

# path(disk or mount point) count, default value is 1

store_path_count=1

# store_path#, based 0, if store_path0 not exists, it's value is base_path

# the paths must be exist

store_path0=/home/storage

#store_path1=/home/yuqing/fastdfs2

# subdir_count * subdir_count directories will be auto created under each

# store_path (disk), value can be 1 to 256, default value is 256

subdir_count_per_path=256

# tracker_server can ocur more than once, and tracker_server format is

# "host:port", host can be hostname or ip address

tracker_server=172.16.23.176:22122

tracker_server=172.16.23.177:22122

#standard log level as syslog, case insensitive, value list:

### emerg for emergency

### alert

### crit for critical

### error

### warn for warning

### notice

### info

### debug

log_level=info

#unix group name to run this program,

#not set (empty) means run by the group of current user

run_by_group=

#unix username to run this program,

#not set (empty) means run by current user

run_by_user=

# allow_hosts can ocur more than once, host can be hostname or ip address,

# "*" means match all ip addresses, can use range like this: 10.0.1.[1-15,20] or

# host[01-08,20-25].domain.com, for example:

# allow_hosts=10.0.1.[1-15,20]

# allow_hosts=host[01-08,20-25].domain.com

allow_hosts=*

# the mode of the files distributed to the data path

# 0: round robin(default)

# 1: random, distributted by hash code

file_distribute_path_mode=0

# valid when file_distribute_to_path is set to 0 (round robin),

# when the written file count reaches this number, then rotate to next path

# default value is 100

file_distribute_rotate_count=100

# call fsync to disk when write big file

# 0: never call fsync

# other: call fsync when written bytes >= this bytes

# default value is 0 (never call fsync)

fsync_after_written_bytes=0

# sync log buff to disk every interval seconds

# must > 0, default value is 10 seconds

sync_log_buff_interval=10

# sync binlog buff / cache to disk every interval seconds

# default value is 60 seconds

sync_binlog_buff_interval=10

# sync storage stat info to disk every interval seconds

# default value is 300 seconds

sync_stat_file_interval=300

# thread stack size, should >= 512KB

# default value is 512KB

thread_stack_size=512KB

# the priority as a source server for uploading file.

# the lower this value, the higher its uploading priority.

# default value is 10

upload_priority=10

# the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a

# multi aliases split by comma. empty value means auto set by OS type

# default values is empty

if_alias_prefix=

# if check file duplicate, when set to true, use FastDHT to store file indexes

# 1 or yes: need check

# 0 or no: do not check

# default value is 0

check_file_duplicate=0

# namespace for storing file indexes (key-value pairs)

# this item must be set when check_file_duplicate is true / on

key_namespace=FastDFS

# set keep_alive to 1 to enable persistent connection with FastDHT servers

# default value is 0 (short connection)

keep_alive=0

# you can use "#include filename" (not include double quotes) directive to

# load FastDHT server list, when the filename is a relative path such as

# pure filename, the base path is the base path of current/this config file.

# must set FastDHT server list when check_file_duplicate is true / on

# please see INSTALL of FastDHT for detail

##include /home/yuqing/fastdht/conf/fdht_servers.conf

#HTTP settings

http.disabled=true

# use the ip address of this storage server if domain_name is empty,

# else this domain name will ocur in the url redirected by the tracker server

http.domain_name=

# the port of the web server on this storage server

http.server_port=80

http.trunk_size=256KB

# if need find content type from file extension name

http.need_find_content_type=true

#use "#include" directive to include HTTP other settings

##include http.conf

相關文章
相關標籤/搜索