「FastDFS」- 安装及部署(单机)

  CREATED BY JENKINSBOT

环境概述

属性 参数
操作系统 Kali GNU/Linux Rolling
软件版本 FastDFS V6.06

第一步、安装服务

安装 libfastcommon 类库

#!/bin/sh

git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon; git checkout V1.0.43
./make.sh clean && ./make.sh && ./make.sh install

安装 fastdfs 服务

#!/bin/sh

git clone https://github.com/happyfish100/fastdfs.git
cd fastdfs; git checkout V6.06
./make.sh clean && ./make.sh && ./make.sh install

安装配置文件

#!/bin/sh

./setup.sh /etc/fdfs

第二步、修改配置

修改数据存储目录

配置文件使用/home/yuqing/目录,可以根据需要调整:

#!/bin/sh

mkdir -pv /srv/fastdfs/

sed -i 's%/home/yuqing/%/srv/%g' /etc/fdfs/*

修改 tracker 地址

修改/etc/fdfs/storage.conftracker_server配置,根据需要设置正确地址:

tracker_server = host:port

第三步、启动服务

由于系统使用 systemd 管理服务,但是源码包里提供启动脚本不适用。执行如下命令启动服务:

#!/bin/sh

/etc/init.d/fdfs_trackerd start
/etc/init.d/fdfs_storaged start

# 或者

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

(可选)运行监控程序

#!/bin/sh

/usr/bin/fdfs_monitor /etc/fdfs/client.conf

第四步、测试服务可用

#!/bin/sh

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /usr/include/stdlib.h

常见错误汇总

tracker_query_storage fail, error no: 2, error info: No such file or directory

问题描述:
执行/usr/bin/fdfs_test /etc/fdfs/client.conf upload /usr/include/stdlib.h命令,产生如下错误:

This is FastDFS client test program v6.06

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.fastken.com/
for more detail.

[2020-03-04 10:52:32] DEBUG - base_path=/srv/fastdfs, connect_timeout=5, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max
_idle_time=3600s, use_storage_id=0, storage server id count: 0

[2020-03-04 10:52:32] ERROR - file: tracker_proto.c, line: 50, server: 127.0.0.1:22122, response status 2 != 0
[2020-03-04 10:52:32] ERROR - file: ../client/tracker_client.c, line: 1077, fdfs_recv_response fail, result: 2
[2020-03-04 10:52:32] ERROR - file: tracker_proto.c, line: 50, server: 127.0.0.1:22122, response status 2 != 0
[2020-03-04 10:52:32] ERROR - file: ../client/tracker_client.c, line: 899, fdfs_recv_response fail, result: 2
tracker_query_storage fail, error no: 2, error info: No such file or directory

问题原因
查看/srv/fastdfs/logs/storaged.log/srv/fastdfs/logs/trackerd.log日志,日志信息提示/etc/fdfs/storage.conftracker_server配置错误。

解决办法
调整etc/fdfs/storage.conftracker_server配置,并且不能配置127.0.0.1地址。

参考文献

happyfish100/fastdfs/V6.06/INSTALL