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

Installation and configuration steps for FastDFS

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

Share

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

I. brief introduction

FastDFS is an open source distributed file system similar to Google FS, which is implemented in pure C language and supports UNIX systems such as Linux, FreeBSD, AIX and so on. It can only access files through proprietary API, does not support POSIX interface, and cannot be used by mount. To be exact, Google FS and Google FS like FastDFS, mogileFS, HDFS, TFS are not system-level distributed file systems, but application-level distributed file storage services.

There can also be multiple Tracker server in a FastDFS cluster, and there is no single point of problem for both Tracker server and Storage server. There is a peer-to-peer relationship between Tracker server and between Storage server within a group. In the traditional Master-Slave structure, Master is a single point, and the write operation is only for Master. If Master fails, you need to upgrade Slave to Master, and the implementation logic will be complicated. Compared with the Master-Slave structure, the status of all nodes in the peer-to-peer structure is the same, each node is Master, there is no single point problem.

Step 1 of basic deployment: preparation for the experiment

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 a soft link to facilitate the system Unified 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 to change 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

Set up the data file and log file storage directory mkdir-m 755-p / opt/fastdfs modify the tracker configuration file [root@tracker ~] # vim / etc/fdfs/tracker.conf# modify the following configuration port=22122 / / tracker service default port 22122 to base_path=/opt/fastdfs / / tracker to store data and log, you must create the http service process on the http.server_port=8080 / / tracker server in advance. Ignore to enable 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 netstat * LISTEN 43776) fdfstrackerd [root @ tracker ~] # systemctl stop firewalld [root@tracker ~] # setenforce 0

(4) storage server modification

Set up data file and log file storage directory 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, modify port=23000 / / storge default 23000 according to the actual situation The storage port number of the same group must be the same as the root path store_path_count=1 / / of the base_path=/opt/fastdfs / / storage log file. The default is the storage path provided by 1store_path0=/opt/fastdfs / / (stored with the log file by default) tracker_server=192.168.142.66:22122 / / your own tracker server IP (key!! ) the port for http.server_port=80 / / http access files defaults to 8888 The listening ports configured in nginx are consistent to enable the service # enable the 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.0stop 23000 0.0.0.0stop * LISTEN 40430 impulse fdfsstoraged [root @ storage ~] # systemctl stop firewalld [root@ Storage ~] # setenforce 0 checks whether it is successfully associated with the tracker monitor [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 Install nginx and its components [root@storage] # tar zxf nginx-1.12.0.tar.gz-C / opt/# on the nginx side to download the 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/ compilation & 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 Note possible errors: / usr/include/fastdfs/fdfs_define.h:15:27: fatal error: Common_define.h: No such file or directory solution: modify 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/" configuration 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 Fdfs directory # modify 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 the data file, 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 required as the storage configuration Need to match the number of store_path to match the location of store_path0=/opt/fastdfs / / file storage to modify the nginx configuration file [root@storage fdfs] # vim / usr/local/nginx/conf/nginx.conf# blank line to add location ~ / M00 {root / opt/fastdfs/data Ngx_fastdfs_module;} copying http.conf and mime.types# in the fastdfs decompression directory not doing 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

Fdfs_delete_file / etc/fdfs/client.conf group1/M00/00/00/wKiOTV354W2AIf7GAAAAEh4TEws726.txt

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