1. 分布式文件系统应用场景
互联网海量非结构化苏剧的存储需求
- 电商网站:海量商品图片
- 视频网站:海量视频文件
- 网盘:海量文件
- 社交网站:海量图片
2.FastDFS介绍
https://github.com/happyfish100/fastdfs
2.1 简介
FastDFS是一个开源的高性能分布式文件系统(DFS)。它主要功能包括:文件存储,文件同步和文件访问,以及高容量和负载平衡。主要解决了海量数据存储问题,特别适合以中小文件(建议范围:4KB<file_size<500MB
3.FastDFS环境搭建
3.1 环境准备
使用的系统软件
名称 | 说明 |
---|---|
centos | 7.x |
libfastcommon | FastDFS分离出的一些公用函数包 |
FastDFS | FastDFS本体 |
fastdfs-nginx-module | FastDFS和nginx的关联模块 |
nginx | nginx1.15.4 |
编译环境
CentOS7
yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
磁盘目录
说明 | 位置 |
---|---|
所有安装包 | /usr/local/soft |
数据存储位置 | /data/dfs/ |
3.2 安装
第一步:安装libfastcommon
cd /usr/local/soft/
git clone https://github.com/happyfish100/libfastcommon.git --depth 1
cd libfastcommon/
# 编译安装
./make.sh && ./make.sh install
第二步:安装libserverframe
cd /usr/local/soft/
git clone https://github.com/happyfish100/libserverframe.git --depth 1
# 进入libserverframe目录
cd libserverframe/
# 编译安装
./make.sh && ./make.sh install
第三步:安装FastDFS
# 返回上一级目录
cd /usr/local/soft/
git clone https://github.com/happyfish100/fastdfs.git --depth 1
cd fastdfs/
# 编译安装
./make.sh && ./make.sh install
#供nginx访问使用
cp /usr/local/soft/fastdfs/conf/http.conf /etc/fdfs/
cp /usr/local/soft/fastdfs/conf/mime.types /etc/fdfs/
第五步:安装fastdfs-nginx-module
cd /usr/local/soft/
git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
cp /usr/local/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
第六步 安装nginx
cd /usr/local/soft/
wget http://nginx.org/download/nginx-1.15.4.tar.gz #下载nginx压缩包
tar -zxvf nginx-1.15.4.tar.gz #解压
cd nginx-1.15.4
# 添加fastdfs-nginx-module模块
./configure --add-module=/usr/local/soft/fastdfs-nginx-module/src/
make && make install #编译安装