1. What is FastDFS?
FastDFS is an open source distributed file system. It manages files. The functions include: file storage, file synchronization, file access (file upload, File download), etc., to solve the problem of large-capacity storage and load balancing. It is especially suitable for online services that use files as the carrier, such as photo album websites, video websites, and so on.
The FastDFS server has two roles: tracker and storage node (storage). The tracker mainly does the scheduling work, and plays a load balancing role in the access.
The storage node stores files and completes all the functions of file management: storage, synchronization and providing access interfaces. FastDFS also manages the meta data of files. The so-called meta data of a file is the related attribute of the file, expressed in a key value pair, such as width=1024, where the key is width and the value is 1024. File meta data is a list of file attributes, which can contain multiple key-value pairs.
The FastDFS system structure is shown in the figure below:
2. The goal of this article
The goal of this article is to install FastDFS on CentOS on a single machine, including Tracker and Storage, combined with the configuration of Nginx, and finally complete the file upload and pass Nginx path to complete the display of static file content
3. Installation preparation
3.1.1 Install dependent libraries
Before installing FastDFS and Nginx, make sure Dependent libraries and tools such as gcc, gcc-c++, libstdc++-devel, make have been installed.
Basic environment installation
yum -y install gcc gcc-c++ libstdc++-devel
yum -y groupinstall 'Development Tools'
yum -y install wget
yum -y install make
yum -y install pcre-devel
yum install -y zlib-devel
yum -y install libxml2 libxml2-dev
yum -y install libxslt-devel
yum -y install gd-devel
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
3.1.2 Install libfastcommon library
Install FastDFS The libfastcommon library must be installed first, otherwise an error will be reported. The installation can be done directly according to the following steps~
download
wget https://github.com/happyfish100/libfastcommon/archive /master.zip
Unzip
unzip master.zip
Enter
cd libfastcommon-master
or
From https://github.com/happyfish100/libfastcommon/archive /V1.0.39.tar.gz download the specified version
Unzip
tar -zxvf V.1.0.39.tar.gz
cd libfastcommon-master
Compile
./make.sh
Install
./make.sh install
The installation is over.
3.1.3 Install FastDFS
Download
wget https://github.com/happyfish100/fastdfs/archive /master.tar.gz
Unzip
tar -zxvf master.tar.gz
Enter
cd fastdfs-master/
Compile
./make.sh
Install
./make.sh install
The installation is over.
After installation, in the /usr/bin directory, you can see the command tool starting with fdfs~
After FastDFS is installed, all configuration files are in the /etc/fdfs directory, Tracker needs tracker.conf configuration file, storage needs storage.conf configuration file.
So far FastDFS has been installed, but it cannot run yet.
Basic environment installation
yum -y install gcc gcc-c++ libstdc++-devel
yum -y groupinstall 'Development Tools'
yum -y install wget
yum -y install make
yum -y install pcre-devel
yum install -y zlib-devel
yum -y install libxml2 libxml2-dev
yum -y install libxslt-devel
yum -y install gd-devel
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
download
wget https://github.com/happyfish100/libfastcommon/archive /master.zip
Unzip
unzip master.zip
Enter
cd libfastcommon-master
or
From https://github.com/happyfish100/libfastcommon/archive /V1.0.39.tar.gz download the specified version
Unzip
tar -zxvf V.1.0.39.tar.gz
cd libfastcommon-master
Compile
./make.sh
Install
./make.sh install
download
wget https://github.com/happyfish100/fastdfs/archive /master.tar.gz
Unzip
tar -zxvf master.tar.gz
Enter
cd fastdfs-master/
Compile
./make.sh
Install
./make.sh install