环境及版本:
系统环境是 Centos7 请移步这里:FastDFS+nginx+fastdfs-nginx-module服务器配置(on Centos7)
1.1 更新apt
sudo apt update && sudo apt upgrade
1.2 安装build-essential包
sudo apt-get install build-essential
该命令安装一组新的包,包含gcc
,g++
,make
.
1.3 安装libtool
sudo apt install libtool
GNU libtool是通用库支持脚本.它将共享库的使用隐藏在一个一致的可移植的接口后面.
sudo apt install git
sudo git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon
./make.sh clean && ./make.sh && ./make.sh install
sudo git clone https://github.com/happyfish100/fastdfs.git
cd fastdfs
./make.sh clean && ./make.sh && ./make.sh install
./setup.sh /etc/fdfs
请确保防火墙允许 tracker 和 storage 的端口.
tracker:
sudo mkdir -p /home/yuqing/fastdfs
你可以改为自己喜欢的路径名.下面我是以此为基础进行配置.
sudo vi /etc/fdfs/tracker.conf
bind_addr =
绑定此主机的一个地址,如果留空表示绑定此主机所有地址.base_path
=/home/yuqing/fastdfs
(此文件目录若没有,要自己新建,不然会报错)sudo vi /etc/fdfs/storage.conf
base_path
=/home/yuqing/fastdfs
(此文件目录若没有,要自己新建,不然会报错)store_path0
=/home/yuqing/fastdfs
(此文件目录若没有,要自己新建,不然会报错)tracker_server
:192.168.1.100:22122
改为自己的IPgroup_name=group1
(因为现在先只是配一个组,所以这里就为group1,多个组存储时才需要改动)sudo vi /etc/fdfs/client.conf
base_path
=/home/yuqing/fastdfs
(此文件目录若没有,要自己新建,不然会报)tracker_server
=192.168.1.100:22122
改为自己的IP/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
这一步就不用做了,因为Ubuntu18.04上不存在/sbin/service
/sbin/service dfs_trackerd restart
/sbin/service fdfs_storaged restart
/usr/bin/fdfs_monitor /etc/fdfs/client.conf
比如:
/usr/bin/fdfs_test
/usr/bin/fdfs_test1
例子:上传一个文件做测试
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /usr/include/stdlib.h
成功会返回URL如下:
This is FastDFS client test program v6.06
Copyright (C) 2008, Happy Fish / YuQing
FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.fastken.com/
for more detail.
[2020-02-24 03:22:16] DEBUG - base_path=/home/yuqing/fastdfs, connect_timeout=5, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0
tracker_query_storage_store_list_without_group:
server 1. group_name=, ip_addr=192.168.1.100, port=23000
group_name=group1, ip_addr=192.168.1.100, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/aIBdvl5Th7iAM1PwAACLyBo1AoQ37510.h
source ip address: 192.168.1.100
file timestamp=2020-02-24 03:22:16
file size=35784
file crc32=439681668
example file url: http://192.168.1.100/group1/M00/00/00/aIBdvl5Th7iAM1PwAACLyBo1AoQ37510.h
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/aIBdvl5Th7iAM1PwAACLyBo1AoQ37510_big.h
source ip address: 192.168.1.100
file timestamp=2020-02-24 03:22:16
file size=35784
file crc32=439681668
example file url: http://192.168.1.100/group1/M00/00/00/aIBdvl5Th7iAM1PwAACLyBo1AoQ37510_big.h
到这里FastDFS安装完成.
tracker 服务器配置文件例子请查看 conf/tracker.conf
storage 服务器配置文件例子请查看 conf/storage.conf
client 配置文件例子请查看 conf/client.conf
item name | type | default | Must |
---|---|---|---|
base_path | string | Y | |
disabled | boolean | false | N |
bind_addr | string | N | |
network_timeout | int | 30(s) | N |
max_connections | int | 256 | N |
log_level | string | info | N |
run_by_group | string | N | |
run_by_user | string | N | |
allow_hosts | string | * | N |
sync_log_buff_interval | int | 10(s) | N |
thread_stack_size | string | 1M | N |
备注:
base_path
是子目录的基路径:
data
和 logs
base_path
必须存在,如果不存在,其子目录将自动创建.
$base_path/data: store data files
$base_path/logs: store log files
log_level
是syslog的标准日志级别,不区分大小写.
allow_hosts
可以多个,主机可以是主机名或ip地址:
*
表示匹配所有的ip地址,可以使用这样的范围:10.0.1.[1-15,20]
或者 host[01-08,20-25].domain.com, 例如:
allow_hosts=10.0.1.[1-15,20]
allow_hosts=host[01-08,20-25].domain.com
item name | type | default | Must |
---|---|---|---|
port | int | 22000 | N |
store_lookup | int | 0 | N |
store_group | string | N | |
store_server | int | 0 | N |
store_path | int | 0 | N |
download_server | int | 0 | N |
reserved_storage_space | string | 1GB | N |
备注:
store_lookup
设置为1
时(指定组),必须将store_group
设置为指定的组名.reserved_storage_space
是为系统或其他应用程序保留的存储空间.<=
reserved_storage_space`,item name | type | default | Must |
---|---|---|---|
group_name | string | Y | |
tracker_server | string | Y | |
port | int | 23000 | N |
heart_beat_interval | int | 30(s) | N |
stat_report_interval | int | 300(s) | N |
sync_wait_msec | int | 100(ms) | N |
sync_interval | int | 0(ms) | N |
sync_start_time | string | 00:00 | N |
sync_end_time | string | 23:59 | N |
store_path_count | int | 1 | N |
store_path0 | string | base_path | N |
store_path# | string | N | |
subdir_count_per_path | int | 256 | N |
check_file_duplicate | boolean | 0 | N |
key_namespace | string | N | |
keep_alive | boolean | 0 | N |
sync_binlog_buff_interval | int | 60s | N |
备注:
tracker_server
可以多个,且tracker_server
格式是host:port
,主机可以是主机名或ip地址.store_path#
, #
是数字,从0
开始check_file_duplicate
:设置为true
时,必须和FastDHT
服务器一起工作,http://code.google.com/p/fastdht/downloads/list
check_file_duplicate
为真时,FastDHT key_namespace
不能为空,键命名空间应该尽可能短
.FastDFS扩展篇:nginx添加fastdfs-nginx-module模块(非覆盖安装)(on ubuntu18.04)(FastDFS+nginx+fastdfs-nginx-module(2))
github:FastDFS
参考:happyfish100/fastdfs/INSTALL