zoukankan      html  css  js  c++  java
  • fastdfs单机安装实操

    安装环境:centos7,

    安装版本:FastDFS_v5.05,nginx-1.8.1

    安装要求:root用户执行

    1,fastdfs安装

    (1)目录创建
    cd /usr/local

    mkdir mysoft


    cd mysoft
    (2)基础库安装 libfastcommon-1.0.7.tar.gz

    上传到mysoft路径下

    解压:
    [root@localhost mysoft]# tar -zxvf libfastcommon-1.0.7.tar.gz

    [root@localhost mysoft]# cd libfastcommon-1.0.7/

    [root@localhost libfastcommon-1.0.7]# ./make.sh

    [root@localhost libfastcommon-1.0.7]# ./make.sh install


    注意:libfastcommon安装好后会自动将库文件拷贝至/usr/lib64下,由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件拷贝至/usr/lib下

    拷贝:
    [root@localhost lib]# cp /usr/lib64/libfastcommon.so /usr/lib/

    (3)安装fastDFS FastDFS_v5.05.tar.gz
    上传到 /usr/local/mysoft路径下

    [root@localhost lib]# cd /usr/local/mysoft

    [root@localhost mysoft]# tar -zxvf FastDFS_v5.05.tar.gz

    [root@localhost mysoft]# cd FastDFS/

    [root@localhost FastDFS]# ./make.sh  ---该步操作会出现警告warning,可以忽略。

    [root@localhost FastDFS]# ./make.sh install


    注意:安装成功将安装目录下的conf下的文件(主要是http.conf,mime.types)拷贝到/etc/fdfs/下。
    [root@localhost FastDFS]# cd conf

    [root@localhost conf]# cp http.conf /etc/fdfs/
    [root@localhost conf]# cp mime.types /etc/fdfs/

    2,tracker配置

    [root@localhost ~]# cd /etc/fdfs/

    [root@localhost fdfs]# cp tracker.conf.sample tracker.conf

    [root@localhost fdfs]# vi tracker.conf

    自行修改conf文件里的base_path=/home/yuqing/FastDFS

    本次操作改为base_path=/home/fdfs/fastdfs

    注意:创建tracker.conf里配置的路径
    [root@localhost fdfs]# mkdir -p /home/fdfs/fastdfs

    启动:
    [root@localhost fdfs]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart


    验证:
    [root@localhost fdfs]# ps -ef|grep fdfs
    root      74977      1  0 20:16 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
    root      75251  52003  0 20:16 pts/3    00:00:00 grep --color=auto fdfs

    存在fdfs_trackerd进程,说明启动成功

    3,server配置
    [root@localhost fdfs]# cp storage.conf.sample storage.conf

    [root@localhost fdfs]# vi storage.conf

    group_name=group1

    base_path=/home/yuqing/FastDFS改为:base_path=/home/fdfs/fastdfs

    store_path0=/home/yuqing/FastDFS改为:store_path0=/home/fdfs/fastdfs/fdfs_storage

    #如果有多个挂载磁盘则定义多个store_path,如下

    #store_path1=.....

    #store_path2=......
    tracker_server=192.168.60.128:22122 #配置tracker服务器IP

    #如果有多个则配置多个tracker

    tracker_server=192.168.60.128:22122

    创建conf里配置的路径目录
    [root@localhost fdfs]# mkdir -p /home/fdfs/fastdfs/fast_storage

    启动:
    [root@localhost fdfs]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

    验证:
    [root@localhost fdfs]# ps -ef|grep fdfs
    root      74977      1  0 20:16 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
    root     106669      1  2 20:30 ?        00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
    root     106943  52003  0 20:30 pts/3    00:00:00 grep --color=auto fdfs

    出现fdfs_storaged进程说明成功。若没有该进程检查conf里路径是否配置正确


    4,fasttest上传测试

    上传到/home路径下一张图片,用于上传测试

    [root@localhost fdfs]# cp client.conf.sample client.conf

    [root@localhost fdfs]# vi client.conf
    修改
    base_path=/home/fdfs/fastdfs

    tracker_server=192.168.60.128:22122

    上传命令:
    /usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/ting.jpg

    上传前可以打开/home/fdfs/fastdfs/fast_storage/data/00/00路径查看里面内容是空的

    上传命令执行后再次打开会发现里面出现了文件

    [root@localhost fdfs]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/timg.jpg


    This is FastDFS client test program v5.05

    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.

    [2020-04-08 20:37:47] DEBUG - base_path=/home/fdfs/fastdfs, 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.60.128, port=23000

    group_name=group1, ip_addr=192.168.60.128, port=23000
    storage_upload_by_filename
    group_name=group1, remote_filename=M00/00/00/wKg8il6OmIuAehSgAAMkvt7c1AI599.jpg
    source ip address: 192.168.60.128
    file timestamp=2020-04-08 20:37:47
    file size=206014
    file crc32=3739014146
    example file url: http://192.168.60.128/group1/M00/00/00/wKg8il6OmIuAehSgAAMkvt7c1AI599.jpg
    storage_upload_slave_by_filename
    group_name=group1, remote_filename=M00/00/00/wKg8il6OmIuAehSgAAMkvt7c1AI599_big.jpg
    source ip address: 192.168.60.128
    file timestamp=2020-04-08 20:37:47
    file size=206014
    file crc32=3739014146
    example file url: http://192.168.60.128/group1/M00/00/00/wKg8il6OmIuAehSgAAMkvt7c1AI599_big.jpg


    成功后终端会显示以上内容。其中 192.168.60.128为storage服务地址,group1为组名(单机就默认group1),M00/00/00/wKg8il6OmIuAehSgAAMkvt7c1AI599_big.jpg 为目录及上传的文件名称
    后续配置完成nginx后可以通过浏览器访问该文件,访问路径参考http://192.168.60.128/group1/M00/00/00/wKg8il6OmIuAehSgAAMkvt7c1AI599_big.jpg

    5,fast-nginx插件安装 fastdfs-nginx-module_v1.16.tar.gz

    上传到/usr/local/mysoft路径下

    [root@localhost mysoft]# tar -zxvf fastdfs-nginx-module_v1.16.tar.gz

    [root@localhost mysoft]# cd fastdfs-nginx-module/src

    修改config文件,将文件中的/usr/local/路径都改为/usr/

    CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
    CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"

    将mod_FastDFS.conf拷贝至/etc/fdfs/下
    [root@localhost src]# cp mod_fastdfs.conf /etc/fdfs/

    [root@localhost src]# cd /etc/fdfs/

    修改:
    [root@localhost fdfs]# vi mod_fastdfs.conf

    base_path=/home/fdfs/fastdfs

    tracker_server=192.168.60.128:22122

    #tracker_server=192.168.60.129:22122(多个tracker配置多行)

    url_have_group_name=true #url中包含group名称

    store_path0=/home/fdfs/fastdfs/fdfs_storage #指定文件存储路径


    拷贝:

    [root@localhost fdfs]# cp /usr/lib64/libfdfsclient.so /usr/lib/

    6,nginx安装  nginx-1.8.1.tar.gz

    上传到/usr/local/mysoft路径下
    [root@localhost fdfs]# cd /usr/local/mysoft/

    [root@localhost mysoft]# tar -zxvf nginx-1.8.1.tar.gz

    执行nginx配置时添加上FastDFS-nginx-module模块
    [root@localhost nginx-1.8.1]# ./configure --prefix=/usr/local/nginx --add-module=/usr/local/mysoft/fastdfs-nginx-module/src

    [root@bogon nginx-1.8.1]# make

    [root@bogon nginx-1.8.1]# make install

    修改nginx.conf配置

    [root@bogon nginx-1.8.1]# cd /usr/local/nginx/

    [root@bogon nginx]# cd conf

    [root@bogon conf]# vi nginx.conf

    server {

    listen 8888;---由80改为8888,也可以默认80,但需要调整fastdfs配置文件里的端口号

    server_name 192.168.60.128;

    location /group1/M00/{

    ngx_fastdfs_module;

    }

    }

    启动nginx
    [root@bogon nginx]# cd sbin/

    [root@bogon sbin]# ./nginx

    [root@bogon sbin]# ps -ef|grep nginx
    root      87568      1  0 03:30 ?        00:00:00 nginx: master process ./nginx
    nobody    87569  87568  0 03:30 ?        00:00:00 nginx: worker process
    root      87889  31431  0 03:30 pts/1    00:00:00 grep --color=auto nginx

    7,nginx访问测试

    http://192.168.60.128:8888/group1/M00/00/00/wKg8il6OmIuAehSgAAMkvt7c1AI599_big.jpg

    就可以直接在浏览器上打开图片

    8、开机自启配置

    [root@bogon rc.d]# vi /etc/rc.d/rc.local

    添加上

    /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
    /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

    有的rc.local权限太低,需要额外授权

    [root@bogon rc.d]# chmod +x /etc/rc.d/rc.local

  • 相关阅读:
    Leetcode 50.Pow(x,n) By Python
    Leetcode 347.前K个高频元素 By Python
    Leetcode 414.Fizz Buzz By Python
    Leetcode 237.删除链表中的节点 By Python
    Leetcode 20.有效的括号 By Python
    Leetcode 70.爬楼梯 By Python
    Leetcode 190.颠倒二进制位 By Python
    团体程序设计天梯赛 L1-034. 点赞
    Wannafly挑战赛9 C-列一列
    TZOJ Start
  • 原文地址:https://www.cnblogs.com/jybky/p/12668807.html
Copyright © 2011-2022 走看看