FastDFS-1.22 安装
1 下载
cd /usr/local/src/
wget http://fastdfs.googlecode.com/files/FastDFS_v1.22.tar.gz
2 安装libevent
【要想支持web,得需要配置libevent-1.4x...
下载地址为:http://down1.chinaunix.net/distfiles/libevent-1.4.9-stable.tar.gz
需要注意的是,编译libevent的时候,需要指定 --prefix=/usr】
3 安装配置fastdfs
tar zxvf FastDFS_v1.22.tar.gz
cd FastDFS
vim make.sh
找到
#WITH_HTTPD=1 //支持web
#WITH_LINUX_SERVICE=1 //安装成操作系统的服务
需要把这两行的#去掉
./make.sh && ./make.sh install
4 修改配置文件
FastDFS 分为三种角色(跟踪器 tracker ; 存储器 storage; 客户端 client),三种角色的配置文件时不相同的,需要注意的是,三种角色都需要编译安装fastdfs,即执行前三步,作为client是可以不打开WITH_HTTPD=1这个功能的。当编译安装完fastdfs后,自动会在/etc/fdfs下面生成client.conf http.conf mime.types storage.conf tracker.conf 这些文件的,只要我们稍微改动一下就可以了。 分别介绍三种角色的配置文件:
tracker :
disabled=false
bind_addr=
port=22122
network_timeout=60
base_path=/FastDFS
max_connections=256
# 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=2
# which group to upload file
# when store_lookup set to 1, must set store_group to the group name
store_group=group1
# which storage server to upload file
# 0: round robin (default)
# 1: the first server order by ip address
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)
reserved_storage_space = 4GB
#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
check_active_interval = 120
# thread stack size, should > 512KB
# default value is 1MB
thread_stack_size=1MB
#HTTP settings
http.disabled=false
http.server_port=80
#use "#include" directive to include http other settiongs
#include /etc/fdfs/http.conf
注:等改完tracker.conf后就可以启动了,在启动前,需要去建立basedir /FaseDFS 目录,否则启动不了服务
启动方法: /etc/init.d/fdfs_trackerd start
storage:
disabled=false
group_name=group1
bind_addr=
port=23000
network_timeout=60
heart_beat_interval=30
stat_report_interval=60
base_path=/FastDFS
max_connections=256
# when no entry to sync, try read binlog again after X milliseconds
# 0 for try again immediately (not need to wait)
sync_wait_msec=200
# after sync a file, usleep milliseconds
# 0 for sync successively (never call usleep)
sync_interval=0
# 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
# 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
# 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=/FastDFS
#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=58.215.87.170:22122
tracker_server=124.238.249.138: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
# default value is 10 seconds
sync_log_buff_interval=10
# sync binlog buff / cache to disk every interval seconds
# this parameter is valid when write_to_binlog set to 1
# default value is 60 seconds
sync_binlog_buff_interval=60
# thread stack size, should > 512KB
# default value is 1MB
thread_stack_size=1MB
# 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=false
http.server_port=80
http.trunk_size=256KB
#use #include directive to include HTTP other settiongs
#include http.conf
client:
network_timeout=60
base_path=/FastDFS
tracker_server=58.215.87.170:22122
tracker_server=124.238.249.138: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
#HTTP settings
http.tracker_server_port=80
#use #include directive to include HTTP other settiongs
#include http.conf
none