Build Fastdfs Distributed storage environment (using Nginx module)

Source: Internet
Author: User

Original address: Build FASTDFS distributed storage environment (using Nginx module) Author: one page

The last version used to build Fastdfs is v4.05
http://blog.itpub.net/29254281/viewspace-1283539/
This version is already old.

The latest version is v5.04, because the author refactored the code, so there are some inconsistencies in the installation process.
Latest Version Download Address:
http://sourceforge.net/projects/fastdfs/files/
Installation can refer to the install file in the ZIP package.

Experiment or build a FASTDFS environment, and add Nginx module
The software used:
Fastdfs_v5.04.tar.gz
Libfastcommon-master.zip
Fastdfs-nginx-module_v1.16.tar.gz
Nginx-1.6.2.tar.gz


Unlike previous versions, v5.04 first needs to be installed Libfastcommon
Download Address:
Https://github.com/happyfish100/libfastcommon.git

1. Installing Libfastcommon
On each server, unzip the Libfastcommon and go to the Libfastcommon-master directory to execute
./make.sh
./make.sh Install

You can see the libfastcommon.so installed in the/usr/lib64/libfastcommon.so

But the Lib directory set by the FASTDFS main program is/usr/local/lib
So you need to create a soft link.
Ln-s/usr/lib64/libfastcommon.so/usr/local/lib/libfastcommon.so
Ln-s/usr/lib64/libfastcommon.so/usr/lib/libfastcommon.so
Ln-s/usr/lib64/libfdfsclient.so/usr/local/lib/libfdfsclient.so
Ln-s/usr/lib64/libfdfsclient.so/usr/lib/libfdfsclient.so


2. Install the FASTDFS main program
This version seems to have no need for libevent dependencies
On each server, unzip the fastdfs_v5.04.tar.gz and enter the Fastdfs directory
Perform
./make.sh
./make.sh Install
If the soft link creation of the previous step is successful, it should be very smooth.

Configuring the Tracker server (192.168.1.70)
vim/etc/fdfs/tracker.conf file, modify the following content
Base_path=/tracker
Then execute the command.
Fdfs_trackerd tracker.conf

Configuring the Storage server (192.168.1.80,192.168.1.30)
Vim/etc/fdfs/storage.conf
Group_name=group1
Base_path=/storage
Store_path0=/storage
tracker_server=192.168.1.70:22122
Then execute the command.
Fdfs_storaged storage.conf

Perform a test to modify the configuration file for the tracker server 192.168.1.70/etc/fdfs/client.conf
tracker_server=192.168.1.170:22122
Execute command
[Root@mysql1 fdfs]# Fdfs_upload_file client.conf/home/nginx/fastdfs_v5.04.tar.gz
Group1/m00/00/00/wkgbhlqvrqgarrs6aau9tcfazok.tar.gz


3. Unzip the Fastdfs-nginx-module
Fastdfs through the tracker server, put the files on the storage server storage,
However, the server between the same group needs to copy files, there is a delay problem.
Suppose the tracker server uploads the file to 192.168.1.80, the file ID has been returned to the client,
At this point, the background will copy this file to 192.168.1.30, if the replication is not completed, the client will use this ID in the 192.168.1.30 to fetch files, there will definitely be an error
This fastdfs-nginx-module can redirect connections to the source server to fetch files, preventing the client from having errors due to replication delays.

Modify the config file for Fastdfs-nginx-module
The original content is
core_incs= "$CORE _incs/usr/local/include/fastdfs/usr/local/include/fastcommon/"

Vim/home/nginx/fastdfs-nginx-module/src/config, revision changed to
core_incs= "$CORE _incs/usr/includ E/fastdfs/usr/include/fastcommon"

The location of each version is not uniform. So you need to modify the location according to your own version.

4. Installing Nginx
Install Nginx on each storage server
http://blog.itpub.net/29254281/viewspace-1283760/

Yum-y install gcc automake autoconf libtool make gcc-c++ pcre* zlib OpenSSL openssl-devel

Add Fastdfs-nginx-module Module
./configure \
--prefix=/home/nginx/nginx-1.6.2 \
--sbin-path=/home/nginx/nginx-1.6.2/nginx \
--conf-path=/home/nginx/nginx-1.6.2/nginx.conf \
--pid-path=/home/nginx/nginx-1.6.2/nginx.pid \
--with-http_ssl_module \
--add-module=/home/nginx/fastdfs-nginx-module/src

Make-j ' Cat/proc/cpuinfo | grep processor| Wc-l ' && make install

Copy the configuration files from the Fastdfs-nginx-module source to the/etc/fdfs
Cp/home/nginx/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs
Modify the configuration file
Group_name=group1
tracker_server=192.168.1.70:22122
Store_path0=/storage
Base_path=/storage

Copy the configuration of the Fastdfs to/etc/fdfs


modifying Nginx configuration Files
location/m00 {
Root/storage;
Ngx_fastdfs_module;
}
Create a soft connection in the/storage directory, linking it to the directory where the data is actually stored,
[Root@mysql2 storage]# pwd
/storage
[Root@mysql2 storage]# ln-s data/m00

The benefit of creating a soft link is the ease of managing multiple catalogs


When you start Nginx, you can download it using HTTP.

Precautions:
1.FastDFS different versions of the installation method, you need to read the install file
2.FastDFS the default location of each component may be different, you need to create the corresponding soft link according to the version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.