文章目录

  • 环境准备
    • 下载文件
  • 安装 FastDFS
    • 安装依赖
    • 安装 libfastcommon 类库
    • 安装 FastDFS
    • 相关目录结构
      • 服务脚本
      • 配置文件(配置文件样例)
      • 命令工具
  • 配置 FastDFS 跟踪器(Tracker)
    • 编辑配置信息
    • 启动 Tracker
    • 开机自启
  • 配置 FastDFS 存储器(Storage)
    • 编辑配置信息
    • 启动 Storage
    • 开机自启
  • 测试上传文件
    • 编辑配置信息
    • 上传
  • 安装 Nginx
    • 下载 Nginx 需要组件
    • 安装
    • 配置 fastdfs-nginx-module
    • Nginx 配置
  • 访问

环境准备

下载文件

  • https://github.com/happyfish100/fastdfs:
    FastDFS 主安装文件
  • https://github.com/happyfish100/libfastcommon
    FastDFS 要使用到的库
  • https://github.com/happyfish100/fastdfs-nginx-module
    FastDFS 对 Nginx 支持
  • http://nginx.org/download/nginx-1.15.1.tar.gz
    Nginx

  FastDFS 详解:http://www.ityouknow.com/fastdfs/2018/01/06/distributed-file-system-fastdfs.html

安装 FastDFS

安装依赖

yum -y install gcc-c++ perl

安装 libfastcommon 类库

  FastDFS 从 5.x 开始取消了对 libevent 的依赖,添加了对 libfastcommon 的依赖,安装 FastDFS 必须安装 libfastcommon 类库。

[root@host202 tmp]# cd libfastcommon-1.0.39/
[root@host202 libfastcommon-1.0.39]# ./make.sh && ./make.sh install

  如果没有出现错误信息,说明安装完成,如下:

*****************以上省略******************
func.lo local_ip_func.lo avl_tree.lo ioevent.lo ioevent_loop.lo fast_task_queue.lo fast_timer.lo process_ctrl.lo fast_mblock.lo connection_pool.lo fast_mpool.lo fast_allocator.lo fast_buffer.lo multi_skiplist.lo flat_skiplist.lo system_info.lo fast_blocked_queue.lo id_generator.lo char_converter.lo char_convert_loader.lo common_blocked_queue.lo multi_socket_client.lo skiplist_set.lo -lm -lpthread
ar rcs libfastcommon.a hash.o chain.o shared_func.o ini_file_reader.o logger.o sockopt.o base64.o sched_thread.o http_func.o md5.o pthread_func.o local_ip_func.o avl_tree.o ioevent.o ioevent_loop.o fast_task_queue.o fast_timer.o process_ctrl.o fast_mblock.o connection_pool.o fast_mpool.o fast_allocator.o fast_buffer.o multi_skiplist.o flat_skiplist.o system_info.o fast_blocked_queue.o id_generator.o char_converter.o char_convert_loader.o common_blocked_queue.o multi_socket_client.o skiplist_set.o
mkdir -p /usr/lib64
mkdir -p /usr/lib
mkdir -p /usr/include/fastcommon
install -m 755 libfastcommon.so /usr/lib64
install -m 644 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h common_blocked_queue.h multi_socket_client.h skiplist_set.h fc_list.h /usr/include/fastcommon
if [ ! -e /usr/lib/libfastcommon.so ]; then ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so; fi

安装 FastDFS

[root@host202 libfastcommon-1.0.39]# cd ../fastdfs-5.11/
[root@host202 fastdfs-5.11]# ./make.sh && ./make.sh install

  如果没有出现错误信息,说明安装完成,如下:

*****************以上省略******************
cp -f fdfs_storaged  /usr/bin
if [ ! -f /etc/fdfs/storage.conf.sample ]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf.sample; fi
mkdir -p /usr/bin
mkdir -p /etc/fdfs
mkdir -p /usr/lib64
mkdir -p /usr/lib
cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender /usr/bin
if [ 0 -eq 1 ]; then cp -f libfdfsclient.a /usr/lib64; cp -f libfdfsclient.a /usr/lib/;fi
if [ 1 -eq 1 ]; then cp -f libfdfsclient.so /usr/lib64; cp -f libfdfsclient.so /usr/lib/;fi
mkdir -p /usr/include/fastdfs
cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs
if [ ! -f /etc/fdfs/client.conf.sample ]; then cp -f ../conf/client.conf /etc/fdfs/client.conf.sample; fi

相关目录结构

服务脚本

/etc/init.d/fdfs_storaged
/etc/init.d/fdfs_tracker

配置文件(配置文件样例)

/etc/fdfs/client.conf.sample
/etc/fdfs/storage.conf.sample
/etc/fdfs/storage_ids.conf.sample
/etc/fdfs/tracker.conf.sample

命令工具

  都在 /usr/bin/ 目录下。

fdfs_appender_test
fdfs_appender_test1
fdfs_append_file
fdfs_crc32
fdfs_delete_file
fdfs_download_file
fdfs_file_info
fdfs_monitor
fdfs_storaged
fdfs_test
fdfs_test1
fdfs_trackerd
fdfs_upload_appender
fdfs_upload_file
stop.sh
restart.sh

配置 FastDFS 跟踪器(Tracker)

  复制一份配置文件

[root@host202 fdfs]# cp tracker.conf.sample tracker.conf

编辑配置信息

# 是否禁用这个配置文件,由于是 disabled,所以值为 false 即为启用本配置文件
disabled=fals
# 执行 ip,为空则允许任何 ip
bind_addr=
# the tracker server port
port=22122
# the base path to store data and log files
base_path=/data/fdfs/tracker

  其他参数默认配置即可(配置详解),最终配置完毕,使用无误之后可根据不同情况再调试参数。注意,目录要提前创建好。可以先关闭防火墙。

启动 Tracker

[root@host202 fdfs]# /etc/init.d/fdfs_trackerd start
Reloading systemd:                                         [  确定  ]
Starting fdfs_trackerd (via systemctl):                    [  确定  ]
[root@host202 fdfs]# ps -ef | grep fdfs
root      80669      1  0 17:03 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
root      80677  70386  0 17:03 pts/1    00:00:00 grep --color=auto fdfs

开机自启

  如果不想每次重启系统之后都要去启动一下服务的话,可以使用如下方式进行开机自启。

[root@host202 fdfs]# vim /etc/rc.d/rc.loca
# FastDFS Tracker 开机自启
/etc/init.d/fdfs_trackerd start

  由于在 CentOS 7中,/etc/rc.d/rc.local 文件的权限被降低了,没有执行权限,需要给它添加可执行权限:chmod +x /etc/rc.d/rc.local

配置 FastDFS 存储器(Storage)

  复制一份配置文件

[root@host202 fdfs]# cp storage.conf.sample storage.conf

编辑配置信息

# 是否禁用这个配置文件,由于是 disabled,所以值为 false 即为启用本配置文件
disabled=fals
# 执行 ip,为空则允许任何 ip
bind_addr=
# the tracker server port
port=23000
# the base path to store data and log files
base_path=/data/fdfs/storage
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/data/fdfs/storage
# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=192.168.1.241:22122
# the port of the web server on this storage server
http.server_port=8888

  其他参数默认配置即可(配置详解),最终配置完毕,使用无误之后可根据不同情况再调试参数。注意,目录要提前创建好。可以先关闭防火墙。

启动 Storage

[root@host202 fdfs]# /etc/init.d/fdfs_storaged start
Starting fdfs_storaged (via systemctl):                    [  确定  ]
[root@host202 fdfs]# ps -ef | grep fdfs
root      80669      1  0 17:03 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
root      80757      1 12 17:13 ?        00:00:01 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
root      80767  70386  0 17:13 pts/1    00:00:00 grep --color=auto fdfs

开机自启

  如果不想每次重启系统之后都要去启动一下服务的话,可以使用如下方式进行开机自启。

[root@host202 fdfs]# vim /etc/rc.d/rc.loca
# FastDFS Storage 开机自启
/etc/init.d/fdfs_storaged start

  由于在 CentOS 7中,/etc/rc.d/rc.local 文件的权限被降低了,没有执行权限,需要给它添加可执行权限:chmod +x /etc/rc.d/rc.local

测试上传文件

  复制一份 Client 配置文件

[root@host202 fdfs]# cp client.conf.sample client.conf

编辑配置信息

# Client 端产生的数据存放目录
base_path=/data/fdfs/client
# 对应的跟踪器
tracker_server=192.168.1.241:22122

上传

[root@host202 fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf Xnip2018-11-17_13-41-48.png
group1/M00/00/00/wKgB8Vvz0eqAPAuRADFGNNKBSqw218.png

  返回了一个存储路径。第一个参数为 Client 配置文件,第二个参数为需要上传的文件。能返回以上文件 ID, 说明文件上传成功。

[root@host202 fdfs]# ll /data/fdfs/storage/data/00/00/
总用量 3156
-rw-r--r--. 1 root root 3229236 11月 20 17:20 wKgB8Vvz0eqAPAuRADFGNNKBSqw218.png

安装 Nginx

下载 Nginx 需要组件

# 下载 PCRE 库
wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
tar -xzvf pcre-8.41.tar.gz
# 下载 zlib
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -xzvf zlib-1.2.11.tar.gz
# 安装必须组件
yum -y install openssl openssl-devel gcc gcc-c++

安装

[root@host202 tmp]# cd nginx-1.15.1/
[root@host202 nginx-1.15.1]# ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/logs/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --add-module=/usr/local/tmp/fastdfs-nginx-module-1.20/src
[root@host202 nginx-1.15.1]# make && make install

  出错了,简要错误如下:

/usr/include/fastdfs/fdfs_define.h:15:27: 致命错误:common_define.h:没有那个文件或目录#include "common_define.h"^
编译中断。
make[1]: *** [objs/addon/src/ngx_http_fastdfs_module.o] 错误 1
make[1]: 离开目录“/usr/local/tmp/nginx-1.15.1”
make: *** [build] 错误 2

  这个问题在官方的 Issue 上找到了解决办法:

  • 使用 v5.12版本
  • 修改 fastdfs-nginx-module-1.20/src/config 文件,修改如下:
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

  然后重新 configure、make、make install,就可以了。

配置 fastdfs-nginx-module

  复制 fastdfs-nginx-module 源码中的配置文件到/etc/fdfs 目录, 并修改:

[root@host202 fastdfs-nginx-module-1.20]# cp src/mod_fastdfs.conf /etc/fdfs/
[root@host202 fastdfs-nginx-module-1.20]# vim /etc/fdfs/mod_fastdfs.conf
# 默认为2,2秒太少了
connect_timeout=8
base_path=/data/fdfs/mod_fastdfs
# tracker跟踪器地址
tracker_server=192.168.1.241:22122
# storage存储器的端口
storage_server_port=23000
# 组名
group_name=group1
# Url 需要带组名,默认为false 改为true
url_have_group_name = true
store_path0=/data/fdfs/storage #存储器存储地址

  注意,目录要提前创建好。

  复制 FastDFS 的部分配置文件到 /etc/fdfs 目录

[root@host202 fastdfs-5.11]# cd /usr/local/tmp/fastdfs-5.11/conf/
[root@host202 conf]# cp http.conf mime.types /etc/fdfs/

Nginx 配置

server {listen 80;server_name fdfs.com;location ~/group([0-9])/M00 {#alias /data/fdfs/storage/data;ngx_fastdfs_module;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}
[root@host202 nginx]# ./sbin/nginx -c conf/nginx.conf
ngx_http_fastdfs_set pid=92461
[root@host202 nginx]# ps -ef | grep nginx
root      92462      1  0 17:45 ?        00:00:00 nginx: master process ./sbin/nginx -c conf/nginx.conf
nobody    92463  92462  0 17:45 ?        00:00:00 nginx: worker process
root      92465  70386  0 17:45 pts/1    00:00:00 grep --color=auto nginx

访问

  本地电脑的 host 更改成对应的 192.168.1.241 fdfs.com

FastDFS 单机安装相关推荐

  1. Linux下FastDFS单机安装

    1.编译环境安装: 命令:yum install git gcc gcc-c++ make automake vim wget libevent -y 2.安装libfastcommon 基础库: 2 ...

  2. FastDFS单机部署安装

    FastDFS单机部署安装 文章目录 FastDFS单机部署安装 前言 1:服务器规划 2:安装包 3:所有tracker和storage节点都执行如下操作 3.1:安装所需的依赖包 3.2:安装li ...

  3. 第二章、FastDFS单机搭建过程

            上章我们初始了FastDFS的介绍,发展历程和结构,不多说,本章带你走进FastDFS单机版安装步骤,以及相关web项目演示上传下载等功能. 1.准备环境 系统:Centos7.x 相 ...

  4. fastDFS+fastDFS-nginx-module安装部署在线预览

    目录 文章目录 目录 一.部署的环境准备 1.1 机器准备 1.2 系统环境 二.fastdfs安装及配置 2.0 安装软件及版本 2.1 安装依赖包 2.2 安装libfastcommon 2.3 ...

  5. 轻量级分布式文件系统FastDFS使用安装说明手册(新手入门级)

    轻量级分布式文件系统FastDFS使用安装说明手册(新手入门级) 实验室所在的课题组以研究云计算为主,但所有的研究都是在基于理论的凭空想像,缺少分布式环境的平台的实践,云计算神马的都是浮云了.因此,我 ...

  6. linux arcgis10.4安装教程,ArcGIS 10.1 for Server安装教程系列—— Linux下的单机安装

    因为Linux具有稳定,功能强大等特性,因此常常被用来做为企业内部的服务器,我们的很多用户也是将ArcGIS Server安装在Linux上,但是对于初次接触Linux的用户,他们都觉得无从下手,Li ...

  7. 7 centos ssh 单机_centos7单机安装kafka

    基础要求操作系统:CentOS 7x 64位 kafka版本:kafka_2.11-0.8.2.1 #安装使用的jdk以及kafka的包我放到百度云了,需要自取. # 链接:https://pan.b ...

  8. Ⅰ:zookeeper的单机安装 - 详细教程

    2021年Zookeeper最新系列 ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ❤️ ...

  9. FastDFS的安装

    Linux下使用FastDFS 所有操作均在CentOS 6.x环境下进行. 将所需文件,上传到/usr/local/learn目录下: 单节点FastDFS 整个安装过程非常复杂,很容易出错,建议进 ...

最新文章

  1. 建立循环单链表(头插法)
  2. perl学习:一些字符串操作
  3. Gradle构建工具的学习与使用
  4. python初学者怎么找工作_学python找工作好找吗
  5. 信息学奥赛C++语言: 单词的长度
  6. BizTalk中常用到的表达式
  7. 2021母婴行业洞察报告.pdf(附下载链接)
  8. bzoj 1019: [SHOI2008]汉诺塔
  9. 祝各位MM们节日快乐!
  10. 2021年高考成绩查询徐水,2021年4月河北保定徐水区自考成绩5月18日公布
  11. python 成语库_Python“Every Other Element”成语
  12. 小尺寸笔记本将走向何方 — X280 长测
  13. 5操作系统的运行机制和体系结构
  14. curl ip.sb查询公网ip
  15. 【iOS】苹果登录Sign in with Apple
  16. ie浏览器点击F12没反应
  17. qspi(spi四线模式)
  18. 带x的分数解方程计算机,五年级分数解方程
  19. Fortify SCA C#.NET 扫描方法(Visual Studio插件)
  20. jetty服务器使用jersey作为Restful框架

热门文章

  1. 移动端如何解决video层级最高的问题
  2. 文献管理工具EndNote使用
  3. windows下的ubuntu盘符问题
  4. 抢先服服务器维修什么时候玩,王者荣耀抢先服能和那些服务器匹配?匹配开放时间详解介绍...
  5. ERROR:cannot load flash device description
  6. android 手机型号占有量,2021年安卓手机性能排行及手机品牌占有率
  7. 使用css制作跳动的心
  8. 当且仅当函数依赖a→b在r上成立_数据库第06章关系数据理习题课.ppt
  9. 淘宝/天猫API接口,买家卖家订单信息获取
  10. 富贵竹的水养殖方法和注意事项,6个步骤帮你养出翠绿富贵竹