img

FastDFS搭建文件服务器

旁观者 1年前 ⋅ 1284 阅读

FastDFS搭建文件服务器,FastDFS是一个轻量级的分布式文件系统,由跟踪服务器(Tracker Server)、存储服务器(Storage Server)和客户端(Client)构成,支持文件存储,文件同步(使用Nginx),文件访问等

一.安装配置fastdfs

1.下载安装:

安装GCC

yum -y install gcc-c++

安装libevent

yum -y install libevent

安装libfastcommon

wget -O libfastcommon-1.0.39.tar.gz  https://codeload.github.com/happyfish100/libfastcommon/tar.gz/V1.0.39
tar -zxvf libfastcommon-1.0.39.tar.gz
cd libfastcommon-1.0.39/
./make.sh 
./make.sh  install

安装fastdfs

wget -O fastdfs-5.11.tar.gz https://codeload.github.com/happyfish100/fastdfs/tar.gz/V5.11
tar -zxvf fastdfs-5.11.tar.gz
cd fastdfs-5.11/
./make.sh 
./make.sh  install

2.修改配置:

配置tracker

cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
vi /etc/fdfs/tracker.conf
#主要修改
base_path=/fastdfs/tracker/somedir  ##tracker数据和日志目录地址
http.server_port=port

配置storage

cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
vi /etc/fdfs/storage.conf
#主要修改
base_path=/fastdfs/storage/somedir  ##storage数据和日志目录地址
store_path0=/fastdfs/storage/somedir
tracker_server=host:22122
http.server_port=port

3.启动关闭

/etc/init.d/fdfs_trackerd start/stop
/etc/init.d/fdfs_storaged start/stop
或
systemctl start/stop fdfs_trackerd 
systemctl start/stop fdfs_storaged 

4.查看Storage和Tracker是否在通信

/usr/bin/fdfs_monitor /etc/fdfs/storage.conf

二.上传访问文件

1.配置客户端

cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
vi /etc/fdfs/client.conf
#主要修改
base_path=/fastdfs/storage/somedir  ##client数据和日志目录地址
tracker_server=host:22122

2.上传命令

/usr/bin/fdfs_upload_file /etc/fdfs/client.conf file

上传成功会打印文件索引

group1/M00/00/00/rBBBNV-GnQWAH25AAAE28FjpZMY382.jpg

3.访问

nginx配置代理

group/MOO -> base_path(storage)

三.同步

安装配置fastdfs-nginx-module模块

四.spring boot整合fastdfs

集体代码见github


全部评论: 0

    我有话说: