fastdfs文件系统增加自定义路径

fastdfs文件系统增加自定义路径(group1/M00、group1/M01...)

修改fastfds配置文件
vim /etc/fdfs/storage.conf

# 挂载数量  
store_path_count=2  
# 挂载点1  
store_path0=/data/fastdfs/file  
# 挂载点2  
store_path1=/data/fastdfs/file2

 

复制文件系统(可以不用)
copy /data/fastdfs/file /data/fastdfs/file2修改nginx host文件

vim ~/ngnix/ngnix.conf

location /group1/M00 {  
               alias /data/fastdfs/file/data;  
       }

 

在下面加上配置

location /group1/M01 {  
               alias /data/fastdfs/file2/data;  
       }

 

重启服务
[^_^]: /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf

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

[^_^]: /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

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

/usr/local/nginx/sbin/nginx -s reload

修改文件上传方法

增加入参Integer storePath

存储路径storePath对应服务器上fdst设置的0->store_path0, 1->store_path1 ...

TrackerClient trackerClient = new TrackerClient();  
storageServer = trackerClient.getStoreStorage(trackerServer);  
String storageIp = storageServer.getSocket().getInetAddress().getHostAddress();  
Integer port = storageServer.getSocket().getPort();  
storageServer = new StorageServer(storageIp, port, storePath);  
StorageClient1 storageClient = new StorageClient1(trackerServer, storageServer);

 

你可能感兴趣的:(fastfds,文件系统)