单机版fastDFS安装

FastDFS安装

FastDFS 是一个开源的高性能分布式文件系统(DFS)。 它的主要功能包括:文件存储,文件同步和文件访问,以及高容量和负载平衡。

FastDFS 系统有三个角色:跟踪服务器(Tracker Server)、存储服务器(Storage Server)和客户端(Client)。

Tracker Server: 跟踪服务器,主要做调度工作,起到均衡的作用;负责管理所有的storage server和group,每个 storage 在启动后会连接 Tracker,告知自己所属 group 等信息,并保持周期性心跳。多个 Tracker 之间是对等关系,不存在单点故障。
Storage Server: 存储服务器,主要提供容量和备份服务;以 group 为单位,每个 group 内可以有多台 storage server,组内的storage server上的数据互为备份。
**Client:**客户端,上传下载数据的服务器。

相关文件下载

# 下载libfastcommon(如果内网的话就直接通过wget后面的地址下载,然后再上传到服务器)
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.43.zip

# 下载 FastDFS
wget https://github.com/happyfish100/fastdfs/archive/V6.06.zip

# 下载nginx(单机版可不管)
wget https://nginx.org/download/nginx-1.20.1.tar.gz

# nginx相关依赖(单机版可不管)
# pcre
wget https://ftp.pcre.org/pub/pcre/pcre-8.44.zip
# zlib
wget http://zlib.net/zlib-1.2.11.tar.gz
# openssl
wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.zip
# fastdfs-nginx-module
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.zip

# 安装其他
yum -y install unzip
yum -y install gcc gcc-c++ autoconf automake make

安装

# 安装libfastcommon
unzip libfastcommon-1.0.43.zip 
cd libfastcommon-1.0.43
./make.sh
./make.sh install
# 安装fastdfs
unzip fastdfs-6.06.zip
cd fastdfs-6.06
./make.sh
./make.sh install


# 安装完成后/etc/fdfs/下面存在sample文件,拷贝配置文件并修改相关配置
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf  # # tracker节点
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf  # # storage节点
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf  # # # 客户端文件,测试用(单机版可不管)
cp /root/fastdfs/fastdfs-6.06/conf/http.conf /etc/fdfs/  # # 供nginx访问使用(单机版可不管)
cp /root/fastdfs/fastdfs-6.06/conf/mime.types /etc/fdfs/  # 供nginx访问使用

修改相应的配置

# 创建数据和日志存储目录(自定义)
mkdir -p /data/fastdfs
cd /data/fastdfs
mkdir tracker
mkdir storage

# 查看本机地址(查到的地址放在tracker_server)
ip addr
# 修改tracker.conf配置
bind_addr = 本机ip
base_path=/data/fastdfs/storage

# 修改storage.conf配置
base_path=/data/fastdfs/tracker  # 数据和日志文件存储根目录
store_path0=/data/fastdfs/tracker  # 第一个存储目录
tracker_server=本机ip:22122  # tracker服务器IP和端口

# 修改client.conf配置
base_path = /data/fastdfs
tracker_server = 本机ip:22122

启动

# 启动 tracker。
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
# 启动 storage
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

# 查看是否启动成功
[root@0005 fdfs]# ps -ef | grep fdfs
root     1352948       1  0 17:45 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
root     1352957       1  0 17:45 ?        00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
root     1357738 1351722  0 19:00 pts/1    00:00:00 grep fdfs

测试文件上传

[root@0005 fdfs]#  fdfs_test /etc/fdfs/client.conf upload /opt/fast/1.png
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.
...
example file url: http://本机ip/group1/M00/00/00/CuCyCGEuCCiAclCBAAA8CM9lCmg704_big.png

文件下载测试

# 下载有问题
fdfs_test /etc/fdfs/client.conf downlaod group1 M00/00/00/CuCyCGEuCCiAclCBAAA8CM9lCmg704_big.png
# 去上传地方查看文件
[root@0005 fdfs]# cd /data/fastdfs/storage/data/00/00/
[root@0005 00]# ll
-rw-r--r-- 1 root root 15368 Aug 31 18:44 CuCyCGEuCCiAclCBAAA8CM9lCmg704_big.png
-rw-r--r-- 1 root root    49 Aug 31 18:44 CuCyCGEuCCiAclCBAAA8CM9lCmg704_big.png-m
-rw-r--r-- 1 root root 15368 Aug 31 18:44 CuCyCGEuCCiAclCBAAA8CM9lCmg704.png
-rw-r--r-- 1 root root    49 Aug 31 18:44 CuCyCGEuCCiAclCBAAA8CM9lCmg704.png-m

报错一

[root@0005 fdfs]# fdfs_upload_file /etc/fdfs/client.conf testfile.zip
[2021-08-31 17:11:34] ERROR - file: connection_pool.c, line: 142, connect to server 192.168.0.196:22122 fail, errno: 110, error info: Connection timed out
[2021-08-31 17:11:39] ERROR - file: connection_pool.c, line: 142, connect to server 192.168.0.197:22122 fail, errno: 110, error info: Connection timed out

这里我做了两步操作:

# 1、开通22122和23000端口
firewall-cmd --zone=public --add-port=22122/tcp --permanent
firewall-cmd --zone=public --add-port=22122/tcp --permanent
# 2、将所有的tracker.conf、storage.conf和Client.conf中的ip修改文修改为本机的ip
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值