centos7环境下单机安装fastdfs

前言

centos7 下安装fastdfs不是那么容易,涉及的内容比较多,各个工具之间的版本要对应才能遇到更少的坑,如果你查看此教程,请下载我分享的工具 地址:https://download.csdn.net/download/u010004734/11271662

准备工作

1、安装编译工具及库文件

[root@localhost ~]# yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

2、上传所需的文件到linux服务器上

--创建文件在linux服务器上存放的文件夹
[root@localhost ~]# mkdir /usr/local/soft

在这里插入图片描述

开始安装libfastcommon

[root@localhost ~]# cd /usr/local/soft
[root@localhost ~]# yum install unzip
[root@localhost ~]# unzip libfastcommon-master.zip
[root@localhost ~]# cd libfastcommon-master
[root@localhost ~]# ./make.sh && ./make.sh install

--------建立软连接--------------
[root@localhost ~]# cd /usr/local/lib #如果没有/usr/local/lib,则mkdir /usr/local/lib

##建立软连接 
[root@localhost ~]# ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so 
[root@localhost ~]# ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so   
[root@localhost ~]# ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so  
[root@localhost ~]# ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so 
#如果是fastdfs5.0.8,上述创建软连接,可能会提示已经存在,但是为了保证没有漏掉,建议还是都执行一遍

开始安装FastDFS

[root@localhost ~]# cd /usr/local/soft
[root@localhost ~]# tar -zxvf FastDFS_v5.08.tar.gz
[root@localhost ~]# cd FastDFS
[root@localhost ~]# ./make.sh && ./make.sh install #编译并安装

安装成功之后在/etc/init.d/目录会有以下文件
在这里插入图片描述
在/usr/bin/目录会有以下文件
在这里插入图片描述
修改fdfs_storaged、fdfs_trackerd

[root@localhost ~]# vi /etc/init.d/fdfs_storaged  #编辑fdfs_storaged  文件 把文件里面的/usr/local替换成/usr
[root@localhost ~]# vi /etc/init.d/fdfs_trackerd   #编辑fdfs_trackerd  文件 把文件里面的/usr/local替换成/usr

效果如下图:
在这里插入图片描述
在这里插入图片描述
拷贝配置文件

[root@localhost ~]# cp storage.conf.sample storage.conf
[root@localhost ~]# cp client.conf.sample client.conf
[root@localhost ~]# cp tracker.conf.sample tracker.conf

效果如下图:
在这里插入图片描述
编辑tracker.conf

[root@localhost ~]# vi /etc/fdfs/tracker.conf  #编辑tracker.conf
[root@localhost ~]# base_path=/fastdfs/tracker  #暂时就只修改tracker.conf中base_path内容
[root@localhost ~]# mkdir -p /fastdfs/tracker  #由于tracker.conf中base_path的/fastdfs/tracker路径没有,所以需创建

启动tracker

  1. 启动方式一
[root@localhost ~]# /etc/init.d/fdfs_trackerd start  #启动tracker命令
[root@localhost ~]# /etc/init.d/fdfs_trackerd stop   #停止tracker命令
  1. 启动方式二
[root@localhost ~]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start #启动tracker命令
[root@localhost ~]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop #关闭tracker命令

修改storage.conf文件

[root@localhost ~]# vim /etc/fdfs/storage.conf #修改storage.conf文件
 
##修改内容: 
base_path=/fastdfs/storage 
store_path0=/fastdfs/storage 
tracker_server=192.168.0.150:22122 ##改成自己的虚拟机IP地址
http.server_port=80
 
[root@localhost ~]# mkdir -p /fastdfs/storage #创建storage.conf中的base_path、store_path0路径

启动storaged

  1. 启动方式一
[root@localhost ~]#  /etc/init.d/fdfs_storaged start  #启动storaged 
[root@localhost ~]#  /etc/init.d/fdfs_storaged stop #关闭storaged
  1. 启动方式二
[root@localhost ~]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start    #启动storaged
[root@localhost ~]# /usr/bin/fdfs_storaged  /etc/fdfs/storage.conf stop    #关闭storaged

检查是否启动成功

[root@localhost ~]# ps -ef | grep fdfs

在这里插入图片描述
编辑client.conf

[root@localhost ~]# vi /etc/fdfs/client.conf 

修改内容:
base_path=/fastdfs/tracker 
tracker_server=192.168.0.150:22122

开始测试FastDFS

---执行以下命令---
[root@localhost ~]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/soft/FastDFS_v5.08.tar.gz 

效果出现如下图,证明上传成功,至此FastDFS搭建成功
在这里插入图片描述

安装Nginx

[root@localhost ~]# cd /usr/local/soft
[root@localhost ~]# tar -zxvf nginx-1.14.1.tar.gz
[root@localhost ~]# cd nginx-1.14.1
[root@localhost ~]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
[root@localhost ~]# make && make install #编译并安装

检查是否安装成功

[root@localhost ~]# ll /usr/local

在这里插入图片描述
启动nginx

[root@localhost ~]# cd /usr/local/nginx/conf
[root@localhost ~]# ./nginx

检查nginx是否可以访问,在浏览器地址栏中输入192.168.0.150,出现nginx欢迎页证明nginx安装成功了
在这里插入图片描述

FastDFS与Nginx整合

[root@localhost ~]# cd /usr/local/soft/
[root@localhost ~]# tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
[root@localhost ~]# cd fastdfs-nginx-module
[root@localhost ~]# vi /usr/local/soft/fastdfs-nginx-module/src/config  #编辑配置文件config 把/usr/local修改成/usr

[root@localhost ~]# rm -rf /usr/local/nginx #把已经生成的nginx文件夹删除
[root@localhost ~]# cd /usr/local/soft/nginx-1.14.1
[root@localhost ~]# ./configure --add-module=/usr/local/soft/fastdfs-nginx-module/src/
[root@localhost ~]# make && make install #编译安装
[root@localhost ~]# cp /usr/local/fast/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[root@localhost ~]# vi /etc/fdfs/mod_fastdfs.conf

#修改以下内容
tracker_server=192.168.0.150:22122 
url_have_group_name = true 
store_path0=/fastdfs/storage
#复制FastDFS里的2个文件,到/etc/fdfs目录中
[root@localhost ~]# cd /usr/local/soft/FastDFS/conf/ 
[root@localhost ~]# cp http.conf mime.types /etc/fdfs/

#创建一个软连接,在/fastdfs/storage文件存储目录下创建软连接,将其链接到实际存放数据 的目录。
[root@localhost ~]# cd /fastdfs/storage   #进入/fastdfs/storage目录下
[root@localhost ~]# ln -s /fastdfs/storage/data/ /fastdfs/storage/data/M00
[root@localhost ~]# cd /usr/local/nginx/conf
[root@localhost ~]# vi nginx.conf
编译以下内容
 server {
        listen       80;
        server_name  192.168.0.150;#主机IP

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location ~/group([0-9])/M00 {
            root   /fastdfs/storage/data;#文件访问路径
            ngx_fastdfs_module;
        }

在这里插入图片描述
重启nginx验证是否整合成功

[root@localhost ~]# /usr/local/nginx/sbin/nginx -s start #启动nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload #重启nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s stop #停止nginx

在浏览器地址栏输入http://192.168.0.150/group1/M00/00/00/wKgAll0cW86AJ8ZeAAVCLEPUQWI.tar.gz 可以下载文件证明配置成功
在这里插入图片描述
至此 结束 下一篇讲fastdfs集群部署,敬请关注!

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值