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 that manages files, including file storage, file synchronization, file access (file uploads, file downloads), and so on, which solves the problem of large capacity storage and load balancing. Especially suitable for the document as the carrier of online services, such as photo albums, video sites and so on.

Fastdfs for the Internet tailored to fully consider the redundant backup, load balancing, linear expansion and other mechanisms, and focus on high availability, high-performance and other indicators, the use of Fastdfs is easy to build a high-performance file server cluster to provide file upload, download and other services. Environmental Preparedness

System System centos6.5
Six servers: 192.168.53.85/86/90 192.168.54.73/74/75
Install 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 installation Fastdfs (All)

Install Dependency Pack

Note: The Fastdfs 5.x cancels the dependency on the libevent, adding a dependency on Libfastcommon. Before installing Fastdfs and Nginx, make sure that dependent libraries and tools such as GCC, gcc-c++, libstdc++-devel and make 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 Libfastcommon class library, otherwise will cause error, installation directly according to the following steps can ~

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

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

Install Fastdfs

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

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

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

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

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

# root directory for storing logs and data
Mkdir/root/fastdfs

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

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

VI tracker.conf
BASE_PATH=/ROOT/FASTDFS

There are several parameters in the configuration file that need to be noted:

#启用配置文件
disabled=false
#设置tracker的端口号
port=22122
#设置tracker的数据文件和日志目录 (manually created)
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 to see if Port 22122 starts listening and confirms that the startup 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 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 completed, tracker also successfully launched ~, the next thing to do is to complete the storage configuration ~ installation Storage (90/73/74/75)

Divide the storage nodes 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 Base_path,store_path and tracker connection address as well as storage HTTP service port configuration and so on.

There are several main parameters:

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

Start storage

Starting storage automatically creates a multilevel storage directory based on the configuration file's settings to see if Port 23000 starts listening and confirms that the startup was 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 storage log 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 has been enlisted to the tracker server.

You can view the status information for a cluster by using the following command on either storage node

Fdfs_monitor/etc/fdfs/storage.conf

If ip_addr = Active appears, the storage server is 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 so on are completed and successfully started

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

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

Unpack 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 soft links 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 the 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 there are no errors in the compilation, and then install

Make install 

Installation successful, viewing version information

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

Configure Fastdfs-nginx-module

Enter the Fastdfs-nginx-module src directory and copy the md_fastdfs.conf configuration file into 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.