LINUX上部署FastDFS文件服务器

时间:2022-09-17 13:44:23

linux上部署FastDFS网上有很多 这里就不说了。

链接地址:http://oldcat1981.blog.51cto.com/10670523/1766810

http://blog.csdn.net/adminjesseli/article/details/52640775

http://blog.csdn.net/u013378306/article/details/74850231

不懂的地方 对照着看就知道为什么了。


=========================================java 上面访问 文件服务器==========================================

fdfs_client.conf

connect_timeout = 2
network_timeout = 30
#对这些设置还不是很清楚
charset = ISO8859-1
http.tracker_http_port = 8080
http.anti_steal_token = no
http.secret_key = FastDFS1234567890

#tracker_server的设置是必须的
tracker_server = 192.168.0.111:22122


public class fdfsTest {
public static void main(String[] args) throws IOException, MyException {
ClientGlobal.initByProperties("config/fastdfs-client.properties");
//创建一个tracker客户端对象
TrackerClient trackerClient = new TrackerClient();

//使用trackerclient连接trackersever对象
TrackerServer trackerServer = trackerClient.getConnection();

//创建一个straged server对象
StorageServer storageServer = null;

//创建一个storage client 对象
StorageClient1 storageClient = new StorageClient1(trackerServer, storageServer);

//利用storageclient对象上传图片
//参数一为文件所在的路径(不要有中文)
//参数二为文件的拓展名
//参数三为文件扩展信息
String[] upload_file = storageClient.upload_file("C:/Users/Administrator/Desktop/20160802130136931.jpg", "jpg", null);

//upload_file 存储着访问路径
for(String s : upload_file){
System.out.println(s);
}
}
}

返回的路径:

group1
M00/00/00/CmkgN1meia-APHL-AAF4n3s-n5w069.jpg


从文件服务器上获取图片就是:

 http:// ip: 端口/group1/M00/00/00/CmkgN1meia-APHL-AAF4n3s-n5w069.jpg


需要用的jar都可以从 https://github.com/happyfish100https://github.com/happyfish100 上下载


注:所需要的:

FastDFS_v5.08.tar.gz

    nginx-1.8.1.tar.gz

    fastdfs-nginx-module_v1.16.tar.gz

    libfastcommon


发生错误看此链接:http://blog.csdn.net/u013378306/article/details/74852294


java实例:http://blog.csdn.net/wlwlwlwl015/article/details/52682153