FastDFS分布式文件服务器安装,及配置
一,fastdfs是什么
FastDFS是一个开源的分布式文件系统,她对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务,如相册网站、视频网站等等。
二,安装
wget http://fastdfs.googlecode.com/files/FastDFS_v1.22.tar.gz
tar zxf FastDFS_v1.22.tar.gz
cd FastDFS
./make.sh
mkdir /usr/local/include #一般情况下,local下面会有一个include文件夹的,如果没有在建个目录
./make.sh install
三,fastdfs的配置
1),tracker server的配置
disabled=false bind_addr= port=22122 network_timeout=60 base_path=/home/zhangy/FastDFS max_connections=32 # 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 = 1GB #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=8080 #use "#include" directive to include http other settiongs ##include http.conf
2)storager server的配置
disabled=false group_name=group1 bind_addr= port=23000 network_timeout=60 heart_beat_interval=30 stat_report_interval=60 base_path=/home/zhangy/FastDFS #store_path0=/home/zhangy/FastDFS max_connections=32 # 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=/mnt/song/fastfds2 #store_path1=/home/zhangy/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=192.168.1.71: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=8888 http.trunk_size=256KB #use "#include" directive to include HTTP other settiongs ##include http.conf
四,启动fastdfs
/usr/local/bin/fdfs_trackerd /etc/conf.d/tracker.conf #启动tracker服务
/usr/local/bin/fdfs_storaged /etc/conf.d/storage.conf #启动storager服务
[root@BlackGhost include]# ps -e|grep fdfs
22790 ? 00:00:00 fdfs_trackerd
22845 ? 00:00:00 fdfs_storaged
说明已经启动了。
五,测试结果
在一台Storage Server上运行
#/usr/local/bin/fdfs_test /etc/conf.d/storage.conf upload needed_upload_filename
/usr/local/bin/fdfs_monitor /etc/conf.d/storage.conf #查看一下,刚才上传的文件是不是传上去了。