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

Linux system: build Nginx and FastDFS file management middleware under Centos7

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Source code of this article: GitHub click here | | GitEE click here |

1. Introduction to FastDFS 1. Basic concepts

FastDFS is an open source lightweight distributed file system, which manages files. Its functions include file storage, file synchronization, file upload, file download and so on, which solves the problems of mass storage and load balancing.

2. Environment overview 1. Gcc compilation environment exists by default, Centos7 virtual machine 2, installation LibFastCommon environment 3, FastDFS middleware installation 4, Nginx proxy server installation 2, installation LibFastCommon

Core process

Download-> extract-> compile-> install

# # download [root@localhost mysoft] # wget https://github.com/happyfish200/libfastcommon/archive/V1.0.38.tar.gz##, extract [root@localhost mysoft] # tar-zxvf V1.0.38.tar.gz [root@localhost mysoft] # cd libfastcommon-1.0.38/## compilation [root@localhost libfastcommon-1.0.38] #. / make.sh## install [root@localhost libfastcommon-1.0.38] # / make.sh install III, install FastDFS

Process: download-> extract-> compile-> install-> create related paths-> configure Tracker->

Configure data store-> configure client-> Nginx environment configuration

1. Basic installation steps # # download [root@localhost mysoft] # wget https://github.com/happyfish200/fastdfs/archive/V5.11.tar.gz##, extract [root@localhost mysoft] # tar-zxvf V5.11.tar.gz # # compile [root@localhost mysoft] # cd fastdfs-5.11/ [root@localhost fastdfs-5.11] #. / make.sh # # install [root@localhost fastdfs-5.11] #. / make.sh install2, create the relevant path

Useful for follow-up instructions.

[root@localhost data] # mkdir-p / data/fastdfs/log [root@localhost data] # mkdir-p / data/fastdfs/data [root@localhost data] # mkdir-p / data/fastdfs/tracker [root@localhost data] # mkdir-p / data/fastdfs/client3, configuration tracker

Tracker-- > > Tracker

1) View the configuration file

Pay attention to the conversion of the directory here, here is a sample, the specific configuration has to do it yourself.

[root@localhost fastdfs-5.11] # cd / etc/fdfs/ [root@localhost fdfs] # lltotal 24client.conf.samplestorage.conf.samplestorage_ids.conf.sampletracker.conf.sample

2) configure tracker.conf file

[root@localhost fdfs] # cp tracker.conf.sample tracker.conf [root@localhost fdfs] # vim tracker.conf## focus on the following configurations # # basic path to store data and log files base_path=/data/fastdfs/tracker## Http service port http.server_port=80## provides service port port=22122 by default

3) start the tracker

# # launch [root@localhost fdfs] # / usr/bin/fdfs_trackerd / etc/fdfs/tracker.conf start## to check the status [root@localhost fdfs] # netstat-apn | grep fdfs4, configuration data storage

1) View the configuration file

[root@localhost fastdfs-5.11] # cd / etc/fdfs/ [root@localhost fdfs] # llstorage.conf.sample

2) configure storage.conf file

[root@localhost fdfs] # cp storage.conf.sample storage.conf [root@localhost fdfs] # vim storage.conf## focus on the following configurations # # storage storage data and log follow the path base_path=/data/fastdfs/data## default group name group_name=group1## default port The storage port number of the same group must be the same port=23000## configuration a storage path store_path_count=1store_path0=/data/fastdfs/data## configuration tracker IP and port tracker_server=192.168.72.130:22122

3) start the storage service

# # launch [root@localhost fdfs] # / usr/bin/fdfs_storaged / etc/fdfs/storage.conf start## View process [root@localhost fdfs] # netstat-apn | grep fdfstcp 0etc/fdfs/storage.conf start## 22122 LISTEN 4845/fdfs_trackerd tcp 0pur45422 SYN_SENT 5410/fdfs_storaged## View launch Log [root@localhost fdfs] # tail-f / data/fastdfs/data/logs/storaged.log## Log display: a single FastDFS successfully installed set tracker Leader: 192.168.72.130 Tracker 22122 check whether Storage and Tracker are communicating [root@localhost fdfs] # / usr/bin/fdfs_monitor / etc/fdfs/storage.confStorage 1: id = 192.168.72.130 ip_addr = 192.168.72.130 (localhost.localdomain) ACTIVE5, Configure client test

1) View the configuration file

[root@localhost /] # cd / etc/fdfs [root@localhost fdfs] # lltotal 40client.conf.sample

2) configure client.conf file

[root@localhost fdfs] # cp client.conf.sample client.conf [root@localhost fdfs] # vim client.conf## focus on the following configurations # # client data and log directories base_path=/data/fastdfs/client## configuration tracker IP and port tracker_server=192.168.72.130:22122

3) client testing

Call the client file upload command

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

Returns the relative path and number of the file uploaded

Group1/M00/00/00/wKhIgl0mmE-ATEXPAAQ2pIoAy98392.jpg

[root@localhost fdfs] # / usr/bin/fdfs_upload_file / etc/fdfs/client.conf / data/img/img1.jpg group1/M00/00/00/wKhIgl0mmE-ATEXPAAQ2pIoAy98392.jpg

In this way, the FastDFS stand-alone environment is installed, and the steps are a little complicated, but this is life.

The file was successfully uploaded to the storage server, but the download could not be viewed. A Nginx server needs to be installed to support Http access to files.

4. Install Nginx1, download Nginx##, download nginx [root@localhost mysoft] # wget http://nginx.org/download/nginx-1.15.2.tar.gz##, extract nginx [root@localhost mysoft] # tar-zxvf nginx-1.15.2.tar.gz2, Download Fast-Nginx## download fastdfs-nginx [root@localhost mysoft] # wget https://github.com/happyfish200/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip## extract fastdfs-nginx [root@localhost mysoft] # mv 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip fast-nginx.zip [root@localhost mysoft] # unzip fast-nginx.zip [root@localhost mysoft] # mv fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1/ fastdfs-nginx-module3, Installation must depend on # # pcre-devel environment [root@localhost nginx-1.15.2] # yum install-y pcre pcre-devel## zlib-devel environment [root@localhost nginx-1.15.2] # yum install-y zlib zlib-devel## openssl-devel environment [root@localhost nginx-1.15.2] # yum install-y openssl openssl-devel4, Configure and install [root@localhost nginx-1.15.2] # / configure-- add-module=/usr/local/mysoft/fastdfs-nginx-module/src [root@localhost nginx-1.15.2] # make & & make install5, error resolution

Due to the version problem, Fast-Nginx must use this fixed version.

Https://github.com/happyfish200/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip

Make [1]: * * [objs/addon/src/ngx_http_fastdfs_module.o] Error 1make [1]: Leaving directory `/ usr/local/mysoft/nginx-1.15.2'make: * [build] Error 26, view the installation result

The following situation indicates that the installation is successful.

[root@localhost nginx-1.15.2] # / usr/local/nginx/sbin/nginx-Vnginx version: nginx/1.15.2built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) configure arguments:-- add-module=/usr/local/mysoft/fastdfs-nginx-module/src 5, test picture access 1, Configure client # # Mobile profile [root@localhost src] # pwd/usr/local/mysoft/fastdfs-nginx-module/src [root@localhost src] # lltotal 76Apr 14 2017 mod_ fastdfs.confs [root @ localhost src] # cp mod_fastdfs.conf / etc/fdfs/ [root@localhost fdfs] # pwd/etc/fdfs [root@localhost fdfs] # vim mod_fastdfs.conf # # adjust the following configuration # # Link timeout connect_timeout=20## configuration The tracker IP and port tracker_server=192.168.72.130:22122## paths contain groupurl_have_group_name = true# must be configured with the same store_path0=/data/fastdfs/data2 as storage, Perfect FastDFS configuration [root@localhost fdfs] # cd / usr/local/mysoft/fastdfs-5.11/conf/ [root@localhost conf] # cp anti-steal.jpg http.conf mime.types / etc/fdfs/3, configure Nginx

Add the following configuration under the 80 service port of Nginx. Note that the path here is the path automatically generated by the Nginx installation.

[root@localhost nginx] # cd / usr/local/nginx/conf/ [root@localhost conf] # vim nginx.confserver {listen 80; location ~ / group ([0-9]) / M00 {root / data/fastdfs/data; ngx_fastdfs_module;}}

View configuration results

[root@localhost conf] # / usr/local/nginx/sbin/nginx-Vnginx version: nginx/1.15.2built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) configure arguments:-- add-module=/usr/local/mysoft/fastdfs-nginx-module/src

This makes the configuration successful.

4. At the end of the witness

Start the Nginx service.

# # start / usr/local/nginx/sbin/nginx## stop / usr/local/nginx/sbin/nginx-s stop## restart / usr/local/nginx/sbin/nginx-s reload5, visit and upload pictures

It's amazing that it worked.

Http://192.168.72.130/group1/M00/00/00/wKhIgl0mmE-ATEXPAAQ2pIoAy98392.jpg VI. Source code address GitHub address https://github.com/cicadasmile/linux-system-baseGitEE address https://gitee.com/cicadasmile/linux-system-base

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