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

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

Share

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

FasterDFS Basic Configuration Installation Basic Overview

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. It solves the problems of mass storage and Load Balancer. It is especially suitable for online services with files as carriers, such as photo album websites, video websites and so on.

FastDFS is tailor-made for the Internet. It fully considers redundant backup, Load Balancer, linear expansion and other mechanisms, and pays attention to high availability, high performance and other indicators. It is easy to build a set of high-performance file server clusters with FastDFS to provide file upload, download and other services.

primary structural view

FastDFS servers have two roles: tracker and storage. Tracer mainly does scheduling work and plays the role of Load Balancer on access. Both trackers and storage nodes can consist of one or more servers. Servers in both trackers and storage nodes can be added or taken offline at any time without affecting online services. All servers in the tracker are peer-to-peer and can be increased or decreased at any time according to the pressure on the server.

When adding a server to a volume, the synchronization of existing files is automatically completed by the system. After synchronization is completed, the system automatically switches the newly added server to provide services online.

Basic Lab Deployment 1. Lab Preparation Name Role IP Address centos7-1tracker192.168.45.135centos7-2storage+nginx192.168.45.132 Lab Package Extraction Code

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

Extraction code: 9ql5

2. Start installing and modifying the names of the two servers

One changed to tracker, one changed to storage

hostnamectl set-hostname tracker storagesu install basic environment package yum -y install libevent libevent-devel perl make gcc zlib lib-devel pcre gcc-c++ openssl-devel install libfastcommon service (all nodes are installed) mount.cifs //192.168.100.3/lzp #install libfastcommon service cd /mnt/fastDFS/tar zxvf libfastcommon-1.0.39.tar.gz-C /optcd /opt/libfastcommon-1.0.39/#compile installation and establish soft links for system identification./ make.sh && ./ make.sh installln -s /usr/lib64/libfastcommon.so.soln -s /usr/lib libfdfsclient.so Install FastDFS Service (all nodes install) cd /mnt/fastDFS/zxvf fastdfs-5.11.tar.gz -C /opt#compile install cd /opt/fastdfs-5.11/./tar libfdfsclient.so 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 #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 line tracker store data and log follow path, must create a good tracker store data and log follow path, must create a good #http.server_port=8080 //tracker server start http service process, not installed ignore #enable service fdfs_trackerd /etc/fdfs/tracker.conf start#set boot auto-start [root@tracker ~]# vim /etc/rc.local#add fdfs_trackerd at the end of the line /etc/fdfs/tracker.conf start #Turn off firewall and security features [root@tracker ~]# systemctl stop firewalld[root@tracker ~]# setenforce 0storage server-side modification #Create data files, 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 port=23000 according to actual situation //storage default 23000, the same group storage port number must be consistent base_path=/opt/fastdfs //storage root path of log file store_path_count=1 //Same number of paths as below, default is 1store_path0=/opt/fastdfs //109 Storage path provided (default stored with log file) tracker_server=192.168.45.135:22122 //own tracker server IP (focus!!!) http.server_port=80 //http The default port for accessing files is 8888. The listening ports configured in nginx are consistent. Turn on the service and set the startup to start #Turn on the service (start command is supported).| stop| restart)[root@storage ~]# fdfs_storaged /etc/fdfs/storage.conf start[root@storage ~]# netstat -atnp | grep 23000tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 40430/fdfs_stored #Set boot autostart [root@storage ~]# vim /etc/rc.local#Add fdfs_stored to last line /etc/fdfs/storage.conf start [root@storage ~]# systemctl stop firewalld[root@storage ~]# setenforce 0 Check if association with tracker monitor succeeds fdfs_monitor /etc/fdfs/storage.conf

Install 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/fastdusr/fs/fastcommon/" include_INCS="$CORE_INCS /fs/include/fastdusr/fs usr/include/fastcommon/"#compile 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 configuration file mod-fasts.conf[root@storage nginx-1.12.0]# cd /etc/fdfs[root@storage fdfs]# vim mod_fastdfs.conf#Check configuration base_path=/opt/fastdfs //path to store data files and logs tracker_server= 192.168.45.135/: 22122 //address of tracker end (focus!!!) url_have_group_name = true //url contains group name storage_server_port=23000 //requires the same store_path_count=1 as the storage configuration //The number of storage paths needs to match the number of store_paths store_path0=/opt/fastdfs //62 line file storage location #modify nginx configuration file [root@storage fdfs]# vim /usr/local/nginx/conf/nginx.conf#add location ~/M00 { root /opt/fastdfs/data; ngx_fastdfs_module;}#Create soft link [root@localhost ~]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/#Check 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#Initiate nginx[root@localhost ~]# nginx#Copy http.conf and mime.types from fastdfs unzipped directory Failure to do so may result in error [root@storage fdfs]# cd /opt/fastdfs-5.11/conf/[root@storage conf]# cp mime.types http.conf /etc/fdfs/modify storage port #modify 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 // tracker http port number of server, must be and 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/wKiOTV354W2AIf7GAAAAEh4TEws726.jpg test2.jpg** Delete file command: /usr/bin/fdfs_delete_file

Examples:

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