fastdfs安装部署整理

2023-11-01

一.fastdfs环境搭建

下面准备 2 个环境模拟部署并测试
准备工作
主服务器:192.168.100.10
从服务器:192.168.100.11
步骤1. 了解 fastDFS 原理
这次是最简单的 storage 同步,不涉及多 tracker 多 group 的配置,这里简单讲一下 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:客户端,上传下载数据的服务器 模块之间的主要关系如下:
在这里插入图片描述

安装步骤:

1. 首先安装 fastdfs

2. 准备软件包

在这里插入图片描述

3.安装编译工具辅助库文件

yum whatprovides *******
yum install gcc libevent libenent-devel perl gcc-c++ -y 
Yum install unzip -y 

4.安装及配置 fastdfs

unzip libfastcommon-master.zip -d /usr/local tar -zxvf fastdfs-5.05.tar.gz 
mv fastdfs-5.05 /usr/local/ 
cd libfastcommon-master/ 
cp -r /usr/local/fastdfs-5.05 /conf/* /etc/fdfs/

5. 自此 fastdfs 安装完成了,接下来配置 trackerd 和 storaged,并启动它们

6. 规划文件路径

Tracker : mkdir -p /opt/fastdfs/tracker
Storage : mkdir -p /opt/fastdfs/storage
Storage 存储路径 : mkdir -p /opt/fastdfs/storage/file
Client : mkdir -p /opt/fastdfs/client
Module-nginx : mkdir -p /opt/fastdfs/module-nginx

7.启动命令

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

8.修改配置文件

修改/etc/fdfs/tracker.conf 修改一处 path 即可 /opt/fastdfs/tracker
修改/etc/fdfs/storage.conf 修改 2 处
path /opt/fastdfs/storage /opt/fastdfs/storage/file
1 处 server 地址

9.上传下载删除测试

修改 client.Conf

在这里插入图片描述

[root@10 opt]# fdfs_test /etc/fdfs/client.conf upload /opt/test.jpg This is FastDFS client test program v5.05 Copyright © 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.csource.org/ for more detail. [2021-08-22 14:28:52] DEBUG - base_path=/opt/fastdfs/client, connect_timeout=30, 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 tracker_query_storage_store_list_without_group: server 1. group_name=, ip_addr=192.168.100.10, port=23000 group_name=group1, ip_addr=192.168.100.10, port=23000 storage_upload_by_filename group_name=group1, remote_filename=M00/00/00/wKhkCmEh7qSASfnBAAB0oqv4cTA408.jpg source ip address: 192.168.100.10 file timestamp=2021-08-22 14:28:52 file size=29858 file crc32=2885185840 example file url: http://192.168.100.10/group1/M00/00/00/wKhkCmEh7qSASfnBAAB0oqv4cTA408.jpg storage_upload_slave_by_filename group_name=group1, remote_filename=M00/00/00/wKhkCmEh7qSASfnBAAB0oqv4cTA408_big.jpg source ip address: 192.168.100.10 file timestamp=2021-08-22 14:28:52 file size=29858 file crc32=2885185840 example file url: http://192.168.100.10/group1/M00/00/00/wKhkCmEh7qSASfnBAAB0oqv4cTA408_big.jpg ------------------------------------------------------------------------------------------------------------------------------------------------------ [root@11 fdfs]# fdfs_test /etc/fdfs/client.conf upload /opt/test.jpg This is FastDFS client test program v5.05 Copyright © 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.csource.org/ for more detail. [2021-08-22 14:30:15] DEBUG - base_path=/opt/fastdfs/client, connect_timeout=30, 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 tracker_query_storage_store_list_without_group: server 1. group_name=, ip_addr=192.168.100.11, port=23000 group_name=group1, ip_addr=192.168.100.11, port=23000 storage_upload_by_filename group_name=group1, remote_filename=M00/00/00/wKhkC2Eh7veAPwyNAAB0oqv4cTA280.jpg source ip address: 192.168.100.11 file timestamp=2021-08-22 14:30:15 file size=29858 file crc32=2885185840 example file url: http://192.168.100.11/group1/M00/00/00/wKhkC2Eh7veAPwyNAAB0oqv4cTA280.jpg storage_upload_slave_by_filename group_name=group1, remote_filename=M00/00/00/wKhkC2Eh7veAPwyNAAB0oqv4cTA280_big.jpg source ip address: 192.168.100.11 file timestamp=2021-08-22 14:30:15 file size=29858 file crc32=2885185840 example file url: http://192.168.100.11/group1/M00/00/00/wKhkC2Eh7veAPwyNAAB0oqv4cTA280_big.jpg [root@11 fdfs]# 删除测试 [root@10 00]# fdfs_test /etc/fdfs/client.conf delete group1 M00/00/00/wKhkCmEh7qSASfnBAAB0oqv4cTA408_big.jpg This is FastDFS client test program v5.05 Copyright © 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.csource.org/ for more detail. [2021-08-22 14:33:54] DEBUG - base_path=/opt/fastdfs/client, connect_timeout=30, 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 storage=192.168.100.10:23000 delete file success [root@10 00]# ll 总用量 36 -rw-r–r–. 1 root root 29858 8 月 22 14:28 wKhkCmEh7qSASfnBAAB0oqv4cTA408.jpg -rw-r–r–. 1 root root 49 8 月 22 14:28 wKhkCmEh7qSASfnBAAB0oqv4cTA408.jpg-m

10.由于现在还没有和 nginx 整合无法使用 http 下载。

11. FastDFS 和 nginx 整合

12. 安装 zlib pcre 包

./configure
Make
Make install
fastdfs-nginx-module 安装 解压文件,拷贝 src 下配置文件到./etc/fdfs/

在这里插入图片描述

13.安装 NGINX

解压 NGINX 进入目录:
./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module-master/src
Make
Mke install
修改配置文件
Cd /usr/local/nginx/conf/nginx.cong

 server {
  listen 80;
  server_name localhost;
#charset koi8-r;
 #access_log logs/host.access.log main;
  location / { root html; index index.html index.htm; }
  location ~/group[1-3]/M00
   {
    ngx_fastdfs_module;
     }
     #error_page 404 /404.html; 
     # redirect server error pages to the static page /50x.html 
     #error_page 500 502 503 504 /50x.html;
      location = /50x.html { root html; 
      } 

14. 测试

[root@11 sbin]# ./nginx -V nginx version: nginx/1.8.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) configure arguments: --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module-master/src [root@11 sbin]# ./nginx -t ngx_http_fastdfs_set pid=15248 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful 启动进程 [root@11 sbin]# ./nginx ngx_http_fastdfs_set pid=15251 [root@11 sbin]# ps -ef | grep fdfs root 8388 1 0 14:19 ? 00:00:00 fdfs_trackerd /etc/fdfs/tracker.conf root 8400 1 0 14:21 ? 00:00:00 fdfs_storaged /etc/fdfs/storage.conf root 15255 7782 0 15:20 pts/1 00:00:00 grep --color=auto fdfs [root@11 sbin]# ps -ef | grep nginx root 15252 1 0 15:19 ? 00:00:00 nginx: master process ./nginx nobody 15253 15252 0 15:19 ? 00:00:00 nginx: worker process
root 15257 7782 0 15:20 pts/1 00:00:00 grep --color=auto nginx [root@11 sbin]# 访问测试

在这里插入图片描述

在这里插入图片描述

15.相关 tracker 配置文件详解

在这里插入图片描述

16.修改两台的参数测试 2 个 storage 同步:

主机目前文件数 example file url: http://192.168.100.10/group1/M00/00/00/wKhkCmEiIo-AYKJLAAEQF2scZcE975_big.jpg [root@10 00]# ll 总用量 380 -rw-r–r–. 1 root root 29858 8 月 22 14:28 wKhkCmEh7qSASfnBAAB0oqv4cTA408.jpg -rw-r–r–. 1 root root 49 8 月 22 14:28 wKhkCmEh7qSASfnBAAB0oqv4cTA408.jpg-m -rw-r–r–. 1 root root 32625 8 月 22 18:10 wKhkCmEiIoaAZGCDAAB_cdUYvFs176_big.jpg -rw-r–r–. 1 root root 49 8 月 22 18:10 wKhkCmEiIoaAZGCDAAB_cdUYvFs176_big.jpg-m -rw-r–r–. 1 root root 32625 8 月 22 18:10 wKhkCmEiIoaAZGCDAAB_cdUYvFs176.jpg -rw-r–r–. 1 root root 49 8 月 22 18:10 wKhkCmEiIoaAZGCDAAB_cdUYvFs176.jpg-m -rw-r–r–. 1 root root 69655 8 月 22 18:10 wKhkCmEiIo-AYKJLAAEQF2scZcE975_big.jpg -rw-r–r–. 1 root root 49 8 月 22 18:10 wKhkCmEiIo-AYKJLAAEQF2scZcE975_big.jpg-m -rw-r–r–. 1 root root 69655 8 月 22 18:10 wKhkCmEiIo-AYKJLAAEQF2scZcE975.jpg
-rw-r–r–. 1 root root 49 8 月 22 18:10 wKhkCmEiIo-AYKJLAAEQF2scZcE975.jpg-m -rw-r–r–. 1 root root 54526 8 月 22 18:10 wKhkCmEiIoqAUErLAADU_nHm0tI849_big.jpg -rw-r–r–. 1 root root 49 8 月 22 18:10 wKhkCmEiIoqAUErLAADU_nHm0tI849_big.jpg-m -rw-r–r–. 1 root root 54526 8 月 22 18:10 wKhkCmEiIoqAUErLAADU_nHm0tI849.jpg -rw-r–r–. 1 root root 49 8 月 22 18:10 wKhkCmEiIoqAUErLAADU_nHm0tI849.jpg-m [root@10 00]#

17.修改 11 的 stroge 配置文件

退出进程
[root@11 fdfs]# fdfs_trackerd /etc/fdfs/tracker.conf stop waiting for pid [8388] exit … pid [8388] exit. [root@11 fdfs]# fdfs_storaged /etc/fdfs/storage.conf stop waiting for pid [8400] exit … pid [8400] exit. [root@11 ]# vim client.conf tracker_server=192.168.100.10:22122 vim storage.conf tracker_server=192.168.100.10:22122

在这里插入图片描述

18.修改 10 主机的 tracker

在这里插入图片描述

19.重启服务测试

在这里插入图片描述
在这里插入图片描述
已经实现了自动同步

20.上传文件测试

在这里插入图片描述

在这里插入图片描述
测试成功

21.删除文件测试

在这里插入图片描述
在这里插入图片描述
两个 storge 都访问不到了。

22.查看群集信息

[root@10 fdfs]# fdfs_monitor /etc/fdfs/storage.conf [2021-08-22 19:53:17] DEBUG - base_path=/opt/fastdfs/storage, connect_timeout=30, 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 server_count=1, server_index=0 tracker server is 192.168.100.10:22122 group count: 1 Group 1: group name = group1 disk total space = 17394 MB disk free space = 15781 MB trunk free space = 0 MB storage server count = 2 active server count = 2 storage server port = 23000 storage HTTP port = 8888 store path count = 1 subdir count per path = 256 current write server index = 1 current trunk file id = 0 Storage 1: id = 192.168.100.10 ip_addr = 192.168.100.10 (10) ACTIVE http domain = version = 5.05 join time = 2021-08-22 14:21:10 up time = 2021-08-22 18:28:02 total storage = 17394 MB free storage = 15781 MB upload priority = 10 store_path_count = 1 subdir_count_per_path = 256 storage_port = 23000 storage_http_port = 8888 current_write_path = 0 source storage id = if_trunk_server = 0
connection.alloc_count = 256 connection.current_count = 1 connection.max_count = 3 total_upload_count = 10 success_upload_count = 10 total_append_count = 0 success_append_count = 0 total_modify_count = 0 success_modify_count = 0 total_truncate_count = 0 success_truncate_count = 0 total_set_meta_count = 10 success_set_meta_count = 10 total_delete_count = 2 success_delete_count = 2 total_download_count = 0 success_download_count = 0 total_get_meta_count = 0 success_get_meta_count = 0 total_create_link_count = 0 success_create_link_count = 0 total_delete_link_count = 0 success_delete_link_count = 0 total_upload_bytes = 373368 success_upload_bytes = 373368 total_append_bytes = 0 success_append_bytes = 0 total_modify_bytes = 0 success_modify_bytes = 0 stotal_download_bytes = 0 success_download_bytes = 0 total_sync_in_bytes = 59814 success_sync_in_bytes = 59814 total_sync_out_bytes = 0 success_sync_out_bytes = 0 total_file_open_count = 14 success_file_open_count = 14 total_file_read_count = 0 success_file_read_count = 0 total_file_write_count = 14 success_file_write_count = 14 last_heart_beat_time = 2021-08-22 19:53:03 last_source_update = 2021-08-22 18:59:39 last_sync_update = 2021-08-22 18:28:26
last_synced_timestamp = 1970-01-01 08:00:00 (never synced) Storage 2: id = 192.168.100.11 ip_addr = 192.168.100.11 ACTIVE http domain = version = 5.05 join time = 2021-08-22 14:20:57 up time = 2021-08-22 18:28:27 total storage = 17394 MB free storage = 15785 MB upload priority = 8 store_path_count = 1 subdir_count_per_path = 256 storage_port = 23000 storage_http_port = 8888 current_write_path = 0 source storage id = if_trunk_server = 0 connection.alloc_count = 256 connection.current_count = 1 connection.max_count = 1 total_upload_count = 2 success_upload_count = 2 total_append_count = 0 success_append_count = 0 total_modify_count = 0 success_modify_count = 0 total_truncate_count = 0 success_truncate_count = 0 total_set_meta_count = 2 success_set_meta_count = 2 total_delete_count = 0 success_delete_count = 0 total_download_count = 0 success_download_count = 0 total_get_meta_count = 0 success_get_meta_count = 0 total_create_link_count = 0 success_create_link_count = 0 total_delete_link_count = 0 success_delete_link_count = 0 total_upload_bytes = 59716 success_upload_bytes = 59716 total_append_bytes = 0
success_append_bytes = 0 total_modify_bytes = 0 success_modify_bytes = 0 stotal_download_bytes = 0 success_download_bytes = 0 total_sync_in_bytes = 343951 success_sync_in_bytes = 343951 total_sync_out_bytes = 0 success_sync_out_bytes = 0 total_file_open_count = 20 success_file_open_count = 20 total_file_read_count = 0 success_file_read_count = 0 total_file_write_count = 20 success_file_write_count = 20 last_heart_beat_time = 2021-08-22 19:52:58 last_source_update = 2021-08-22 14:30:14 last_sync_update = 2021-08-22 18:59:42 last_synced_timestamp = 2021-08-22 18:59:39 (0s delay)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

fastdfs安装部署整理 的相关文章

随机推荐

  • Qt槽函数识别发送的信号

    Qt是通过信号和槽的机制进行事件传递的 当有多个不同类型 或相同类型的物件的发送信号都通过一个槽来处理的时候 需要在槽中识别出这些信号然后做相应的处理 例如 在一个界面中有16个按钮 QPushButton 和4个 QRadioButton
  • [STM32系列]二、实现STM32 GPIO端口状态实现最大速度翻转

    STM32系列 二 实现STM32 GPIO最快速度翻转 文章目录 STM32系列 二 实现STM32 GPIO最快速度翻转 前言 一 实验准备 二 测试 1 C语言翻转测试 2 汇编翻转测试 总结 前言 在STM32F103系列应用过程中
  • TimeLine的使用

    TimeLine是什么 TimeLine是Unity的影视制作工具 该工具可以创建项目内部用到的动画过场部分 包括动作动画 声音 脚本 物体移动范围 粒子系统等 该工具不需要使用任何代码控制 TimeLine的使用 TimeLine编辑器可
  • JVM系列之故障排查与性能调优(重点)

    1 故障排查与性能调优 1 1 概述 1 1 1 生产环境中的问题 生产环境发生了OOM 该如何处理 如何判断是否是内存泄漏导致的 生产环境应该给Java进程分配多少内存 生产环境应该如何选择垃圾收集器 生产环境如何设置JVM参数 如何对垃
  • windows installer服务坏了修复方法

    昨天 经过一轮破解window 2003server后 因为是盗版的所以打不了sp2补丁 老是说密钥无效 后来还得多谢朋友的帮助 改了注册后 就可以成功的打上了sp2补丁 然后装上正版的SqlServer 2005 装着装着突然安装界面不见
  • php-cgi.exe系统错误 无法启动程序,因为计算机中丢失api-ms-win-crt-conio-l1-1-0.dll 解决此问题

    下载地址 http www jb51 net dll api ms win crt conio l1 1 0 dll html download 安装 gt 解压 gt 获得dll文件 如下 解决此问题 1 Windows 95 98 Me
  • QGIS+PyUIC+PyQt5 ImportError: DLL load failed 解决方法

    软件环境 QGIS下载地址 https qgis org downloads https qgis org downloads QGIS OSGeo4W 3 16 5 1 Setup x86 64 exe PyCharm下载地址 https
  • IDEA使用Maven创建SpingMVC项目

    IDEA使用Maven创建SpingMVC项目 1 新建Maven Project 并且选择webapp原型 然后next 2 这里的GroupId和ArtifactID随意填写 但是ArtifactID最好和你的项目一名一致 然后next
  • 二分 AcWing 790. 数的三次方根

    二分 AcWing 790 数的三次方根 原题链接 AcWing 790 数的三次方根 算法标签 二分 代码 include
  • Multisim 14.0安装包+详细安装步骤

    Multisim是美国国家仪器 NI 有限公司推出的以Windows为基础的仿真工具 适用于板级的模拟 数字电路板的设计工作 它包含了电路原理图的图形输入 电路硬件描述语言输入方式 具有丰富的仿真分析能力 安装步骤 1 选择下载的软件压缩包
  • C++ stack用法

    C 库以提供 模板 为主 所谓模板 是指不必预先制定类型的函数或类 我们可以借助STL 标准模板库 Standard Template Library STL 提供的高效算法来管理数据 为应对多种需求 STL为用户提供了多种名为容器 Con
  • chatgpt赋能python:Title:Python编程中的空格怎么用?详细教程!

    Title Python编程中的空格怎么用 详细教程 Introduction Python编程的空格使用一直是令人困惑的话题之一 但它却是Python语言中非常重要的一部分 空格在Python程序中用来表示代码块的开始和结束 因此不同的空
  • python中的堆(Heap)

    python中的堆 Heap 堆 Heap 是一种特殊的完全二叉树数据结构 有两种类型 大顶堆和小顶堆 在大顶堆中 父节点的值大于或等于其子节点的值 而在小顶堆中 父节点的值小于或等于其子节点的值 特点 堆是一种完全二叉树 意味着当除最后一
  • 软件测试之白盒测试、自动化测试练习题报告

    一 白盒测试 1 代码走查 2 代码编写及测试 二 自动化测试 总结 今天下午熟背白盒测试的代码 第一题进行详细分析 背完之后 写第一题代码 运行测试 写入报告中 花时间15分钟以内 在编译的时候 出现错误 都是小细节的错误 手抖多敲一个字
  • 谁还在AI焦虑?

    时至今日 人们对GPT 为首的诸多AI 大有热情消退的迹象 与2个月前相比 简直恍如隔世 这也进步一部印证了 山洞隐喻 人类始终对未知充满恐惧和焦虑 曾经人们忧心忡忡 整天讨论AI 取代人类工作之后 大家应该何去何从 AI入侵人类社会 大家
  • PooledConnection has already been closed.

    PooledConnection has already been closed java sql SQLException PooledConnection has already been closed 数据库链接被关闭 排查被关闭的原
  • 何恺明团队最新力作RegNet:超越EfficientNet,GPU上提速5倍,这是网络设计新范式

    鱼羊 十三 发自 凹非寺量子位 报道 公众号 QbitAI 大神 组团 出奇招 踢馆各路神经网络 还是熟悉的团队 还是熟悉的署名 Facebook AI实验室 推陈出新挑战新的网络设计范式 嗯 熟悉的Ross 熟悉的何恺明 他们带来全新的
  • 九十四.深入递归(一)

    题一 走楼梯 有个小孩正上楼梯 楼梯有n阶台阶 小孩一次可以上1阶 2阶 3阶 请实现一个方法 计算小孩有多少种上楼的方式 为了防止溢出 请将结果Mod 1000000007 给定一个正整数int n 请返回一个数 代表上楼的方式数 保证n
  • 查询与进程调度(CFS)相关信息

    目录 查询与进程相关的调度信息 查看CFS调度信息 CPU相关的信息 CFS就绪队列的总运行时间 实时队列与deadline调度的相关信息 所有进程相关的信息 查询与进程相关的调度信息 进程的nice值 优先级 调度策略 vruntime等
  • fastdfs安装部署整理

    一 fastdfs环境搭建 下面准备 2 个环境模拟部署并测试 准备工作 主服务器 192 168 100 10 从服务器 192 168 100 11 步骤1 了解 fastDFS 原理 这次是最简单的 storage 同步 不涉及多 t