• centos7单机快速搭建FastDFS


    下载:

    #cd /root
    
    #wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz -SO fastdfs-nginx-module.tar.gz
    #wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz -SO fastdfs.tar.gz
    #wget https://github.com/happyfish100/libfastcommon/archive/V1.0.39.tar.gz -SO libfastcommon.tar.gz
    
    #wget http://nginx.org/download/nginx-1.10.3.tar.gz

    解压:

    #tar zxvf XXX.tar.gz

    安装:

    #yum -y install gcc-c++
    #cd libfastcommon-1.0.39/ #./make.sh #./make.sh install
    #cd ../fastdfs-5.11/
    #./make.sh 
    
    ./make.sh install

     vim ../fastdfs-nginx-module-1.20/src/config

    ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
    
    CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
    #useradd -s /sbin/nologin -M nginx
    #cd ../nginx-1.10.3/ #yum install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel -y
    #./configure  --prefix=/usr/local/nginx  --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log  --http-log-path=/var/log/nginx/access.log  --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock  --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-stream --with-pcre --add-module=/root/fastdfs-nginx-module-1.20/src --with-stream
    #make && make install

    创建目录:

    mkdir /opt/fastdfs

    复制配置:

    #cp /root/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf /etc/fdfs/
    #cp /root/fastdfs-5.11/conf/* /etc/fdfs/ -f

    修改配置

    # ls
    anti-steal.jpg  client.conf.sample  mime.types        storage.conf         storage_ids.conf         tracker.conf
    client.conf     http.conf           mod_fastdfs.conf  storage.conf.sample  storage_ids.conf.sample  tracker.conf.sample
    storage.conf

    # grep -v "^#" storage.conf
    disabled=false
    
    group_name=group1
    
    bind_addr=
    
    client_bind=true
    
    port=23000
    
    connect_timeout=30
    
    network_timeout=60
    
    heart_beat_interval=30
    
    stat_report_interval=60
    
    base_path=/opt/fastdfs
    
    max_connections=256
    
    buff_size = 256KB
    
    accept_threads=1
    
    work_threads=4
    
    disk_rw_separated = true
    
    disk_reader_threads = 1
    
    disk_writer_threads = 1
    
    sync_wait_msec=50
    
    sync_interval=0
    
    sync_start_time=00:00
    
    sync_end_time=23:59
    
    write_mark_file_freq=500
    
    store_path_count=1
    
    store_path0=/opt/fastdfs
    
    subdir_count_per_path=256
    
    tracker_server=10.10.3.89:22122
    
    log_level=info
    
    run_by_group=
    
    run_by_user=
    
    allow_hosts=*
    
    file_distribute_path_mode=0
    
    file_distribute_rotate_count=100
    
    fsync_after_written_bytes=0
    
    sync_log_buff_interval=10
    
    sync_binlog_buff_interval=10
    
    sync_stat_file_interval=300
    
    thread_stack_size=512KB
    
    upload_priority=10
    
    if_alias_prefix=
    
    check_file_duplicate=0
    
    file_signature_method=hash
    
    key_namespace=FastDFS
    
    keep_alive=0
    
    
    use_access_log = false
    
    rotate_access_log = false
    
    access_log_rotate_time=00:00
    
    rotate_error_log = false
    
    error_log_rotate_time=00:00
    
    rotate_access_log_size = 0
    
    rotate_error_log_size = 0
    
    log_file_keep_days = 0
    
    file_sync_skip_invalid_record=false
    
    use_connection_pool = false
    
    connection_pool_max_idle_time = 3600
    
    http.domain_name=
    
    http.server_port=8888

    tracker.conf

    # grep -v "^#" tracker.conf
    disabled=false
    
    bind_addr=
    
    port=22122
    
    connect_timeout=30
    
    network_timeout=60
    
    base_path=/opt/fastdfs
    
    max_connections=256
    
    accept_threads=1
    
    work_threads=4
    
    min_buff_size = 8KB
    
    max_buff_size = 128KB
    
    store_lookup=2
    
    store_group=group2
    
    store_server=0
    
    store_path=0
    
    download_server=0
    
    reserved_storage_space = 10%
    
    log_level=info
    
    run_by_group=
    
    run_by_user=
    
    allow_hosts=*
    
    sync_log_buff_interval = 10
    
    check_active_interval = 120
    
    thread_stack_size = 64KB
    
    storage_ip_changed_auto_adjust = true
    
    storage_sync_file_max_delay = 86400
    
    storage_sync_file_max_time = 300
    
    use_trunk_file = false 
    
    slot_min_size = 256
    
    slot_max_size = 16MB
    
    trunk_file_size = 64MB
    
    trunk_create_file_advance = false
    
    trunk_create_file_time_base = 02:00
    
    trunk_create_file_interval = 86400
    
    trunk_create_file_space_threshold = 20G
    
    trunk_init_check_occupying = false
    
    trunk_init_reload_from_binlog = false
    
    trunk_compress_binlog_min_interval = 0
    
    use_storage_id = false
    
    storage_ids_filename = storage_ids.conf
    
    id_type_in_filename = ip
    
    store_slave_file_use_link = false
    
    rotate_error_log = false
    
    error_log_rotate_time=00:00
    
    rotate_error_log_size = 0
    
    log_file_keep_days = 0
    
    use_connection_pool = false
    
    connection_pool_max_idle_time = 3600
    
    http.server_port=9270
    
    http.check_alive_interval=30
    
    http.check_alive_type=tcp
    
    http.check_alive_uri=/status.html
    mod_fastdfs.conf
    # grep -v "#" mod_fastdfs.conf 
    connect_timeout=2
    
    network_timeout=30
    
    base_path=/tmp
    
    load_fdfs_parameters_from_tracker=true
    
    storage_sync_file_max_delay = 86400
    
    use_storage_id = false
    
    storage_ids_filename = storage_ids.conf
    
    tracker_server=10.10.3.89:22122
    
    storage_server_port=23000
    
    group_name=group1
    
    url_have_group_name = false
    
    store_path_count=1
    
    store_path0=/opt/fastdfs
    
    log_level=info
    
    log_filename=
    
    response_mode=proxy
    
    if_alias_prefix=
    
    
    
    flv_support = true
    
    flv_extension = flv
    
    
    group_count = 0

    nginx.conf

    # cat /usr/local/nginx/conf/nginx.conf
    
    #user  nobody;
    worker_processes  1;
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        sendfile        on;
    
        keepalive_timeout  65;
    
        server {
            listen       80;
            server_name  localhost;
    
            location ~/M00 {
                 root ~/fdfs/data;
                 ngx_fastdfs_module;
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    
        }
        }

    启动服务

    # fdfs_trackerd /etc/fdfs/tracker.conf start
    # fdfs_storaged /etc/fdfs/storage.conf start
    #cd /usr/local/nginx/
    #./sbin/nginx -c conf/nginx.conf

    测试:

    #fdfs_test /etc/fdfs/client.conf upload yu.jpg

    访问:

    用户要求带端口号和group名称。

    则需要做以下修改:

    /etc/fdfs/mod_fastdfs.conf

    url_have_group_name = true

    /etc/fdfs/storage.conf

    http.server_port=7071

    /usr/local/nginx/conf/nginx.conf

        server {
            listen       7071; #和storage.conf配置的http.server_port端口必须一致
            server_name  localhost;
    
            location ~/group[0-9]/ {
    #             root ~/fdfs/data;
                 ngx_fastdfs_module;
            }

    重启各个服务

  • 相关阅读:
    Create方法失效而没有提示错误信息
    JS弹出窗口控制
    本周活动
    JavaScript的初步了解
    关于PHP接收文件的资料
    mvc模式改进网站结构
    一周动态
    排序
    Java的内存泄漏
    Android笔记
  • 原文地址:https://www.cnblogs.com/zoujiaojiao/p/12295418.html
Copyright © 2020-2023  润新知