引用博客:
https://www.cnblogs.com/chiangchou/p/fastdfs.html#_labelTop
https://www.jianshu.com/p/1c71ae024e5e
开源的高性能分布式文件系统(DFS)
项目地址:
https://github.com/happyfish100
https://gitee.com/fastdfs100
(略,见Docker学习总结:https://www.cnblogs.com/hutianyao/p/11395445.html)
docker pull centos:7
docker run -dit -p 30001:30001 -p 30002:30002 -p 30003:30003 --name=FastDFS centos:7
docker exec -it 63 /bin/bash
# wget
yum -y install wget
# make
yum -y install gcc automake autoconf libtool make
# vim
yum -y install vim
# netstat
yum -y install net-tools
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.43.tar.gz
tar -zxvf V1.0.43.tar.gz
cd libfastcommon-1.0.43/
./make.sh
./make.sh install
wget https://github.com/happyfish100/fastdfs/archive/V6.06.tar.gz
tar -zxvf V6.06.tar.gz
./make.sh
./make.sh install
cd /etc/fdfs
cp tracker.conf.sample tracker.conf
vim tracker.conf
# 配置文件是否不生效,false 为生效
disabled=false
# 提供服务的端口(默认22122)
port=30001
# Tracker 数据和日志目录地址(根目录必须存在,子目录会自动创建)
base_path=/apps/FastDFS/data/tracker
# HTTP 服务端口(默认8080)
http.server_port=30003
cd /usr/bin
fdfs_trackerd /etc/fdfs/tracker.conf restart
netstat -unltp|grep fdfs
正常启动结果
tcp 0 0 0.0.0.0:30001 0.0.0.0:* LISTEN 744/fdfs_trackerd
cd /etc/fdfs
cp storage.conf.sample storage.conf
vim storage.conf
# 配置文件是否不生效,false 为生效
disabled=false
# 指定此 storage server 所在 组(卷)
group_name=group1
# storage server 服务端口(默认23000)
port=30002
# 心跳间隔时间,单位为秒 (这里是指主动向 tracker server 发送心跳)
heart_beat_interval=30
# Storage 数据和日志目录地址(根目录必须存在,子目录会自动生成)
base_path=/apps/FastDFS/data/storage
# 存放文件时 storage server 支持多个路径。这里配置存放文件的基路径数目,通常只配一个目录。
store_path_count=1
# 逐一配置 store_path_count 个路径,索引号基于 0。
# 如果不配置 store_path0,那它就和 base_path 对应的路径一样。
store_path0=/apps/FastDFS/data/file
# FastDFS 存储文件时,采用了两级目录。这里配置存放文件的目录个数。
# 如果本参数只为 N(如: 256),那么 storage server 在初次运行时,会在 store_path 下自动创建 N * N 个存放文件的子目录。
subdir_count_per_path=256
# tracker_server 的列表 ,会主动连接 tracker_server
# 有多个 tracker server 时,每个 tracker server 写一行
tracker_server=120.55.101.177:30001
# 允许系统同步的时间段 (默认是全天) 。一般用于避免高峰同步产生一些问题而设定。
sync_start_time=00:00
sync_end_time=23:59
# 访问端口(默认8888)
http.server_port=30002
cd /usr/bin
./fdfs_storaged /etc/fdfs/storage.conf restart
netstat -unltp|grep fdfs
正常启动结果
tcp 0 0 0.0.0.0:30002 0.0.0.0:* LISTEN 755/./fdfs_storaged
tcp 0 0 0.0.0.0:30001 0.0.0.0:* LISTEN 744/fdfs_trackerd
cd /etc/fdfs
cp client.conf.sample client.conf
vim client.conf
# Client 的数据和日志目录
base_path=/apps/FastDFS/data/client
# Tracker端口
tracker_server=120.55.101.177:30001
cd /apps
touch test.txt
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf test.txt
成功返回:
group1/M00/00/00/eDdlsV7k1TKALIuqAAAAAAAAAAA648.txt
① gcc 安装
# yum install gcc-c++
② PCRE pcre-devel 安装
# yum install -y pcre pcre-devel
③ zlib 安装
# yum install -y zlib zlib-devel
④ OpenSSL 安装
# yum install -y openssl openssl-devel
wget http://nginx.org/download/nginx-1.19.0.tar.gz
tar -zxvf nginx-1.19.0.tar.gz
cd nginx-1.19.0
./configure --prefix=/apps/Nginx/nginx
make
make install
cd /apps/Nginx/nginx/sbin
./nginx
# nginx命令
./nginx -s stop
./nginx -s quit
./nginx -s reload
listen 30003;
location /group1/M00 {
alias /apps/FastDFS/data/file/data;
}
cd /apps/Nginx/nginx/sbin
./nginx -s reload
安装配置Nginx模块:fastdfs-nginx-module
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.tar.gz
tar zxvf V1.22.tar.gz
重新配置Nginx
cd /apps/Nginx/nginx/sbin
./nginx -s stop
./configure --prefix=/apps/Nginx/nginx --add-module=/apps/FastDFS/app/fastdfs-nginx-module/fastdfs-nginx-module-1.22/src
make
make install
cd /apps/Nginx/nginx/sbin
./nginx -V
出现结果:
nginx version: nginx/1.19.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
configure arguments: --prefix=/apps/Nginx/nginx --add-module=/apps/FastDFS/app/fastdfs-nginx-module/fastdfs-nginx-module-1.22/src
修改配置文件
cd /apps/FastDFS/app/fastdfs-nginx-module/fastdfs-nginx-module-1.22/src
cp mod_fastdfs.conf /etc/fdfs/
cd /etc/fdfs/
vim mod_fastdfs.conf
# 连接超时时间connect_timeout=10
# Tracker Server(默认22122)
tracker_server=120.55.101.177:30001
# Storage Server 端口(默认23000)
storage_server_port=30002
# 如果文件ID的uri中包含/group**,则要设置为true
url_have_group_name = true
# Storage 配置的store_path0路径,必须和storage.conf中的一致
store_path0=/apps/FastDFS/data/file
复制 FastDFS 的部分配置文件到/etc/fdfs 目录
cd /apps/FastDFS/app/fastdfs/fastdfs-6.06/conf/
cp anti-steal.jpg http.conf mime.types /etc/fdfs/
cd /apps/Nginx/nginx/conf/
vim nginx.conf
将
location /group1/M00 {
alias /apps/FastDFS/data/file/data;
}
修改为
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
}
ln -s /ljzsg/fastdfs/file/data/ /ljzsg/fastdfs/file/data/M00
cd /apps/Nginx/nginx/sbin/
./nginx
docker commit -a "hutianyao" -m "fastdfs" -p 6352f82ed1b8 fastdfs:0.1
原文:https://www.cnblogs.com/hutianyao/p/13122271.html