随着用户量的变大,图片,视频等的量会不断的增大,这个时候一个硬盘可能不够用了,就要加硬盘,硬盘加不了时,就要增加服务器了,同一组服务器,文件服务器的东西是一样,不同组的服务器,有不同的文件,不同的组之间,共同组建了文件服务器的所有内容。
以增加磁盘为例
修改storage配置
# vim /etc/fdfs/storage.conf group_name=group2 #组名,根据实际情况修改 port=23000 #设置storage的端口号 base_path=/data/fastdfs #设置storage的日志目录(需预先创建) store_path_count=2 #存储路径个数,需要和store_path个数匹配 store_path0=/var/www/fastdfs #存储路径1 store_path1=/mnt/fastdfs2 #存储路径2(新增加的磁盘) tracker_server=10.99.0.11:22122 #tracker服务器的IP地址和端口号 tracker_server=10.99.0.12:22122 #tracker服务器2的IP地址和端口号
修改storage节点nginx配置
# vim /etc/nginx/conf.d/storage.conf    #配置storage
server {
    listen 80;
    server_name 10.99.0.14;
    location /group2/M00/ {
         alias /var/www/fastdfs/data;
         ngx_fastdfs_module;
    }
    location /group2/M01/ {
        alias /mnt/usb/fastdfs2/data;
        ngx_fastdfs_module;
    }
}
修改storage节点mod_fastdfs.conf配置
将group_name=group1改为group_name=group2
修改tracker节点nginx配置
# vim /etc/nginx/conf.d/tracker.conf    #配置nginx的tracker
upstream fdfs_group1 { #设置group1的服务器
    server 192.168.10.209:80 weight=1 max_fails=2 fail_timeout=30s;
    server 192.168.10.219:80 weight=1 max_fails=2 fail_timeout=30s;
}
upstream fdfs_group2 { #设置group2的服务器
    server 192.168.10.103:80 weight=1 max_fails=2 fail_timeout=30s;
}
server {
    listen 80;                      #设置服务器端口
    server_name 10.99.0.11;
    location /group1/M00 {          #设置group1的负载均衡参数
        proxy_next_upstream http_502 http_504 error timeout invalid_header;
	proxy_cache cache;
        proxy_cache_valid 200 304 12h;
        proxy_cache_valid 301 302 1d;
        proxy_cache_valid any 1m;
        proxy_cache_key "$scheme://$host$request_uri";
        proxy_pass http://fdfs_group1;
	include proxy.conf;
    	add_header X-Cache $upstream_cache_status;
        expires 30d;
}
    location ~* /group2/(M00|M01) { #设置group2的负载均衡参数
        proxy_next_upstream http_502 http_504 error timeout invalid_header;
	proxy_cache cache;
        proxy_cache_valid 200 304 12h;
        proxy_cache_valid 301 302 1d;
        proxy_cache_valid any 1m;
        proxy_cache_key "$scheme://$host$request_uri";
        proxy_pass http://fdfs_group2;
	include proxy.conf;
    	add_header X-Cache $upstream_cache_status;
        expires 30d;
    }
}