【文件存储FastDFS】1、安装指导

1、前言

配置环境以及依赖:

分项具体要求
系统要求centos7
软件版本fastdfs-5.12(软件主体),libfastcommon-1.0.40(依赖包)
软件地址https://github.com/happyfish100/fastdfs/releases v5.12
软件地址https://github.com/happyfish100/libfastcommon/releases v1.0.40
软件地址https://github.com/happyfish100/fastdfs-nginx-module/releases v1.21

2、安装gcc–编译时需要

FastDFS是C语言开发,安装FastDFS需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gc
使用一下命令查看宿主机是否已经安装gcc

gcc -v

如果未安装gcc,则使用一下命令安装gcc

yum install -y gcc gcc-c++  maven

3、安装libevent–运行时需要

若安装了桌面图形界面,就不需要安装;FastDFS依赖libevent库。

yum -y install libevent

4、安装perl

使用以下命令查看宿主机是否安装perl

perl -v

如果未安装,则使用下列命令安装

yum -y install perl

5、安装libfastcommon(版本1.0.40)

libfastcommon是FastDFS官方提供的,libfastcommon包含了FastDFS运行所需要的一些基础库。
可以使用wget从网上下载,这边是使用下载好传输到宿主机。

unzip libfastcommonV1.0.40.zip  //解压
cd libfastcommonV1.0.40
./make.sh //编译
./make.sh install //安装

安装完之后的截图
在这里插入图片描述
安装好之后会在/usr/lib64目录下生成libfastcommon.so 库文件,由此验证是否安装成功。
在这里插入图片描述

6、安装fastdfs

上传fastdfs-5.12.tar.gz至宿主机,解压至/usr/local中

tar -zxvf fastdfs-5.12.tar.gz -C /usr/local

fastdfs源码编译,安装

cd /usr/local/fastdfs-5.12
./make.sh
./make.sh install

7、配置和启动tracker

将fastdfs配置文件目录复制到/etc/fdfs目录下

cp /usr/local/FastDFS/conf/* /etc/fdfs/   #复制配置文件

查看是否有tracker.conf文件是否存在,如果没有则复制一份

cp tracker.conf.sample tracker.conf

修改tracker.conf配置文件,主要修改
1)base_path,原先设置的路径为/home/yuqing/fastdfs修改为本地的路径,推荐/home/fastdfs
2)http.server_port,根据自定义的要求确定是否修改端口。
根据上步设置的路径,新建文件夹

mkdir /home/fastdfs

启动tracker

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

8、配置和启动storage

由于上面已经安装过FastDFS,这里只需要配置storage就好了;
1)切换目录到:/etc/fdfs/ 目录下;
2)拷贝一份新的storage配置文件
cp storage.conf.sample storage.conf
3)修改storage.conf ; vim storage.conf

group_name=group1 #配置组名
base_path=/home/yuqing/fastdfs    改为:  base_path=/home/fastdfs
#store存放文件的位置(store_path)
store_path0=/home/yuqing/fastdfs  改为: store_path0=/home/fastdfs_storage 
#如果有多个挂载磁盘则定义多个store_path,如下
#store_path1=.....
#store_path2=......
#配置tracker服务器:IP
tracker_server=172.17.0.231:22122
#如果有多个则配置多个tracker
#tracker_server=172.17.0.231:22122
#根据自定义要求确定是否修改配置http端口
http.server_port=88

4)创建 /home/fastdfs_storage 目录

mkdir /home/fastdfs_storage

5)启动storage, 运行命令如下:

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

启动完成后进入 /home/fdfs_storage/data 目录下,显示目录如下:
在这里插入图片描述

7、测试-使用FastDFS自带工具测试

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /tmp/9448607_203308534000_2.jpg
在这里插入图片描述
返回的文件ID由group、存储目录、两级子目录、fileid、文件后缀名(由客户端指定,主要用于区分文件类型)拼接而成。
在这里插入图片描述
用xftp可以看到,在磁盘的存放路径为:
在这里插入图片描述

错误处理

当发现无法处理的错误时,请参考base_path下的log日志:本文中的log日志在 /home/fastdfs下。

文章参考:
https://www.cnblogs.com/chiangchou/p/fastdfs.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值