1 新增磁盤掛載點,在新磁盤新建文件存儲目錄
2 修改/etc/fdfs/Storage.conf配置,store_path_count = 2,store_path0=/data/push/fastdfs,store_path1=/newdata/push/fastdfs
3 查看/etc/fdfs/tracker.conf配置的store_path是否等於2,應該采用負載均衡策略,令新文件存儲在新磁盤下。
4 修改/etc/fdfs/mod_fastdfs.conf配置, store_path_count = 2,store_path0=/data/push/fastdfs,store_path1=/newdata/push/fastdfs
5 修改/usr/local/nginx/conf/fastdfs.conf
location /group[0~9]/M00 {
alias /data/push/fastdfs/data;
ngx_fastdfs_module;
}
location /group[0~9]/M01 {
alias /newdata/push/fastdfs/data;
ngx_fastdfs_module;
}
6 重啟tracker,storage,Nginx服務
---##############################################################################
基於group模式的文件存儲擴容(添加磁盤)
group模式擴容是通過給group的機器添加硬盤的方式,實現某個group的擴容。fastdfs在一台服務器支持多個store_path,每個store_path指向一個存儲路徑。如:url “M00/3F/E1/oYYBAFXfyuOABOf5AAAHoDwhqE0491.txt”中M00表示使用store_path0,如果沒有配置store_path,就使用base_path的路徑。添加了硬盤后,通過把新的store_path指向新硬盤的掛載點,再修改配置文件,就能實現group的擴容。擴容后的地址如:url “M01/3F/E3/oYYBAFXfyuOABOf5AAAHoDwhqE0591.txt”中M01表示使用store_path1。group模式擴容主要步驟如下:
- 1.停止現有的tracker服務,storage服務,操作指令如:/etc/init.d/fdfs_trackerd stop ,/etc/init.d/fdfs_storaged stop ;
- 2.修改/etc/fdfs/storage.conf配置文件,修改字段store_path_count,新增store_path1文件存儲路徑,新建store_path1的文件目錄;
3.修改/etc/fdfs/storage.conf/mod_fastdfs.conf配置文件,修改字段store_path_count,新增store_path1文件存儲路徑,設置group1的配置信息;
4.修改/application/nginx/conf/nginx.conf配置文件,增加store_path1的訪問代理;
5.重新啟動tracker,storage,nginx服務,通過命令 /usr/bin/fdfs_monitor /etc/fdfs/storage.conf( /usr/bin/fdfs_monitor為f調用astdfs的命令,根據安裝目錄而定)可查看文件服務器的運行狀態和配置信息。
結果展示:調用文件clent.conf配置文件,通過文件上傳命令上傳文件,查看文件的存儲地址信息如下: