Distributed File System FastDFS describes the installation configuration

Distributed File System FastDFS describes how to install a configuration. Introduction FastDFS is a lightweight open source distributed file system, features include: file storage, file synchronization, file access (file upload, file download), etc., to solve the high-capacity storage and load balancing issues. Particularly suitable for the carrier to file online services, such as photo album sites, video sites, and more. FastDFS has two roles: tracker (tracker) and the storage node (storage). Tracker main job scheduling work, since load balancing role in access. File storage node, all complete file management functions: storage, synchronization, and provide access to interfaces, while managing file metadata. related meta data is called file attribute of the file to the key-value pair (key valuepair) represented manner, such as: width = 1024, which is the key width, value 1024. Property list file metadata file can contain multiple pairs. FastDFS the organization chart below: Tracking and storage nodes may be constituted by one or more servers. Tracker server and storage node can be increased at any time without affecting the online or offline service. Wherein the tracker servers are all equal, the pressure may be increased or decreased according to the server at any time. In order to support a large capacity, the storage node (server) using the sub-volume (or packet) is organized. Storage system consists of one or more volumes that, between the volume with the volume file are independent, the file capacity of all volumes is the file accumulation capacity of the overall storage system. A volume may be formed from one or more storage servers, the storage server under a file volume is the same, the volume of the multiple storage servers played redundancy and load balancing effect. Increase in the volume server, the existing file synchronization is completed automatically by the system, after synchronization is complete, the system automatically switches to the new server online service. When memory is low or about to run out, you can dynamically add volume. Only need to add one or more servers, and configure them for a new roll, so that the expansion of the capacity of the storage system. FastDFS document identification divided into two parts: a volume and file names, both are indispensable. Upload file interaction: 1. client query uploaded to the tracker storage, no additional parameters; 2. tracker returns an available storage; 3. client communications and storage file upload done directly. Download file interaction: 1. client asks tracker download file storage, file identification parameters (volume name and file name); 2. tracker returns a usable storage; 3. client direct communication and storage complete the file download. Synchronization mechanism between the storage server within the same group is a peer, file upload, delete and other operations can be performed on any storage server; file synchronization between only within the same group of storage server, using push mode, that is, when the above-mentioned second rule there is an exception, is adding a new storage server, from the existing one; synchronization source server to the target server; only need to source data synchronization, backup data does not sync again, otherwise it will constitute a loop Taiwan storage server will have all the data (including source data and backup data) synchronized to the new server. two. Installation wget # http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.14-stable.tar.gz # zxvf the libevent the tar-2.0.14-stable.tar.gz -C ../software / # ./configure --prefix = / usr / local / the libevent the make-2.0.14 # # # wget the install the make http://fastdfs.googlecode.com/files/FastDFS_v3.02.tar.gz # Tar zxvf FastDFS_v3.02.tar.gz -C ../software/ # ./make.sh C_INCLUDE_PATH = / usr / local / libevent-2.0.14 / include LIBRARY_PATH = / usr / local / libevent-2.0.14 / lib # ./make.sh install [Note:] If you want to support web and boot automatically fastdfs script (default is not supported), you need to modify make.sh file # WITH_HTTPD = 1 # WITH_LINUX_SERVICE = 1 three profiles DESCRIPTION. tracker.conf] # is this config file disabled # false for enabled # true for disabled disabled = false // whether the configuration file to take effect, false entry into force, true not take effect # bind an address of this host # empty for bind all addresses of this host bind_addr = // bind ip # the tracker server port port = 22122 // specify the port # connect timeout in seconds # default value is 30s connect_timeout = 30 // connection timeout, timeout in seconds # default # network socket for socket value is 30s network_timeout = 60 // tracker server network timeout # the base path to store data and log files base_path = / data / fastdfs // address directory, a directory structure is as follows: $ {base_path} | __data | | __Storage_groups. dat: storing group information | | __storage_servers.dat: storage server list | __logs | __trackerd.log: tracker server log files and data files between the recording storage_servers.dat storage_groups.dat in a newline (\ n) separated by the field inter west of text comma (,) separated. storage_groups.dat fields in order to: 1. group_name: Group Name 2. storage_port: storage server port number storage_servers.dat recording information storage server, the fields were: 1. group_name: belonging group name 2. ip_addr: ip address 3. status: status 4. sync_src_ip_addr: storage server to the synchronization server 5. sync_until_timestamp existing source data files: As already time synchronized data file (UNIX timestamp) 6. stat.total_upload_count: 7. stat file upload times .success_upload_count: number of successfully uploaded files 8. stat.total_set_meta_count: change the number of meta data 9. stat.success_set_meta_count: the number of changed successfully meta data 10. stat.total_delete_count: number of deleted files 11. stat.success_delete_count: number of successfully deleted file 12. stat .total_download_count: file downloads 13. stat.success_download_count: the number of successful downloads files 14. stat.total_get_meta_count: Get the number of meta data 15. stat.success_get_meta_count: number of successfully acquired meta data 16. stat. the first server order by priority (the minimal) store_server = 0 // choose which storage server upload operation. After uploading a file, the storage server is equivalent to the storage server source of the file, the group will be synchronized with the storage server. 0 poll, select the first 1, 2 which path (means disk or mount point) of the storage server to upload file # 0 # sorted according to priority in accordance with ip address ordering: round robin # 2: load balance, select the max free space path to upload file store_path = 0 // select the storage server which directory to upload, storage server can have multiple base path storing files. 0 poll, load balancing 2, select the remaining space for the largest catalog # which storage server to download file # 0: round robin (default) # 1: the source storage server which the current file uploaded to download_server = 0 // choose which storage server as the download server. 0 1 Select polling original source storage server # 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. 20] # allow_hosts = host [01-08,20-25] .domain.com allow_hosts = * // ip allowed range # sync log buff this tracker server is connected to disk every interval seconds # default value is 10 seconds sync_log_buff_interval = 10 // synchronization log to disk time interval, tracker server logs to be written to memory. # Check storage server alive interval seconds check_active_interval = 120 // detected storage server keepalive interval # thread stack size, should> = 64KB # default value is 64KB thread_stack_size = 64KB // thread stack size # auto adjust when the ip address of the storage server changed # default value is true storage_ip_changed_auto_adjust = true // when the storage server IP address changes, whether to automatically adjust the cluster. Required to complete the storage server to restart automatically adjust # storage sync file max delay seconds # default value is 86400 seconds (one day) # since V2. # False for binding any address of this host client_bind = true // When specifying bind_addr This parameter is valid # the storage server port port = 23000 // specified port # connect timeout in seconds # default value is 30s connect_timeout = 30 // connection time, timeout in seconds # default value is 30s network_timeout = 60 // storage server network timeout for socket # network # heart beat interval in seconds heart_beat_interval = 30 // heartbeat interval # disk usage report interval in seconds stat_report_interval = 60 # // storage server interval time tracker server to report the size of the remainder of the disk the base path to store data and log files base_path data / fastdfs // list address, directory structure = /:. $ {base_path} | __data | | __ data_init_flag : the current storage server initialization information | | __storage_stat.dat: current storage server statistics | | __sync: storing data synchronization related files | | | __binlog.index: current binlog file index number | | | __binlog ###:. store update operation record (log) | | | __ $ {ip_addr} _ $ {port}. mark: complete synchronous storage case | | | | __ level directory: Directory 256 store data files, such as: 00, try read binlog again after X milliseconds # 0 for try when again immediately (not need to wait) sync_wait_msec = 50 // synchronize files, if the file is not read to be synchronized from the binlog, reread after X milliseconds, 0 indicates no wait immediately tries to read again # after sync a file, usleep milliseconds # 0 for sync successively (never call usleep) sync_interval = 0 // End synchronization after a file, a file of the next resynchronization interval 0 indicates continuous synchronization # storage 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 // storage server synchronization start time # storage 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 // storage server synchronization end time # write to the mark file after sync N files # default value is 500 write_mark_file_freq = 500 // synchronous N after a file is written to mark the file # path (disk or mount point) count, default value is 1 store_path_count = 1 // storage server supports multiple Road King Specifies the number of files stored base path # store_path #, based 0, if store_path0 not exists, it's value is base_path # the paths must be exist store_path0 = / data / fastdfs # store_path1 = / data / fastdfs2 // store the data file directory # 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 // the number of directory files will be stored. When Fastdfs store files, using two directories # 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.209.121: 22122 // specified tracker server address #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 // log level #unix group name to run this program, then rotate to next path # default value is 100 file_distribute_rotate_count = 100 // When file_distribute_to_path = 0, this parameter valid. When the number of files in a directory reaches this value, the subsequent uploading files to a directory is stored in # 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 // when a large file is written, each N bytes is written, the system calls a function fsync content genlock to disk. 0 means do not call fsync # sync log buff to disk every interval seconds # default value is 10 seconds sync_log_buff_interval = 10 // synchronization logs to disk intervals # 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 = 10 // binlog sync interval to disk # sync storage stat info to disk every interval seconds # default value is 300 seconds sync_stat_file_interval = 300 // synchronize the status information storage to disk the time interval # thread stack size, should> = 512KB # default value is 512KB thread_stack_size = 512KB // thread stack size # the priority as a source server for uploading file. # the lower this value, the higher its uploading priority. # Default value is 10 upload_priority = 10 // upload priority, the smaller the value the higher the priority # the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a # multi aliases split by comma. Empty value means auto set by OS type # default values ​​is empty if_alias_prefix = # 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 // detect whether the uploaded file already exists. If set to true need fastdht. If it does exist, then create a symbolic link to save disk space # namespace for storing file indexes (key-value pairs) # this item must be set when check_file_duplicate is true / on key_namespace = FastDFS // When check_file_duplicate = 1, in fastdht namespaces # set keep_alive to 1 to enable persistent connection FastDHT servers # default value is 0 (short connection) keep_alive = 0 // the connection with the fastdht server. 0 Short-Fi, a long connection # you can use " http://nginx.org/download/nginx-1.0.8.tar.gz # tar zxvf nginx-1.0.8.tar.gz -C ../software/ # wget http://fastdfs-nginx-module.googlecode.com/files/fastdfs-nginx-module_v1.08.tar.gz # tar zxvf fastdfs-nginx-module_v1.08.tar.gz -C ../software/ # apt-get install libpcre3 libpcre3-dev openssl libssl-dev # ./configure --prefix=/usr/local/nginx-1.0.8 --user=nginx --group=nginx --add-module=/usr/local/src/software/fastdfs-nginx-module/src/ # make # make install # cp mod_fastdfs.conf /etc/fdfs/ # vi nginx.conf添加如下内容 location /M00 { root /data/fastdfs/data; ngx_fastdfs_module; } # ln -s /data/fastdfs/data /data/fastdfs/data/M00 # vim mod_fastdfs.conf connect_timeout=2 network_timeout=30 base_path=/data/fastdfs tracker_server=192.168.1.114:22122 storage_server_port=23000 group_name=group1 url_have_group_name = false store_path_count=1 store_path0=/data/fastdfs log_level=debug log_filename= response_mode=redirect if_alias_prefix= http.need_find_content_type=false # /usr/local/nginx-1.0.8/sbin/nginx -c /usr/local/nginx-1.0.8/conf/nginx.conf ngx_http_fastdfs_set pid=28525 [2011-10-22 16:39:53] INFO - fastdfs apache / nginx module v1.08, response_mode=redirect, base_path=/data/fastdfs, path_count=1, connect_timeout=2, network_timeout=30, tracker_server_count=1, storage_server_port=23000, group_name=group1, if_alias_prefix=, local_host_ip_count=2, need_find_content_type=0, default_content_type=, anti_steal_token=0, token_ttl=0s, anti_steal_secret_key length=0, token_check_fail content_type=, token_check_fail buff length=0, storage_sync_file_max_delay=86400s 七.上传文件 # vim client.conf connect_timeout=30 network_timeout=60 base_path=/data/fastdfs tracker_server=192.168.1.114:22122 log_level=info # /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload .bashrc [2011-10-22 17:24:49] INFO - base_path=/data/fastdfs, 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.1.101, port=23000 group_name=group1, ip_addr=192.168.1.101, port=23000 storage_upload_by_filename group_name=group1, remote_filename=M00/00/00/wKgBZU6ii-GamB5eAAALcAZ5KwI.bashrc source ip address: 192.168.1.101 file timestamp=2011-10-22 17:24:49 file size=2928 file crc32=108604162 file url: http://192.168.1.114/group1/M00/00/00/wKgBZU6ii-GamB5eAAALcAZ5KwI.bashrc storage_upload_slave_by_filename group_name=group1, remote_filename=M00/00/00/wKgBZU6ii-GamB5eAAALcAZ5KwI_big.bashrc source ip address: 192.168.1.101 file timestamp=2011-10-22 17:24:49 file size=2928 file crc32=108604162 file url: http://192.168.1.114/group1/M00/00/00/wKgBZU6ii-GamB5eAAALcAZ5KwI_big.bashrc 八.用浏览器访问 http://192.168.1.101/M00/00/00/wKgBZU6ii-GamB5eAAALcAZ5KwI_big.bashrc

Reproduced in: https: //my.oschina.net/766/blog/211239

Guess you like

Origin blog.csdn.net/weixin_33842328/article/details/91548547