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 of FasterDFS

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

Share

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

Basic overview

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.

Basic structure diagram

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.

Basic experiment deployment 1. Experiment preparation name role IP address centos7-1tracker192.168.45.135centos7-2storage+nginx192.168.45.132 experiment package extraction code

Link: https://pan.baidu.com/s/1_Xs09mdST6VNLue11dqhyQ

Extraction code: 9ql5

2. Start the installation and modify the names of the two servers

One is changed to tracker, the other to storage

Hostnamectl set-hostname tracker storagesu install basic environment package yum-y install libevent libevent-devel perl make gcc zlib zlib-devel pcre pcre-devel gcc-c++ openssl-devel install libfastcommon service (all nodes are installed) mount.cifs / / 192.168.100.3/lzp / mnt# install libfastcommon service cd / mnt/fastDFS/tar zxvf libfastcommon-1.0.39.tar.gz-C / optcd / opt/libfastcommon-1.0.39/# compile and install and establish software Link to facilitate system identification. / make.sh &. / make.sh installln-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 install the FastDFS service (all nodes are installed) cd / mnt/fastDFS/tar zxvf fastdfs-5.11.tar.gz-C / opt# Translate and install cd / opt/fastdfs-5.11/./make.sh &. / make.sh install cd / etc/fdfs/cp tracker.conf.sample tracker.confcp storage.conf.sample storage.confcp client.conf.sample client.conftracker monitoring configuration # to create data files, Log file storage directory [root@tracker ~] # 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 base_path=/opt/fastdfs / / 22 lines tracker storage data and log path The following paths for tracker storage data and log must be created in advance, and the http service process on the # http.server_port=8080 / / tracker server must be created in advance. Not installed ignore # enable service fdfs_trackerd / etc/fdfs/tracker.conf start# setting boot self-boot [root@tracker ~] # vim / etc/rc.local# last line add fdfs_trackerd / etc/fdfs/tracker.conf start# shutdown firewall and security function [root@tracker ~] # systemctl stop firewalld [root@tracker ~] # setenforce 0storage server modification # create data file, Log file storage directory [root@storage ~] # 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 the port=23000 / / storge default of 23000 according to the actual situation. The storage port number of the same group must be the same. The root path of the base_path=/opt/fastdfs / / storage log file is the same as the number of the following paths. By default, the storage path provided by 1store_path0=/opt/fastdfs / / 109 (stored with the log file by default) tracker_server=192.168.45.135:22122 / / your own tracker server IP (focus! ) 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 and set to boot self-boot # 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.0 stop 23000 0.0.0.0 * LISTEN 40430/fdfs_storaged# setting since Start [root@storage ~] # vim / etc/rc.local# to add fdfs_storaged / etc/fdfs/storage.conf start [root@storage ~] # systemctl stop firewalld [root@storage ~] # setenforce 0 to check whether it is successfully associated with tracker monitor fdfs_monitor / etc/fdfs/storage.conf

Install the nginx service (storage:192.168.45.132)

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

Cd / mnt/fastDFS/ [root@storage fastDFS] # tar zxvf nginx-1.12.0.tar.gz-C / opt tar zxvf fastdfs-nginx-module-1.20.tar.gz-C / opt# modify / opt/fastdfs-nginx-module-1.20/src/config file [root@storage fastDFS] # vim / opt/fastdfs-nginx-module-1.20/src/configngx_module_incs= "/ usr/include/fastdfs / usr/include/fastcommon/" CORE_INCS= "$CORE _ INCS / usr/include/fastdfs / usr/include/fastcommon/ "# compile and install 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/make & & make installcd / opt/fastdfs-nginx-module-1.20/srccp mod_fastdfs.conf / etc/fdfs/ # modify fastdfs-nginx-module mode Block 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.45.135/: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 / / 62 line file storage # modify nginx configuration file [root@storage fdfs] # vim / usr/local/nginx/conf/nginx.conf#server add location ~ / M00 {root / opt/fastdfs/data in the blank line Ngx_fastdfs_module } # create soft link [root@localhost ~] # ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/# car inspection nginx configuration file [root@localhost ~] # nginx-tnginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful# launch nginx [root @ localhost ~] # nginx# copy http.conf and mime.types in the decompression directory do not do This step may cause an error [root@storage fdfs] # cd / opt/fastdfs-5.11/conf/ [root@storage conf] # cp mime.types http.conf / etc/fdfs/ modify the storageside # 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.45.135:22122 / / tracker Server IP address and port number http.tracker_server_port=8080 / / http port number of the tracker server Must be with the upload test file command: / usr/bin/fdfs_upload_file

Command demonstration:

[root@localhost mnt] # / usr/bin/fdfs_upload_file / etc/fdfs/client.conf 1.jpggroup1/M00/00/00/wKgthF4AKVmAY9WYABIrwU4wXNs537.jpg

Download file command: / usr/bin/fdfs_download_file [local_filename]

Example

/ usr/bin/fdfs_download_file / etc/fdfs/client.conf group1/M00/00/00/wKiOTV354W2AIf7GAAAAEh4TEws726.jpg test2.jpg** delete file command: / usr/bin/fdfs_delete_file

Example:

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

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