FastDFS installation and deployment

Source: Internet
Author: User
Tags crc32 file url

FastDFS installation and deployment

1. installation environment
1.1 System Environment
System: Minimal RedHat 6.4 Installation

Versions: 2.6.32-358. el6.x86 _ 64

1.2 Software Version
FastDFS version: FastDFS_v3.06.tar.gz

Nginx version: nginx-1.0.11.tar.gz

FastDFS-Nginx-module version: fastdfs-nginx-module_v1.10.tar.gz

1.3 directory structure
/Data/fastdfs/Stores logs and data

1.4 Role Assignment
Two trackers

Tracker1: 192.168.199.125

Tracker2: 192.168.199.126

Two storage

Storage1: 192.168.199.126

Storage2: 192.168.199.127

Note: 192.168.199.126 is both tracker and storage

1.5 precautions
Check whether the firewall is enabled or whether related ports are allowed to pass

2 FastDFS deployment
2.1 deploy in tracker1
1. Install the dependency package

Yum groupinstall-y "Development Tools"

Yum install-y libevent-devel pcre-devel zlib-devel

2. Install FastDFS

Mkdir-p/data/fastdfs

Tar xvzf FastDFS_v3.06.tar.gz

Cd FastDFS

Sed-I's @ # WITH_HTTPD = 1 @ WITH_HTTPD = 1 @ G' make. sh

Sed-I's @ # WITH_LINUX_SERVICE = 1 @ WITH_LINUX_SERVICE = 1 @ G' make. sh

./Make. sh

./Make. sh install

Note: The following two lines are found and the "#" in the front is removed to install the httpd and fdfs_trackerd/fdfs_storaged services.

WITH_HTTPD = 1

WITH_LINUX_SERVICE = 1

Note: if an error occurs

/Usr/bin/ld: cannot find-levent

Collect2: ld returned 1 exit status

Make: *** [fdfs_monitor] Error 1

Because libevent-devel is missing, you must install libevent-devel.

Installation Method:

Rpm-ivh libevent-doc-1.4.13-4.el6.noarch.rpm libevent-headers-1.4.13-4.el6.noarch.rpm libevent-devel-1.4.13-4.el6.x86_64.rpm

 

3. modify the configuration file tracker. conf.

Vim/etc/fdfs/tracker. conf

Base_path =/data/fastdfs

Note: configure the path for storing data and logs. If the path does not exist, you must create one by yourself.

# Include http. conf

Note: Find ## include http. conf and remove "#"

4. Modify the client. conf configuration file

Vim/etc/fdfs/client. conf

# Modify base_path

Base_path =/data/fastdfs

Note: Modify base_path

Tracker_server = 192.168.199.125: 22122

Tracker_server = 192.168.199.126: 22122

Note: Modify the tracker address. Multiple trackers are written as multiple lines. The IP address must be followed by a port.

2.2 deploy in tracker2
1. Install the dependency package

Yum groupinstall-y "Development Tools"

Yum install-y libevent-devel pcre-devel zlib-devel

 

2. Install FastDFS

Mkdir-p/data/fastdfs

Tar xvzf FastDFS_v3.06.tar.gz

Cd FastDFS

Sed-I's @ # WITH_HTTPD = 1 @ WITH_HTTPD = 1 @ G' make. sh

Sed-I's @ # WITH_LINUX_SERVICE = 1 @ WITH_LINUX_SERVICE = 1 @ G' make. sh

./Make. sh

./Make. sh install

 

Note: The following two lines are found and the "#" in the front is removed to install the httpd and fdfs_trackerd/fdfs_storaged services.

WITH_HTTPD = 1

WITH_LINUX_SERVICE = 1

Note: if an error occurs

/Usr/bin/ld: cannot find-levent

Collect2: ld returned 1 exit status

Make: *** [fdfs_monitor] Error 1

Because libevent-devel is missing, you must install libevent-devel.

Installation Method:

Rpm-ivh libevent-doc-1.4.13-4.el6.noarch.rpm libevent-headers-1.4.13-4.el6.noarch.rpm libevent-devel-1.4.13-4.el6.x86_64.rpm

 

3. modify the configuration file tracker. conf.

Vim/etc/fdfs/tracker. conf

Base_path =/data/fastdfs

Note: configure the path for storing data and logs. If the path does not exist, you must create one by yourself.

# Include http. conf

Note: Find ## include http. conf and remove "#"

 

4. Modify the client. conf configuration file

Vim/etc/fdfs/client. conf

# Modify base_path

Base_path =/data/fastdfs

Note: Modify base_path

Tracker_server = 192.168.199.125: 22122

Tracker_server = 192.168.199.126: 22122

Note: Modify the tracker address. Multiple trackers are written as multiple lines. The IP address must be followed by a port.

 

2.3 deploy in storage1
1. storage1 is tracker2, and FastDFS has been installed.

 

2. Modify the storage. conf configuration file.

Vim/etc/fdfs/storage. conf

Base_path =/data/fastdfs

Note: Modify base_path

Store_path0 =/data/fastdfs

Note: Modify store_path0, which is the data storage path.

Tracker_server = 192.168.199.125: 22122

Tracker_server = 192.168.199.126: 22122

Note: Modify the tracker address. Multiple trackers are written as multiple lines. The IP address must be followed by a port.

Http. disabled = true

Note: Disable the built-in web server

Http. server_port = 80

Note: The web server port is changed to 80.

Group_name = group1

Note: The name of the server group to which the storage1 belongs. The storage data in the same group is identical.

 

3. Install Nginx and fastdfs-nginx-module

Tar xvzf fastdfs-nginx-module_v1.10.tar.gz-C/opt

Tar xvzf nginx-1.0.11.tar.gz

Cd nginx-1.0.11

./Configure -- prefix =/usr/local/nginx -- add-module =/opt/fastdfs-nginx-module/src

Make & make install

 

Add the following content to the Nginx configuration file:

Vim/usr/local/nginx/conf/nginx. conf

 

Location/group1/M00 {

Root/data/fastdfs/data;

Ngx_fastdfs_module;

}

 

4. modify the configuration file mod_fastdfs.conf.

Cp/opt/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/

 

Vim/etc/fdfs/mod_fastdfs.conf

Base_path =/data/fastdfs

Note: directory for storing logs

Tracker_server = 192.168.199.125: 22122

Tracker_server = 192.168.199.126: 22122

Note: the ip address and port of tracker1. Multiple tracker servers can be written here, one per line

Group_name = group1

Note: name of the service group to which the storage server belongs

Url_have_group_name = true

Note: It is important to include a group name in a URL.

Store_path0 =/data/fastdfs

Note: directory for storing files

2.4 deploy in storage2
1. Install the dependency package

Yum groupinstall-y "Development Tools"

Yum install-y libevent-devel pcre-devel zlib-devel

 

2. Install FastDFS

Mkdir-p/data/fastdfs

Tar xvzf FastDFS_v3.06.tar.gz

Cd FastDFS

Sed-I's @ # WITH_HTTPD = 1 @ WITH_HTTPD = 1 @ G' make. sh

Sed-I's @ # WITH_LINUX_SERVICE = 1 @ WITH_LINUX_SERVICE = 1 @ G' make. sh

./Make. sh

./Make. sh install

 

Note: The following two lines are found and the "#" in the front is removed to install the httpd and fdfs_trackerd/fdfs_storaged services.

WITH_HTTPD = 1

WITH_LINUX_SERVICE = 1

Note: if an error occurs

/Usr/bin/ld: cannot find-levent

Collect2: ld returned 1 exit status

Make: *** [fdfs_monitor] Error 1

Because libevent-devel is missing, you must install libevent-devel.

Installation Method:

Rpm-ivh libevent-doc-1.4.13-4.el6.noarch.rpm libevent-headers-1.4.13-4.el6.noarch.rpm libevent-devel-1.4.13-4.el6.x86_64.rpm

 

2. Modify the storage. conf configuration file.

Vim/etc/fdfs/storage. conf

Base_path =/data/fastdfs

Note: Modify base_path

Store_path0 =/data/fastdfs

Note: Modify store_path0, which is the data storage path.

Tracker_server = 192.168.199.125: 22122

Tracker_server = 192.168.199.126: 22122

Note: Modify the tracker address. Multiple trackers are written as multiple lines. The IP address must be followed by a port.

Http. disabled = true

Note: Disable the built-in web server

Http. server_port = 80

Note: The web server port is changed to 80.

Group_name = group1

Note: The name of the server group to which the storage1 belongs. The storage data in the same group is identical.

 

3. Install Nginx and fastdfs-nginx-module

Tar xvzf fastdfs-nginx-module_v1.10.tar.gz-C/opt

Tar xvzf nginx-1.0.11.tar.gz

Cd nginx-1.0.11

./Configure -- prefix =/usr/local/nginx -- add-module =/opt/fastdfs-nginx-module/src

Make & make install

 

Add the following content to the Nginx configuration file:

Vim/usr/local/nginx/conf/nginx. conf

 

Location/group1/M00 {

Root/data/fastdfs/data;

Ngx_fastdfs_module;

}

 

4. modify the configuration file mod_fastdfs.conf.

Cp/opt/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/

 

Vim/etc/fdfs/mod_fastdfs.conf

Base_path =/data/fastdfs

Note: directory for storing logs

Tracker_server = 192.168.199.125: 22122

Tracker_server = 192.168.199.126: 22122

Note: the ip address and port of tracker1. Multiple tracker servers can be written here, one per line

Group_name = group1

Note: name of the service group to which the storage server belongs

Url_have_group_name = true

Note: It is important to include a group name in a URL.

Store_path0 =/data/fastdfs

Note: directory for storing files

3. Start the service
3.1 start the tracker Service
 

1. Start tracker1 and tracker2

/Etc/init. d/fdfs_trackerd start

2. View ports 8080 and 22122

Netstat-lntup | grep-E "8080 | 22122"

Tcp 0 0 0.0.0.0: 8080 0.0.0.0: * LISTEN 6087/fdfs_trackerd

Tcp 0 0 0.0.0.0: 22122 0.0.0.0: * LISTEN 6087/fdfs_trackerd

3.2 start the storage service
1. Start storage1 and storage2

/Etc/init. d/fdfs_storaged start

2. view port 80 and port 23000

Netstat-lntup | grep-E "80 | 23000"

Tcp 0 0 0.0.0.0: 80 0.0.0.0: * LISTEN 31501/nginx

Tcp 0 0 0.0.0.0: 23000 0.0.0.0: * LISTEN 31705/fdfs_storaged

3.3 start the Nginx Service

/Usr/local/nginx/sbin/nginx

4 Detection
4.1 Test on tracker1
Echo 'hello, this is my first fastdfs test'> test.txt

/Usr/local/bin/fdfs_test/etc/fdfs/client. conf upload test.txt

This is FastDFS client test program v3.06

 

Copyright (C) 2008, Happy Fish/YuQing

 

FastDFS may be copied only under the terms of the GNU General

Public License V3, which may be found in the FastDFS source kit.

Please visit the FastDFS Home Page http://www.csource.org/

For more detail.

 

[15:24:11] INFO-base_path =/data/fastdfs, connect_timeout = 30, network_timeout = 60, tracker_server_count = 2, anti_steal_token = 0, anti_steal_secret_key length = 0

 

Tracker_query_storage_store_list_without_group:

Server 1. group_name = group1, ip_addr = 192.168.199.126, port = 23000

Server 2. group_name = group1, ip_addr = 192.168.199.127, port = 23000

 

Group_name = group1, ip_addr = 192.168.199.126, port = 23000

Storage_upload_by_filename

Group_name = group1, remote_filename = M00/00/00/wKjHflYYvRuOsw3pAAAAJP1L3N8043.txt

Source ip address: 192.168.199.126

File timestamp = 15:24:11

File size = 36

File crc32 = 4249607391

File url: http: // 192.168.199.125: 8080/group1/M00/00/00/wKjHflYYvRuOsw3pAAAAJP1L3N8043.txt

Storage_upload_slave_by_filename

Group_name = group1, remote_filename = M00/00/00/wKjHflYYvRuOsw3pAAAAJP1L3N8043_big.txt

Source ip address: 192.168.199.126

File timestamp = 15:24:11

File size = 36

File crc32 = 4249607391

File url:

Http: // 192.168.199.125: 8080/group1/M00/00/00/wKjHflYYvRuOsw3pAAAAJP1L3N8043_big.txt

Use a browser to test the above URL

If the "hello, this is my first fastdfs test" content is displayed, it indicates the operation is successful.

4.2 Test on tracker2
Echo 'hello, this is fastdfs test 2'> test.txt

/Usr/local/bin/fdfs_test/etc/fdfs/client. conf upload test.txt

This is FastDFS client test program v3.06

 

Copyright (C) 2008, Happy Fish/YuQing

 

FastDFS may be copied only under the terms of the GNU General

Public License V3, which may be found in the FastDFS source kit.

Please visit the FastDFS Home Page http://www.csource.org/

For more detail.

 

[15:30:10] INFO-base_path =/data/fastdfs, connect_timeout = 30, network_timeout = 60, tracker_server_count = 2, anti_steal_token = 0, anti_steal_secret_key length = 0

 

Tracker_query_storage_store_list_without_group:

Server 1. group_name = group1, ip_addr = 192.168.199.126, port = 23000

Server 2. group_name = group1, ip_addr = 192.168.199.127, port = 23000

 

Group_name = group1, ip_addr = 192.168.199.127, port = 23000

Storage_upload_by_filename

Group_name = group1, remote_filename = M00/00/00/wKjHf1YYvoH76oI2AAAAHk9-q5s651.txt

Source ip address: 192.168.199.127

File timestamp = 15:30:09

File size = 30

File crc32 = 1333701531

File url: http: // 192.168.199.125: 8080/group1/M00/00/00/wKjHf1YYvoH76oI2AAAAHk9-q5s651.txt

Storage_upload_slave_by_filename

Group_name = group1, remote_filename = M00/00/00/wKjHf1YYvoH76oI2AAAAHk9-q5s651_big.txt

Source ip address: 192.168.199.127

File timestamp = 15:30:09

File size = 30

File crc32 = 1333701531

File url:

Http: // 192.168.199.125: 8080/group1/M00/00/00/wKjHf1YYvoH76oI2AAAAHk9-q5s651_big.txt

Use a browser to test the above URL

If "hello, this is fastdfs test 2" is displayed, it means the operation is successful.

4.3 FAQ
View the current monitoring information. Execute fdfs_monitor/etc/fdfs/client. conf on the tracker and execute fdfs_monitor/etc/fdfs/storage. conf on the storage to get the same result.

Complete installation and configuration steps for fastDFS in CentOS 6.2

FastDFS installation in Ubuntu, PHP Client

Install, configure, and test the FastDFS Distributed File Server

FastDFS integration Nginx problem sorting

Build FastDFS in CentOS

Full record of FastDFS installation in Ubuntu

FastDFS details: click here
FastDFS: click here

This article permanently updates the link address:

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.