• FastDFS配置过程


    在我的生产环境中利用FastDFS实现动静分离的方案

    配置过程

    1.  系统环境

    CentOS 5.5

    Tracker server: 192.168.204.135

    Storage server: 192.168.204.136

    2. 环境配置

    为了速度,配置使用sohu的源

    cd /etc/yum.repo.d/
    wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo

    装开发工具和编译nginx所需的开发包

    yum groupinstall "Development Tools"
    yum install libevent-devel pcre-devel  zlib-devel

    3.安装trackerserver

    # wget http://fastdfs.googlecode.com/files/FastDFS_v3.05.tar.gz
    # tar xvzf FastDFS_v3.05.tar.gz
    # cd FastDFS
    # vi make.sh
        将如下两行前边的"#"删除
        WITH_HTTPD=1
        WITH_LINUX_SERVICE=1
    # ./make.sh
    # ./make.sh install

    修改/etc/fdfs/tracker.conf,主要修改以下两处,如有其他调整,可参考文档自行调整,默认的配置也可以工作。

    # vi /etc/fdfs/tracker.conf
        # the base path to store data and log files
        base_path=/fastdfs/tracker     ====> 放置data和log的目录
      ##include http.conf   ====>   #include http.conf    这里一定要注意!是 #include,不是include!!!
    # mkdir -p /fastdfs/tracker
    # /etc/init.d/fdfs_trackerd start
    # netstat –ntplu |grep -E ‘8080|22122’
    tcp        0      0 0.0.0.0:22122               0.0.0.0:*                   LISTEN      5149/fdfs_trackerd
    tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      5149/fdfs_trackerd

    4. 在storage上的操作

    # wget http://fastdfs.googlecode.com/files/FastDFS_v3.05.tar.gz
    # wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.10.tar.gz
    # wget http://nginx.org/download/nginx-1.0.11.tar.gz
    # tar xvzf FastDFS_v3.05.tar.gz
    # cd FastDFS
    # vi make.sh
        将如下两行前边的"#"删除
        WITH_HTTPD=1
        WITH_LINUX_SERVICE=1
    # ./make.sh
    # ./make.sh install
    # tar xvzf nginx-1.0.11.tar.gz
    # tar xvzf fastdfs-nginx-module_v1.10.tar.gz
    # cd nginx-1.0.11
    # ./configure --prefix=/soft/nginx --add-module=/root/fastdfs-nginx-module/src
    # make
    # make install

    修改/etc/fdfs/storage.conf,主要修改以下几处,如有其他调整,可参考文档自行调整,默认的配置也可以工作。

    # vi /etc/fdfs/storage.conf
       # the name of the group this storage server belongs to
        group_name=group1 ====> 此台storage server所属的服务器组名
        # the base path to store data and log files
        base_path=/home/storage ====> 放置data和log的目录
       
        # store_path#, based 0, if store_path0 not exists, it's value is base_path
        # the paths must be exist
        store_path0=/fastdfs/storage             ====> 放置文件的目录
        # tracker_server can ocur more than once, and tracker_server format is
        #  "host:port", host can be hostname or ip address
        tracker_server=192.168.204.135:22122         ====> tracker server的ip和端口,此处可以写多个tracker server,每行一个
        #HTTP settings
        http.disabled=true                    ====> 关闭内置的web server
        # the port of the web server on this storage server
        http.server_port=80                    ====> web server的端口改成80
    # cp /root/fastdfs-nginx-module/mod_fastdfs.conf /etc/fdfs/
    # vi /etc/fdfs/mod_fastdfs.conf
        # the base path to store log files
        base_path=/fasdfs/storage                 ====> 放置log的目录
        # FastDFS tracker_server can ocur more than once, and tracker_server format is
        #  "host:port", host can be hostname or ip address
        tracker_server=192.168.204.135:22122         ====> tracker server的ip和端口,此处可以写多个tracker server,每行一个
        # the group name of storage server
        group_name=group1                     ====> 此台storage server所属的服务器组名
        # if uri including group name
        # default value is false
        url_have_group_name = true             ====> 在URL中包含group名称
        # store_path#, based 0, if store_path0 not exists, it's value is base_path
        # the paths must be exist
        store_path0=/fastdfs/storage             ====> 放置文件的目录
    response_mode=redirect                ====> 对文件同步延迟的处理方式,通过redirect跳转和proxy代理两种方式解决
    # mkdir -p /fastdfs/storage

    启动storage服务

    #  /etc/init.d/fdfs_storaged start

    启动nginx

    #  /usr/local/nginx/sbin/nginx

    确认8080,22122端口已经监听

    # netstat -ntplu|grep -E '80|23000'
    tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      2797/nginx
    tcp        0      0 0.0.0.0:23000               0.0.0.0:*                   LISTEN      6524/fdfs_storaged

    5.在tracker上的操作[作为client测试]

    修改/etc/fdfs/client.conf文件,主要修改以下几处,如有其他调整,可参考文档自行调整,默认的配置也可以工作。

        # the base path to store log files
        base_path=/tmp
     
        # tracker_server can ocur more than once, and tracker_server format is
        #  "host:port", host can be hostname or ip address
        tracker_server=192.168.204.135:22122

    创建一个用于测试的文件demofile.txt

    [root@tracker]# vi demofile.txt
        内容就一行字:  dddddddddd

    使用自带的fdfs_test上传文件测试。

    [root@tracker]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload demofile.txt
    This is FastDFS client test program v3.05
     
    Copyright (C) 2008, Happy Fish / YuQing
     
    FastDFS may be copied only under the terms of the GNU General
    Public License V3, which may be found in the FastDFS source kit.
    Please visit the FastDFS Home Page http://www.csource.org/
    for more detail.
     
    [2012-01-20 14:36:04] INFO - base_path=/tmp, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0
     
    tracker_query_storage_store_list_without_group:
            server 1. group_name=group1, ip_addr=192.168.204.136, port=23000
     
    group_name=group1, ip_addr=192.168.204.136, port=23000
    storage_upload_by_filename
    group_name=group1, remote_filename=M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484.txt
    source ip address: 192.168.204.136
    file timestamp=2012-01-20 14:36:04
    file size=11
    file crc32=2037505305
    file url: http://192.168.204.135:8080/group1/M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484.txt
    storage_upload_slave_by_filename
    group_name=group1, remote_filename=M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484_big.txt
    source ip address: 192.168.204.136
    file timestamp=2012-01-20 14:36:04
    file size=11
    file crc32=2037505305
    file url: http://192.168.204.135:8080/group1/M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484_big.txt

    通过http://192.168.204.136/group1/M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484_big.txt 址可以直接访问storage地址。

  • 相关阅读:
    aircrack-ng 多网卡启动后环境清理
    Docker create image
    预加载(学习一)
    activity+fragment多次切换出现页面空白问题
    万能的Volley
    关于下拉刷新你是否真的非常理解还是只会搬砖?附 Android 实例子源代码文件下载地址380个合集
    如何将Java源代码文件的编码从GBK转为UTF-8?
    如何操作笔记本显得逼格很高?
    跑马灯源代码
    关于java、Android中Math的一些用法
  • 原文地址:https://www.cnblogs.com/wenbiao/p/3375851.html
Copyright © 2020-2023  润新知