Keywords:FastDFS、分布式文件系统、Ubuntu
Author:soartju
FastDFS的配置文件在%FastDFS%/conf目录下,其中包括
Client.conf 客户端上传配置文件
Storage.conf 文件存储服务器配置文件
Tracker.conf 负责均衡调度服务器配置文件
http.conf http服务器配置文件
配置文件需要根据服务器环境的不同,进行不同的配置,具体可以参考FastDFS官方的安装配置文档http://code.google.com/p/fastdfs/wiki/Setup,以及FastDFS原理介绍文档http://code.google.com/p/fastdfs/wiki/Overview
在本例中,Tracker Server,Storage Server都安装在一台服务器上,IP:10.0.2.15
1、配置及启动Tracker Server
A、修改%FastDFS%/conf/tracker.conf文件,修改如下
#可以自己指定目录位置,但目录必须存在,用于存储日志及storage server等信息,否则tracker server无法启动
Txt代码
- base_path=/home/yuqing/fastdfs -> base_path=/home/soar/fastdfs_tracker
base_path=/home/yuqing/fastdfs -> base_path=/home/soar/fastdfs_tracker
#改成你想要的http端口,将来http下载文件的端口就是他了
Txt代码
- http.server_port=8080 -> http.server_port=8090
http.server_port=8080 -> http.server_port=8090
#http支持
Txt代码
- ##include http.conf -> #include http.conf
##include http.conf -> #include http.conf
#默认4GB,如果空间不足,建议调小,否则会报no free space的异常,无法正常启动
Txt代码
- reserved_storage_space = 4GB -> reserved_storage_space = 1GB
reserved_storage_space = 4GB -> reserved_storage_space = 1GB
#tracker server对storage server供服务的端口,使用默认的即可,也可以自定义
Txt代码
- port=22122
port=22122
B、将http.conf文件拷贝到/etc/fdfs目录下,执行
Shell代码
- sudo cp %FastDFS%/conf/http.conf /etc/fdfs/
sudo cp %FastDFS%/conf/http.conf /etc/fdfs/
注:为了支持http,必须将这个文件拷贝到此目录,否则无法启动,报param http.XXX not exist or is empty类似的错误
C、进入/usr/local/bin/目录,启动tracker服务器,执行
Shell代码
- sudo fdfs_trackerd %FastDFS%/conf/tracker.conf
sudo fdfs_trackerd %FastDFS%/conf/tracker.conf
D、进入/home/soar/fastdfs_tracker/logs/trackerd.log查看tracker的启动日志,如果看到类似
Shell代码
- [2010-11-04 16:21:25] INFO - FastDFS v2.02, base_path=/home/soar/fastdfs_tracker, connect_timeout=30s, network_timeout=60s, port=22122, bind_addr=, max_connections=256, work_threads=4, store_lookup=2, store_group=, store_server=0, store_path=0, reserved_storage_space=4MB, download_server=0, allow_ip_count=-1, sync_log_buff_interval=10s, check_active_interval=120s, thread_stack_size=64 KB, storage_ip_changed_auto_adjust=1, storage_sync_file_max_delay=86400s, storage_sync_file_max_time=300s
- [2010-11-04 16:21:25] INFO - HTTP supported: server_port=8090, default_content_type=application/octet-stream, anti_steal_token=0, token_ttl=0s, anti_steal_secret_key length=0, token_check_fail content_type=, token_check_fail buff length=0, check_active_interval=30, check_active_type=tcp, check_active_uri=/status.html
[2010-11-04 16:21:25] INFO - FastDFS v2.02, base_path=/home/soar/fastdfs_tracker, connect_timeout=30s, network_timeout=60s, port=22122, bind_addr=, max_connections=256, work_threads=4, store_lookup=2, store_group=, store_server=0, store_path=0, reserved_storage_space=4MB, download_server=0, allow_ip_count=-1, sync_log_buff_interval=10s, check_active_interval=120s, thread_stack_size=64 KB, storage_ip_changed_auto_adjust=1, storage_sync_file_max_delay=86400s, storage_sync_file_max_time=300s [2010-11-04 16:21:25] INFO - HTTP supported: server_port=8090, default_content_type=application/octet-stream, anti_steal_token=0, token_ttl=0s, anti_steal_secret_key length=0, token_check_fail content_type=, token_check_fail buff length=0, check_active_interval=30, check_active_type=tcp, check_active_uri=/status.html
恭喜你,tracker server已经启动成功!
2、配置及启动Storage Server
A、修改%FastDFS%/conf/storage.conf文件,修改如下:
#可以自定义,但必须存在此目录,用于存储storage相关的log、group内的相关信息
Txt代码
- base_path=/home/yuqing/fastdfs -> /home/soar/fastdfs_storge
base_path=/home/yuqing/fastdfs -> /home/soar/fastdfs_storge
#文件的存储位置,在一台storage server上可以指定多个存储位置
Txt代码
- store_path0=/home/yuqing/fastdfs -> store_path0=/home/soar/fastdfs_storge
store_path0=/home/yuqing/fastdfs -> store_path0=/home/soar/fastdfs_storge
#必须指定
Txt代码
- group_name=group1
group_name=group1
#修改成tracker server的IP和端口信息
Txt代码
- tracker_server=192.168.209.121:22122 -> tracker_server=10.0.2.15:22122
tracker_server=192.168.209.121:22122 -> tracker_server=10.0.2.15:22122
#http支持
Txt代码
- ##include http.conf ->#include http.conf
##include http.conf ->#include http.conf
B、进入/usr/local/bin/目录,启动storage服务器,执行
Shell代码
- sudo fdfs_storaged %FastDFS%/conf/storage.conf
sudo fdfs_storaged %FastDFS%/conf/storage.conf
C、进入/home/soar/fastdfs_tracker/logs/storage.log查看storage服务器启动日志,如果看到类似
Shell代码
恭喜你,storage server已经启动成功!