你的位置:首页 > Java教程

[Java教程]FastDFS安装配置


FastDFS

FastDFS为互联网量身定制,充分考虑了冗余备份、负载均衡、线性扩容等机制,并注重高可用、高性能等指标,使用FastDFS很容易搭建一套高性能的文件服务器集群提供文件上传、下载等服务。

1.所需要的安装包

2.安装服务器(关闭服务器防火墙service iptables stop    setenforce 0)

192.168.241.137------------------------>tracker服务器

192.168.241.138------------------------>storage服务器(group1)

192.168.241.139------------------------>storage服务器(group1)

   

3.tracker安装

yum -y install gcc-c++ (安装编译工具)
yum -y install libevent (FastDFS依赖libevent库)
mv libfastcommonV1.0.7.tar.gz /usr/local (将libfastcommon放到/usr/local目录下)
cd /usr/local
tar -zxvf libfastcommonV1.0.7.tar.gz (解压libfastcommon)
cd libfastcommon-1.0.7/
./make.sh (编译libfastcommon)
./make.sh install (安装libfastcommon)
cp /usr/lib64/libfastcommon.so /usr/lib (注意:libfastcommon安装好后会自动将库文件拷贝至/usr/lib64下,由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件拷贝至/usr/lib下)
mv FastDFS_v5.05.tar.gz /usr/local/ (将FastDFS安装包放到/usr/local目录下)
cd /usr/local
tar -zxvf FastDFS_v5.05.tar.gz (解压FastDFS安装包)
cd FastDFS
./make.sh (编译FastDFS)
./make.sh install (安装FastDFS)
cp /usr/local/FastDFS/conf/http.conf /etc/fdfs/ (将http.conf拷贝到/etc/fdfs目录下)
cp /usr/local/FastDFS/conf/mime.types /etc/fdfs/ (将mime.types拷贝到/etc/fdfs目录下)
cd /etc/fdfs/ (进入FastDFS配置文件目录)
cp tracker.conf.sample tracker.conf (拷贝一份新的tracker配置文件)
mkdir -p /home/FastDFS (创建FastDFS工作目录)
vim tracker.conf (配置配置文件,# HTTP port on this tracker server http.server_port=8080 # the tracker server port port=22122 这里的端口没有配置使用默认端口)
base_path=/home/FastDFS
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart (启动tracker服务器)

 

4.storage安装

yum -y install gcc-c++ (安装编译工具)
yum -y install libevent (FastDFS依赖libevent库)
mv libfastcommonV1.0.7.tar.gz /usr/local (将libfastcommon放到/usr/local目录下)
cd /usr/local
tar -zxvf libfastcommonV1.0.7.tar.gz (解压libfastcommon)
cd libfastcommon-1.0.7/
./make.sh (编译libfastcommon)
./make.sh install (安装libfastcommon)
cp /usr/lib64/libfastcommon.so /usr/lib (注意:libfastcommon安装好后会自动将库文件拷贝至/usr/lib64下,由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件拷贝至/usr/lib下)
mv FastDFS_v5.05.tar.gz /usr/local/ (将FastDFS安装包放到/usr/local目录下)
cd /usr/local
tar -zxvf FastDFS_v5.05.tar.gz (解压FastDFS安装包)
cd FastDFS
./make.sh (编译FastDFS)
./make.sh install (安装FastDFS)
cp /usr/local/FastDFS/conf/http.conf /etc/fdfs/ (将http.conf拷贝到/etc/fdfs目录下)
cp /usr/local/FastDFS/conf/mime.types /etc/fdfs/ (将mime.types拷贝到/etc/fdfs目录下)
cd /etc/fdfs/ (进入FastDFS配置文件目录)
cp storage.conf.sample storage.conf (拷贝一份新的tracker配置文件)
vim storage.conf(# the port of the web server on this storage server http.server_port=8888 默认,根据需要设置)
group_name=group1 (组名)
base_path=/home/FastDFS (基础目录)
store_path0=/home/FastDFS/fdfs_storage (存储目录)
tracker_server=192.168.101.3:22122 (tracker服务器)
mkdir -p /home/FastDFS (创建FastDFS工作目录)
mkdir -p /home/FastDFS/fdfs_storage (存储目录)
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart (启动storage服务器)

 

5.上传图片测试(tracker服务器)

cd /etc/fdfs/
cp client.conf.sample client.conf (FastDFS安装成功可通过/usr/bin/fdfs_test测试上传、下载等操作)
vim client.conf (修改配置文件)
base_path=/home/FastDFS
tracker_server=192.168.241.137:22122

 

使用格式:/usr/bin/fdfs_test  客户端配置文件地址   upload   上传文件

比如将/home下的图片上传到FastDFS中:
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/567.png
tracker服务器显示日志: