分布式文件系统(FastDFS)安装 配置

[TOC]

百度百科:

FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务,如相册网站、视频网站等等。
FastDFS为互联网量身定制,充分考虑了冗余备份、负载均衡、线性扩容等机制,并注重高可用、高性能等指标,使用FastDFS很容易搭建一套高性能的文件服务器集群提供文件上传、下载等服务。
FastDFS项目地址:https://github.com/happyfish100

FastDFS架构图:

分布式文件系统(FastDFS)安装 配置_第1张图片
fastdfs.jpg

通过架构图可以很清晰的看出FastDFS由两个核心模块组成Tracker(跟踪器)、Storage(存储器)。

FastDFS安装

第一步:克隆libfastcommon项目

编译、安装: ./make.sh &&./make.sh install

第二步:克隆fastdfs项目

编译、安装: ./make.sh &&./make.sh install
安装完成后会在/etc/init.d下生成两个可执行脚本fdfs_storaged和fdfs_trackerd。

分布式文件系统(FastDFS)安装 配置_第2张图片
image.png

FastDFS配置

配置tracker服务

编辑配置文件
[root@hmhbt tracker]# cd /etc/fdfs/
[root@hmhbt fdfs]# cp tracker.conf.sample tracker.conf
[root@hmhbt fdfs]# vim tracker.conf

#启用配置文件
disabled=false
#设置tracker的端口号
port=22122
#设置tracker的数据文件和日志目录(需手动创建)
base_path=/mnt/fastdfs/tracker  
#设置http端口号
http.server_port=9090
创建base_path路径
mkdir -p /mnt/fastdfs/tracker
防火墙打开22122端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT 
启动tracker服务器
/etc/init.d/fdfs_trackerd start

配置storage服务

[root@hmhbt /]# cd /etc/fdfs
[root@hmhbt fdfs]# cp storage.conf.sample storage.conf
# 修改的内容如下:
disabled=false                      # 启用配置文件
port=23000                          # storage服务端口
base_path=/mnt/fastdfs/storage          # 数据和日志文件存储根目录
store_path0=/mnt/fastdfs/storage        #第一个存储目录,第二个存储目录起名为:store_path1=xxx,其它存储目录名依次类推...
store_path_count=1                  # 存储路径个数,需要和store_path个数匹配
tracker_server=192.168.1.200:22122  # tracker服务器IP和端口 可配置多个
tracker_server=192.168.1.200:22122
创建base_path
[root@hmhbt fdfs]# mkdir -p /mnt/fastdfs/storage
防火墙开启23000端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 23000 -j ACCEPT
启动storage
[root@hmhbt fdfs]# /etc/init.d/fdfs_storaged start
分布式文件系统(FastDFS)安装 配置_第3张图片
image.png

文件上传测试

修改Tracker服务器客户端配置文件
[root@hmhbt fdfs]# cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
[root@hmhbt fdfs]# vim /etc/fdfs/client.conf
# 修改以下配置,其它保持默认
base_path=/mnt/fastdfs/tracker
tracker_server=192.168.1.200:22122

[root@hmhbt bin]# cd /usr/bin
[root@hmhbt bin]# ./fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/EB5B05F395308337453689873914EB94.jpg
group1/M00/00/00/wKgByFkjAXeAFwc3AAGX2D-yq14580.jpg

返回文件ID号:group1/M00/00/00/wKgByFkjAXeAFwc3AAGX2D-yq14580.jpg

FastDFS介绍(官方文档):http://download.csdn.net/detail/xyang81/9656542
FastDFS配置文件详解:http://download.csdn.net/detail/xyang81/9656557

以上属于原创文章,转载请注明作者@怪咖
QQ:208275451

你可能感兴趣的:(分布式文件系统(FastDFS)安装 配置)