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

FasterDFS distributed file system (instance!!)

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

FasterDFS Overview ​ FastDFS is an open source lightweight distributed file system that manages files with functions such as file storage, file synchronization, file access (file upload, file download), etc., solving 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. ​ 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. It is easy to build a high-performance file server cluster with FastDFS to provide file upload, download and other services. The ​ FastDFS server has two roles: tracker (tracker) and storage node (storage). The tracker mainly does the scheduling work and plays the role of load balancing on the access. Both the ​ tracker and the storage node can consist of one or more servers. Servers in trackers and storage nodes can be added or offline at any time without affecting online services. All the servers in the tracker are peer-to-peer and can be increased or decreased at any time according to the pressure on the server. When the server is added to the volume, the synchronization of the existing files is automatically completed by the system, and after the synchronization is completed, the system automatically switches the new server to provide services online.

Lab environment server role IP address tracker192.168.45.135storage+nginx192.168.45.132 step 1: install the libfastcommon service (all nodes are installed)

1. Install the base environment package

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

two。 Install libfastcommon

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

3. Compilation and installation

. / make.sh & &. / make.sh install

4. Establish soft links to facilitate system identification

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 the FastDFS service (all nodes are installed)

1. Download and install fastDFS

Wget https://github.com/happyfish200/fastdfs/archive/V5.11.tar.gz tar zxf V5.11.tar.gz-C / opt/cd / opt/fastdfs-5.11/

two。 Compilation and installation

. / make.sh & &. / make.sh install

3. Copy the template file for modification

# switch configuration file template path cd / etc/fdfs/ cp tracker.conf.sample tracker.confcp storage.conf.sample storage.confcp client.conf.sample client.conf step 3: configure tracker monitor

1. Establish a directory for storing data files and log files

Mkdir-m 755-p / opt/fastdfs

two。 Modify tracker configuration file

Vim / etc/fdfs/tracker.conf# modify the following configuration: port=22122 # tracker service default port 22122 allows base_path=/opt/fastdfs # tracker to store data and log. The http service process must be created in advance to start the http service on the http.server_port=8080 # tracker server.

3. Turn on the service and set to boot.

# enable service (command supports start | stop | restart) fdfs_trackerd / etc/fdfs/tracker.conf startnetstat-atnp | grep 2212 sets boot vim / etc/rc.local# last line to add fdfs_trackerd / etc/fdfs/tracker.conf start # turn off firewall and security features systemctl stop firewalldsetenforce 0 step 4: configure storage server

1. Establish a directory for storing data files and log files

Mkdir-m 755-p / opt/fastdfs

two。 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. The root path of base_path=/opt/fastdfs # storage log file is the same as the number of the following paths. The storage path provided by default for 1store_path0=/opt/fastdfs # (stored with log files by default) the port for accessing files on tracker_server=192.168.45.135:22122 # tracker server IPhttp.server_port=80 # http is consistent with the listening port configured in 8888 Maginx

3. Turn on the service and set to boot.

# enable service (command supports start | stop | restart) fdfs_storaged / etc/fdfs/storage.conf startnetstat-atnp | grep 2300 sets self-boot vim / etc/rc.local# last line to add fdfs_storaged / etc/fdfs/storage.conf start # turn off firewall and security features systemctl stop firewalldsetenforce 0

4. Check whether the association with the tracker monitoring side is successful

Fdfs_monitor / etc/fdfs/storage.confStorage 1: id = 192.168.45.135 ip_addr = 192.168.45.135 (storage) ACTIVE http domain = step 5: install the nginx service on the storage side

1. Install nginx and its components

Tar zxf nginx-1.12.0.tar.gz-C / opt/

two。 Download the fastdfs-nginx-module installation package

Wget https://github.com/happyfish200/fastdfs-nginx-module/archive/V1.20.tar.gztar zxf V1.20.tar.gz-C / opt/

3. Compilation and installation

Cd / opt/nginx-1.12.0./configure-- prefix=/usr/local/nginx-- add-module=/opt/fastdfs-nginx-module-1.20/src/ make & & make install

A solution to the error report

Error message: / usr/include/fastdfs/fdfs_define.h:15:27: fatal error: common_define.h: No such file or directory processing method: modify the fastdfs-nginx-module-1.20/src/config file, and then restart step 7 to start ngx_module_incs= "/ usr/include/fastdfs/ usr/include/fastcommon/" CORE_INCS= "$CORE_INCS / usr/include/fastdfs/ usr/include/fastcommon/"

4. Configure the fastdfs-nginx-module module

Cd fastdfs-nginx-module-1.20/srccp mod_fastdfs.conf / etc/fdfs/ # move its configuration file to the fdfs directory # modify the configuration file mod-fasts.confvim / etc/fdfs/mod_fastdfs.conf# check the following configuration base_path=/opt/fastdfs # store data files, The path to the log tracker_server=192.168.45.132:22122 # tracker address 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 configured by storage Need to match the number of store_path to the location of store_path0=/opt/fastdfs # file storage

5. Modify nginx configuration file

Append the following content location ~ / M00 {root / opt/fastdfs/data; ngx_fastdfs_module;} to the blank line of vim / usr/local/nginx/conf/nginx.conf#

6. Copy fastdfs and extract http.conf and mime.types in the directory

Cd / opt/fastdfs-5.11/conf/cp mime.types http.conf / etc/fdfs/

7. Enable the Nginx service

# create a soft connection to let the system recognize the nginx startup script ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/ # enable service nginx step 6: configure the client client

Modify the configuration file

Vim / etc/fdfs/client.confbase_path=/opt/fastdfs # tracker server file path tracker_server=192.168.45.132:22122 # tracker server IP address and port number http.tracker_server_port=8080 # tracker server's http port number must correspond to the tracker setting. 3. Verify the distributed effect command

Upload test file command

/ usr/bin/fdfs_upload_file

Example demonstration

/ usr/bin/fdfs_upload_file / etc/fdfs/client.conf test.jpg

View uploaded pictures

Download file command

/ usr/bin/fdfs_download_file [local_filename]

Delete file command

/ 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