FASTDFS Cluster Installation configuration

Source: Internet
Author: User
Tags file upload mkdir zip

This article describes how to build a Fastdfs cluster

Fastdfs is an open source lightweight Distributed File system, which manages files, including file storage, file synchronization, file access (file upload, file download), and so on, which solves the problem of large capacity storage and load balancing. Especially suitable for file-based online services, such as photo album sites, video sites and so on.

Fastdfs for the Internet, fully consider the redundant backup, load balancing, linear expansion and other mechanisms, and pay attention to high availability, high performance and other indicators, the use of Fastdfs easily set up a high-performance file server cluster to provide file upload, download and other services. Environment Preparation

System System centos6.5
Six servers: 192.168.53.85/86/90 192.168.54.73/74/75
Installation package:

fastdfs-5.05.tar.gz
libfastcommon-1.0.36.zip
nginx-1.7.9.tar.gz

Server Planning

Tracker Server: 192.168.53.85/86 Storage server: 192.168.53.90 192.168.54.73/74/75 Install Fastdfs (All)

Install dependent packages

Note: Fastdfs 5.x cancels the dependency on the libevent and adds a dependency on the Libfastcommon. Before installing Fastdfs and nginx, ensure that dependent libraries and tools such as GCC, gcc-c++, libstdc++-devel, make, etc. are installed

#安装依赖软件
yum-y Install gcc gcc-c++ libstdc++-devel pcre-devel zlib-devel wget make
yum-y groupinstall ' developmen T Tools ' 

Installing the Libfastcommon class Library

Installation Fastdfs must first install the Libfastcommon class library, otherwise it will lead to error, installation directly according to the following steps can be ~

Unzip Libfastcommon-1.0.36.zip  -d/usr/local

cd/usr/local/libfastcommon-1.0.36
./make.sh
./ make.sh Install

Installing Fastdfs

Tar-xvzf fastdfs-5.05.tar.gz-c/usr/local

cd/usr/local/fastdfs-5.05/make.sh
./make.sh Install

After the installation, in the/usr/bin directory, you can see the Fdfs beginning of the command tool

After the Fastdfs installation is complete, all the configuration files in the/etc/fdfs directory, tracker need tracker.conf configuration file, storage need storage.conf configuration file. Installing Tracker (85/86)

Rename the Tracker.conf.sample file to tracker.conf, and then modify the configuration file/etc/fdfs/tracker.conf

# Store logs and data root directory
Mkdir/root/fastdfs

cd/etc/fdfs
CP tracker.conf.sample tracker.conf

Only need to modify the Base_pash path (file Store path)

VI tracker.conf
BASE_PATH=/ROOT/FASTDFS

There are several parameters to note in the configuration file:

#启用配置文件
disabled=false
#设置tracker的端口号
port=22122
#设置tracker的数据文件和日志目录 (manual creation required)
base_path=/ Root/fastdfs
#设置http端口号
http.server_port=9090

Use/usr/bin/fdfs_trackerd/etc/fdfs/tracker.conf start to try to start tracker

[root@localhost ~]# fdfs_trackerd/etc/fdfs/tracker.conf restart
[root@localhost ~]# 

Without an error, check if Port 22122 is listening and confirm that the boot was successful.

[Root@localhost ~]# ps-ef|grep fdfs
root      6078     1  0 11:59?        00:00:00/usr/bin/fdfs_trackerd/etc/fdfs/tracker.conf start
root      6101  6054  0 12:01 pts/2    00:00:00 grep fdfs
[root@localhost ~]# netstat-unltp | grep fdfs
TCP        0      0 0.0.0.0:22122               0.0.0.0:*                   LISTEN      6078/fdfs_trackerd  

You can also see if the Tracker log was started successfully

[Root@localhost ~]# cat/root/fastdfs/logs/trackerd.log 
[2017-10-09 11:59:12] Info-fastdfs v5.05, Base_path=/root /fastdfs, run_by ...

At this point, a simple tracker configuration is complete, tracker also successfully started ~, the next thing to do is to complete the configuration of storage ~ Install storage (90/73/74/75)

Divide the storage node into two groups, where Group1 (72, 73), Group2 (74, 75).

Creating a storage directory and configuration file

Mkdir/root/fastdfs

Cd/etc/fdfs
CP storage.conf.sample storage.conf

Modify Configuration

Storage mainly completes the connection address of Base_path,store_path and tracker, as well as the HTTP service port configuration of storage.

There are several main parameters:

vi/etc/fdfs/storage.conf
# content
group_name=group1                   # Group name (first group is group1, second group is group2, and so on ...) )
Base_path=/root/fastdfs             # Data and log files store the root directory
Store_path0=/root/fastdfs           #第一个存储目录, and the second storage directory is named: store_ PATH1=XXX, other storage directory names
and so on ... Store_path_count=1                  # Number of storage paths, need to match Store_path number
tracker_server=192.168.53.85:22122          # Tracker server IP and port
tracker_server=192.168.53.86:22122          # Tracker Server IP and ports

Start storage

Starting storage, the multi-level storage directory is automatically created based on the settings of the configuration file to see if Port 23000 starts listening and confirms that the boot is successful.

[root@localhost fdfs]# fdfs_storaged/etc/fdfs/storage.conf restart
[root@localhost fdfs]# NETSTAT-UNLTP | grep Fdfs
TCP        0      0 0.0.0.0:23000               0.0.0.0:*                   LISTEN      5551/fdfs_storaged  

You can also see if the log for storage started successfully.

[Root@localhost logs]# cat/root/fastdfs/logs/storaged.log 
[2017-10-09 15:39:12] Info-fastdfs v5.05, base_path=/ Root/fastdfs, Store_path_count=1 ...

Verify that storage is enlisted to the tracker server

Using fdfs_monitor/etc/fdfs/storage.conf, run Fdfs_monitor to see if the storage server is enlisted to the tracker server.

You can use the following command on any storage node to view the status information for a cluster

Fdfs_monitor/etc/fdfs/storage.conf

If ip_addr = Active is present, the storage server has been enlisted to the tracker server, as follows:

Storage 1:
        id = 192.168.53.90
        ip_addr = 192.168.53.90 (localhost)  ACTIVE

At this point, tracker, storage and other configurations are complete and successfully started

Next, continue the installation and configuration of Nginx and Fastdfs-nginx-module to install Nginx on storage

Note: The Fastdfs-nginx-module module only needs to be installed on the storage. installation

Unpacking the installation package

Tar-xvzf fastdfs-nginx-module_v1.16.tar.gz-c/usr/local
tar-zvxf nginx-1.7.9.tar.gz  -c/usr/local

You need to configure a soft link first:

Ln-sv/usr/include/fastcommon/usr/local/include/fastcommon 
ln-sv/usr/include/fastdfs/usr/local/include/ Fastdfs 
ln-sv/usr/lib64/libfastcommon.so/usr/local/lib/libfastcommon.so

When installing Nginx, add the Fastdfs-nginx-module-master module, such as:./configure--add-module=. /fastdfs-nginx-module/src/

cd/usr/local/nginx-1.7.9
./configure--prefix=/usr/local/nginx--add-module=/usr/local/fastdfs-nginx-module/ Src

Configure successful output results:

Checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... found
 + using GNU c compiler< c3/>+ gcc version:4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
checking for gcc-pipe switch ... found ...

Nginx HTTP access log file: "/usr/local/nginx/logs/access.log"
nginx HTTP client request body Temporary files: "Client _body_temp "
nginx http proxy temporary files:" proxy_temp "
nginx http fastcgi temporary files:" Fastcgi_temp " C10/>nginx http Uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "Scgi_temp" 

Configure succeeded.

Next execute make and make install

Make

Make sure the compilation is error-free and then install

Make install 

Installation successful, view version information

/usr/local/nginx/sbin/nginx-v
Configuration

Configure Fastdfs-nginx-module

Enter the SRC directory of the Fastdfs-nginx-module and copy the md_fastdfs.conf configuration file to the/etc/fdfs/directory

CD/USR/LOCAL/FASTDFS-NGINX-MODULE/SRC
CP mod_fastdfs.conf/etc/fdfs/

Configure mod_fastdfs.conf

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.