设为首页 收藏本站
查看: 1319|回复: 0

[经验分享] FastDFS 应用测试

[复制链接]

尚未签到

发表于 2019-1-31 13:31:45 | 显示全部楼层 |阅读模式
配置nginx为storage server提供http访问接口:

  ==============================================================================
  背景:

  •   在大多数业务场景中,往往需要为FastDFS存储的文件提供http下载服务,而尽管FastDFS在其storage及tracker都内置了http服务, 但性能表现却不尽如人意;
  •   作者余庆在后来的版本中增加了基于当前主流web服务器的扩展模块(包括nginx/apache),其用意在于利用web服务器直接对本机storage数据文件提供http服务,以提高文件下载的性能。

  描述:

  •   nginx 配置在storage节点上(本例以storage节点的node2为例);
  •   因为 nginx 要想连接 fastdfs 就必须要有相应的模块,所以要编译安装 nginx 把fastdfs-nginx-module 模块编译进去

  步骤如下:

  1.首先下载 fastdfs-nginx-module 和 编译安装nginx 的源码包
# 从官方站点上克隆 fastdfs-nginx-module 模块
[root@centos7 ~]# git clone https://github.com/happyfish100/fastdfs-nginx-module.git
Cloning into 'fastdfs-nginx-module'...
remote: Counting objects: 57, done.
remote: Total 57 (delta 0), reused 0 (delta 0), pack-reused 57
Unpacking objects: 100% (57/57), done.
# 准备好的nginx源码包如下
[root@centos7 fastdfs]# ls
fastdfs-nginx-module  nginx-1.10.0.tar.gz  
[root@centos7 fastdfs]# tar xf nginx-1.10.0.tar.gz
[root@centos7 fastdfs]# ls
fastdfs-nginx-module  nginx-1.10.0  nginx-1.10.0.tar.gz  2.准备编译安装的环境
yum groupinstall "Development Tools" "Server Platfrom Development" -y
yum install pcre-devel openssl-devel zlib-devel -y  3.创建 nginx 用户编译安装nginx,指明 fastdfs-nginx-module 模块的位置
[root@centos7 nginx-1.10.0]# useradd -r nginx
[root@centos7 nginx-1.10.0]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src
[root@centos7 nginx-1.10.0]# ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx
--with-http_ssl_module --with-http_stub_status_module --with-pcre --add-module=/root/fastdfs/fastdfs-nginx-module/src
[root@centos7 nginx-1.10.0]# make && make install  3、复制配置文件
# cp fastdfs-nginx/module/src/mod_fastdfs.conf  /etc/fdfs/
# cp fastdfs-5.0.8/conf/{httpd.conf,mime.types}  /etc/fdfs/
   注意:fastdfs-5.0.8为fastdfs源码目录;  4、配置/etc/fdfs/mod_fastdfs.conf配置文件,部分指令类似如下所示;
  base_path=/data/fdfs/storage
  tracker_server=192.168.1.112:22122
  storage_server_port=23000
  group_name=group1
  url_have_group_name = true
  store_path_count=1
  store_path0=/data/fdfs/storage/0
  [group1]
  group_name=group1
  storage_server_port=23000
  store_path_count=1
  store_path0=/data/fdfs/storage/0  5、配置nginx,编辑nginx.conf,在server中添加类似如下内容:
  location ~ /group[0-9]+/M00/ {
      root /data/fdfs/storage/0/data/;
      ngx_fastdfs_module;
  }  6、为存储文件路径创建链接至M00,此示例中使用的storage_path0为/data/fdfs/storage/0;
# ln -sv /data/fdfs/storage/0  /data/fdfs/storage/0/M00
[root@centos7 ~]# ll /data/fdfs/storage/0/
total 12
drwxr-xr-x 258 root root 8192 Mar 24 11:50 data
lrwxrwxrwx   1 root root   20 Mar 24 11:23 M00 -> /data/fdfs/storage/0  7、启动nginx服务即可;
[root@centos7 sbin]# pwd
/usr/local/nginx/sbin
[root@centos7 sbin]# ./nginx -t
ngx_http_fastdfs_set pid=27041
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@centos7 sbin]# ./nginx
[root@centos7 sbin]# ps aux| grep 'nginx'
root      27011  0.0  0.1  52880  1160 ?        Ss   11:25   0:00 nginx: master process ./nginx
nginx     27012  0.0  0.2  55524  2516 ?        S    11:25   0:00 nginx: worker process  8、上传文件,测试:
# node3 节点上传文件
[root@centos7 fdfs]# fdfs_upload_file /etc/fdfs/client.conf /usr/share/wallpapers/Autumn/contents/images/1600x1200.jpg
group1/M00/00/00/wKgBcVjUlzqAEyeUAAxFCUUQ0Sc981.jpg
[root@centos7 fdfs]# fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/wKgBcVjUlzqAEyeUAAxFCUUQ0Sc981.jpg
source storage id: 0
source ip address: 192.168.1.113
file create timestamp: 2017-03-24 11:49:14
file size: 804105
file crc32: 1158730023 (0x4510D127)
[root@centos7 fdfs]# fdfs_upload_file /etc/fdfs/client.conf /usr/share/wallpapers/Hanami/contents/images/1920x1200.jpg
group1/M00/00/00/wKgBcljUGkCAEkdsAAqAdF8ZgSw271.jpg
[root@centos7 fdfs]# fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/wKgBcljUGkCAEkdsAAqAdF8ZgSw271.jpg
source storage id: 0
source ip address: 192.168.1.114
file create timestamp: 2017-03-24 02:56:00
file size: 688244
file crc32: 1595506988 (0x5F19812C)  9.在浏览器中访问路径的URL为fid:

  

  

  

  

  

  

  

  

  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-670094-1-1.html 上篇帖子: 【编译打包】fastdfs 下篇帖子: FastDFS分布式文件存储系统
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表