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?
- installation, gcc,automake,autoconf and other dependent packages
- [email protected] download]$ Yum install gettext gettext-devel libxft libxft-devel libxpm libxpm-devel\
- Automake autoconf libxtst-devel gtk+-devel gcc zlib-devel libpng-devel gtk2-devel glib-devel
- Installing Fastdfs
- [Email protected] download]# tar zxf fastdfs_v5.01.tar.gz
- [Email protected] download]# CD Fastdfs
- [Email protected] download]#./make.sh
- [[email protected] download]#./make.sh Install
- Installation is successful with the following content
- [Email protected] fdfs]# ll/usr/local/bin/|grep Fdfs
- -rwxr-xr-x 1 root root 522870 July 4 03:20 fdfs_appender_test
- -rwxr-xr-x 1 root root 522823 July 4 03:20 fdfs_appender_test1
- -rwxr-xr-x 1 root root 513975 July 4 03:20 fdfs_append_file
- -rwxr-xr-x 1 root root 513393 July 4 03:20 FDFS_CRC32
- -rwxr-xr-x 1 root root 513927 July 4 03:20 fdfs_delete_file
- -rwxr-xr-x 1 root root 514329 July 4 03:20 fdfs_download_file
- -rwxr-xr-x 1 root root 514093 July 4 03:20 fdfs_file_info
- -rwxr-xr-x 1 root root 525024 July 4 03:20 fdfs_monitor
- -rwxr-xr-x 1 root root 1179642 July 4 03:20 fdfs_storaged
- -rwxr-xr-x 1 root root 529805 July 4 03:20 fdfs_test
- -rwxr-xr-x 1 root root 527726 July 4 03:20 fdfs_test1
- -rwxr-xr-x 1 root root 655761 July 4 03:20 fdfs_trackerd
- -rwxr-xr-x 1 root root 514173 July 4 03:20 Fdfs_upload_appender
- -rwxr-xr-x 1 root root 514951 July 4 03:20 fdfs_upload_file
2, install Nginx
- [[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?
- [Email protected] fdfs]# vim/etc/fdfs/tracker.conf
- port=22122 #设置tracker的端口号
- 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?
- [Email protected] fdfs]# vim/etc/fdfs/storage.conf
- Group_name=group1 #组名, modify according to the actual situation
- port=23000 #设置storage的端口号
- base_path=/Var/www/fastdfs #设置storage的日志目录 (pre-creation required)
- Store_path_count=1 #存储路径个数, need to match Store_path number
- store_path0=/Var/www/fastdfs #存储路径
- tracker_server=192.168.10.219:22122 #tracker服务器的IP地址和端口号
Nginx Configuration of 2,tracker
View copy print?
- [Email protected] nginx]# cat/etc/nginx/nginx.conf #配置主配置文件
- User Nginx;
- Worker_processes 1;
- Events {
- Worker_connections 65535; #最大链接数
- Use epoll; #新版本的Linux可使用epoll加快处理性能
- }
- Error_log/Var/log/nginx/error.log;
- PID/Var/run/nginx.pid;
- HTTP {
- Server_names_hash_bucket_size 128;
- Client_header_buffer_size 32k;
- Large_client_header_buffers 4 32k;
- Client_max_body_size 300m;
- Sendfile on;
- Tcp_nopush on;
- Proxy_redirect off;
- Proxy_set_header Host $http _host;
- Proxy_set_header x-real-ip $remote _addr;
- Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
- Proxy_connect_timeout 90;
- Proxy_send_timeout 90;
- Proxy_read_timeout 90;
- Proxy_buffer_size 16k;
- Proxy_buffers 4 64k;
- Proxy_busy_buffers_size 128k;
- Proxy_temp_file_write_size 128k;
- Log_format main ' $remote _addr-$remote _user [$time _local] "$request" '
- ' $status $body _bytes_sent ' $http _referer '
- ' "$http _user_agent" "$http _x_forwarded_for";
- Access_log/Var/log/nginx/access.log main;
- #设置缓存存储路径, storage mode, allocated memory size, disk maximum space, cache age
- Proxy_cache_path/var/cache/nginx/proxy_cache levels=1:2 keys_zone=http-cache:500m max_size=10g inactive=30d;
- Proxy_temp_path/var/cache/nginx/proxy_cache/tmp;
- Upstream Fdfs_group1 {#设置group1的服务器
- Server 192.168.10.209:8080 weight=1 max_fails=2 fail_timeout=30s;
- Server 192.168.10.219:8080 weight=1 max_fails=2 fail_timeout=30s;
- }
- Upstream Fdfs_group2 {#设置group2的服务器
- Server 192.168.10.103:10000 weight=1 max_fails=2 fail_timeout=30s;
- }
- include/etc/nginx/conf.d/*.conf;
- }
View copy print?
- [Email protected] fdfs]# cat/etc/nginx/conf.d/tracker.conf #配置nginx的tracker
- server {
- Listen 80; #设置服务器端口
- server_name 192.168.10.219;
- location/group1/m00 {#设置group1的负载均衡参数
- Proxy_next_upstream http_502 http_504 error timeout invalid_header;
- Proxy_cache Http-cache;
- Proxy_cache_valid 304 12h;
- Proxy_cache_key $uri$is _args$args;
- Proxy_pass http://fdfs_group1;
- Expires 30d;
- }
- Location ~*/group2/(m00| M01) {#设置group2的负载均衡参数
- Proxy_next_upstream http_502 http_504 error timeout invalid_header;
- Proxy_cache Http-cache;
- Proxy_cache_valid 304 12h;
- Proxy_cache_key $uri$is _args$args;
- Proxy_pass http://fdfs_group2;
- Expires 30d;
- }
- }
View copy print?
- [Email protected] conf.d]# cat/etc/nginx/conf.d/storage.conf #配置nginx的storage
- Server
- {
- Listen 8080;
- server_name 192.168.10.219;
- location/group1/m00/{
- Root/var/www/fastdfs/data;
- Rewrite ^/group1/m00/(. *)/break ;
- }
- }
3, start Tracker,storage and Nginx
View copy print?
- Start
- [Email protected] fdfs]#/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart
- [Email protected] fdfs]#/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf restart
- [[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?
- [Email protected] fdfs]# vim/etc/fdfs/storage.conf
- Group_name=group1 #组名, modify according to the actual situation
- port=23000 #设置storage的端口号
- base_path=/Var/www/fastdfs #设置storage的日志目录 (pre-creation required)
- Store_path_count=1 #存储路径个数, need to match Store_path number
- store_path0=/Var/www/fastdfs #存储路径
- tracker_server=192.168.10.219:22122 #tracker服务器的IP地址和端口号
2,nginx Configuration
View copy print?
- [Email protected] conf.d]# cat/etc/nginx/conf.d/storage.conf #配置storage
- Server
- {
- Listen 8080;
- server_name 192.168.10.209;
- location/group1/m00/{
- Root/var/www/fastdfs/data;
- Rewrite ^/group1/m00/(. *)/break ;
- }
- }
3, start
View copy print?
- Start
- [Email protected] fdfs]#/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf restart
- [[email protected] fdfs]#/etc/init.d/nginx start
Six, configure 192.168.10.103 server
1, Configuration Storage
View copy print?
- [Email protected] fdfs]# vim/etc/fdfs/storage.conf
- Group_name=group2 #组名, modify according to the actual situation
- port=23000 #设置storage的端口号
- base_path=/Var/www/fastdfs #设置storage的日志目录 (pre-creation required)
- store_path_count=2 #存储路径个数, need to match Store_path number
- store_path0=/Var/www/fastdfs #存储路径
- STORE_PATH1=/MNT/USB/FASTDFS2 #硬盘2的存储路径
- 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?
- [Email protected] conf.d]# cat/etc/nginx/conf.d/storage.conf #配置storage
- Server
- {
- Listen 10000;
- server_name 192.168.10.103;
- location/group2/m01/{
- Root/mnt/usb/fastdfs2/data;
- Rewrite ^/group2/m01/(. *)/break ;
- }
- location/group2/m00/{
- Root/var/www/fastdfs/data;
- Rewrite ^/group2/m00/(. *)/break ;
- }
- }
3, start
View copy print?
- Start
- [Email protected] fdfs]#/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf restart
- [[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