分布式文件系统(DistributedFileSystem)是指文件系统管理的物理存储资源不一定直接连接到本地节点,而是通过计算机网络连接到节点.分布式文件系统的设计基于客户端/服务器模型。典型的网络可能包括由多个用户访问的多个服务器。此外,点对点特性允许一些系统执行客户端和服务器的双重角色。 FastDFS是一个开源的轻量级分布式文件系统。它管理文件。其功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了海量存储和负载均衡。问题。特别适用于以文件为载体的在线服务,如相册网站、视频网站等。 1:安装FastDFS 1。首先安装libevent。wgethttps://img.ydisp.cn/news/20220729/5q4vq3ndxzx.gztar-zxvflibevent-2.0.11-stable.tar.gzcdlibevent-2.0.11-stable./configure--prefix=/usrmakecleanmakemakeinstall 2。安装FastDFS的步骤wgethttps://img.ydisp.cn/news/20220729/g11d5lkxxcj.gztar-zxvfFastDFS_v3.03.tar.gzcdFastDFSvimmake.sh将#WITH_HTTPD=1改为WITH_HTTPD=1支持http./make。sh./make.shinstall 二:FastDFS配置 1、配置并启动TrackerServer:mkdir/home/fastdfsvi/etc/fdfs/tracker.confbase_path=/home/yuqing/fastdfs->base_path=/home/fastdfshttp.server_port=8080->http.server_port=9090##includehttp.conf->#includehttp.confreserved_storage_space=4GB->reserved_storage_space=1GBcd/usr/local/binfdfs_trackerd/etc/fdfs/tracker.conf查看tracker是否启动成功,可以查看以下文件/home/fastdfs/logs/trackerd.log:[2011-10-2114:29:44]INFO-FastDFSv3.03,base_path=/home/fastdfs,run_by_group=,run_by_user=,connect_timeout=30s,network_timeout=60s,port=22122,bind_addr=,max_connections=256,work_threads=4,store_lookup=2,store_group=,store_server=0,store_path=0,reserved_storage_space=1024MB,download_server=0,allow_ip_count=-1,sync_log_buff_interval=10s,check_active_interval=120s,thread_stack_6KB,sized_size=1,storage_sync_file_max_delay=86400s,storage_sync_file_max_time=300s,use_trunk_file=0,slot_min_size=256,slot_max_size=16MB,trunk_file_s大小=64MB[2011-10-2114:29:44]在FO-HTTPsupported:server_port=9090,default_content_type=application/octet-stream,anti_steal_token=0,token_ttl=0s,anti_steal_secret_keylength=0,token_check_failcontent_type=,token_check_failbufflength=0,check_active_interval=30,check_active_type=tcp,check_active_uri=/status.html2、配置及启动存储服务器:mkdir/home/fastdfs/fdfs_storagecd/etc/fdfsvistorage.confbase_path=/home/yuqing/fastdfs->/home/fastdfs/fdfs_storagestore_path0=/home/yuqing/fastdfs->store_path0=/home/fastdfs/fdfs_storagegroup_name=group1tracker_server=192.168.209.121:22122->tracker_server=173.252.200.228:22122##includehttp.conf->#includehttp.conf 接下来会出现很多mkdir数据路径,这是系统在创建数据目录。[2011-10-2114:49:20]INFO-FastDFSv3.03,base_path=/home/fastdfs/fdfs_storage,store_path_count=1,subdir_2count_6per_path,group_name=group1,run_by_group=,run_by_user=,connect_timeout=30s,network_timeout=60s,port=23000,bind_addr=,client_bind=1,max_connections=256,work_threads=4,disk_rw_separated=1,disk_reader_threads=1,disk_writer_threads=1,disk_rw_direct=0,buff_size=256KB,heart_beat_interval=30s,stat_report_interval=60s,tracker_server_count=1,sync_wait_msec=50ms,sync_interval=0ms,sync_start_time=00:00,sync_end_time=23:59,write_mark_file_freq=500,allow_ip_count=-1,file_distribute_path=0,file_distribute_rotate_count=100,fsync_after_written_bytes=0,sync_log_buff_interval=10s,sync_binlog_buff_interval=10s,sync_stat_file_interval=300s,thread_stack_size=512KB,upload_priority=10,if_alias_prefix=,check_file_duplicate=0,FDHTgroupcount=0,FDHTkepspace=0,FDHTkepspace=0=0,HTTP服务器端口=8888,域名ame=[2011-10-2114:49:20]INFO-HTTPsupported:server_port=8888,http_trunk_size=262144,default_content_type=application/octet-stream,anti_steal_token=0,token_ttl=0s,anti_steal_secret_keylength=0,token_check_failcontent_type=,token_check=_failblufflength0[2011-10-2114:49:42]INFO-file:storage_param_getter.c,line:97,storage_ip_changed_auto_adjust=1,store_path=0,reserved_storage_space=1024MB,use_trunk_file=0,slot_min_size=0,slot_max_size=16MB,trunk_file_size=64MB[2011-10-2114:49:44]INFO-file:tracker_client_thread.c,line:304,successfullyconnecttotrackerserver173.252.200.228:22122,asatrackerclient,myipis173.252.200.228[2011-10-2114:50:14]INFO-file:tracker_client_thread.c,line:1100,trackerserver173.252.200.228:22122,settrackerleader:173.252.200.228:22122三:测试及使用FastDFS 1、FastDFS配置客户端:vi/etc/fdfs/client.confbase_path=/home/yuqing/fastdfs->base_path=/home/fastdfstracker_server=192.168.209.121:22122->tracker_server=173.252.200.228:22122http.tracker_server_port=8080->http.tracker_server_port=9090##includehttp.conf->#includehttp.conf 2.测试上传文件:cd~fdfs_test/etc/fdfs/client.confuploadFastDFS_v3.03.tar.gz 执行成功后会出现如下提示:ThisisFastDFSclienttestprogramv3.03Copyright(C)2008,HappyFish/YuQingFastDFSmaybecopiedonlyunderthetermsoftheGNUGeneralPublicLicenseV3,whichmaybefoundintheFastDFSsourcekit.请访问FastDFS主页http://www.csource.org/了解更多详情。[2011-10-2115:14:59]INFO-base_path=/home/fastdfs,connect_timeout=30,network_timeout=60,tracker_server_count=1,anti_steal_token=0,anti_steal_secret_keylength=0tracker_query_storage_store_list_without_group:server1.group_name=group1,ip_addr=173.252。200.228,port=23000group_name=group1,ip_addr=173.252.200.228,port=23000storage_upload_by_filenamegroup_name=group1,remote_filename=M00/00/00/rfzI5E6hG_O5wNKxAAVAc72y1Jc.tar.gzsourceipaddress:173.252.200.228filetimestamp=2011-10-2115:14:59filesize=344179filecrc32=3182613655fileurl:https://img.ydisp.cn/news/20220729/cjvri0ro5ze.gzstorage_upload_slave_by_filenamegroup_name=group1,remote_filename=M00/00/00/rfzI5E6hG_O5wNKxAAVAc72ytar.g_bigsource.1Jcg_bigipaddress:173.252.200.228Filetimestamp=2011-10-2115:14:59Filesize=344179filecrc32=318261365555555555555555555.22282.228.228:9090/group1/group1/group1/m00/m00/m00/m00/rffilerl.r.15e/rffileurl。在浏览器中输入上图中的url地址,tracker服务器会自动重定向到存储文件的存储服务器,文件下载成功。至此FastDFS搭建成功,自己写客户端访问吧!
