本文最后更新于 2024-01-26,文章内容可能已经过时。

OpenEuler22.03 LTS 源码编译安装Fastdfs-6.06 分布式存储

1、环境

名称 版本 备注
openeuler 22.03 LTS
fastdfs 6.06
libfastcommon 1.0.43 libfastcommon是一个开源的C语言库,用于实现高性能的分布式文件系统和分布式存储系统

2、准备安装包

fastdfs 官网: https://github.com/happyfish100/fastdfs/tree/V6.06 官网可参考的安装手册:https://github.com/happyfish100/fastdfs/blob/V6.06/INSTALL
#fastdfs下载地址
https://github.com/happyfish100/fastdfs/archive/refs/tags/V6.06.zip

# libfastcommon下载地址
https://github.com/happyfish100/libfastcommon/archive/refs/tags/V1.0.43.zip

3、安装源码编译相关依赖包:

[root@0003 ~]# yum -y install make gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel kernel-headers

4、安装libfastcommon :

#解压 
unzip  V1.0.43.zip
#并进入目录,执行 ./make.sh,执行./make.sh install

5、安装fastdfs

#解压 
unzip V6.06.zip
#并进入目录,执行./make.sh,执行./make.sh install

#安装成功后,根据模板创建3个配置文件
[root@0003 ~]#cd /etc/fdfs/

[root@0003 ~]# cp client.conf.sample client.conf  && cp storage.conf.sample storage.conf  &&  cp tracker.conf.sample tracker.conf   


#创建fastdfs数据目录
[root@0003 ~]# mkdir -p /home/application/fastdfs/

6、配置并启动tracker

[root@0003 ~]# vim /etc/fdfs/tracker.conf
..............
disabled=false                              #配置文件是否失效
port=22122                                     #默认端口号
base_path= /home/application/fastdfs/          #日志及运行数据存储目录
..............
添加自启动,并启动服务
[root@fastdfs 00]# chkconfig --add fdfs_trackerd

[root@0003 ~]# /etc/init.d/fdfs_trackerd start

7、配置并启动storage

[root@0003 ~]# vim /etc/fdfs/storage.conf
..............
disabled=false                                  #配置文件是否失效
group_name=group1                               #组名,根据实际情况修改
port=23000                                      #设置storage的端口号,默认是23000
base_path = /home/application/fastdfs/          #设置storage数据文件和日志目录
store_path_count=1                              #存储路径个数,需要和store_path个数匹配
store_path0 = /home/application/fastdfs/        #实际文件存储路径
tracker_server = 10.131.225.40:22122            #如果有多个tracker, tracker_server可以写多行
..............
添加自启动,并启动服务
[root@fastdfs 00]# chkconfig --add fdfs_storaged

[root@0003 ~]# /etc/init.d/fdfs_storaged start

8、配置client.conf 配置文件

[root@0003 ~]#vim /etc/fdfs/client.conf
  • 只保留如下内容,默认的文件内容都可以清空
base_path=/tmp
tracker_server=10.131.225.40:22122
创建一个测试文件并上传
[root@0003 ~]# echo "hello openeuler" > /tmp/test

#指定client.conf配置文件,并指定需要上传的文件
[root@0003 ~]# fdfs_upload_file  /etc/fdfs/client.conf   /tmp/test
返回值如 group1/M00/00/00/wKgBY2SaRKOABUlXAAAAEAGd5Pk2122913, 在 storage server1上相应目录中均能查看到该文件


具体的文件应该在: /home/application/fastdfs/data/00/00/wKgBY2SaRKOABUlXAAAAEAGd5Pk2122913

9、需注意!Fastdfs预留空间问题!

注意FastDFS中有预留空间的概念,在tracker.conf中设置,配置项为:reserved_storage_space,为磁盘总空间的20%,请酌情设置reserved_storage_space这个参数,配合监控系统来监控文件系统大小