HOWTO: Installing FastDFS

Introduction
FastDFS is a high performance distributed file system (DFS). Its major functions include: file storing, file syncing and file accessing, and design for high capacity and load balancing.

You may not mount a FastDFS volume directly to FreeBSD, however, you can access the volume(s) through the provided Nginx/Apache module and/or several languages such as C++, PHP, .NET, Java, Python

The software works in the same manner a RAID 10 volume would be configured, but instead of harddrives you configure the array with servernodes. One can read more about it here: http://code.google.com/p/fastdfs/wiki/Overview

Installation
  • Let's start with installing the only dependency:

    Code:
    cd /usr/ports/devel/libevent
    make install clean
  • Create and add pre-make stuff that FastDFS needs to be able to be built properly without errors:


    Code:
    mkdir /usr/lib64
    echo '' >> /usr/include/sys/errno.h
    echo '#ifndef ENONET' >> /usr/include/sys/errno.h
    echo '#define ENONET		64		/* Machine is Not on the Network */' >> /usr/include/sys/errno.h
    echo '#endif' >> /usr/include/sys/errno.h

    Note that the line
    Code:
    echo '#define ENONET		64		/* Machine is Not on the Network */' >> /usr/include/sys/errno.h
    needs to contain tabs. For some reason the forum won´t allow me to output them. So if you copy/paste from this guide you have to open /usr/include/sys/errno.h and add tabs to the value you just inserted for it to work properly. Just compare the line you added to the rest of the lines in /usr/include/sys/errno.h and you will understand.
  • Let's download FastDFS and install:
    Code:
    cd ~/
    fetch "http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz"
    tar -zxvf FastDFS_v4.06.tar.gz
    cd ~/FastDFS
    sh make.sh
    sh make.sh install
  • Init scripts:
    FastDFS does not provide any native FreeBSD init scripts for its daemons so I did create them. I have also provided them upstream so at the time of installing you might be able to skip this step depending on if they have been added or not.
  • Download http://forums.freebsd.org/attachment.php?attachmentid=1963&d=1380026763 and place it in /usr/local/etc/rc.d/
    Code:
    cd /usr/local/etc/rc.d/
    tar -zxvf fdfs_init_scripts.tar.gz
    rm fdfs_init_scripts.tar.gz
    chmod 555 fdfs*
  • Enable the daemon you want to run on the specific server:
    echo 'fdfs_trackerd_enable="YES"' >> /etc/rc.conf
    echo 'fdfs_storaged_enable="YES"' >> /etc/rc.conf

    You may also specify a different configuration location with
    Code:
    fdfs_trackerd_config=""
    and
    Code:
    fdfs_storaged_config=""
    in your /etc/rc.conf.
 

Attachments

  • fdfs_init_scripts.tar.gz
    693 bytes · Views: 212
I am curious as well on how you would set this up for a production environment. For me, the only experience with DFS would be OpenAFS, and a customized version of what S3 is like in terms of volumes.
 
So far it's been working great in production, unfortunately I have no stats to show but it's a pretty busy environment. I'm using it for web-content storing so everything is uploaded with PHP through the extension and accessed through Nginx. My setup isn't that big, it's only a 3.5 TB volume with two nodes for HA purposes. (More or less like a RAID 1 setup.)

Server structure:
  • fw-01 running trackerd
  • fw-02 running trackerd
  • content-01 running storaged (has a 3.5 TB RAID)
  • content-02 running storaged (has a 3.5 TB RAID)
And if I want at a later time I can add content-03 and 04 and I´ll get the space those have available added.
 
Back
Top