CentOS FASTDFS Multi-server multi-drive multi-group configuration detailed

Source: Internet
Author: User
Tags vars automake

Before saying the text, thank happy_fish100 for providing the FASTDFS, lightweight Distributed File server.

With the amount of users, pictures, videos and so on will continue to increase, this time a hard disk may not be enough, you need to add hard disk. When the hard disk does not add, you need to increase the server. The same set of servers, file server things are the same, different groups of servers, have different files, different groups, and co-organized all the contents of the file server.

The following is the installation of the configuration process, the method here, the root developer provides a different method, I did not use the Fastdfs-nginx-module, through the configuration Nginx implementation of the Fastdfs-nginx-module function.

One, Fastdfs's download

Address: http://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/

Two, server, and system

I use the CentOS 6.5 x86_64, Fastdfs v5.01 architecture as follows:

Architecture diagram

Here the tracker is a single point, if out of trouble on the depressed, had once done once more tracker, but the version is relatively old . Please refer to:FASTDFS multi-server configuration

Third, install Fastdfs and Nginx

1, install Nginx

View copy print?
  1. installation, gcc,automake,autoconf and other dependent packages
  2. [email protected] download]$ Yum install gettext gettext-devel libxft libxft-devel libxpm libxpm-devel\
  3. Automake autoconf libxtst-devel gtk+-devel gcc zlib-devel libpng-devel gtk2-devel glib-devel
  4. Installing Fastdfs
  5. [Email protected] download]# tar zxf fastdfs_v5.01.tar.gz
  6. [Email protected] download]# CD Fastdfs
  7. [Email protected] download]#./make.sh
  8. [[email protected] download]#./make.sh Install
  9. Installation is successful with the following content
  10. [Email protected] fdfs]# ll/usr/local/bin/|grep Fdfs
  11. -rwxr-xr-x 1 root root 522870 July 4 03:20 fdfs_appender_test
  12. -rwxr-xr-x 1 root root 522823 July 4 03:20 fdfs_appender_test1
  13. -rwxr-xr-x 1 root root 513975 July 4 03:20 fdfs_append_file
  14. -rwxr-xr-x 1 root root 513393 July 4 03:20 FDFS_CRC32
  15. -rwxr-xr-x 1 root root 513927 July 4 03:20 fdfs_delete_file
  16. -rwxr-xr-x 1 root root 514329 July 4 03:20 fdfs_download_file
  17. -rwxr-xr-x 1 root root 514093 July 4 03:20 fdfs_file_info
  18. -rwxr-xr-x 1 root root 525024 July 4 03:20 fdfs_monitor
  19. -rwxr-xr-x 1 root root 1179642 July 4 03:20 fdfs_storaged
  20. -rwxr-xr-x 1 root root 529805 July 4 03:20 fdfs_test
  21. -rwxr-xr-x 1 root root 527726 July 4 03:20 fdfs_test1
  22. -rwxr-xr-x 1 root root 655761 July 4 03:20 fdfs_trackerd
  23. -rwxr-xr-x 1 root root 514173 July 4 03:20 Fdfs_upload_appender
  24. -rwxr-xr-x 1 root root 514951 July 4 03:20 fdfs_upload_file

2, install Nginx

    1. [[email protected] fdfs]# Yum install Nginx

All machines have the same Fastdfs and Nginx installation methods.

Four, configure the 192.168.10.219 server

1, configuring Tracker and storage

View copy print?
    1. [Email protected] fdfs]# vim/etc/fdfs/tracker.conf
    2. port=22122 #设置tracker的端口号
    3. base_path=/Var/www/fastdfs #设置tracker的数据文件和日志目录 (pre-creation required)

If you are tuning, refer to: http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=1941456

View copy print?
  1. [Email protected] fdfs]# vim/etc/fdfs/storage.conf
  2. Group_name=group1 #组名, modify according to the actual situation
  3. port=23000 #设置storage的端口号
  4. base_path=/Var/www/fastdfs #设置storage的日志目录 (pre-creation required)
  5. Store_path_count=1 #存储路径个数, need to match Store_path number
  6. store_path0=/Var/www/fastdfs #存储路径
  7. tracker_server=192.168.10.219:22122 #tracker服务器的IP地址和端口号

Nginx Configuration of 2,tracker

View copy print?
  1. [Email protected] nginx]# cat/etc/nginx/nginx.conf #配置主配置文件
  2. User Nginx;
  3. Worker_processes 1;
  4. Events {
  5. Worker_connections 65535; #最大链接数
  6. Use epoll; #新版本的Linux可使用epoll加快处理性能
  7. }
  8. Error_log/Var/log/nginx/error.log;
  9. PID/Var/run/nginx.pid;
  10. HTTP {
  11. Server_names_hash_bucket_size 128;
  12. Client_header_buffer_size 32k;
  13. Large_client_header_buffers 4 32k;
  14. Client_max_body_size 300m;
  15. Sendfile on;
  16. Tcp_nopush on;
  17. Proxy_redirect off;
  18. Proxy_set_header Host $http _host;
  19. Proxy_set_header x-real-ip $remote _addr;
  20. Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
  21. Proxy_connect_timeout 90;
  22. Proxy_send_timeout 90;
  23. Proxy_read_timeout 90;
  24. Proxy_buffer_size 16k;
  25. Proxy_buffers 4 64k;
  26. Proxy_busy_buffers_size 128k;
  27. Proxy_temp_file_write_size 128k;
  28. Log_format main ' $remote _addr-$remote _user [$time _local] "$request" '
  29. ' $status $body _bytes_sent ' $http _referer '
  30. ' "$http _user_agent" "$http _x_forwarded_for";
  31. Access_log/Var/log/nginx/access.log main;
  32. #设置缓存存储路径, storage mode, allocated memory size, disk maximum space, cache age
  33. Proxy_cache_path/var/cache/nginx/proxy_cache levels=1:2 keys_zone=http-cache:500m max_size=10g inactive=30d;
  34. Proxy_temp_path/var/cache/nginx/proxy_cache/tmp;
  35. Upstream Fdfs_group1 {#设置group1的服务器
  36. Server 192.168.10.209:8080 weight=1 max_fails=2 fail_timeout=30s;
  37. Server 192.168.10.219:8080 weight=1 max_fails=2 fail_timeout=30s;
  38. }
  39. Upstream Fdfs_group2 {#设置group2的服务器
  40. Server 192.168.10.103:10000 weight=1 max_fails=2 fail_timeout=30s;
  41. }
  42. include/etc/nginx/conf.d/*.conf;
  43. }
View copy print?
  1. [Email protected] fdfs]# cat/etc/nginx/conf.d/tracker.conf #配置nginx的tracker
  2. server {
  3. Listen 80; #设置服务器端口
  4. server_name 192.168.10.219;
  5. location/group1/m00 {#设置group1的负载均衡参数
  6. Proxy_next_upstream http_502 http_504 error timeout invalid_header;
  7. Proxy_cache Http-cache;
  8. Proxy_cache_valid 304 12h;
  9. Proxy_cache_key $uri$is _args$args;
  10. Proxy_pass http://fdfs_group1;
  11. Expires 30d;
  12. }
  13. Location ~*/group2/(m00| M01) {#设置group2的负载均衡参数
  14. Proxy_next_upstream http_502 http_504 error timeout invalid_header;
  15. Proxy_cache Http-cache;
  16. Proxy_cache_valid 304 12h;
  17. Proxy_cache_key $uri$is _args$args;
  18. Proxy_pass http://fdfs_group2;
  19. Expires 30d;
  20. }
  21. }
View copy print?
    1. [Email protected] conf.d]# cat/etc/nginx/conf.d/storage.conf #配置nginx的storage
    2. Server
    3. {
    4. Listen 8080;
    5. server_name 192.168.10.219;
    6. location/group1/m00/{
    7. Root/var/www/fastdfs/data;
    8. Rewrite ^/group1/m00/(. *)/break ;
    9. }
    10. }

3, start Tracker,storage and Nginx

View copy print?
    1. Start
    2. [Email protected] fdfs]#/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart
    3. [Email protected] fdfs]#/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf restart
    4. [[email protected] fdfs]#/etc/init.d/nginx start

Here is a point to note that is to start tracker in the start storage, if the Nginx directory is not built, create a, in the restart

Five. Configuring the 192.168.10.209 Server

1, Configuration Storage

View copy print?
  1. [Email protected] fdfs]# vim/etc/fdfs/storage.conf
  2. Group_name=group1 #组名, modify according to the actual situation
  3. port=23000 #设置storage的端口号
  4. base_path=/Var/www/fastdfs #设置storage的日志目录 (pre-creation required)
  5. Store_path_count=1 #存储路径个数, need to match Store_path number
  6. store_path0=/Var/www/fastdfs #存储路径
  7. tracker_server=192.168.10.219:22122 #tracker服务器的IP地址和端口号

2,nginx Configuration

View copy print?
    1. [Email protected] conf.d]# cat/etc/nginx/conf.d/storage.conf #配置storage
    2. Server
    3. {
    4. Listen 8080;
    5. server_name 192.168.10.209;
    6. location/group1/m00/{
    7. Root/var/www/fastdfs/data;
    8. Rewrite ^/group1/m00/(. *)/break ;
    9. }
    10. }

3, start

View copy print?
    1. Start
    2. [Email protected] fdfs]#/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf restart
    3. [[email protected] fdfs]#/etc/init.d/nginx start

Six, configure 192.168.10.103 server

1, Configuration Storage

View copy print?
  1. [Email protected] fdfs]# vim/etc/fdfs/storage.conf
  2. Group_name=group2 #组名, modify according to the actual situation
  3. port=23000 #设置storage的端口号
  4. base_path=/Var/www/fastdfs #设置storage的日志目录 (pre-creation required)
  5. store_path_count=2 #存储路径个数, need to match Store_path number
  6. store_path0=/Var/www/fastdfs #存储路径
  7. STORE_PATH1=/MNT/USB/FASTDFS2 #硬盘2的存储路径
  8. tracker_server=192.168.10.219:22122 #tracker服务器的IP地址和端口号

One thing to note here is that there are two hard drives, and there are two directories in the file

2, configuring Nginx

View copy print?
  1. [Email protected] conf.d]# cat/etc/nginx/conf.d/storage.conf #配置storage
  2. Server
  3. {
  4. Listen 10000;
  5. server_name 192.168.10.103;
  6. location/group2/m01/{
  7. Root/mnt/usb/fastdfs2/data;
  8. Rewrite ^/group2/m01/(. *)/break ;
  9. }
  10. location/group2/m00/{
  11. Root/var/www/fastdfs/data;
  12. Rewrite ^/group2/m00/(. *)/break ;
  13. }
  14. }

3, start

View copy print?
    1. Start
    2. [Email protected] fdfs]#/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf restart
    3. [[email protected] fdfs]#/etc/init.d/nginx start

Here is the installation configuration, one thing to note:

is to access the file server file, the address to use tracker address, for example:

Http://192.168.10.219/group2/M01/00/00/wKgKZ1PAEquAbLj1AAK4TxGeCvM649.jpg

CentOS FASTDFS Multi-server multi-drive multi-group configuration detailed

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.