• CentOS7 部署单节点 FastDFS


    准备

    环境  

      系统:CentOS7.5  

      软件即依赖

    • libfatscommon FastDFS分离出的一些公用函数包
    • FastDFS
    • fastdfs-nginx-module FastDFS和nginx的关联模块
    • nginx nginx1.15.7

    编译环境

    yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y

    磁盘目

    所有安装包 /usr/local/src
    数据存储位置 /home/dfs/
    mkdir /home/dfs #创建数据存储目录
    cd /usr/local/src #切换到安装目录准备下载安装包

    安装libfatscommon

    git clone https://github.com/happyfish100/libfastcommon.git --depth 1
    cd libfastcommon/
    ./make.sh && ./make.sh install #编译安装

    安装FastDFS

    cd ../ #返回上一级目录
    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 #客户端文件,测试用
    cp /usr/local/src/fastdfs/conf/http.conf /etc/fdfs/ #供nginx访问使用
    cp /usr/local/src/fastdfs/conf/mime.types /etc/fdfs/ #供nginx访问使用

    注:copy 文件路径可能会不同,需自己确定(可通过find命令进行查找)

    安装fastdfs-nginx-module

    cd ../ #返回上一级目录
    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

    wget http://nginx.org/download/nginx-1.15.7.tar.gz #下载nginx压缩包
    tar -zxvf nginx-1.15.7.tar.gz #解压
    cd nginx-1.15.7/
    #添加fastdfs-nginx-module模块
    ./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/ 
    make && make install #编译安装

    单机部署

    tracker配置

    #服务器ip为 192.168.6.3
    #我建议用ftp下载下来这些文件 本地修改
    vim /etc/fdfs/tracker.conf
    #需要修改的内容如下
    port=22122  # tracker服务器端口(默认22122,一般不修改)
    base_path=/home/dfs  # 存储日志和数据的根目录

    storage配置

    vim /etc/fdfs/storage.conf
    #需要修改的内容如下
    port=23000  # storage服务端口(默认23000,一般不修改)
    base_path=/home/dfs  # 数据和日志文件存储根目录
    store_path0=/home/dfs  # 第一个存储目录
    tracker_server=192.168.6.3:22122  # tracker服务器IP和端口
    http.server_port=8888  # http访问文件的端口(默认8888,看情况修改,和nginx中保持一致)

    client测试

    vim /etc/fdfs/client.conf
    #需要修改的内容如下
    base_path=/home/dfs
    tracker_server=192.168.6.3:22122    #tracker服务器IP和端口
    #保存后测试,返回ID表示成功 如:group1/M00/00/00/xx.tar.gz
    fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/nginx-1.15.7.tar.gz

    笔者测试报错:ERROR - file: connection_pool.c, line: 142, connect to server 192.168.6.3:22122 fail, errno: 111, error info: Connection refused

    网上查的结果都是说防火墙没关(笔者虚拟机上测试,线上环境谨慎为之)

    systemctl status fire #查询防火墙状态

     发现是关的,所以不是这个问题

    最后结果是:安装的软件没启动(如果已启动可以重启一下)

    #tracker
    /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf 
    #storage
    /usr/bin/fdfs_storaged /etc/fdfs/storage.conf 

    上传测试成功

    group1/M00/00/00/wKgGA13KGKaAVF5uAA-qrPI_9Ec.tar.gz

    配置nginx访问

    vim /etc/fdfs/mod_fastdfs.conf
    #需要修改的内容如下
    tracker_server=192.168.6.3:22122  #tracker服务器IP和端口
    url_have_group_name=true
    store_path0=/home/dfs
    #配置nginx.config
    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是注意应用的配置文件 

    测试下载,用外部浏览器访问刚才已传过的nginx安装包,引用返回的ID

     http://192.168.6.3:8888/group1/M00/00/00/wKgGA13KGKaAVF5uAA-qrPI_9Ec.tar.gz

    #弹出下载单机部署全部跑通

     

    成功

    笔者基本按照一下参照地址进行的,但对实际部署中的遇到的问题进行记录

    参考地址

  • 相关阅读:
    Android对话框自定义标题
    JSONObject和JSONArray的关系
    Java的List排序
    重写onStart()函数
    SSH框架执行自己定义的SQL语句
    nested exception is org.hibernate.QueryException: could not resolve property
    java.lang.NullPointerException org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
    Java项目打包部署war文件
    一道腾讯面试题
    SSH服务器与Android通信(3)--Android客户端发送数据
  • 原文地址:https://www.cnblogs.com/brokencolor/p/11840955.html
Copyright © 2020-2023  润新知