软件地址
创建目录
mkdir -p /fastdfs/tracker mkdir -p /fastdfs/storage/path0
安装libfastcommon
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
如图
安装fastdfs
wget https://github.com/happyfish100/fastdfs/archive/V6.06.tar.gz tar -zxvf V6.06.tar.gz ./make.sh ./make.sh install
如图
fastdfs安装完成后会在/etc/fdfs下生成配置文件
配置tracker
cd /etc/fdfs cp tracker.conf.sample tracker.conf vim tracker.conf
bash_path=/fastdfs /tracker #用于存放tracker数据和日志 http.server_port=80 #与http端口对应
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
配置storage
cp storage.conf.sample storage.conf vim storage.conf
group_name=group1 #指定storage所在组 base_path=/fastdfs/storage #storage日志和数据目录 store_path0=/fastdfs/storage/path0 tracker_server=你的IP地址:22122 #单机tracker只需写一个ip,将下一行的tracker_server注释 http.server_port=80
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
查看服务启动情况
netstat -apn|grep fdfs
如图
通过monitor来查看storage参数:
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf
配置客户端文件
cp client.conf.sample client.conf vim client.conf
base_path=/fastdfs/tracker #和tarcker.conf中base_path一致
tracker_server=你的IP地址:22122 # Tracker地址:端口
测试上传文件
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf ~/test.txt #返回上传信息及文件地址
配置nginx.conf 在server{}中写入后重启,配置成功后可通过上传文件后返回的地址访问文件
location /group1/M00 { alias /fastdfs/storage/path0/data; }
nginx整合fastdfs模块
下载fastdfs-nginx模块
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.tar.gz tar zxvf V1.22.tar.gz mv fastdfs-nginx-module-1.22 /usr/local/
安装nginx
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 --add-module=/usr/local/fastdfs-nginx-module-1.22/src/ make make install