博主本人平和谦逊,热爱学习,读者阅读过程中发现错误的地方,请帮忙指出,感激不尽


服务器信息:

Storage:192.168.247.20

Traker:192.168.247.21

一、搭建环境准备:

1.1 yum检查安装

  1. yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget

1.2 非yum安装:

  1. Fastdfs:
  2. https://github.com/happyfish100
  3. NGINX
  4. http://nginx.org/download/
  5. zib:
  6. http://www.zlib.net/
  7. pcre-devel:
  8. https://centos.pkgs.org/6/centos-x86_64/pcre-devel-7.8-7.el6.x86_64.rpm.html
  9. pcre rpm
  10. http://mirrors.163.com/centos/6/os/x86_64/Packages/pcre-7.8-7.el6.x86_64.rpm

1.3 环境准备注意事项:

  1. 1.3.1注意1
  2. pcrepcre-devel版本必须保持一致
  3. 检查版本命令:
  4. [root@localhost /]# rpm -qa pcre
  5. pcre-.el6.i686
  6. 安装pcre
  7. rpm -ivh pcre-.el6.x86_64.rpm
  8. 注意2
  9. 添加Zlib安装指向必须是软件包解压的位置而不是编译安装的目录
  10. 例如:with-zlib=/usr/local/src/zlib-

二、traker安装部署(192.168.247.21)

2.1 安装libfastcommon

  1. 解压与查看
  2. unzip libfastcommon-master.zip
  3. cd libfastcommon-master
  4. ll
  5.  
  6. 编译安装
  7. ./make.sh
  8. ./make.sh install
  9. 创建软连接
  10. ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
  11. ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
  12. ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so

2.2 FastDFS安装(traker)

  1. 解压与编译安装
  2. unzip fastdfs-5.11.zip
  3. cd fastdfs-5.11
  4. ./make.sh
  5. ./make.sh install
  6. 查看fdfs是否存在以下文件:
  7. [root@localhost tansk]# cd /etc/fdfs/
  8. [root@localhost fdfs]# ll
  9. -rw-r--r-- root root Jun : client.conf.sample
  10. -rw-r--r-- root root Jun : storage.conf.sample
  11. -rw-r--r-- root root Jun : tracker.conf.sample
  12. 在/etc/fdfs/目录下复制配置文件
  13. 执行命令:
  14. cp client.conf.sample client.conf
  15. cp storage.conf.sample storage.conf
  16. cp tracker.conf.sample tracker.conf
  17. chmod *
  18. 或是:
  19. cat client.conf.sample | grep -v '^#'>client.conf
  20. cat tracker.conf.sample |grep -v '^#'>tracker.conf
  21. cat storage.conf.sample | grep -v '^#'>storage.conf
  22. traker安装与配置
  23. 创建目录如下:
  24. /usr/tansk/dev/fastdfs/fastdfs_tracker #这个是我在192.168.247.21最终创建的目录
  25. mkdir /usr/tansk/dev/fastdfs/fastdfs_tracker -p
  26. 配置tracker
  27. cd /etc/fdfs
  28. vi tracker.conf
  29. 修改以下四个地方:
  30. .disabled=false #默认开启
  31. .port= #默认端口号 .base_path=/usr/tansk/dev/fastdfs/fastdfs_tracker #刚刚创建的目录 .http.server_port= #默认端口是8080
  32. 启动与验证traker
  33. 启动命令:service fdfs_trackerd start
  34. 成功之后可以看见:
  35. [root@localhost fdfs]# service fdfs_trackerd startStarting fdfs_trackerd (via systemctl): [ OK ]
  36. 如果不能成功启动,可以通systemctl命令:systemctl start fdfs_trackerd
  37.  
  38. 验证traker
  39. 启动后发现目录多了datalog两个目录
  40. [root@localhost fdfs]# cd /usr/tansk/dev/fastdfs/fastdfs_tracker/
  41. [root@localhost fastdfs_tracker]# ll
  42. total
  43. drwxr-xr-x root root Jun : data
  44. drwxr-xr-x root root Jun : logs
  45. 查看tracker端口监听情况:
  46. [root@localhost fastdfs_tracker]# netstat -unltp|grep fdfs
  47. tcp /fdfs_trackerd
  48. 到此22122端口监听成功。

2.3 添加traker开机启动

  1. 添加可执行权限:
  2. chmod +x /etc/rc.d/rc.local
  3. 添加开机启动
  4. vim /etc/rc.d/rc.local
  5. 在最后添加:
  6. touch /var/lock/subsys/local
  7. service fdfs_trackerd start
  8. 保存退出即可
  9. 或是:
  10. [root@traker ~]# /sbin/chkconfig fdfs_trackerd on

三、storage安装部署(192.168.247.20

3.1 安装libfastcommon

(参考上文)

3.2 FastDFS安装(storage)

  1. 解压与编译安装
  2. unzip fastdfs-5.11.zip
  3. cd fastdfs-5.11
  4. ./make.sh
  5. ./make.sh install
  6. 查看fdfs是否存在以下文件:
  7. [root@localhost tansk]# cd /etc/fdfs/
  8. [root@localhost fdfs]# ll
  9. -rw-r--r-- root root Jun : client.conf.sample
  10. -rw-r--r-- root root Jun : storage.conf.sample
  11. -rw-r--r-- root root Jun : tracker.conf.sample
  12. 在/etc/fdfs/目录下复制配置文件
  13. 执行命令:
  14. cp client.conf.sample client.conf
  15. cp storage.conf.sample storage.conf
  16. cp tracker.conf.sample tracker.conf
  17. chmod *
  18. 或是:
  19. cat client.conf.sample | grep -v '^#'>client.conf
  20. cat tracker.conf.sample |grep -v '^#'>tracker.conf
  21. cat storage.conf.sample | grep -v '^#'>storage.conf
  22. storage安装与配置
  23. 创建目录如下:
  24. #这个是我在192.168.247.20最终创建的目录
  25. mkdir /usr/tansk/dev/fastdfs/fastdfs_storage -p (新增-ln)
  26. mkdir /usr/tansk/dev/fastdfs/fastdfs_storage_data -p
  27. mkdir /usr/tansk/dev/fastdfs/fastdfs_tracker -p
  28. 修改storage配置文件
  29. vi /etc/fdfs/storage.conf
  30. 找到如下8个地方修改即可
  31. .disabled=false
  32. .group_name=group1 #组名,根据实际情况修改
  33. .port= #设置storage的端口号,默认是23000,同一个组的storage端口号必须一致
  34. .base_path=/usr/tansk/dev/fastdfs/fastdfs_storage #设置storage数据文件和日志目录
  35. .store_path_count= #存储路径个数,需要和store_path个数匹配 .store_path0=/usr/tansk/dev/fastdfs/fastdfs_storage_data #实际文件存储路径
  36. .tracker_server= #我traker的ip地址与服务端口 .http.server_port= #设置 http 端口号,与traker的端口号相同
  37. 保存之后 创建软引用
  38. ln -s /usr/bin/fdfs_storaged /usr/local/bin
  39. 启动storage
  40. service fdfs_storaged start
  41. 成功应该是如下
  42. [root@localhost fdfs]# service fdfs_stroaged startStarting fdfs_storaged (via systemctl): [ OK ]
  43. 同理 如果不能启动可以用下述命令
  44. systemctl start fdfs_storaged

3.3 设置开机启动

  1. 添加可执行权限:
  2. chmod +x /etc/rc.d/rc.local
  3. 添加开机启动
  4. vim /etc/rc.d/rc.local
  5. 在最后添加:
  6. touch /var/lock/subsys/local
  7. service fdfs_storaged start
  8. 保存退出即可
  9. 或是:
  10. /sbin/chkconfig fdfs_storaged on
  11.  
  12. 查看服务是否启动
  13. [root@localhost fastdfs]# netstat -unltp | grep fdfs
  14. tcp /fdfs_storaged

3.4 检查storage是否注册到了tracker中去。

  1. 执行以下命令:
  2. /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
  3. 成功后可以看到: 
  4. ip_addr = 192.168.247.20 (localhost.localdomain) ACTIVE 的字样

四、客户端配置(在storage服务器上

4.1 修改客户端配置

  1. vim /etc/fdfs/client.conf
  2. .base_path=/usr/tansk/dev/fastdfs/fastdfs_tracker #tracker服务器文件路径
  3. .tracker_server= #tracker服务器IP地址和端口号
  4. .http.tracker_server_port= # tracker 服务器的 http端口号,必须和tracker的设置对应起来

4.2 上传图片测试验证

  1. /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/测试.jpg
  2. #你上传的图片路径(linux上的)
  3. 成功之后会返回图片的路径
  4. group1/M00///wKiWhFrdeCeAC_vCAABqgowGIFg399.jpg
  1. 进入上传的路径查看是否上传成功
  2. find / -name wKiWhFrdeCeAC_vCAABqgowGIFg399.jpg (新增-ln)
  3. cd /usr/tansk/dev/fastdfs/fastdfs_storage_data/data/M00//
  4. [root@localhost ]# ls
  5. wKiWhFrdeCeAC_vCAABqgowGIFg399.jpg

五、NGINX安装配置(在storage服务器)

5.1 fastdfs-nginx-module安装与配置

  1. 创建这个目录:
  2. /usr/tansk/dev/nginx /
  3. 上传fastdfs-nginx-module模块
  4. fastdfs-nginx-module上传至该目录下
  5.  
  6. /usr/tansk/dev/nginx /
  1. 解压fastdfs-nginx-module unzip fastdfs-nginx-module.zip
  2. 打印目录
  3. 进入src,打印目录(在后面用到)
  4. /usr/tansk/dev/nginx/fastdfs-nginx-module/src

5.2 NGINX安装与配置

  1. 解压
  2. tar -zxvf nginx-.tar.gz
  3. 编译安装
  4. 依次执行以下命令:
  5. ./configure --prefix=/usr/local/nginx --add-module=/usr/tansk/dev/nginx/fastdfs-nginx-module/src
  6. make
  7. make install

5.3 配置storage nginx

  1. 进入配置文件目录:
  2. cd /usr/local/nginx/conf
  3. 修改配置文件(绿色为修改的内容,如有不明白,可登录150.142查看):
  4. user root; #(补充-ln:如果要设置nginx worker process 所属用户、群组,可以在./configure user=nginx --group=nginx 指定配置;或者在nginx.conf中指定,例如:user nginx ngxin【前提是先创建好用户useradd -M -s /sbin/nologin nginx】)
  5. worker_processes ;
  6. error_log logs/error.log;
  7. events {
  8. worker_connections ;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. server {
  14. listen ;
  15. server_name tansk.com;
  16. location /{
  17. root html;
  18. index index.html index.htm;
  19. }
  20. location ~/group([-])/M00 {
  21. ngx_fastdfs_module;
  22. }
  23. error_page /50x.html;
  24. location = /50x.html {
  25. root html;
  26. }
  27. }
  28. }

5.4 修改模块配置,使其生效

  1. 复制FastDFS配置文件
  2. 然后进入FastDFS安装时的解压过的目录,将http.confmime.types拷贝到/etc/fdfs目录下:
  3. [root@ZL-FSL-FTP-AP conf]# cd /usr/local/fastdfs/fastdfs-5.11/conf
  4. [root@ZL-FSL-FTP-AP conf]# ls
  5. anti-steal.jpg http.conf storage.conf tracker.conf
  6. client.conf mime.types storage_ids.conf
  7. [root@ZL-FSL-FTP-AP conf]#
  8. cp http.conf /etc/fdfs/
  9. cp mime.types /etc/fdfs/
  10. 复制模块配置文件
  11. 另外还需要把fastdfs-nginx-module安装目录中src目录下的mod_fastdfs.conf也拷贝到/etc/fdfs目录下:
  12. cp /usr/tansk/dev/nginx/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
  13. 对刚刚拷贝的mod_fastdfs.conf文件进行修改:
  14. cd /etc/fdfs/
  15. chmod *
  16. vim /etc/fdfs/mod_fastdfs.conf
  17. .base_path=/usr/tansk/dev/fastdfs/fastdfs_storage #保存日志目录
  18. .tracker_server= #tracker服务器的IP地址以及端口号
  19. .storage_server_port= #storage服务器的端口号
  20. .url_have_group_name = true #文件 url 中是否有 group 名
  21. .store_path0=/usr/tansk/dev/fastdfs/fastdfs_storage_data #存储路径
  22. .group_count = #设置组的个数
  23. .在文件的最后,设置group
  24. [group1]
  25. group_name=group1
  26. storage_server_port=
  27. store_path_count=
  28. store_path0=/usr/tansk/dev/fastdfs/fastdfs_storage_data
  29. store_path1=/usr/tansk/dev/fastdfs/fastdfs_storage_data

5.5 测试验证

  1. 开启NGINX
  2. 图片验证
  3. 上传图片web浏览器按地址访问
  4. http://192.168.247.20:8095/group1/M00/00/00/wKj3FF1mf12AZdX8AAd6IwSKkH0380.jpg
  5.  
  1.  

六、结尾

  1.  

至此,FastDFS塔建成功,感谢查阅,如有遗漏,欢迎联系与补充

  1.  

转载需注明出处:https://www.cnblogs.com/tanshouke/p/12187915.html

 

FastDFS安装部署的更多相关文章

  1. 分布式文件系统之FastDFS安装部署

    前面我们了解了分布式文件系统mogilefs的框架以及安装部署和简单使用,回顾请参考https://www.cnblogs.com/qiuhom-1874/tag/MogileFS/:今天我们来了解下 ...

  2. FastDFS安装步骤

    FastDFS是用c语言编写的一款开源的分布式文件系统,充分考虑了冗余备份.负载均衡.线性扩容等机制,并注重高可用.高性能等指标,使用FastDFS很容易搭建一套高性能的文件服务器集群提供文件上传.下 ...

  3. 分布式文件系统 - FastDFS 在 CentOS 下配置安装部署

    少啰嗦,直接装 看过上一篇分布式文件系统 - FastDFS 简单了解一下的朋友应该知道,本次安装是使用目前余庆老师开源的最新 V5.05 版本,是余庆老师放在 Github 上的,和目前你能在网络上 ...

  4. 安装部署FastDFS

    安装部署FastDFS 此篇博文是在安装好虚拟机和CentOS7的前提和转自以下几篇博客得来: 1.开启CentOS的网络连接:   1.1.网址:http://blog.csdn.net/white ...

  5. docker安装部署、fastDFS文件服务器搭建与springboot项目接口

    一.docker安装部署 1.更新yum包:sudo yum update 2.安装需要的软件包,yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动 ...

  6. FastDFS安装、配置、部署(一)-安装和部署 (转)

    FastDFS是一个开源的,高性能的的分布式文件系统,他主要的功能包括:文件存储,同步和访问,设计基于高可用和负载均衡,FastDFS非常适用于基于文件服务的站点,例如图片分享和视频分享网站 Fast ...

  7. FastDFS学习总结(1)--FastDFS安装和部署

    FastDFS是一个开源的,高性能的的分布式文件系统,他主要的功能包括:文件存储,同步和访问,设计基于高可用和负载均衡,FastDFS非常适用于基于文件服务的站点,例如图片分享和视频分享网站 Fast ...

  8. FastDFS+Nginx部署详细教程

    本例使用到的所有tar和zip包地址:http://download.csdn.net/detail/corey_jk/9758664 本例中使用CentOS1.CentOS2两台机器实现. 1 GC ...

  9. FastDFS 安装与使用

    FastDFS 安装与使用 1. 什么是 FastDFS FastDFS是一个开源的高性能分布式文件系统(DFS). 它的主要功能包括:文件存储,文件同步和文件访问,以及高容量和负载平衡的设计. Fa ...

随机推荐

  1. P(Y=y|x;θ)表示什么意思

    https://blog.csdn.net/jh1137921986/article/details/88999539 在机器学习中,特别是学习到关于概率/似然估计方面的内容,经常看到类似P(Y=y| ...

  2. 吴裕雄--天生自然MySQL学习笔记:MySQL ALTER命令

    需要修改数据表名或者修改数据表字段时,就需要使用到MySQL ALTER命令. root@host# mysql -u root -p password; Enter password:******* ...

  3. 吴裕雄--天生自然 JAVASCRIPT开发学习: 验证 API

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> ...

  4. Git 报错:Updates were rejected because the tip of your current branch is behind

    刚开始学习 git 命令,发现会出现很多的错误,所以就总结下出现的错误,以此来加深理解和掌握吧! 环境:在本地库操作了一系列的 add 和 commit 操作后,想把本地仓库推送到远端,但是发生以下错 ...

  5. idea指定启动参数、环境变量

    1.  点击Edit Configurations 2 # VM Arguments 是设置的虚拟机的属性 # VM options # 环境变量参数 这里需要指定-D参数 -server -XX:M ...

  6. Django的模板变量

    变量的值来自context中的数据字典, 类似于字典对象的keys到values的映射关系. 变量是被}}和{{括起来的部分 变量看起来就像是这样: {{ variable }}. 当模版引擎遇到一个 ...

  7. ubuntu搭建web服务器

    https://www.linuxidc.com/Linux/2015-11/125477.htm 到“sudo apt-get install libapache2-mod-php5”出现1错误.

  8. Thinkcmf子栏目获取父级栏目所有子栏目列表

    网站建设时经常需要输出某个栏目的子栏目,对应的在子栏目列表页也需要输出父级栏目的子栏目列表,thinkcmf可以输出所有子栏目,但却无法在子栏目列表页也适用, 因此就需要通过对数据库表查询来完成需求: ...

  9. CodeForces 1287B Hyperset

    N^2遍历所有得(i,j)然后可以根据(i,j)字符串构造出来第三个T字符串,然后查找一下是否有这个T存在即可,注意最后答案要/3因为会重复出现. #include <stdio.h> # ...

  10. Python 学习笔记:Python 连接 SQL Server 报错(20009, b'DB-Lib error message 20009, severity 9)

    问题及场景: 最近需要使用 Python 将数据写到 SQL Server 数据库,但是在进行数据库连接操作时却报以下错误:(20009, b'DB-Lib error message 20009, ...