paulwong

FastDFS部署总结

一、 安装tracker_server

1、安装libevent

卸载原有的linevent

yum -y remove libevent

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

tar xvf libevent1.4.12-stable.tar.gz

cd libevent

./configure -prefix=/usr

make

make install

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办法默认开机启动

启动时报错:

image

处理方式:

原因是系统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的日志是否正常启动

二、 安装storage_server

1、安装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

2、安装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

3、配置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

3、查看组中运行多个storage_server

进入tracker_server /home/tracker/data

cat storage_servers_new.dat

image

image

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

image

浏览

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

三、文件操作

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.confgroup1/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

四、 服务器信息

1、存储服务器信息查看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

2、 存储服务器踢出集群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还在线上服务的情况下,是无法删除掉的。

3、 存储服务器状态

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 :在线,可以提供服务

五、 扩展

1、扩展到多台tracker和storage的配置方法

2、按照步骤一配置所需数量的tracker,只需要ip地址不重复就可以。

3、按照步骤二配置所需数量的storage,注意Group_name项,如果是同一组,那么group_name相同,端口号也相同,如果group_name不同,那么端口号也不同。

4、在storage的配置文件中修改tracker_server的地址和端口,可以指定多个,将新增的tracker也加进去就可以了。

原始文件名和FastDFS上的文件名对应关系都是保存在DB, 源文件只有client知道.

六、 内部测试

 

1、测试上传文件的选组方式。

 

#func:上传文件的选组方式。
#valu:0、1或2。
# 0:表示轮询
# 1:表示指定组
# 2:表示存储负载均衡(选择剩余空间最大的组)
store_lookup=2

测试环境建立group1(172.16.23.173、172.16.23.175)、group2(172.16.23.172);172.16.23.172挂在10G磁盘空间,默认store_lookup=2,当两个组同时活动时客户端测试上传文件默认到组group2(172.16.23.172)。

2、测试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

 

3、 测试组group1中storang server宕机

Group 中172.16.23.173宕机,测试上传至172.16.23.175读取成功。

 

七、 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台就足够了。

八、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扩展模块,配置文件无需更改

八、 应用场景

image

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

posted on 2014-10-11 18:32 paulwong 阅读(5447) 评论(0)  编辑  收藏 所属分类: FASTDFS


只有注册用户登录后才能发表评论。


网站导航: