Centos7安装部署fastDFS

 

安装难度: ★★★★☆

繁琐程度:★★★★★

易错程度:★★★★☆

一 准备

本教程使用的安装文件:

 链接:https://pan.baidu.com/s/1cnhx8_14qI-NCiwggfWXxA 密码:igm1

注意:正常使用FastDFS要安装racker和storage, 而tracker和storage使用相同的安装包也就是说如果你在一台服务器上安装了tracker也就同时安装了storage

本教程使用的:FastDFS_v5.05.tar.gz

http://sourceforge.net/projects/FastDFS/https://github.com/happyfish100/FastDFS(推荐)

 

1、fastDFS安装环境

FastDFS是C语言开发,建议在linux上运行,本教程使用Centos6.4作为安装环境。安装FastDFS需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc:

检查gcc是否安装: gcc -v

安装gcc:

yum install gcc-c++

2、安装libevent

FastDFS依赖libevent库,需要安装:

yum -y install libevent

3、安装libfastcommon

libfastcommon是FastDFS官方提供的,libfastcommon包含了FastDFS运行所需要的一些基础库。

将libfastcommonV1.0.7.tar.gz拷贝至/usr/local/下

依次执行以下命令:

解压:

tar -zxvf libfastcommonV1.0.7.tar.gz

进入 libfastcommon-1.0.7 执行:

./make.sh
./make.sh install

libfastcommon安装好后会自动将库文件拷贝至/usr/lib64下,由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件libfastcommon.so拷贝至/usr/lib下。

要拷贝的文件如下:

 cp /usr/lib64/libfastcommon.so /usr/lib/

二 安装tracker

1、安裝tracker(同时storage也安装了)

将FastDFS_v5.05.tar.gz拷贝至/usr/local/下执行依次执行以下命令:

解压: 

tar -zxvf FastDFS_v5.05.tar.gz

 进入FastDFS执行以下命令

./make.sh
./make.sh install

2、修改配置

  • 安装成功后进入/etc/fdfs目录:
cd /etc/fdfs

             

                  

  • 拷贝一份新的tracker配置文件:
cp tracker.conf.sample   tracker.conf
  • 修改tracker.conf:
vi tracker.conf

base_path=/home/yuqing/fastdfs   改为: base_path=/home/fastdfs

/home/fastdfs 目录不存在的话创建/home/fastdfs目录 :  mkdir -p /home/fastdfs 

3、启动(也是重启命令): 

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

启动的日志显示先停止5619进程(实际环境不是5619)再启动,如下图:

注意:如果没有显示上图要注意是否正常停止原有进程(如果不显示再执行一次此命令)。

设置开机自动启动:

在/etc/rc.d/rc.local中添加 /usr/bin/fdfs_trackerd  /etc/fdfs/tracker.conf restart

三 安装storage

注意: 如果本服务器上已经安装过tracker,则只需修改storage配置即可(因为storage与tracker使用同一个安装包),如果服务器上没有安装过tracker需用执行步骤一和tracker的安装步骤(不需要配置,因为不使用tracker的功能)

 

安装libevent : 同tracker安装

安装libfastcommon : 同tracker安装。

storage编译安装 : 同tracker编译安装。

 

1、修改配置

安装成功后进入/etc/fdfs目录:

 

  • 拷贝一份新的storage配置文件:
cp storage.conf.sample storage.conf
  • 修改storage.conf
vi storage.conf

group_name=group1

base_path=/home/yuqing/fastdfs改为:base_path=/home/fastdfs

store_path0=/home/yuqing/fastdfs改为:store_path0=/home/fastdfs/fdfs_storage#没有此目录的话需要创建

#如果有多个挂载磁盘则定义多个store_path,如下

#store_path1=.....

#store_path2=......
tracker_server=192.168.101.3:22122   #配置tracker服务器:IP注意此IP不能是127.0.0.1

#如果有多个则配置多个tracker

tracker_server=192.168.101.4:22122

2、启动(也是重启)

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

启动的日志显示先停止8931进程(实际环境不是8931)再启动,如下图:

注意:如果没有显示上图要注意是否正常停止原有进程。

设置开机自动启动:

在/etc/rc.d/rc.local 添加运行命令行:/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

四 上传图片测试:

通过fdfs_test程序

FastDFS安装成功可通过/usr/bin/fdfs_test测试上传、下载等操作。

1、修改配置

 复制文件: 

cp client.conf.sample client.conf

修改: 

vi /etc/fdfs/client.conf

base_path=/home/fastdfs

tracker_server=192.168.101.3:22122    #tracker服务器所在IP

 

2、测试

使用格式:

/usr/bin/fdfs_test   客户端配置文件地址    upload     上传文件

比如将/home下的图片上传到FastDFS中:

/usr/bin/fdfs_test    /etc/fdfs/client.conf    upload    /home/timg.jpg

http://172.17.139.88/group1/M00/00/00/rBGLWFuZ1tqATlKbAAEewj_-ZNU312.jpg就是文件的下载路径。

对应storage服务器上的

/home/fastdfs/fdfs_storage/data/M00/00/00/rBGLWFuZ1tqATlKbAAEewj_-ZNU312.jpg文件。

 

由于现在还没有和nginx整合无法使用http下载。

 

FastDFS配置文件tracker.conf详解  

猜你喜欢

转载自blog.csdn.net/ityqing/article/details/82685533