一、FastDFS安装
前置条件: CentOS 7.2、FastDFS_4.06、libevent-1.4.14b-stable
1. 安装依赖
安装gcc、openssl、pcre和perl
yum install gcc gcc+ gcc-c++
yum install openssl openssl-devel
yum install pcre pcre-devel
yum install perl perl-devel
2. 安装 libevent-1.4.14b-stable
libevent目录下
./configure --prefix=/usr
make clean
make
make install
3. 安装FastDFS
./make.sh clean
./make
./make install
命令默认安装目录:/usr/local/bin
配置默认安装目录:/etc/fdfs
文件存储目录参照/etc/fdfs/client.conf storage.conf tracker.conf
4. 启动FastDFStrackerserver
进入/usr/local/bin目录,启动 tracker 服务器,执行如下命令:
cd /usr/local/bin
fdfs_trackerd /opt/FastDFS/conf/tracker.conf
注意:如果操作系统为 64 位环境,则事先需要手工将/usr/lib/libevent-2.0.so.5 文件,复制到 /usr/lib64目录下(32位的系统不需要复制),再启动 tracker 服务器。复制命令如下:
cd /usr/lib
cp libevent-2.0.so.5 ../lib64
5. 启动FastDFS storage server
进入/usr/local/bin/目录,启动storage服务器,执行如下命令:
cd /usr/local/bin
fdfs_storaged /opt/FastDFS/conf/storage.con
6. #测试上传文件.
fdfs_test /etc/fdfs/client.conf upload a.txt
7. java 客户端调试
7-1)源码下载https://github.com/happyfish100/fastdfs-client-java
7-2)编译该工程,install后生成fastdfs-client-java-1.27-SNAPSHOT.jar;
mvn install:install-file -Dfile=C:\fastdfs-client-java-1.27-SNAPSHOT.jar -DgroupId=org.springframework -DartifactId=spring-context-support -Dversion=3.1.0.RELEASE -Dpackaging=jar
7-3) 业务工程加下面的依赖
<!-- fastdfs-client -->
<dependency>
<groupId>org.csource</groupId>
<artifactId>fastdfs-client-java</artifactId>
<version>1.25</version>
</dependency>
7-4)
参考转载:https://www.oschina.net/p/fastdfs?fromerr=HDgrPyfU
8、项目应用示例:
前端代码
二
后端代码