FastDFS installation configuration, fastdfs

Source: Internet
Author: User

FastDFS installation configuration, fastdfs

FastDFS

FastDFS is customized for the Internet, fully considering redundant backup, load balancing, linear resizing and other mechanisms, and paying attention to high availability, high performance and other indicators, using FastDFS, you can easily build a high-performance file server cluster to provide file upload and download services.

1. The required installation package

2. Install the server (disable the Server Firewall service iptables stop setenforce 0)

192.168.241.20.------------------------> tracker server

192.168.241.138 ------------------------> storage server (group1)

192.168.241.139 ----------------------> storage server (group1)

3. tracker Installation

Yum-y install gcc-c ++ (install the compilation tool)
Yum-y install libevent (FastDFS depends on libevent Library)
Mv libfastcommonV1.0.7.tar.gz/usr/local (put libfastcommon in the/usr/local directory)
Cd/usr/local
Tar-zxvf libfastcommonV1.0.7.tar.gz (decompress libfastcommon)
Cd libfastcommon-1.0.7/
./Make. sh (compile libfastcommon)
./Make. sh install (install libfastcommon)
Cp/usr/lib64/libfastcommon. so/usr/lib (Note: After libfastcommon is installed, the library file is automatically copied to/usr/lib64, because the FastDFS program references the usr/lib directory, You need to copy the library files under/usr/lib64 to/usr/lib)
Mv FastDFS_v5.05.tar.gz/usr/local/(put the FastDFS installation package in the/usr/local directory)
Cd/usr/local
Tar-zxvf FastDFS_v5.05.tar.gz (unzip the FastDFS installation package)
Cd FastDFS
./Make. sh (compile FastDFS)
./Make. sh install (install FastDFS)
Cp/usr/local/FastDFS/conf/http. conf/etc/fdfs/(copy http. conf to the/etc/fdfs directory)
Cp/usr/local/FastDFS/conf/mime. types/etc/fdfs/(copy mime. types to the/etc/fdfs directory)
Cd/etc/fdfs/(enter the FastDFS configuration file directory)
Cp tracker. conf. sample tracker. conf (copy a new tracker configuration file)
Mkdir-p/home/FastDFS (create the FastDFS working directory)
Vim tracker. conf (configuration file, # HTTP port on this tracker server http. server_port = 8080 # the tracker server port = 22122 the default port is not configured here)
Base_path =/home/FastDFS
/Usr/bin/fdfs_trackerd/etc/fdfs/tracker. conf restart (start the tracker server)

 

4. storage Installation

Yum-y install gcc-c ++ (install the compilation tool)
Yum-y install libevent (FastDFS depends on libevent Library)
Mv libfastcommonV1.0.7.tar.gz/usr/local (put libfastcommon in the/usr/local directory)
Cd/usr/local
Tar-zxvf libfastcommonV1.0.7.tar.gz (decompress libfastcommon)
Cd libfastcommon-1.0.7/
./Make. sh (compile libfastcommon)
./Make. sh install (install libfastcommon)
Cp/usr/lib64/libfastcommon. so/usr/lib (Note: After libfastcommon is installed, the library file is automatically copied to/usr/lib64, because the FastDFS program references the usr/lib directory, You need to copy the library files under/usr/lib64 to/usr/lib)
Mv FastDFS_v5.05.tar.gz/usr/local/(put the FastDFS installation package in the/usr/local directory)
Cd/usr/local
Tar-zxvf FastDFS_v5.05.tar.gz (unzip the FastDFS installation package)
Cd FastDFS
./Make. sh (compile FastDFS)
./Make. sh install (install FastDFS)
Cp/usr/local/FastDFS/conf/http. conf/etc/fdfs/(copy http. conf to the/etc/fdfs directory)
Cp/usr/local/FastDFS/conf/mime. types/etc/fdfs/(copy mime. types to the/etc/fdfs directory)
Cd/etc/fdfs/(enter the FastDFS configuration file directory)
Cp storage. conf. sample storage. conf (copy a new tracker configuration file)
Vim storage. conf (# the port of the web server on this storage server http. server_port = 8888 by default, set as needed)
Group_name = group1 (group name)
Base_path =/home/FastDFS (Basic directory)
Store_path0 =/home/FastDFS/fdfs_storage (storage directory)
Tracker_server = 192.168.101.3: 22122 (tracker server)
Mkdir-p/home/FastDFS (create the FastDFS working directory)
Mkdir-p/home/FastDFS/fdfs_storage (storage directory)
/Usr/bin/fdfs_storaged/etc/fdfs/storage. conf restart (start the storage server)

 

5. Upload image test (tracker server)

Cd/etc/fdfs/
Cp client. conf. sample client. conf (you can test the upload and download operations through/usr/bin/fdfs_test if FastDFS is successfully installed)
Vim client. conf (modify the configuration file)
Base_path =/home/FastDFS
Tracker_server = 192.168.241.20.: 22122

 

Format:/usr/bin/fdfs_test client configuration file address upload File

For example, upload an image under/home to FastDFS:/usr/bin/fdfs_test/etc/fdfs/client. conf upload/home/567.png tracker server. Display log: storage Server:

 

6. FastDFS and nginx Integration

The tracker server installs nginx for load balancing, And the nginx server installs nginx for http download.

To reflect the load balancing effect, set 192.168.241.138 to group1 and 192.168.241.139 to group2.

6.1 install nginx on tracker

Yum install-y pcre-devel (dependency)
Yum install-y zlib-devel (dependency)
Yum install-y openssl-devel (dependency)
Mv nginx-1.8.0.tar.gz/usr/local (put the nginx installation package in the/usr/local/directory)
Cd/usr/local
Tar-zxvf nginx-1.8.0.tar.gz (unzip nginx installation package)
Mkdir-p/var/temp/nginx (create nginx temporary file directory)
Cd/usr/local/nginx-1.8.0

(Configure nginx prefix and specify the installation directory. Specify the temporary file directory/var/temp/nginx on the nginx installation directory, create temp and nginx directories under/var)
. /Configure \ -- prefix =/usr/local/nginx \ -- pid-path =/var/run/nginx. pid \ -- lock-path =/var/lock/nginx. lock \ -- error-log-path =/var/log/nginx/error. log \ -- http-log-path =/var/log/nginx/access. log \ -- with-http_gzip_static_module \ -- http-client-body-temp-path =/var/temp/nginx/client \ -- http-proxy-temp-path =/var/temp/nginx /proxy \ -- http-fastcgi-temp-path =/var/temp/nginx/fastcgi \ -- http-uwsgi-temp-path =/var/temp/nginx/uwsgi \-- http-scgi-temp-path =/var/temp/nginx/scgi make (Compilation) make install (installation)

 

Cd/usr/local/nginx/conf/(open the nginx configuration file)
Vim nginx. conf (edit nginx configuration file)

 

 upstream storage_server_group1{        server 192.168.241.138:8888 weight=10;    }    upstream storage_server_group2{        server 192.168.241.139:8888 weight=10;    }    server {        listen 8080;        server_name ccc.test.com;        location /group1{                proxy_redirect off;                proxy_set_header Host $host;                proxy_set_header X-Real-IP $remote_addr;                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;                proxy_pass http://storage_server_group1;        }        location /group2{                proxy_redirect off;                proxy_set_header Host $host;                proxy_set_header X-Real-IP $remote_addr;                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;                proxy_pass http://storage_server_group2;        }    }

 

 

6.2storage: nginx

Yum install-y pcre-devel (dependency) yum install-y zlib-devel (dependency) yum install-y openssl-devel (dependency)
Mv fastdfs-nginx-module_v1.16.tar.gz/usr/local (put fastdfs and nginx integration package under/usr/local)
Mv nginx-1.8.0.tar.gz/usr/local (put the nginx installation package under/usr/local)
Tar-zxvf fastdfs-nginx-module_v1.16.tar.gz (extract integration package)
Cd fastdfs-nginx-module/src/(open the configuration folder)
Vim config

 

Modify the/usr/local/path in the config file to/usr/

Cp/usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/(put the integrated configuration file in the fastdfs configuration folder)
Vi/etc/fdfs/mod_FastDFS.conf (modify the configuration file)
Base_path =/home/FastDFS
Tracker_server = 192.168.101.3: 22122
Url_have_group_name = true # The url contains the group name.
Store_path0 =/home/FastDFS/fdfs_storage # specify the file storage path
Cp/usr/lib64/libfdfsclient. so/usr/lib/
Mkdir-p/var/temp/nginx/client (create nginx/client Directory)

 

Nginx Installation
Tar-zxvf nginx-1.8.0.tar.gz
Cd nginx-1.8.0
. /Configure \ -- prefix =/usr/local/nginx \ -- pid-path =/var/run/nginx. pid \ -- lock-path =/var/lock/nginx. lock \ -- error-log-path =/var/log/nginx/error. log \ -- http-log-path =/var/log/nginx/access. log \ -- with-http_gzip_static_module \ -- http-client-body-temp-path =/var/temp/nginx/client \ -- http-proxy-temp-path =/var/temp/nginx /proxy \ -- http-fastcgi-temp-path =/var/temp/nginx/fastcgi \ -- http-uwsgi-temp-path =/var/temp/nginx/uwsgi \-- http-scgi-temp-path =/var/temp/nginx/scgi \ -- add-module =/usr/local/fastdfs-nginx-module/src make
Make install
Cd/usr/local/nginx/conf/(open the nginx configuration file)
Vim nginx. conf (edit nginx configuration file)

 

 server {                listen       8888;                server_name  192.168.241.138;                location /group1/M00/{                        root /home/FastDFS/fdfs_storage/data;                        ngx_fastdfs_module;                }        }

 

Note: server_name specifies the local iplocation/group1/M00/: group1 is the group name of the nginx service FastDFS, and M00 is the ID automatically generated by FastDFS, corresponding to store_path0 =/home/FastDFS/fdfs_storage, if FastDFS defines store_path1, M01 is used here.

 

Related Article

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.