fastdfs 新添加一个项目的图片目录 实现独立的上传下载功能

1,功能需求

Fastdfs已经安装完成,部署过程见:http://blog.csdn.net/mchdba/article/details/50933405,fastdfs安装启动后,默认只有一个group1,只能适合用于一个项目;那么如果有新项目过来了,是否需要再准备新的linux服务器重新安装一套fastdfs呢?答案是否定的

 

这里已经实现了group1/group2/group3,现在有新的项目过来,不想重新搭建安装fastdfs环境,想直接在这上面再添加一个项目图片目录group4,存储位置要分开,实现正常上传下载访问功能。我们可以在原来的fastdfs上新添加一个group4来实现这个新的项目的图片目录的功能,这省了服务器资源也节省了部署时间。

 

操作思路是:在mod_fastdfs.conf上添加新的group组,然后准备新的storage_group4.conf文件,再启动一个fdfs_storaged进程。

 

2,配置mod_fastdfs.conf文件

 

# 创建新的group文件夹

mkdir /file/fastdfs_group4

chown –R

 

vim /etc/fdfs/mod_fastdfs.conf

# runing for haisheng,在这里添加一个新的group                      

[group4]

group_name=group4

storage_server_port=23004

store_path_count=1

store_path0=/file/fastdfs_group4

 

 

3,在nginx配置group4

        # for wenhaisheng on 20160617                                               

        location /group4/M00 {

            root   /file/fastdfs_group4/data;

            include gzip.conf;

            ngx_fastdfs_module;

            client_max_body_size 100m;

            expires 12h;

        }

 

 

 

4,启动新的fastdfs服务

 

配置新的storage_group4.conf,如下所示:

cp /etc/fdfs/storage.conf /etc/fdfs/storage_group4.conf

vim  /etc/fdfs/storage_group4.conf  # 修改如下三个值

group_name=group4

base_path=/file/fastdfs_group4

store_path0=/file/fastdfs_group4

 

 

 

启动命令比较方便,加上新的group4配置文件即可:

# 开始启动

[root@test_dev_fastdfs_32 ~]# /usr/local/bin/fdfs_storaged /etc/fdfs/storage_group4.conf

[root@test_dev_fastdfs_32 ~]#

 

# 查看fdfs进程,已经有了group4的storaged进程

[root@test_dev_fastdfs_32 ~]# ps -eaf|grep fastdfs |grep conf

fastdfs   3023     1  0 Jun17 ?        00:00:05 /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf

fastdfs  10851     1  0 Jun08 ?        00:00:42 /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

fastdfs  10867     1  0 Jun08 ?        00:00:37 /usr/local/bin/fdfs_storaged /etc/fdfs/storage_group2.conf      

fastdfs  10891     1  0 Jun08 ?        00:00:36 /usr/local/bin/fdfs_storaged /etc/fdfs/storage_group3.conf

fastdfs  31820     1  0 Jun17 ?        00:00:03 /usr/local/bin/fdfs_storaged /etc/fdfs/storage_group4.conf         

[root@test_dev_fastdfs_32 ~]#

 

 

5,测试功能

使用fdfs_test命令上传文件:

[fastdfs@test_dev_fastdfs_32 fdfs]$ /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /tmp/xg.png

This is FastDFS client test program v4.06

 

Copyright (C) 2008, Happy Fish / YuQing

 

FastDFS may be copied only under the terms of the GNU General

Public License V3, which may be found in the FastDFS source kit.

Please visit the FastDFS Home Page http://www.csource.org/

for more detail.

 

[2016-06-17 16:03:53] DEBUG - base_path=/file/fastdfs_group4, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

 

tracker_query_storage_store_list_without_group:

         server 1. group_name=, ip_addr=192.168.121.32, port=23001

 

group_name=group1, ip_addr=192.168.121.32, port=23001

storage_upload_by_filename

group_name=group1, remote_filename=M00/00/23/wKh5IFdjrumAc879AASrW0_jx78607.png

source ip address: 192.168.121.32

file timestamp=2016-06-17 16:03:53

file size=306011

file crc32=1340327871

file url: http://192.168.121.32/group1/M00/00/23/wKh5IFdjrumAc879AASrW0_jx78607.png

storage_upload_slave_by_filename

group_name=group4, remote_filename=M00/00/23/wKh5IFdjrumAc879AASrW0_jx78607_big.png

source ip address: 192.168.121.32

file timestamp=2016-06-17 16:03:53

file size=306011

file crc32=1340327871

file url: http://192.168.121.32/group1/M00/00/23/wKh5IFdjrumAc879AASrW0_jx78607_big.png

[fastdfs@test_dev_fastdfs_32 fdfs]$ vim /etc/fdfs/client.conf

[fastdfs@test_dev_fastdfs_32 fdfs]$

[fastdfs@test_dev_fastdfs_32 fdfs]$

 

 

这里fdfs_test组件默认是上传到group1上面去,那如何测试group4的功能,可以将/group1/M00/00/23/wKh5IFdjrumAc879AASrW0_jx78607_big.png copy到group4里面的对应目录去,然后把网址中的group1换成group4,新网址变成:

http://192.168.121.32/group4/M00/00/23/wKh5IFdjrumAc879AASrW0_jx78607_big.png

 

 

这样先证明了这个fastdfs的group4新目录里面的图片是可以被访问的,然后再让开发人员在调用组件上传突破的时候,将调用url里面的group1变成group4即可。

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值