• 云途科技成立于2010年 - 专注全球跨境电商服务器租赁托管!
  • 帮助中心

    您可以通过下方搜索框快速查找您想知道的问题

    FastDFS分布式文件服务器安装,及配置

      in  unix      Tags: 

    一,fastdfs是什么

    FastDFS是一个开源的分布式文件系统,她对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务,如相册网站、视频网站等等。

    二,安装

    wget http://fastdfs.googlecode.com/files/FastDFS_v1.22.tar.gz
    tar zxf FastDFS_v1.22.tar.gz
    cd FastDFS
    ./make.sh
    mkdir /usr/local/include             #一般情况下,local下面会有一个include文件夹的,如果没有在建个目录
    ./make.sh install

    三,fastdfs的配置

    1),tracker server的配置

    disabled=false
    bind_addr=
    port=22122
    network_timeout=60
    base_path=/home/zhangy/FastDFS
    max_connections=32
    
    # the method of selecting group to upload files
    # 0: round robin
    # 1: specify group
    # 2: load balance, select the max free space group to upload file
    store_lookup=2
    
    # which group to upload file
    # when store_lookup set to 1, must set store_group to the group name
    store_group=group1
    
    # which storage server to upload file
    # 0: round robin (default)
    # 1: the first server order by ip address
    store_server=0
    
    # which path(means disk or mount point) of the storage server to upload file
    # 0: round robin
    # 2: load balance, select the max free space path to upload file
    store_path=0
    
    # which storage server to download file
    # 0: round robin (default)
    # 1: the source storage server which the current file uploaded to
    download_server=0
    
    # reserved storage space for system or other applications.
    # if the free(available) space of any stoarge server in
    # a group <= reserved_storage_space,
    # no file can be uploaded to this group.
    # bytes unit can be one of follows:
    ### G or g for gigabyte(GB)
    ### M or m for megabyte(MB)
    ### K or k for kilobyte(KB)
    ### no unit for byte(B)
    reserved_storage_space = 1GB
    
    #standard log level as syslog, case insensitive, value list:
    ### emerg for emergency
    ### alert
    ### crit for critical
    ### error
    ### warn for warning
    ### notice
    ### info
    ### debug
    log_level=info
    
    #unix group name to run this program,
    #not set (empty) means run by the group of current user
    run_by_group=
    
    #unix username to run this program,
    #not set (empty) means run by current user
    run_by_user=
    
    # allow_hosts can ocur more than once, host can be hostname or ip address,
    # "*" means match all ip addresses, can use range like this: 10.0.1.[1-15,20] or
    # host[01-08,20-25].domain.com, for example:
    # allow_hosts=10.0.1.[1-15,20]
    # allow_hosts=host[01-08,20-25].domain.com
    allow_hosts=*
    
    # sync log buff to disk every interval seconds
    # default value is 10 seconds
    sync_log_buff_interval = 10
    
    # check storage server alive interval
    check_active_interval = 120
    
    # thread stack size, should > 512KB
    # default value is 1MB
    thread_stack_size=1MB
    
    #HTTP settings
    http.disabled=false
    http.server_port=8080
    
    #use "#include" directive to include http other settiongs
    ##include http.conf

    2)storager server的配置

    disabled=false
    group_name=group1
    bind_addr=
    port=23000
    network_timeout=60
    heart_beat_interval=30
    stat_report_interval=60
    base_path=/home/zhangy/FastDFS
    #store_path0=/home/zhangy/FastDFS
    
    max_connections=32
    
    # when no entry to sync, try read binlog again after X milliseconds
    # 0 for try again immediately (not need to wait)
    sync_wait_msec=200
    
    # after sync a file, usleep milliseconds
    # 0 for sync successively (never call usleep)
    sync_interval=0
    
    # sync start time of a day, time format: Hour:Minute
    # Hour from 0 to 23, Minute from 0 to 59
    sync_start_time=00:00
    
    # sync end time of a day, time format: Hour:Minute
    # Hour from 0 to 23, Minute from 0 to 59
    sync_end_time=23:59
    
    # path(disk or mount point) count, default value is 1
    store_path_count=1
    
    # store_path#, based 0, if store_path0 not exists, it's value is base_path
    # the paths must be exist
    store_path0=/mnt/song/fastfds2
    #store_path1=/home/zhangy/fastdfs2
    
    # subdir_count  * subdir_count directories will be auto created under each
    # store_path (disk), value can be 1 to 256, default value is 256
    subdir_count_per_path=256
    
    # 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.1.71:22122
    
    #standard log level as syslog, case insensitive, value list:
    ### emerg for emergency
    ### alert
    ### crit for critical
    ### error
    ### warn for warning
    ### notice
    ### info
    ### debug
    log_level=info
    
    #unix group name to run this program,
    #not set (empty) means run by the group of current user
    run_by_group=
    
    #unix username to run this program,
    #not set (empty) means run by current user
    run_by_user=
    
    # allow_hosts can ocur more than once, host can be hostname or ip address,
    # "*" means match all ip addresses, can use range like this: 10.0.1.[1-15,20] or
    # host[01-08,20-25].domain.com, for example:
    # allow_hosts=10.0.1.[1-15,20]
    # allow_hosts=host[01-08,20-25].domain.com
    allow_hosts=*
    
    # the mode of the files distributed to the data path
    # 0: round robin(default)
    # 1: random, distributted by hash code
    file_distribute_path_mode=0
    
    # valid when file_distribute_to_path is set to 0 (round robin),
    # when the written file count reaches this number, then rotate to next path
    # default value is 100
    file_distribute_rotate_count=100
    
    # call fsync to disk when write big file
    # 0: never call fsync
    # other: call fsync when written bytes >= this bytes
    # default value is 0 (never call fsync)
    fsync_after_written_bytes=0
    
    # sync log buff to disk every interval seconds
    # default value is 10 seconds
    sync_log_buff_interval=10
    
    # sync binlog buff / cache to disk every interval seconds
    # this parameter is valid when write_to_binlog set to 1
    # default value is 60 seconds
    sync_binlog_buff_interval=60
    
    # thread stack size, should > 512KB
    # default value is 1MB
    thread_stack_size=1MB
    
    # if check file duplicate, when set to true, use FastDHT to store file indexes
    # 1 or yes: need check
    # 0 or no: do not check
    # default value is 0
    check_file_duplicate=0
    
    # namespace for storing file indexes (key-value pairs)
    # this item must be set when check_file_duplicate is true / on
    key_namespace=FastDFS
    
    # set keep_alive to 1 to enable persistent connection with FastDHT servers
    # default value is 0 (short connection)
    keep_alive=0
    
    # you can use "#include filename" (not include double quotes) directive to
    # load FastDHT server list, when the filename is a relative path such as
    # pure filename, the base path is the base path of current/this config file.
    # must set FastDHT server list when check_file_duplicate is true / on
    # please see INSTALL of FastDHT for detail
    ##include /home/yuqing/fastdht/conf/fdht_servers.conf
    
    #HTTP settings
    http.disabled=false
    http.server_port=8888
    http.trunk_size=256KB
    
    #use "#include" directive to include HTTP other settiongs
    ##include http.conf

    四,启动fastdfs
    /usr/local/bin/fdfs_trackerd /etc/conf.d/tracker.conf       #启动tracker服务
    /usr/local/bin/fdfs_storaged /etc/conf.d/storage.conf    #启动storager服务

    [root@BlackGhost include]#  ps -e|grep fdfs
    22790 ?        00:00:00 fdfs_trackerd
    22845 ?        00:00:00 fdfs_storaged

    说明已经启动了。

    五,测试结果
    在一台Storage Server上运行
    #/usr/local/bin/fdfs_test /etc/conf.d/storage.conf upload needed_upload_filename

    /usr/local/bin/fdfs_monitor /etc/conf.d/storage.conf      #查看一下,刚才上传的文件是不是传上去了。



    • 外贸虚拟主机

      1GB硬盘

      2个独立站点

      1000M带宽

      不限制流量

      美国外贸专用虚拟主机,cPanel面板,每天远程备份.
      服务器配置:2*E5 32核,96GB 内存,4*2TB 硬盘 RAID10 阵列.

      ¥180/年

    • 美国/荷兰外贸VPS

      2核CPU

      1G内存

      30硬盘

      10M带宽

      美国/荷兰外贸云服务器,专注外贸服务器行业12年.
      服务器配置:2*E5 32核,96GB 内存,4*2TB 硬盘 RAID10 阵列.

      ¥99/月

    • 全球外贸服务器

      8核CPU

      32G内存

      1TB硬盘

      1000M带宽

      已部署数据中心:美国洛杉矶/亚特兰大、荷兰、加拿大、英国伦敦、德国、拉脱维亚、瑞典、爱沙尼亚
      自有机柜(全球九大数据中心),稳定在线率:99.9%

      ¥999/月 原价1380

    7*24小时 在线提交工单

    如果您的问题没有得到解决,推荐您在线提交工单,我们的客服人员会第一时间为您解决问题

    展开