zoukankan      html  css  js  c++  java
  • Linux下使用FastDFS

    本文所有操作均在CentOS 7.x环境下进行。

    1.1.单节点FastDFS

    整个安装过程非常复杂,很容易出错,建议进行多次备份。

    我们这里不打算安装多台虚拟机,因此会把tracker和storage都安装在一起。

    1.1.1.安装gcc

    GCC用来对C语言代码进行编译运行,使用yum命令安装:

    yum -y install gcc

    后面会用到解压命令(unzip),所以这里可以用yum把unzip 也装一下

    yum install -y unzip zip

    1.1.2.安装libevent

    yum -y install libevent

    1.1.3.安装libfastcommon-master

    解压刚刚上传的libfastcommon-master.zip
    unzip libfastcommon-master.zip
    
    进入解压完成的目录
    cd libfastcommon-master
    
    编译并且安装:
    ./make.sh 
    ./make.sh install

    1.1.4.安装fastdfs

    tar -zxvf FastDFS_v5.08.tar.gz
    
    cd FastDFS
    
    ./make.sh
    
    ./make.sh install

    如果安装成功,会看到/etc/init.d/下看到提供的脚本文件:

    • fdfs_trackerd 是tracker启动脚本

    • fdfs_storaged 是storage启动脚本

    能够在 /etc/fdfs/ 目录下看到默认的配置文件模板:

    ll /etc/fdfs/

     

    • tarcker.conf.sample 是tracker的配置文件模板

    • storage.conf.sample 是storage的配置文件模板

    • client.conf.sample 是客户端的配置文件模板

    .1.5.配置并启动tracker服务

    FastDFS的tracker和storage在刚刚的安装过程中,都已经被安装了,因此我们安装这两种角色的方式是一样的。不同的是,两种需要不同的配置文件。

    我们要启动tracker,就修改刚刚看到的tarcker.conf,并且启动fdfs_trackerd脚本即可。

    1)首先将模板文件复制

    cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf

    2)修改复制后的配置文件:

    vim /etc/fdfs/tracker.conf 

    # 修改的内容如下:

    base_path=/自己定义的存储路径(后文用~~~代替)/tracker                 # 存储日志和数据的根目录

    3)新建目录:

    mkdir -p /~~~/tracker

    注意:关闭防火墙:

    //临时关闭
    systemctl stop firewalld
    //禁止开机启动
    systemctl disable firewalld

    4)启动和停止

    启动tracker服务器: /etc/init.d/fdfs_trackerd start
    
    停止tracker服务器: /etc/init.d/fdfs_trackerd stop

    检查FastDFS Tracker Server是否启动成功:

    ps -ef | grep fdfs_trackerd

    设置tracker服务开机启动:

    chkconfig fdfs_trackerd on

    1.1.6.配置并启动storage服务

    1)首先将模板文件复制

    cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf

     

    2)修改复制后的配置文件:

    vim /etc/fdfs/storage.conf

    # 修改的内容如下:

    base_path=/leyou/storage                 # 数据和日志文件存储根目录 
    ​
    store_path0=/leyou/storage           # 第一个存储目录 
    ​
    tracker_server=192.168.56.101:22122       #  tracker服务器IP和端口 

     

    3)新建目录:

    mkdir -p /leyou/storage

    注意:关闭防火墙
    //临时关闭
    systemctl stop firewalld
    //禁止开机启动
    systemctl disable firewalld
    
    

    4)启动和停止

    启动storage服务器:/etc/init.d/fdfs_storaged start
    
    停止storage服务器:/etc/init.d/fdfs_storaged stop

    设置storage服务开机启动:

    chkconfig fdfs_storaged on
    ps -ef | grep fdfs

    使用nginx代理FastDFS访问参考博文:

    https://www.cnblogs.com/TJ21/p/12617221.html

    FastDFS使用java客户端操作参考博文:

    https://www.cnblogs.com/TJ21/p/12617226.html

  • 相关阅读:
    天梯赛5-12 愿天下有情人都是失散多年的兄妹 【dfs】
    poj2718 Smallest Difference【贪心】
    HDU problem 5635 LCP Array【思维】
    codeforces 782C Andryusha and Colored Balloons【构造】
    HDU 4278 Faulty Odometer【进制转换】
    codeforces B. The Meeting Place Cannot Be Changed【二分】
    POJ 3264 Balanced Lineup 【线段树】
    HDU 1850
    CodeForces-714C
    HDU Problem 1247 Hat's Words 【字典树】
  • 原文地址:https://www.cnblogs.com/TJ21/p/12617187.html
Copyright © 2011-2022 走看看