fastdfs之同一台storage server下包含多个store path
作者:互联网
一,查看本地centos的版本
[root@localhost lib]# cat /etc/redhat-release CentOS Linux release 8.1.1911 (Core)
说明:架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,查看fdfs的版本
[root@localhost data]# fdfs_monitor /etc/fdfs/client.conf | grep version version = 6.06
三,配置storage.conf文件
[root@localhost fdfs]# vi /etc/fdfs/storage.conf
以下为各示例项的值:
我们创建3个path:
base_path = /data/fastdfs store_path_count = 3 store_path0 = /data/fastdfs/storage0 store_path1 = /data/fastdfs/storage1 store_path2 = /data/fastdfs/storage2
说明: base_path应该位于多个子目录的父层级
store_path的名字应该从0开始:例:store_path0、store_path1、
一个group中有多台storage server时,每台机器上的子目录配置应相同
四,创建storage.conf中配置的各个子目录
[root@localhost liuhongdi]# mkdir /data/fastdfs/storage0 [root@localhost liuhongdi]# mkdir /data/fastdfs/storage1 [root@localhost liuhongdi]# mkdir /data/fastdfs/storage2 [root@localhost liuhongdi]# chmod 777 /data/fastdfs/storage1 [root@localhost liuhongdi]# chmod 777 /data/fastdfs/storage0 [root@localhost liuhongdi]# chmod 777 /data/fastdfs/storage2
五,重启服务
[root@localhost liuhongdi]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop [root@localhost liuhongdi]# ps auxfww | grep fdfs root 5157 0.0 0.0 12320 1076 pts/0 S+ 16:41 0:00 | \_ grep --color=auto fdfs root 4703 0.0 0.1 155692 6964 ? Sl 16:27 0:00 \_ /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start [root@localhost liuhongdi]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start [root@localhost liuhongdi]# ps auxfww | grep fdfs root 5203 0.0 0.0 12320 1100 pts/0 S+ 16:42 0:00 | \_ grep --color=auto fdfs root 4703 0.0 0.1 155692 6964 ? Sl 16:27 0:00 \_ /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start root 5190 92.5 0.0 15168 2312 ? R 16:42 0:03 \_ /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
六,查看新建的目录是否已被fastdfs管理
[root@localhost liuhongdi]# ls /data/fastdfs/storage0/data/
说明:如果看到fastdfs已在配置目录下创建了 data及logs目录,表示目录被初始化成功
七,测试上传到指定目录
[root@localhost liuhongdi]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /home/liuhongdi/image/nginx.jpg 192.168.3.172:23000 1 group1/M01/00/00/wKgDrF5WMRWAFebkAAAyP-hllUI424.jpg
[root@localhost liuhongdi]# ls /data/fastdfs/storage1/data/00/00/ wKgDrF5WMRWAFebkAAAyP-hllUI424.jpg
说明: fdfs_upload_file命令行最后的参数1,表示对应 store_path1
如果为0,表示对应 store_path0
说明:返回的path是M01,和我们设置的path相对应
从storage1目录下可以看到相应的文件
八,在web访问中的配置
1,修改fastdfs的nginx模块的配置文件
[root@localhost liuhongdi]# vi /etc/fdfs/mod_fastdfs.conf
设置以下几项:
store_path_count=3 store_path0=/data/fastdfs/storage0 store_path1=/data/fastdfs/storage1 store_path2=/data/fastdfs/storage2
2,重启nginx
[root@localhost liuhongdi]# /usr/local/soft/nginx/sbin/nginx -s stop ngx_http_fastdfs_set pid=5946 [root@localhost liuhongdi]# /usr/local/soft/nginx/sbin/nginx ngx_http_fastdfs_set pid=5959
3,测试效果:
从浏览器访问:
http://192.168.3.172/group1/M01/00/00/wKgDrF5WMRWAFebkAAAyP-hllUI424.jpg
可以看到图片
标签:liuhongdi,fastdfs,storage,server,data,fdfs,root,localhost 来源: https://www.cnblogs.com/architectforest/p/12388923.html