zoukankan      html  css  js  c++  java
  • CentOS7搭建FastDFS系统

    • 创建存放目录
    cd /usr/local
    mkdir src  # 所有安装包、源码包
    cd /home
    mkdir dfs  # 数据存储位置
    
    • 安装依赖
    yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
    
    • 获取当前机器IP地址
    ifconfig 或者 ip addr
    
    • 安装libfastcommon
    #进入软件安装目录
    cd /usr/local/src
    #下载libfastcommon源码包
    git clone https://github.com/happyfish100/libfastcommon.git --depth 1
     
    cd libfastcommon/
    #编译安装
    ./make.sh
    ./make.sh install
    
    • 安装FastDFS
    #进入软件安装目录
    cd /usr/local/src
    #下载FastDFS源码包
    git clone https://github.com/happyfish100/fastdfs.git --depth 1
    cd fastdfs/
    #编译安装
    ./make.sh
    ./make.sh install
    #配置文件准备
    cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
    cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
    #客户端文件,测试用
    cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
    #供nginx访问使用
    cp /usr/local/src/fastdfs/conf/http.conf /etc/fdfs/
    #供nginx访问使用
    cp /usr/local/src/fastdfs/conf/mime.types /etc/fdfs/
    

    这里安装FastDFS后会带有tracker服务和storage服务,这里因为是单机环境,所以一台机器同时充当了tracker服务器和storage服务器

    • tracker配置
    vim /etc/fdfs/tracker.conf
    #tracker服务器端口(默认22122,一般不修改)
    port=22122
    #存储日志和数据的根目录
    base_path=/home/dfs
    #退出vim
     
    #启动tracker
    fdfs_trackerd /etc/fdfs/tracker.conf start
    
    • storage配置
    vim /etc/fdfs/storage.conf
    #storage服务端口(默认23000,一般不修改)
    port=23000
    #数据和日志文件存储根目录
    base_path=/home/dfs
    #第一个存储目录
    store_path0=/home/dfs
    #tracker服务器IP和端口,这边是单机环境,所以填的是本机地址和上面tracker配置里写的端口,如果tracker单独部署,填写对应的地址
    #配置文件里有两个tracker_server,可以注释掉一个
    tracker_server=192.168.56.103:22122
    #http访问文件的端口(默认8888,看情况修改,和nginx中保持一致)
    http.server_port=8888
    #退出wim
     
    #启动storage
    fdfs_storaged /etc/fdfs/storage.conf start
    
    • 安装fastdfs-nginx-module
    
    #进入软件安装目录
    cd /usr/local/src
    #下载fastdfs-nginx-module源码包
    git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
    #准备配置文件
    cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
    
    • 安装nginx
    #进入软件安装目录
    cd /usr/local/src
    #下载nginx压缩包
    wget http://nginx.org/download/nginx-1.15.4.tar.gz
    #解压
    tar -zxvf nginx-1.15.4.tar.gz
    cd nginx-1.15.4/
    #添加fastdfs-nginx-module模块
    ./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/
    #编译安装
    make
    make install
    
    • 配置nginx访问
    vim /etc/fdfs/mod_fastdfs.conf
    #需要修改的内容如下
    #tracker服务器IP和端口,同上面storage配置
    tracker_server=192.168.56.103:22122
    url_have_group_name=true
    store_path0=/home/dfs
    
    vim /usr/local/nginx/conf/nginx.conf
    #添加如下配置
    server {
        listen        8888; ## 该端口为storage.conf中的http.server_port相同
        server_name  localhost;
        location ~/group[0-9]/ {
            ngx_fastdfs_module;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    
    #启动nginx
    /usr/local/nginx/sbin/nginx
    
    • client测试配置
    vim /etc/fdfs/client.conf
    #需要修改的内容如下
    base_path=/home/dfs
    #tracker服务器IP和端口,同上面stroage配置
    tracker_server=192.168.56.103:22122
    #退出vim
     
    #保存后测试,返回ID表示成功 如:group1/M00/00/00/xx.tar.gz
    fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/nginx-1.15.4.tar.gz
    
    • 关闭防火墙
    systemctl stop firewalld
    #这里是暂时关闭,机器关闭后重启防火墙还会打开,如果有需要可以永久关闭
    

    测试下载,用宿主机的浏览器访问地址+nginx上传时访问返回的ID,格式如下
    http://192.168.56.103:8888/group1/M00/00/00/wKgAQ1pysxmAaqhAAA76tz-dVgg.tar.gz
    弹出下载窗口

  • 相关阅读:
    一起谈.NET技术,浅析ASP.NET清空缓存时遇到的问题 狼人:
    一起谈.NET技术,.NET平台上的ModelViewPresenter模式实践 狼人:
    一起谈.NET技术,.Net下的分布式缓存从Discuz!NT的缓存设计谈起 狼人:
    一起谈.NET技术,.NET缓存机制探讨与比对 狼人:
    一起谈.NET技术,.Net下的分布式缓存(2)实现分布式缓存同步的手段 狼人:
    一起谈.NET技术,.Net下的分布式缓存(3)如果我们没有缓存会怎么样 狼人:
    newlisp的lambda表达式
    SQL Server2008登录记录怎么删除?
    线段树端点更新 poj 2828 Buy Tickets
    111 History Grading
  • 原文地址:https://www.cnblogs.com/davion2017/p/14035073.html
Copyright © 2011-2022 走看看