fastdfs_v5.0 Distributed Storage (introduction, installation and use)

Source: Internet
Author: User
Tags odrive

Introducing Schema Analysis (http://blog.csdn.net/MONKEY_D_MENG/article/details/6038133)

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.

The FASTDFS server has two roles: Tracker (tracker) and storage node (storage).
The tracker mainly does the dispatching work, and the function of load balancing on the access.
The storage node stores files and completes all the functions of file management: storing, synchronizing and providing the Access interface, FASTDFS simultaneously manages the metadata of the files. The so-called meta data of a file is the relevant property of the file, expressed as a key-value pair (key Valuepair), such as: width=1024, where the key is Width,value 1024. File metadata is a list of file attributes that can contain multiple key-value pairs.

The storage system consists of one or more volumes, and the files between the volumes and volumes are independent of each other, and the cumulative file capacity of all volumes is the file capacity of the entire storage system. A volume can consist of one or more storage servers, and the files in a storage server under a volume are the same, and multiple storage servers in the volume play a role of redundant backup and load balancing. When adding servers to a volume, synchronizing existing files is done automatically by the system, and after synchronization is complete, the system automatically switches the new server to the online service. You can add volumes dynamically when storage space is low or is about to be exhausted. You only need to add one or more servers and configure them as a new volume, which increases the capacity of the storage system.

Upload interaction
1. Client asked tracker upload to the storage, do not need additional parameters;
2. Tracker returns a usable storage;
3. Client directly and storage communication to complete the file upload.
Download interaction
1. The client asks tracker to download the file storage, the parameter is the file identification (volume name and file name);
2. Tracker returns a usable storage;
3. Client direct and storage communication to complete the file download.

The following steps are carried out:

Server ip:192.9.38.192/193

Server System Information:

First, create a data store directory:

Mkdir/usr/local/odrive/fastdfs

Mkdir/usr/local/odrive/fastdfs/tracker #tracker目录保存运行日志

Mkdir/usr/local/odrive/fastdfs/storage #Storage目录保存运行日志及其data数据

Second, install the dependent package:

Yum install-y zlib zlib-devel pcre pcre-devel gcc gcc-c++ OpenSSL openssl-devel libevent libevent-devel Perl unzip

You can also manually download the following dependent packages as required:

Fastdfs-nginx-module_v1.16.tar.gz

Fastdfs_v5.08.tar.gz

Nginx-1.9.7.tar.gz

Libfastcommon-master.zip (Https://github.com/happyfish100/libfastcommon/archive/master.zip)

Third, installation Libfastcommon

CD libfastcommon-master/

./make.sh

./make.sh Install

Iv. installation of Fastdfs

wget http://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/FastDFS%20Server%20with% 20php%20extension%20source%20code%20v5.05/fastdfs_v5.05.tar.gz/download

Unzip into CD Fastdfs

TAR-ZXVF fastdfs_v5.05.tar.gz

sudo./make.sh

sudo./make.sh Install

Copy (unzip source code directory) under/usr/local/odrive/installsoft/fastdfs/conf/directory for all text years to/etc/fdfs/directory

Go to catalogue/USR/LOCAL/ODRIVE/INSTALLSOFT/FASTDFS-NGINX-MODULE/SRC

sudo cp mod_fastdfs.conf/etc/fdfs/

V. Configuring tracker and storage configuration files, corresponding modifications

cd/etc/fdfs/

VI storage.conf

Group_name=group1

Base_path=/export/fastdfs/storage

Store_path0=/export/fastdfs/storage

tracker_server=192.9.38.192:22122

tracker_server=192.9.38.193:22122

Http.server_port=80

I tracker.conf

Base_path=/export/fastdfs/tracker

VI mod_fastdfs.conf

Group_name=group1

Base_path=/export/fastdfs/storage

Store_path0=/export/fastdfs/storage

tracker_server=192.9.38.192:22122

tracker_server=192.9.38.193:22122

Url_have_group_name = True

VI client.conf

tracker_server=192.9.38.192:22122

tracker_server=192.9.38.193:22122

Vi. installing Nginx and Fastdfs-nginx-module modules

wget http://nginx.org/download/nginx-1.8.0.tar.gz

Http://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_ V1.16.tar.gz/download

Tar zxf fastdfs-nginx-module_v1.16.tar.gz && tar zxf nginx-1.8.0.tar.gz

#修改模块中对应的路径, or the module does not install properly

CD FASTDFS-NGINX-MODULE/SRC

VI conf #更改如下, remove local, and specify LIB64 (64 system)

core_incs= "$CORE _incs/usr/include/fastdfs/usr/include/fastcommon/"

core_libs= "$CORE _libs-l/usr/lib64-lfastcommon-lfdfsclient"

The modified example

Ngx_addon_name=ngx_http_fastdfs_module

http_modules= "$HTTP _modules ngx_http_fastdfs_module"

ngx_addon_srcs= "$NGX _addon_srcs $ngx _addon_dir/ngx_http_fastdfs_module.c"

core_incs= "$CORE _incs/usr/include/fastdfs/usr/include/fastcommon/"

core_libs= "$CORE _libs-l/usr/lib64-lfastcommon-lfdfsclient"

cflags= "$CFLAGS-d_file_offset_bits=64-dfdfs_output_chunk_size= ' 256*1024 '-dfdfs_mod_conf_filename= ' \"/etc/fdfs/ Mod_fastdfs.conf\ "'"

Ulimit-shn 102400

Useradd-s/sbin/nologin www

CD nginx-1.8.0

/configure--user=www--group=www--add-module=. /fastdfs-nginx-module/src/--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module-- With-http_realip_module

Make

Make install

Seven, configuration Nginx

server_name 192.9.38.192;

root/webdata/fastdfs.com;

Index index.html index.htm;

Location/{

if (!-e $request _filename) {

Rewrite ^ (. *) $/index.html last;

}

location/group1/m00 {

root/export/fastdfs/storage/data/;

Ngx_fastdfs_module;

}

Location ~. *\. (GIF|JPG|JPEG|PNG|BMP|SWF|JS) $ {

# Fastcgi_cache Cache_one; #nginx. conf Open the cache or start an error

Fastcgi_cache_valid 10m;

Fastcgi_cache_valid 304 3m;

Fastcgi_cache_valid 301 302 1h;

Fastcgi_cache_valid any 1m;

Fastcgi_cache_min_uses 1;

Fastcgi_cache_use_stale error timeout Invalid_header http_500;

Fastcgi_cache_key $host $request_uri;

Access_log off;

}

}

Access_log off;

}

Cd/usr/local/odrive/nginx/conf

Modify Nginx.conf

Add the following content

server {

Listen 80;

server_name 192.9.38.192;

#charset Koi8-r;

#access_log Logs/host.access.log Main;

Location/{

root HTML;

Index index.html index.htm;

}

location/group1/m00 {

root/usr/local/odrive/fastdfs/storage/data/;

Ngx_fastdfs_module;

}

#error_page 404/404.html;

# REDIRECT Server error pages to the static page/50x.html

#

Error_page 502 503 504/50x.html;

Location =/50x.html {

root HTML;

}

Eight, 193 configuration, nginx corresponding IP is 193, start Nginx and Fastdfs

/etc/init.d/nginx-t

Ngx_http_fastdfs_set pid=8985

Nginx:the configuration file/usr/local/nginx/conf/nginx.conf syntax is OK

Nginx:configuration file/usr/local/nginx/conf/nginx.conf Test is successful

[Email protected] vhost]#/etc/init.d/nginx-s Reload

Ngx_http_fastdfs_set pid=8986

Nine, testing

Enter the generated URL in the browser:

Follow up: Related knowledge, and installation configuration problems.

fastdfs_v5.0 Distributed Storage (introduction, installation and use)

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.