Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Construction of FastDFS distributed File system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Content points FastDFS brief introduction FastDFS build FastDFS common commands 1. Introduction:

1. FastDFS is an open source lightweight distributed file system, which manages files. Its functions include file storage, file synchronization, file access (file upload, file download), etc., which solves the problems of mass storage and load balancing. It is especially suitable for online services with files as carriers, such as photo album websites, video websites and so on.

2. FastDFS is tailored to the Internet, taking full account of redundant backup, load balancing, linear expansion and other mechanisms, and pays attention to high availability, high performance and other indicators. Using FastDFS, it is easy to build a high-performance file server cluster to provide file upload, download and other services.

3. The FastDFS server has two roles:

(1) tracker: the tracker is mainly used for scheduling

(2) Storage node (storage): plays the role of load balancing on access.

The storage node stores files and completes all the functions of file management: it stores, synchronizes and provides access interfaces, and FastDFS manages the metadata of files at the same time. The so-called meta data of a file is the relevant attributes of the file, expressed in the form of key-value pairs (key value).

4. In order to support large capacity, storage nodes (servers) are organized into volumes (or groups). The storage system consists of one or more volumes, the files between the volumes are independent of each other, and the file capacity of all volumes is the file capacity of the whole storage system. A volume can be composed of one or more storage servers, the files in the storage servers under one volume are all the same, and multiple storage servers in the volume play the role of redundant backup and load balancing.

(1) when the server is added to the volume, the synchronization of the existing files is automatically completed by the system. After the synchronization is completed, the system automatically switches the new server to provide services online.

(2) volumes can be added dynamically when storage space is insufficient or running out. Only one or more servers need to be added and configured as a new volume, thus expanding the capacity of the storage system

(3) the file identification in FastDFS is divided into two parts: volume name and file name, both of which are indispensable.

Second, set up FastDFS: prepare two virtual machines, one for DFS and one for storage.

Hostname IP address main software tracker192.168.50.139libfastcommon, fastdstorage192.168.50.140libfastcommon step 1: install libfastcommon (required for all nodes)

1. Install the environment package:

Yum-y install libevent libevent-devel perl make gcc zlib zlib-devel pcre pcre-devel gcc-c++ openssl-devel

2. Install libfastcommon:

Wget https://github.com/happyfish200/libfastcommon/archive/V1.0.38.tar.gztar zxf V1.0.38.tar.gz-C / opt/cd / opt/libfastcommon-1.0.38/./make.sh & &. / make.sh install

3. Create a soft connection:

Ln-s / usr/lib64/libfastcommon.so / usr/local/lib/libfastcommon.soln-s / usr/lib64/libfdfsclient.so / usr/local/lib/libfdfsclient.soln-s / usr/lib64/libfdfsclient.so / usr/lib/libfdfsclient.so step 2: install FastDFS:wget https://github.com/happyfish200/fastdfs/archive/V5.11.tar.gztar zxf V5.11.tar.gz-C / opt/cd / opt/fastdfs-5.11/./make.sh & & . / make.sh install [root@localhost fdfs] # lsclient.conf.sample / / client upload configuration file (template) storage.conf.sample / / File storage server configuration file (template) tracker.conf.sample / / responsible for balanced scheduling server configuration file (template) copy configuration file: cp tracker.conf.sample tracker.confcp storage.conf.sample storage.confcp client.conf.sample client.conf step 3: modify on tracker side

1. Tracker monitor (there can be more than one) to create a directory for storing data and logs:

Mkdir-m 755-p / opt/fastdfs

2. Modify the tracker configuration file:

Vim / etc/fdfs/tracker.conf adds and modifies the following: port=22122 base_path=/opt/fastdfs / / tracker stores the path of data and log, and the http service process on the http.server_port=8080 / / tracker server must be created in advance (ignore is not installed)

3. Enable the service:

Fdfs_trackerd / etc/fdfs/tracker.conf start / / start the service netstat-atnp | grep 22122 / / check whether the port is open normally. Tcp 0 0 0.0 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 00 of the grep * LISTEN 43776/fdfs_trackerd

4. Set to enable self-startup:

Vim / etc/rc.local# last line add: fdfs_trackerd / etc/fdfs/tracker.conf start step 4: storage side modification # storage data storage side (can have multiple) # establish data, log storage directory mkdir-m 777-p / opt/fastdfs# modify storage configuration file vim / etc/fdfs/storage.confgroup_name=group1 # default group name, modify port=23000 # storge default 23000 according to the actual situation The storage port number of the same group must be the same base_path=/opt/fastdfs # storage log file root path store_path_count=1 # is the same as the following path, default is the storage path provided by 1store_path0=/opt/fastdfs # (default is stored with the log file) tracker_server=192.168.50.140:22122 # own tracker server IP (emphasis!! ) http.server_port=80 (the default port for http to access files is 8888 The listening port configured in nginx remains the same) # enable the service fdfs_storaged / etc/fdfs/storage.conf startnetstat-atnp | grep 23000tcp 00 0.0.0.0etc/fdfs/storage.conf startnetstat 23000 0.0.0.0etc/fdfs/storage.conf startnetstat * LISTEN 40430/fdfs_storaged# boot self-starting trackervim / etc/rc.local# add fdfs_storaged / etc/fdfs/storage.conf start # check whether it matches tracker Successful fdfs_monitor / etc/fdfs/storage.confStorage 1: id = 192.168.50.140 ip_addr = 192.168.50.140 (storage) ACTIVE step 5: install nginx# decompress nginx installation package tar zxf nginx-1.12.0.tar.gz-C / opt/# download fastdfs-nginx-module installation package wget https://github.com/happyfish200/fastdfs-nginx-module/archive on the storage side / V1.20.tar.gztar zxf V1.20.tar.gz-C / opt/# compile and install nginx./configure\-- prefix=/usr/local/nginx\-- add-module=/opt/fastdfs-nginx-module-1.20/src/ # fastdfs-nginx-module module make & & make instal

L

Step 6: configure Nginx and fastdfs-nginx-module module cd fastdfs-nginx-module-1.20/srccp mod_fastdfs.conf / etc/fdfs/# modify fastdfs-nginx-module module configuration file mod-fasts.confvim mod_fastdfs.confbase_path=/opt/fastdfs # the path where data files and logs are stored tracker_server=192.168.50.140:22122 # tracker side address (key! ) url_have_group_name = true # whether the url contains the group name storage_server_port=23000 # the same number of store_path_count=1 # storage paths as the storage configuration, and need to match the number of store_path to match the location of the store_path0=/opt/fastdfs # file storage # modify the nginx configuration file vim / usr/local/nginx/conf/nginx.conf# blank line to add location ~ / M00 {root / opt/fastdfs/data Ngx_fastdfs_module;} # copy the http.conf and mime.typescd / opt/fastdfs-5.11/conf/cp mime.types http.conf / etc/fdfs/ in the fastdfs decompression directory. 3. FastDFS common commands:

1. Upload files:

/ usr/bin/fdfs_upload_file

2. Download the file:

/ usr/bin/fdfs_download_file [local_filename]

3. Delete the file:

/ usr/bin/fdfs_delete_file

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report