FastDFS安装部署与使用
安装部署
- 1.安装依赖库: yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
- 2.提前下载好需要的软件包(你也可以按照其他版本,但是需要版本间匹配):
- (1)下载libfastcommon环境包:wget https://github.com/happyfish100/libfastcommon/archive/refs/tags/V1.0.64.tar.gz
- (2)下载Fastdfs分离出的网络框架-libserverframe:wget https://github.com/happyfish100/libserverframe/archive/refs/tags/V1.1.23.tar.gz
- (3)下载Fastdfs包:wget https://github.com/happyfish100/fastdfs/archive/refs/tags/V6.9.1.tar.gz
- 3.按照上面的顺序以此解压包,并cd进入之后执行 ./make.sh && ./make.sh isntall
- 4.配置文件:依次安装完成后,配置文件也被安装在/etc/fdfs/下
- cd /fastdfs-6.9.1/conf 并执行 cp anti-steal.jpg http.conf mime.types /etc/fdfs/
- 修改/etc/fdfs/下面的tracker.conf,storage.conf和client.conf 主要是修改base_path等路径(搜索关键字/home/yuqing/),tracker_server(一般填写本机IP,多个server请填写多个)
- 5.启动服务:
- (1)安装完成后有服务启动文件/usr/lib/systemd/system/fdfs_trackerd.service 和 fdfs_storaged.service,根据情况修改里面的 PIDFile 文件位置和二进制文件位置。
- (2)systemctl start fdfs_trackerd; systemctl start fdfs_trackerd
- (3)netstat -apn|grep fdfs 可以查看到22122端口和23000端口的服务
- 6.验证服务:
- fdfs_monitor /etc/fdfs/client.conf 查看运行状态,集群状态
- fdfs_upload_file /etc/fdfs/client.conf test.jpg
- fdfs_download_file client.conf group1/M00/00/00/wKgfgGTtl_mAfzbcAAAADVZ4uvs276.txt; fdfs_download_file client.conf group1/M00/00/00/CTveAAADeLE3ZJc.29.txt /usr/other-name.txt
- fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt
- fdfs_append_file <config_file> <appender_file_id> <local_filename> 上传断点文件
nginx配合FastDFS实现HTTP文件访问
安装nginx并修改nginx的配置文件,添加如下内容:
location /group1/M00 {
alias /home/fastdfs/storage/data;
}
重启nginx即可。可以访问已上传文件http://192.168.1.2/group1/M00/00/00/wKgfgGTtl_mAfzbcAAAADVZ4uvs276.txt,访问端口是nginx端口。