FastDFS 安装

FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储、文件同步、文件上传、文件下载等,解决了大容量存储和负载均衡的问题。

FastDFS 安装

  1. 安装 libfastcommon
# 下载
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.41.tar.gz
# 解压 
tar -zxvf V1.0.41.tar.gz

# 编译 安装
cd libfastcommon-1.0.41/
sh make.sh
sh make.sh install
  1. 安装 fast dfs

    # 下载
    wget https://github.com/happyfish100/fastdfs/archive/V6.01.tar.gz
    # 解压编译安装
    tar -zxvf V6.01.tar.gz
    cd fastdfs-6.01/
    sh make.sh
    sh make.sh install
    
  2. 创建必要文件夹

    mkdir -p /data/fastdfs/log
    mkdir -p /data/fastdfs/data
    mkdir -p /data/fastdfs/tracker
    mkdir -p /data/fastdfs/client
    
  3. 修改配置文件 配置文件在 /etc/fdfs 下

    • 配置 tracker.conf

      cd /etc/fdfs/
      cp tracker.conf.sample tracker.conf
      注意下 tracker.conf 文件的几个地方
          ## 存储数据和日志文件的基本路径
          base_path=/data/fastdfs/tracker
          ## Http服务端口
          http.server_port=8080
          ## 默认提供服务端口
          port=22122
          
      启动 跟踪器
      /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
      查看状态
      netstat -apn|grep fdfs
      
    • 配置 storage.conf 存储服务

      cp storage.conf.sample storage.conf
      
      ## 关注如下几个配置
      ## storage存储data和log的跟路径
      base_path=/data/fastdfs/data
      ## 默认组名
      group_name=group1
      ## 默认端口,相同组的storage端口号必须一致
      port=23000
      ## 配置一个存储路径
      store_path_count=1
      store_path0=/data/fastdfs/data
      ## 配置跟踪器IP和端口
      tracker_server=192.168.72.130:22122
      
      ## 启动
      /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
      ## 查看进程
      netstat -apn|grep fdfs
       -----------------------
      ## 查看启动日志
      tail -f /data/fastdfs/data/logs/storaged.log
      
      
    • 配置 client.conf

      cp client.conf.sample client.conf
      
      ## 关注如下几个配置
      ## client数据和日志目录
      base_path=/data/fastdfs/client
      ## 配置跟踪器IP和端口
      tracker_server=192.168.72.130:22122
      

      测试 上传:

      
      /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/test.txt
       会反馈一个 字符串 也就是路径
       group1/M00/00/00/XXXXX-XXXX.txt
      

Nginx 安装 & 整合FastDFS

  1. 下载 nginx

    wget http://nginx.org/download/nginx-1.16.1.tar.gz
    
  2. 下载 Fastdfs-nginx-moudle

    wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.
    
  3. 安装必要依赖

    ## pcre-devel 环境
    yum install -y pcre pcre-devel
    ## zlib-devel 环境
    yum install -y zlib zlib-devel
    ## openssl-devel 环境
    yum install -y openssl openssl-devel
    
  4. nginx 配置安装

    在nginx 文件夹下,执行:

    # =/root/fastdfs-nginx-module/src 填你的 Fastdfs-nginx-moudle文件位置
    # 有必要的话 将 src 下config 文件中的local 去掉 
    ./configure --add-module=/root/fastdfs-nginx-module/src
    
    make && make install
    
  5. 查看是否安装成功

    $ /usr/local/nginx/sbin/nginx -V
    
    nginx version: nginx/1.16.1
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
    configure arguments: --add-module=/root/fastdfs/fastdfs-nginx-module-1.21/src
    
    
    

测试访问

  1. 配置客户端

    ## 移动配置文件
    [root@localhost src]# pwd
    /root/fastdfs-nginx-module/src
    [root@localhost src]# ls
    mod_fastdfs.conf
    [root@localhost src]# cp mod_fastdfs.conf /etc/fdfs/
    [root@localhost fdfs]# pwd
    /etc/fdfs
    [root@localhost fdfs]# vim mod_fastdfs.conf 
    ## 调整如下配置
    ## 连接超时
    connect_timeout=30
    ## 配置跟踪器IP和端口
    tracker_server=你的ip:22122
    ## 路径包含group
    url_have_group_name = true
    # 必须和storage配置相同
    store_path0=/data/fastdfs/data
    
  2. 完善dfs 配置

    [root@localhost fdfs]# cd /root/fastdfs-5.11/conf/
    [root@localhost conf]# cp anti-steal.jpg http.conf mime.types /etc/fdfs/
    
  3. 更改nginx 文件配置 (路径是 /usr/local/nginx/conf/ 一定不要搞错了)

    server {
        listen       80;
        
        location ~/group([0-9])/M00 {
            root /data/fastdfs/data;
            ngx_fastdfs_module;
        }
    }
    

启动nginx 等

## 启动
/usr/local/nginx/sbin/nginx
## 停止
/usr/local/nginx/sbin/nginx -s stop
## 重启
/usr/local/nginx/sbin/nginx -s reload
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值