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 basic configuration installation-practice

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

Share

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

I. brief 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. FastDFS consists of a tracking server (Tracker Server), a storage server (Storage Server) and a client (Client). The tracker mainly does the scheduling work and plays the role of load balancing on the access.

4. Both trackers and storage nodes can be made up 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.

5. 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.

II. Basic deployment steps

I. Experimental preparation

Centos7-1: tracker 192.168.142.66

Centos7-2: storage+nginx 192.168.142.77

2. Start installation

(1) install libfastcommon service (all nodes are installed)

Install the base environment package

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

Install libfastcommon

[root@storage ~] # wget https://github.com/happyfish200/libfastcommon/archive/V1.0.38.tar.gz[root@storage ~] # tar zxf V1.0.38.tar.gz-C / opt/ [root@storage ~] # cd / opt/libfastcommon-1.0.38/

Compile and establish soft links to facilitate system identification

[root@storage libfastcommon-1.0.38] #. / make.sh &. / make.sh install [root@storage libfastcommon-1.0.38] # ln-s / usr/lib64/libfastcommon.so / usr/local/lib/libfastcommon.so [root@storage libfastcommon-1.0.38] # ln-s / usr/lib64/libfdfsclient.so / usr/local/lib/libfdfsclient.so [root@storage libfastcommon-1.0.38] # ln-s / usr/lib64/libfdfsclient.so / usr/lib/libfdfsclient.so

(2) install FastDFS service (all nodes are installed)

Download and install

[root@storage ~] # wget https://github.com/happyfish200/fastdfs/archive/V5.11.tar.gz[root@storage ~] # tar zxf V5.11.tar.gz-C / opt/ [root@storage ~] # cd / opt/fastdfs-5.11/

Compile

[root@storage fastdfs-5.11] #. / make.sh &. / make.sh install

Make changes to the template file

[root@storage fastdfs-5.11] # cd / etc/fdfs/ profile template path [root@storage fdfs] # cp tracker.conf.sample tracker.conf [root@storage fdfs] # cp storage.conf.sample storage.conf [root@storage fdfs] # cp client.conf.sample client.conf

(3) configuration of tracker monitoring terminal

Establish a directory for storing data files and log files

Mkdir-m 755-p / opt/fastdfs

Modify tracker configuration file

[root@tracker ~] # vim / etc/fdfs/tracker.conf# modify the following configuration port=22122 / / tracker service default port 22122 to store the path of data and log in base_path=/opt/fastdfs / / tracker. The http service process must be created in advance to start the http service on the http.server_port=8080 / / tracker server, and ignore it.

Start the service

[root@tracker ~] # fdfs_trackerd / etc/fdfs/tracker.conf start [root@tracker ~] # netstat-atnp | grep 22122tcp 0 0 0.0.0.0 etc/fdfs/tracker.conf start 22122 0.0.0.0 etc/fdfs/tracker.conf start * LISTEN 43776 Maple fdfstrackerd [root @ tracker] # systemctl stop firewalld [root@tracker ~] # setenforce 0

(4) storage server modification

Establish a directory for storing data files and log files

Mkdir-m 755-p / opt/fastdfs

Modify storage configuration file

[root@storage ~] # vim / etc/fdfs/storage.conf# modify the following configuration group_name=group1 / / default group name, and 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 store_path_count=1 / / of the base_path=/opt/fastdfs / / storage log file is the same as the number of lower paths. The storage path provided by default is 1store_path0=/opt/fastdfs / / (which is stored with the log file by default) tracker_server=192.168.142.66:22122 / / your own tracker server IP (focus! ) the port of http.server_port=80 / / http access file defaults to 8888. The listening port configured in Maginx is consistent.

Start the service

# enable service (command supports start | stop | restart) [root@storage ~] # fdfs_storaged / etc/fdfs/storage.conf start [root@storage ~] # netstat-atnp | grep 23000tcp 00 0.0.0.0restart 23000 0.0.0.0restart * LISTEN 40430 Univ fdfsstoraged [root @ storage ~] # systemctl stop firewalld [root@storage ~] # setenforce 0

Check whether the association with the tracker monitoring side is successful

[root@storage] # fdfs_monitor / etc/fdfs/storage.confStorage 1: id = 192.168.142.77 ip_addr = 192.168.142.77 (storage) ACTIVE http domain =. Omit

(5) install nginx service (storage:192.168.142.77)

Here, in order to reduce the number of virtual machines turned on, nginx is installed on the storage side.

Install nginx and its components

[root@storage ~] # tar zxf nginx-1.12.0.tar.gz-C / opt/# download fastdfs-nginx-module installation package [root@storage ~] # wget https://github.com/happyfish200/fastdfs-nginx-module/archive/V1.20.tar.gz[root@storage ~] # tar zxf V1.20.tar.gz-C / opt/

Compile & install

[root@storage ~] # cd / opt/nginx-1.12.0 [root@storage nginx-1.12.0] #. / configure\-- prefix=/usr/local/nginx\-- add-module=/opt/fastdfs-nginx-module-1.20/src/ fastdfs-nginx-module module [root@storage nginx-1.12.0] # make & & make install

Be careful

Possible error report: / usr/include/fastdfs/fdfs_define.h:15:27: fatal error: common_define.h: No such file or directory solution: modify the fastdfs-nginx-module-1.20/src/config file, then reconfigure, compile and install ngx_module_incs= "/ usr/include/fastdfs/ usr/include/fastcommon/" CORE_INCS= "$CORE_INCS / usr/include/fastdfs/ usr/include/fastcommon/"

Configure the fastdfs-nginx-module module

[root@storage nginx-1.12.0] # cd fastdfs-nginx-module-1.20/src [root@storage nginx-1.12.0] # cp mod_fastdfs.conf / etc/fdfs/ move its configuration file to the fdfs directory # modify the fastdfs-nginx-module module configuration file mod-fasts.conf [root@storage nginx-1.12.0] # cd / etc/fdfs [root@storage fdfs] # vim mod_fastdfs.conf# Check the configuration base_path=/opt/fastdfs / / store data files, The address of the tracker_server=192.168.142.66:22122 / / tracker side of the log path (key! ) url_have_group_name = whether true / / url contains the group name storage_server_port=23000 / / the same number of store_path_count=1 / / storage paths configured as storage, and the number of store_path needs to match the location of store_path0=/opt/fastdfs / / file storage

Modify nginx configuration file

[root@storage fdfs] # vim / usr/local/nginx/conf/nginx.conf# add location ~ / M00 {root / opt/fastdfs/data; ngx_fastdfs_module;} at the blank line

Copy the http.conf and mime.types in the fastdfs decompression directory

# failure to do this may result in an error [root@storage fdfs] # cd / opt/fastdfs-5.11/conf/ [root@storage conf] # cp mime.types http.conf / etc/fdfs/

(6) modify the client (this experiment is the storage)

Modify the configuration file

[root@storage ~] # vim / etc/fdfs/client.conf# check the following configuration base_path=/opt/fastdfs / / tracker server file path tracker_server=192.168.142.66:22122 / / tracker server IP address and port number http.tracker_server_port=8080 / / tracker server's http port number, which must correspond to the setting of tracker.

Upload test file abc.txt

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

Download the file abc.txt

/ usr/bin/fdfs_download_file / etc/fdfs/client.conf group1/M00/00/00/wKiOTV354W2AIf7GAAAAEh4TEws726.txt abc.txt

Delete the file abc.txt

Thank you for watching fdfs_delete_file / etc/fdfs/client.conf group1/M00/00/00/wKiOTV354W2AIf7GAAAAEh4TEws726.txt. Keep updating!

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