安装示意图
- 需要安装Tracker、Storage节点,以及集成Nginx,可以采用Http方式访问
安装FastDFS(所有机器都安装)
-
安装依赖包
yum install make cmake gcc gcc-c++ -y
-
安装libfastcommon
源码地址:https://github.com/happyfish100/libfastcommon
解压libfastcommon到/usr/local/fast/
进入源码目录unzip libfastcommon-master.zip -d /usr/local/fast/
编译和安装cd /usr/local/fast/libfastcommon-master/
./make.sh ./make.sh install
-
安装FastDFS
cd /usr/local/software tar -zxvf FastDFS_v5.08.tar.gz -C /usr/local/fast/ cd /usr/local/fast/FastDFS/ ./make.sh ./make.sh install
文件配置
-
配置跟踪器(tracker)
IP:192.168.47.203
拷贝配置文件cd /etc/fdfs/ cp tracker.conf.sample tracker.conf
修改tracker.conf
vim /etc/fdfs/tracker.conf
修改bash_path
创建目录mkdir -p /fastdfs/tracker
启动跟踪器
/etc/init.d/fdfs_trackerd start
配置开机自启vim /etc/rc.d/rc.local
加入配置
/etc/init.d/fdfs_trackerd start
-
配置存储器(storage)
IP:192.168.47.203
拷贝配置文件cd /etc/fdfs/ cp storage.conf.sample storage.conf
修改storage.conf文件
vim /etc/fdfs/storage.conf
修改内容
base_path=/fastdfs/storage store_path0=/fastdfs/storage tracker_server=192.168.47.201:22122 #tracker地址 http.server_port=88888
创建存储目录
mkdir -p /fastdfs/storage
启动存储器
/etc/init.d/fdfs_storaged start
ps -ef | grep fdfs
进入/fastdfs/storage/data/文件夹下会看到目录文件(256*256)
设置开机启动vim /etc/rc.d/rc.local
加入命令
/etc/init.d/fdfs_storaged start
-
环境测试
使用命令上传文件,在tracker(跟踪器)中上传
拷贝客户端配置文件
cd /etc/fdfs/ cp client.conf.sample client.conf
编辑client.conf文件
vim /etc/fdfs/client.conf
修改内容
base_path=/fastdfs/tracker tracker_server=192.168.47.201:22122
文件上传
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/test.png
/usr/bin/fdfs_upload_file:fdfs文件上传命令
/etc/fdfs/client.conf:文件上传配置文件
/root/test.png::上传的文件路径storage查看文件