FastDFS增加存儲路徑配置

FastDFS在使用過程中最近碰到一種情況,存儲被佔滿了,隨即增加外掛存儲映射到FastDFS所在服務器上,以下是新掛存儲後FastDFS需要做的一些修改配置:

1.修改tracker.conf配置文件

# vim /etc/fdfs/tracker.conf
將 store_path=0 修改爲 store_path=2
意思是從輪詢的方式改爲存儲負載均衡的方式(選擇剩餘空間最大的目錄存放文件)

2.修改storage.conf配置文件

# vim /etc/fdfs/storage.conf
將 store_path_count=1 改爲 store_path_count=2
增加store_path1=/fdfs/storage1

3.修改mod_fastdfs.conf配置文件

# vim /etc/fdfs/mod_fastdfs.conf
將 store_path_count=1 改爲 store_path_count=2

在 store_path0=/opt/netstore/fdfs 下面增加一行store_path1=/opt/netstore1/fdfs

配置文件的最下面,[group1]下面
store_path_count=1改爲store_path_count=2

在 store_path0=/opt/netstore/fdfs 下面增加一行store_path1=/opt/netstore1/fdfs

建立軟連接:ln -s /opt/netstore1/fdfs/storage/data /opt/netstore1/fdfs/storage/data/M01

查看:ll/opt/netstore1/fdfs/storage/data/M01

4.修改nginx.conf配置文件

# vim /usr/local/nginx/conf/nginx.conf
# 在server中增加:

    location ~/group1/M01    {
        root /opt/netstore1/fdfs;
        ngx_fastdfs_module;
    }

    #設置group1的第二個路徑的負載均衡參數
    location /group1/M01 {
        proxy_next_upstream http_502 http_504 error timeout invalid_header;
        proxy_cache http-cache;
        proxy_cache_valid  200 304 12h;
        proxy_cache_key $uri$is_args$args;
        proxy_pass http://fdfs_group1;
        expires 30d;
    }

    #設置group2的第二個路徑的負載均衡參數
    location /group2/M01 {
        proxy_next_upstream http_502 http_504 error timeout invalid_header;
        proxy_cache http-cache;
        proxy_cache_valid  200 304 12h;
        proxy_cache_key $uri$is_args$args;
        proxy_pass http://fdfs_group2;
       expires 30d;
    }

5.重啓tracker:

/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

6.重啓storage:

/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf restart

7.查看storage狀態,有兩個ACTIVE則爲正常:

/usr/local/bin/fdfs_monitor /etc/fdfs/storage.conf

8.重啓nginx:

# /usr/local/nginx/sbin/nginx -s reload
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章