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

FastDFS stand-alone construction

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Brief introduction

FastDFS is an open source high-performance distributed file system (DFS).

The FastDFS system has three roles: tracking server (Tracker Server), storage server (Storage Server), and client (Client).

Tracker Server: tracking server, mainly doing scheduling work, plays a balanced role; responsible for managing all storage server and group, each storage will connect to Tracker after startup, inform itself of group and other information, and maintain a periodic heartbeat.

Storage Server: storage server, which mainly provides capacity and backup services. In group units, there can be multiple storage server in each group, and the data can be backed up each other.

Client: the client, the server for uploading and downloading data, that is, the server on which our own project is deployed.

Installation

Environmental preparation

Gcc gcc-c++ perl is required to compile the source code, and unzip yum-y install gcc gcc-c++ perl unzip is needed to decompress the package.

Download the required software packages in advance (download them in the / usr/local/src directory)

Download libfastcommon environment package: wget https://github.com/happyfish200/libfastcommon/archive/V1.0.7.tar.gz download FastDFS package: wget https://github.com/happyfish200/fastdfs/archive/V5.05.tar.gz download nginx source code package: wget-c https://nginx.org/download/nginx-1.12.1.tar.gz download fastdfs-nginx-module plug-in package: wget https://github.com / happyfish200/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip

1. Install libfastcommon

Decompress and enter

Tar-zxvf V1.0.7.tar.gzcd libfastcommon-1.0.7

Compile, install

. / make.sh. / make.sh install

Libfastcommon.so is installed to / usr/lib64/libfastcommon.so by default. But the lib directory of our subsequent installation of the FastDFS main program is / usr/local/lib, so we need to create a soft link.

Ln-s / usr/lib64/libfastcommon.so / usr/local/lib/libfastcommon.soln-s / usr/lib64/libfastcommon.so / usr/lib/libfastcommon.soln-s / usr/lib64/libfdfsclient.so / usr/local/lib/libfdfsclient.soln-s / usr/lib64/libfdfsclient.so / usr/lib/libfdfsclient.so

two。 Download and install FastDFS

Decompress and enter

Tar-zxvf V5.05.tar.gz cd fastdfs-5.05

Compile, install

. / make.sh. / make.sh install

The corresponding files and directories after installation are as follows:

Service script for fastdfs

/ etc/init.d/fdfs_storaged/etc/init.d/fdfs_tracker

Fastdfs profile

/ etc/fdfs/client.conf.sample/etc/fdfs/storage.conf.sample/etc/fdfs/tracker.conf.sample

The command tool is located in / usr/bin/.

The bin directory set by the FastDFS service script is / usr/local/bin, but the actual commands are installed under / usr/bin/. We need to establish a soft link from / usr/bin to / usr/local/bin

Ln-s / usr/bin/fdfs_trackerd / usr/local/binln-s / usr/bin/fdfs_storaged / usr/local/binln-s / usr/bin/stop.sh / usr/local/binln-s / usr/bin/restart.sh / usr/local/bin

3. Configure the FastDFS Tracker (Tracker)

Enter / etc/fdfs, copy the FastDFS tracker sample configuration file tracker.conf.sample, and rename it to tracker.conf

Cd / etc/fdfs cp tracker.conf.sample tracker.conf vim tracker.conf

Edit tracker.conf, the following needs to be modified, other default can be.

# Tracker data and log directory address (root directory must exist, subdirectory will be created automatically) base_path=/home/fastdfs/tracker# HTTP service port http.server_port=80

Create a tracker basic data directory, that is, the directory corresponding to base_path

Mkdir-p / home/fastdfs/tracker

Start Tracker

# service fdfs_trackerd start or # systemctl start fdfs_trackerdnetstat-unltp | grep fdfs

Close

Service fdfs_trackerd stop

4. Configure FastDFS storage (Storage)

Enter the / etc/fdfs directory

# cd / etc/fdfs# cp storage.conf.sample storage.conf# vim storage.conf

Edit storage.conf

# Storage data and log directory address (the root directory must exist and the subdirectory will be generated automatically) if store_path0 is not configured, it will be the same as the path corresponding to base_path and will be commented out directly here. # when store_path0=/home/fastdfs/file# has multiple tracker server, write a line of tracker_server=192.168.244.8:22122# access port http.server_port=80 for each tracker server

Create a Storage basic data directory, corresponding to a base_path directory

# mkdir-p / home/fastdfs/storage

Start Storage

# service fdfs_storaged # View status # netstat-unltp | grep fdfs# is off # service fdfs_storaged stop

Check to see if Storage and Tracker are communicating

/ usr/bin/fdfs_monitor / etc/fdfs/storage.conf

5. File upload test

Modify the client profile in the Tracker server

# cd / etc/fdfs# cp client.conf.sample client.conf# vim client.conf

Just modify the following configuration, other defaults.

# Client data and log directory base_path=/home/fastdfs/client# Tracker port tracker_server=192.168.244.8:22122#tracker server port http.tracker_server_port=8081

Upload test

# / usr/bin/fdfs_upload_file / etc/fdfs/client.conf xxx.jpg

Install nginx

1. The environment required to install nginx

PCRE pcre-devel installation

# yum install-y pcre pcre-devel

Zlib installation

# yum install-y zlib zlib-devel

OpenSSL installation

# yum install-y openssl openssl-devel

two。 Install nginx

# tar-zxvf nginx-1.12.1.tar.gz# cd nginx-1.12.1#. / configure# make# make install# launch # cd / usr/local/nginx/sbin/#. / nginx#. / nginx- s stop#. / nginx- s quit#. / nginx- s reload/usr/local/nginx/sbin/nginx-V

Modify nginx.conf

# vim / usr/local/nginx/conf/nginx.conf# is added as shown below, mapping / group1/M00 to / home/fastdfs/storage/datalocation / group1/M00 {alias / home/fastdfs/storage/data;}

Restart

# / usr/local/nginx/sbin/nginx-s reload

Uploaded files before browser access, successful.

Http://192.168.244.8/group1/M00/00/00/wKj0CF0cTBKAYwBiAABdrZgsqUU227.jpg

Fastdfs module of 3.Nginx

Decompress fastdfs-nginx-module

# decompress # unzip 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip# rename # mv fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1 fastdfs-nginx-module

Configure Nginx

# stop the nginx service # / usr/local/nginx/sbin/nginx-s stop enter the nginx decompression package directory # cd / usr/local/src/nginx-1.12.1/# add module #. / configure-- add-module=../fastdfs-nginx-module/src recompile, install # make & & make install# to view the version module of Nginx # / usr/local/nginx/sbin/nginx-V

Copy the configuration file in the fastdfs-nginx-module source code to the / etc/fdfs directory and modify

# cd / usr/local/src/fastdfs-nginx-module/src# cp mod_fastdfs.conf / etc/fdfs/

Modify the following configuration, other defaults

# connection timeout connect_timeout=10# Tracker Servertracker_server=192.168.244.8:22122# if the uri of the file ID contains / group**, it must be set to the store_path0 path configured by trueurl_have_group_name = true# Storage, which must be consistent with that in storage.conf, and # store_path0= / home/yuqing/fastdfs must be commented out uniformly

Copy some of the configuration files from FastDFS to the / etc/fdfs directory

# cd / usr/local/src/fastdfs-5.05/conf/# cp anti-steal.jpg http.conf mime.types / etc/fdfs/

Configure nginx, modify nginx.conf

Add fastdfs-nginx module under port 80

Location ~ / group0/M00 {ngx_fastdfs_module;}

Note:

The listen 80 port value corresponds to the http.server_port=80 in / etc/fdfs/storage.conf (previously changed to 80).

Start nginx

# / usr/local/nginx/sbin/nginx

Re-upload a picture, which can be opened with a browser, that is, the installation is successful.

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

Internet Technology

Wechat

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

12
Report