源码
https://github.com/happyfish100/fastdfs
https://github.com/tobato/FastDFS_Client
安装
http://www.ityouknow.com/fastdfs/2017/10/10/cluster-building-fastdfs.html
安装包下载
https://github.com/happyfish100/libfastcommon.git
https://github.com/happyfish100/libfastcommon/archive/V1.0.43.tar.gz
https://github.com/happyfish100/fastdfs.git
https://github.com/happyfish100/fastdfs/archive/V6.06.tar.gz
https://github.com/happyfish100/fastdfs-nginx-module.git
https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.tar.gz
http://nginx.org/download/nginx-1.15.4.tar.gz
单机安装部署
1.基础依赖
1 | yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y |
cd /usr/local/src
git clone https://github.com/happyfish100/libfastcommon.git –depth 1
cd libfastcommon
./make.sh && ./make.sh install
1 |
|
cd /usr/local/src
git clone https://github.com/happyfish100/fastdfs.git –depth 1
cd fastdfs
./make.sh && ./make.sh install
1 |
|
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
#启用配置文件
disabled=false
#设置tracker的端口号
port=22122
#设置tracker的数据文件和日志目录(需手动创建)
base_path=/data/fastdfs/tracker/
#设置http端口号
http.server_port=8888
1 | 4.2 启动tracker |
cp storage.conf.sample storage.conf
内容
group_name=group1 # 组名(第一组为group1,第二组为group2,依次类推…)
base_path=/data/fastdfs/storage # 数据和日志文件存储根目录
store_path0=/data/fastdfs/storage #第一个存储目录,第二个存储目录起名为:store_path1=xxx,其它存储目录名依次类推…
store_path_count=1 # 存储路径个数,需要和store_path个数匹配
tracker_server=192.168.18.147:22122 # tracker服务器IP和端口
1 | 5.2 启动storage节点 |
fdfs_storaged /etc/fdfs/storage.conf restart ##启动
cat /data/fastdfs/storage/logs/storaged.log ## 日志文件
fdfs_monitor /etc/fdfs/storage.conf ## 查看storage服务器是否已经登记到tracker服务器
1 |
|
cd /usr/local/src
wget http://nginx.org/download/nginx-1.15.4.tar.gz
tar -zxvf nginx-1.15.4.tar.gz
cd nginx-1.15.4/
./configure –add-module=/usr/local/src/fastdfs-nginx-module/src/
make && make install
1 | 6.2 mod_fastdfs.conf配置 |
cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
一般只需改动以下几个参数即可:
base_path=/data/fastdfs/storage #保存日志目录
tracker_server=192.168.18.147:22122
storage_server_port=23000 #storage服务器的端口号
group_name=group1 #当前服务器的group名
url_have_group_name = true #文件url中是否有group名
store_path_count=1 #存储路径个数,需要和store_path个数匹配
store_path0=/data/fastdfs/storage #存储路径
group_count = 0 #设置组的个数
1 | 6.3 nginx.conf |
ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/M00
vim /usr/local/nginx/conf/nginx.conf
在server段中添加:
location ~/group[1-2]/M00 {
root /data/fastdfs/storage/data;
ngx_fastdfs_module;
}
1 | 6.4 启动nginx |
cp /usr/local/src/fastdfs/conf/http.conf /etc/fdfs/
cp /usr/local/src/fastdfs/conf/mime.types /etc/fdfs/
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s reload ##重启nginx
tail -f /usr/local/nginx/logs/error.log ## nginx日志
1 |
|
vim /usr/local/nginx/conf/nginx.conf
server {
#设置服务器端口
listen 8888;
#设置group1的负载均衡参数
location /group1/M00 {
proxy_pass http://192.168.18.147;
}
}
1 |
|
[root@localhost ~]# cp /etc/fdfs/client.conf.sample client.conf
[root@localhost ~]# mkdir /data/fastdfs/client
[root@localhost ~]# vim client.conf
base_path=/data/fastdfs/client #日志存放路径
tracker_server=192.168.18.147:22122
http.tracker_server_port=8080
[root@localhost ~]# fdfs_upload_file client.conf test.jpg
group1/M00/00/00/wKgSk16fpQyAH5AiAAAuxhLY-MA119.jpg
# docker
# 其他
https://zhuanlan.zhihu.com/p/32734357
https://zhuanlan.zhihu.com/p/32798888