FastDFS-5.11安装配置指南

1、简介

    FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务,如相册网站、视频网站等等。

    FastDFS由跟踪服务器(Tracker Server)、存储服务器(Storage Server)和客户端(Client)构成。

2、基础环境

3、 依赖安装

 yum install  gcc-c++ pcre pcre-devel openssl ssl-devel perl-devel -y

安装FastDFS依赖包libfastcommon
cd /usr/local/src
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.38.tar.gz 
tar xf V1.0.38.tar.gz 
cd libfastcommon-1.0.38/
./make.sh
./make.sh install

4、组件编译安装

安装FastDFS

cd /usr/local/src

wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz

tar -zxvf V5.11.tar.gz

cd fastdfs-5.11/

./make.sh

.make.sh install

5系统配置

将配置文件复制到系统为fdfs预设的目录

cd /usr/local/src/fastdfs-5.11/conf

cp mime.types http.conf /etc/fdfs/

#查看安装FastDFS过程中产生的可执行文件。

ls -la /usr/bin/fdfs*

配置FastDFS

分别对tracker,storage,client进行配置。

创建目录

mkdir /home/fastdfs/tracker -p

mkdir /home/fastdfs/storage -p

cd /etc/fdfs/

 配置tracker

cp tracker.conf.sample tracker.conf

vi tracker.conf  //标红部分

# the base path to store data and log files

base_path=/home/fastdfs/tracker

......

# thread stack size, should >= 64KB

# default value is 64KB

thread_stack_size = 128KB

启动tracker。

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

 配置storage 

cd /etc/fdfs/

cp storage.conf.sample storage.conf

vi storage.conf

# the base path to store data and log files

base_path=/home/fastdfs/storage

...

# store_path#, based 0, if store_path0 not exists, it's value is base_path

# the paths must be exist

store_path0=/home/fastdfs/storage

#store_path1=/home/yuqing/fastdfs2

.....

# tracker_server can ocur more than once, and tracker_server format is

#  "host:port", host can be hostname or ip address

tracker_server=192.168.0.166:22122

启动storage。

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

查看storage启动日志。

vi /home/fastdfs/storage/logs/storaged.log

 配置client

cd /etc/fdfs/

cp client.conf.sample client.conf

vi  client.conf

# the base path to store log files

base_path=/home/fastdfs/tracker

......

# tracker_server can ocur more than once, and tracker_server format is

#  "host:port", host can be hostname or ip address

tracker_server=192.168.0.166:22122

安装和配置fastdfs-nginx-module 

cd /usr/local/src

wget  https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz

tar -zxvf V1.20.tar.gz

配置fastdfs-nginx-module的“config”文件。

cd /usr/local/src/fastdfs-nginx-module-1.20/src/

vi config

ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"

CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

配置fastdfs-nginx-module的“mod_fastdfs.conf”文件。

cp /usr/local/src/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf /etc/fdfs/

vi /etc/fdfs/mod_fastdfs.conf

base_path=/home/fastdfs

tracker_server=192.168.0.166:22122

url_have_group_name = true

store_path0=/home/fastdfs/storage

 安装和配置Nginx

安装Nginx

cd /usr/local/src/

wget http://nginx.org/download/nginx-1.15.2.tar.gz

tar -zxvf nginx-1.15.2.tar.gz

cd nginx-1.15.2

./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/fastdfs-nginx-module-1.20/src/

make &&make install

配置Nginx

cd /usr/local/nginx/conf/

vi nginx.conf

location ~/M00{

root   /home/fastdfs/storage/data;

ngx_fastdfs_module;

}

6、测试 

 测试已完成编译的软件 

启动nginx

/usr/local/nginx/sbin/nginx

a生成测试文件

cd /usr/local/src

touch a.txt

vi a.txt

**如下内容并保存。

kungpeng test fastdfs ok!

b.生成文件链接

/usr/bin/fdfs_upload_file  /etc/fdfs/client.conf a.txt

预期:

注:问题描述

 make: *** 没有规则可以创建“default”需要的目标“build”。 停止。

解决方法:

  • 安装依赖
yum -y install gcc openssl openssl-devel pcre-devel zlib zlib-devel

 

查看所有端口号

netstat -nultp